terraform-aws-fargate icon indicating copy to clipboard operation
terraform-aws-fargate copied to clipboard

Adding and Removing Services Causing Re-creation of all the resource

Open Sanyambansal76 opened this issue 5 years ago • 7 comments

Hi,

Thanks for building this module, I am facing a similar issue described in the following link https://github.com/hashicorp/terraform/issues/17179

I think we should modify the existing code to use for_each

Sanyambansal76 avatar Oct 03 '19 13:10 Sanyambansal76

Hello @Sanyambansal76, thanks for reaching out.

Please, could you provide the version you're using and steps to reproduce?

What do you mean by "Re-creation of all the resource"?

jlsan92 avatar Oct 04 '19 07:10 jlsan92

I experience similar inconsistencies and an exhaustive re-creation of resources if I change anything inside a service. For me, this leads to unnecessary downtimes of the application when I upgrade the fargate declaration.

Maybe too many resources depend on something that is defined in a service, and thus it triggers recreation of those resources.

Overbryd avatar Oct 24 '19 14:10 Overbryd

For example: Adding an acm_certificate_arn to a service, should not cause the following changeset:

Plan: 22 to add, 1 to change, 21 to destroy.

------------------------------------------------------------------------

It event recreates the ECR repository, leading to the CodePipeline to fail, leading to new pushes being ignored, leading to a complete standstill.

Overbryd avatar Oct 24 '19 15:10 Overbryd

@jlsan92 Sorry I was on vacation for last few days, I think it is happening because the resource and their state are uniquely identified by the index, not by their name, so if we change something in the order, hash calculated again and resources mismatched with hash index values and lead to the re-creation of resources. Following are the use-cases when hash recalculated for index

*We can add new rules only at the end of the hash. *We can remove rules only at the end of the hash. *We can modify the rules, as long as their position in the hash doesn't change. *But we can never remove any other rule or change their position in the hash.

Terraform Version - 0.12.12

Sanyambansal76 avatar Oct 25 '19 07:10 Sanyambansal76

I had re-written the whole module for my use-case if you want i can send a PR request next week.

Sanyambansal76 avatar Oct 25 '19 07:10 Sanyambansal76

@jlsan92 any update?

Sanyambansal76 avatar Dec 08 '19 11:12 Sanyambansal76

@Sanyambansal76 could you share this code in your own fork online so we can all benefit?

sloops77 avatar Oct 19 '20 08:10 sloops77