destroying aws_iam_policy_attachment to a managed policy deletes everyone's attachments #94
Labels
bug
Addresses a defect in current functionality.
service/iam
Issues and PRs that pertain to the iam service.
This issue was originally opened by @slowbluecamera as hashicorp/terraform#5483. It was migrated here as part of the provider split. The original body of the issue is below.
If you use the "aws_iam_policy_attachment" resource to attach a role to a managed_policy, when you destroy the configuration, it will remove attachments made by other configurations, or even manually setup attachments.
In the example configurations below, configuration "plan_one.tf" sets up an attachment to the "AWSLambdaBasicExecutionRole" managed policy. The configuration "plan_two.tf" also sets up a similar attachment. If you apply both configurations, and then delete one, you'll find that both attachments have bene removed.
Also, if you have set up role attachments to the managed policy by other scripts, or manually, then you will find that those attachments have been removed (which is how we discovered it! :-( ).
Have reproduced this in terraform-0.6.12 on OSX.
(This is my first issue reported to the terraform project. I've reviewed submitting guidelines and tried to be complete, but I'd like this issue to be as useful as possible. So if there is any additional information needed or changes in style that would be helpful, please don't hesitate to let me know. Thanks!)
Workarounds:
Steps to reproduce:
export TF_VAR_access_key=AWS ACCESS KEY
export TF_VAR_secret_key=AWS SECRET KEY
Notice that the policy attachment in
plan_two.tf
is no longer there.plan_one.tf
two/plan_two.tf
variables.tf (identical in both configurations)
The text was updated successfully, but these errors were encountered: