Example to demonstrate using of Dynamic Blocks.
🤯 TO set up ECS service definition such a way that, deploying my application behind multiple-loadbalancer/single-loadbalancer/no-loadbalancer should be optional.
I am using dynamic Block to set
loadbalancer block in my service definition as optional.
🐼 Set variable as type
list and pass
target group arn through varaible. Remember its list of string, therefore defined in quotes.
🐼 In ECS service definition I have said
loadbalancer is my
Iterate based on
for each values defined in
target_group vraibles set the loadbalancer block definition respectively. If there are two values defined in variable set two loadbalancer block with each value. Same goes with one and no value defined in varaible.
🐼 Since my
container_name are same but only target_group_arn
is different (one is behind private LB and other public LB), hence just change it's values in loadbalancer block. target_group_arn = target_group_arn.value`