-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
provider/aws : IAM policy attachment/detach bug ? #133
Comments
Terraform removes attachments that are not terraform-managed, this is hugely disruptive and downright dangerous to use in a live environment. Folks should probably stick with using |
|
For those finding this old issue which I'm going to close out now, we updated the resource documentation to very obviously display a big red warning message at the top. https://www.terraform.io/docs/providers/aws/r/iam_policy_attachment.html
In almost all cases we tend to highly recommend using the separate |
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 @saswatp as hashicorp/terraform#6045. It was migrated here as part of the provider split. The original body of the issue is below.
I have a AWS policy ARN and and I am attaching a role to that policy. Since the policy is a global policy (arn:aws:iam::aws:policy/AmazonS3FullAccess) , there are some other users also associated with that policy ( not through terraform) . In my plan and apply , I am not explicitly attaching a particular user.
When I detach the role from policy , terraform detaches users associated with that policy. So ,the bug is we don't explicitly attach users to a policy , however when we detach a role from policy we also detach users that we didn't attach in the first place. I tried to hack around by providing a null value for user , assuming that when I detach , it won't detach other users as the user I am associating is null. That failed as a "" user can't be attached in the first place.(doesnt exist)
Detaching an IAM policy detaches users attached to that policy
resource "aws_iam_policy_attachment" "management-host-policy-attach" { name = "${var.service}-management-attachment" roles = ["${aws_iam_role.management-instance-role.name}"] //users = ["${var.iam_users}"] policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess" lifecycle { create_before_destroy = true } }
terraform version
Terraform v0.6.15-dev (b20f680cbf0505825e6ae173c5986243683d8eb3)
The text was updated successfully, but these errors were encountered: