Loading...
Loading...
Hi there, I've faced this issue with `terraform` on multiple occasions with different resources. On renaming or tainting a resource terraform does not wait for the resource to be destroyed completely before attempting to create it. (the output for this is shown under `debug output`) The same if you want to rename a resource (AWS ALB). Then when we run `terraform apply` again. Everything works as expected becuase now the resource destruction is complete. Also when a user is tainted and marked for recreation, `terraform apply` has to be re-run to apply the group memberships again, or else the user will have no groups. I feel these issues are somewhat inter-related. In the case below I renamed the group module and and modularized the `aws_iam_user` resource, henceforth triggering a recreate. ### Terraform Version ``` terraform -v Terraform v0.12.23 ``` ### Debug Output ```code aws_iam_user_group_membership.memberships["testuser"]: Destroying... [id=terraform-20200413153132068600000001] module.pm_group_policy.aws_iam_group_policy.policy: Destroying... [id=test:test_access_policy] > module.group.aws_iam_group.group: Creating... <----- THIS GROUP module.group_memberships.aws_iam_user_group_membership.memberships["testuser"]: Creating... >> module.users.aws_iam_user.users["testuser"]: Creating... <-------THIS USER module.pm_group_policy.aws_iam_group_policy.policy: Destruction complete after 1s > module.pm_group.aws_iam_group.group: Destroying... [id=test] <------- THIS GROUP module.pm_group.aws_iam_group.group: Destruction complete after 0s aws_iam_user_group_membership.memberships["testuser"]: Destruction complete after 2s >> aws_iam_user.users["testuser"]: Destroying... [id=testuser] <-------THIS USER module.group_memberships.aws_iam_user_group_membership.memberships["testuser"]: Creation complete after 2s [id=terraform-20200418123826515600000001] aws_iam_user.users["testuser"]: Destruction complete after 4s Error: Error creating IAM Group test: EntityAlreadyExists: Group with name test already exists. status code: 409, request id: 721c37c7-faeb-48af-b0bf-71361d82849f on ../modules/groups/main.tf line 1, in resource "aws_iam_group" "group": 1: resource "aws_iam_group" "group" { Error: Error creating IAM User testuser: EntityAlreadyExists: User with name testuser already exists. status code: 409, request id: 96597ff1-4e79-4d84-94ba-96a61de5e04a on ../modules/users/main.tf line 1, in resource "aws_iam_user" "users": 1: resource "aws_iam_user" "users" { ``` ### Expected Behavior - Maybe a make sure the resource to be recreated is destroyed first. ### Actual Behavior - Resources is created before destruction is complete. ### Steps to Reproduce - `taint` or rename a resource (IAM user) then `terraform apply`. ### Additional Context - If I set `parallelism` to 1 everytime then everything works accordingly
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.