-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Failing to delete a role if if policies are attached #883
Comments
As suggested by @radeksimko in the original ticket, can you please add the ability to force detach any attached policies before deleting a role? That would be a great help for anyone in the same situation as myself. Basically, if you could add a flag |
Fixes: #883 ``` % make testacc TEST=./aws TESTARGS='-run=TestAccAWSIAMRole_' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -run=TestAccAWSIAMRole_ -timeout 120m === RUN TestAccAWSIAMRole_importBasic --- PASS: TestAccAWSIAMRole_importBasic (90.60s) === RUN TestAccAWSIAMRole_basic --- PASS: TestAccAWSIAMRole_basic (63.38s) === RUN TestAccAWSIAMRole_basicWithDescription --- PASS: TestAccAWSIAMRole_basicWithDescription (160.94s) === RUN TestAccAWSIAMRole_namePrefix --- PASS: TestAccAWSIAMRole_namePrefix (82.85s) === RUN TestAccAWSIAMRole_testNameChange --- PASS: TestAccAWSIAMRole_testNameChange (104.43s) === RUN TestAccAWSIAMRole_badJSON --- PASS: TestAccAWSIAMRole_badJSON (5.03s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 507.244s ```
* provider/aws: Add support for iam_role tp force_detach_policies Fixes: #883 ``` % make testacc TEST=./aws TESTARGS='-run=TestAccAWSIAMRole_' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -run=TestAccAWSIAMRole_ -timeout 120m === RUN TestAccAWSIAMRole_importBasic --- PASS: TestAccAWSIAMRole_importBasic (90.60s) === RUN TestAccAWSIAMRole_basic --- PASS: TestAccAWSIAMRole_basic (63.38s) === RUN TestAccAWSIAMRole_basicWithDescription --- PASS: TestAccAWSIAMRole_basicWithDescription (160.94s) === RUN TestAccAWSIAMRole_namePrefix --- PASS: TestAccAWSIAMRole_namePrefix (82.85s) === RUN TestAccAWSIAMRole_testNameChange --- PASS: TestAccAWSIAMRole_testNameChange (104.43s) === RUN TestAccAWSIAMRole_badJSON --- PASS: TestAccAWSIAMRole_badJSON (5.03s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 507.244s ``` * provider/aws: Address feedback from review
Hey @stack72 , unfortunately it seems it doesn't work correctly in the newest Terraform version (0.10.0): This is a snippet from my terraform template:
And the error:
I know that the flag was included in the newest version of the Terraform, so is there anything I'm doing wrong? |
Hi My IAM policy created in first terraform run, than when i am running same apply with few updates than i'm getting this message. my question how to remove this message. i am using 0.11.2 terraform version. Error: Error applying plan: 3 error(s) occurred:
|
Hi @Laxman-SM! Sorry you're having trouble. You can use the import functionality to bring in existing infrastructure into Terraform, e.g. aws_iam_role import documentation. If you have further problems, I would suggest opening a new Github issue or asking your question on the terraform-tool Google Group for better visibility over a comment in a closed 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
This issue was originally opened by @aleybovich as hashicorp/terraform#15301. It was migrated here as part of the provider split. The original body of the issue is below.
I'm using TF v0.9.7
I am adding a simple service role. Then I am running
terraform destroy
to delete that role and I am getting an erroraws_iam_role.code-deploy-ec2-instance-profile: DeleteConflict: Cannot delete entity, must detach all policies first.
After some troubleshooting I realized that turbot (the 3rd party software that manages our enterprise aws accounts) attaches its own additional policies to any created roles. So, when terraform tries to delete the role, those policies, added outside of terraform, cause the error.
Is there any way to force detach all unmanaged policies using terraform so I could successfully destroy the managed role?
The text was updated successfully, but these errors were encountered: