-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terraform keeps forcing new resource on unchanged container_definitions #16769
Comments
I have been able to figure out the issue. It seems like the old terraform versions didn't throw errors when duplicate environment variables were present in the container_definitions file due to human error. In version 0.11.0 terraform seems to actually recognise these duplicates and forces a recreation of the resource (without applying the duplicate key). Resulting in terraform trying to recreate the resource every time a plan is issued. |
I'm still experiencing this, new in terraform 0.11.1 (from 0.10.8) despite having no duplicate environment variables or other attributes. Terraform is incorrectly detecting the addition by AWS of a field with a value of "null" as a change. Even when letting terraform apply and then copying and pasting the container definitions from the task definition in the aws console, I can't reliably get terraform to detect no changes. |
What helped me determine the issue was running terraform plan with This might help you determine a difference in your container definitions that you possibly oversaw. |
I faced a similar problem. Seems that what is stored in the state is what AWS makes of the container definitions. In my case in the port mapping
Became
I'm using |
@spangaer Thanks for pointing out the
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html I figured only the first sentence applied, Looking at what Terraform outputs in the template though:
It's filling it all in per
Once I amended my task definition JSON, as you have done: "portMappings": [
{
"containerPort": 8000,
"hostPort": 8000,
"protocol": "tcp"
}
], It no longer wants to recreate the resource. Thank you for finding that! |
The issue with a missing hostPort forces changes of the task definition is addressed over here hashicorp/terraform-provider-aws#3401 |
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
Terraform detects no changes and plans nothing when using
terraform plan
.Actual Behavior
Terraform keeps forcing a new resource on
container_definitions
when the output JSON file hasn't changed and forces a new resource deleting and recreating the old one. It seems to be duplicating the container definition json file.Debug Output
Steps to Reproduce
terraform plan
Important Factoids
We generate our JSON files with the
template_dir
resource and pass them to our ECS services / Task Definitions. This behaviour is new and did not occur with older versions, upgrading to version 0.11.0 has started showing this. Terraform also started dumping the entire JSON as text into theterraform plan
output, while it used to show the random generated id. Also worth noting terraform doesn't do this for every ecs service.The text was updated successfully, but these errors were encountered: