Open remiflament opened 1 week ago
why do you need to use this in a for_each
loop? seems like the problem is solved by having two ASG definitions, and will be much more stable
@bryantbiggs yes it could be done with both ASG module declarations (150 lines for me right now for one ASG). In this example, I have two ASG, but you can go for example to 5 in your ECS cluster (small, medium, spot, on-demand instances)
The difference is not a huge change from the module perspective. And it fix an AWS limitation that when you declare instance_requirements
you should not declare instance_type
.
I hope you will find it helpful as it unlocks a new possibility.
but you can go for example to 5 in your ECS cluster (small, medium, spot, on-demand instances)
For what?
The difference is not a huge change from the module perspective. And it fix an AWS limitation that when you declare instance_requirements you should not declare instance_type.
There isn't anything broken so there isn't anything to fix in terms of limitations - its just that you are trying to force two very different configurations into one
For what?
To place your ECS services depending on the application requirements in small, medium or large node. And if you are allowed to use spot, you can either run your workload 100% on spot or balance it between on-demand and spot. All these considerations are base on finOps. So it's a common thing to have multiple ASG in an ECS cluster.
its just that you are trying to force two very different configurations into one
Maybe, but I prefer using for_each
loop when it's possible. You seem preferring duplicate a hundred lines of HCL.
Your comments are not based on the contribution, as it's just a small thing unlocking a huge possibility. It's more based on your HCL writing vision.
Any third opinion would be helpful @antonbabenko
Description
I'm using this module to create ASG and resources associated to be used in my ECS cluster.
Motivation and Context
I searched to use
for_each
on this module to createon-demand
andspot
ASG/LaunchTemplate. I faced a problem because you can't declareinstance_requirements
ifinstance_type
is set too.To avoid this problem, I added a check that
var.instance_type == null
when you declare yourinstance_requirements.
Personal code example
if my asg is
spot == false
I keep the defaultinstance_requirements
as{}
and setinstance_type
if my asg is
spot == true
I set theinstance_requirements
,use_mixed_instances_policy
and set theinstance_type
tonull
locals.tf
asg.tf
Breaking Changes
No breaking changes.
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request