You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a very convenient way to setup modules using maps. There is a bunch of resources which accept that way of configuration. I've stumbled upon an "aws_ecs_service" resource.
The "aws_ecs_service" resource accept "load_balancer" inline parameter which has it's internal configuration with arguments: "target_group_arn", "container_name", "container_port". The way that Terraform offers to configure it is to use a map like that:
It's even work if we would use external configuration: outside of a module. The "load_balancer" parameter is plausible to mention several times in module declaration. So we can use a list of those maps in our module configuration:
Create the settings file "debug.tfvars" and fill it with your auth data and VPC id (VPC doesn't need to be exist on that moment if you are trying a failing scenario)
There is a similar issue #13103 where have been discussed about the way how to correctly pass argument from the output of one module to the input of another. And the recommendation is to use interpolation syntax like that:
But it also doesn't work. It returns another error:
Error: module.ecs-service.aws_ecs_service.simple_ecs_service: "load_balancer.0.container_name": required field is not set
Error: module.ecs-service.aws_ecs_service.simple_ecs_service: "load_balancer.0.container_port": required field is not set
The nature of the problem differs. In my case, the argument is the list of maps, but in the issue, it's just list of arguments.
Unfortunately this is not really a valid configuration, and though assigning a list of maps to a block takes advantage of some internal implementation details, and works in some cases, you can see does not work in all cases.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
ghost
locked and limited conversation to collaborators
Mar 30, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
There is a very convenient way to setup modules using maps. There is a bunch of resources which accept that way of configuration. I've stumbled upon an "aws_ecs_service" resource.
The "aws_ecs_service" resource accept "load_balancer" inline parameter which has it's internal configuration with arguments: "target_group_arn", "container_name", "container_port". The way that Terraform offers to configure it is to use a map like that:
It's even work if we would use external configuration: outside of a module. The "load_balancer" parameter is plausible to mention several times in module declaration. So we can use a list of those maps in our module configuration:
But, if is it necessary to put ARN value as an output of another module it turns out to get an error:
Steps to Reproduce
References
There is a similar issue #13103 where have been discussed about the way how to correctly pass argument from the output of one module to the input of another. And the recommendation is to use interpolation syntax like that:
But it also doesn't work. It returns another error:
The nature of the problem differs. In my case, the argument is the list of maps, but in the issue, it's just list of arguments.
Terraform Version
The text was updated successfully, but these errors were encountered: