Closed spaceofmiah closed 8 months ago
Hi @spaceofmiah
This isn't a bug in the Terraform AWS provider. It's just something wrong in the particular example you're using. It's much simpler to use jsonencode directly in the aws_ecs_task_definition resource rather than abstracting it through using a template file and then using the rendered template file in the aws_ecs_task_definition resource. The end result is the same but doing it that way is much harder to troubleshoot.
The Terraform docs have excellent examples at https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition of how to use jsonencode.
resource "aws_ecs_task_definition" "service" {
family = "service"
container_definitions = jsonencode([
{
name = "first"
image = "service-first"
cpu = 10
memory = 512
essential = true
portMappings = [
{
containerPort = 80
hostPort = 80
}
]
},
{
name = "second"
image = "service-second"
cpu = 10
memory = 256
essential = true
portMappings = [
{
containerPort = 443
hostPort = 443
}
]
}
])
}
Since we haven't heard back, and with the above in mind, I'm going to close this issue.
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.
Terraform Version
Terraform Configuration Files
Expected Behavior
I expected a generated resource plan, showing all the resource to be created or updated
Actual Behavior
I get an error
Steps to Reproduce
terraform init
terraform fmt
terraform validate
terraform plan
Additional Context
This error only comes up when I run
terraform plan
within my CI pipeline. Running it on my local machine (same config) pass the plan stage.