When setting setting environment variables in aws_ecs_task_definition to null or the empty value AWS seems to filter out those environment variables when creating the Task Definition.
Running apply or preview should not detect changes if the aws_ecs_task_definition was not modified.
Actual Behavior
aws_ecs_task_definition permanently shows a diff when setting environment variables to null or the empty value.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
provider "aws" {
region = "us-west-2"
}
resource "aws_ecs_task_definition" "example_task_definition" {
family = "example-service"
container_definitions = jsonencode([
{
name = "example-service"
image = "nginx"
memory = 128
environment = [
{
name = "EXAMPLE_VARIABLE"
value = "" # Also happens for nulls
}
]
}
])
}
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Terraform Core Version
1.5.7
AWS Provider Version
5.69.0
Affected Resource(s)
aws_ecs_task_definition
Expected Behavior
When setting setting environment variables in
aws_ecs_task_definition
to null or the empty value AWS seems to filter out those environment variables when creating the Task Definition.Running apply or preview should not detect changes if the
aws_ecs_task_definition
was not modified.Actual Behavior
aws_ecs_task_definition
permanently shows a diff when setting environment variables to null or the empty value.Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
terraform apply
terraform preview
and observe the diffDebug Output
No response
Panic Output
No response
Important Factoids
No response
References
This could be fixed by filtering out nulls/empty values in the environment variables. The same is already done for the
ecs_properties
parameter ofaws_batch_job_definition
: https://github.com/hashicorp/terraform-provider-aws/blame/ad3a8be1c171039ddec00dd87d5e4e2ae8497519/internal/service/batch/ecs_properties.go#L84-L86Would you like to implement a fix?
None