Skip to content
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

aws_iam_role.force_detach_policies no longer works #2279

Closed
hashibot opened this issue Nov 14, 2017 · 9 comments · Fixed by #2388
Closed

aws_iam_role.force_detach_policies no longer works #2279

hashibot opened this issue Nov 14, 2017 · 9 comments · Fixed by #2388
Labels
bug Addresses a defect in current functionality.
Milestone

Comments

@hashibot
Copy link

This issue was originally opened by @aleybovich as hashicorp/terraform#16637. It was migrated here as a result of the provider split. The original body of the issue is below.


Reproduce:

  1. Create an aws role with terraform
resource "aws_iam_role" "sample-instance-role" {
   name               = "sample-instance-role"
   path               = "/"
   force_detach_policies = true
   ... other stuff ...
}
  1. Manually add another policy to that role (e.g. via aws console)
  2. run terraform destroy

You get an error sample-instance-role: DeleteConflict: Cannot delete entity, must detach all policies first.

force_detach_policies feature has been added a few months ago specifically for this purpose - it detaches all policies that weer added outside of terraform so that the role can be deleted. This used to work briefly in one or two versions but it no longer does in 0.10.7

Documentation: https://www.terraform.io/docs/providers/aws/r/iam_role.html#force_detach_policies

@hashibot hashibot added the bug Addresses a defect in current functionality. label Nov 14, 2017
@atsushi-ishibashi
Copy link
Contributor

@aleybovich There is a possibility that policies is truncated because a lot of policies are attached.
Could you share how many policies are attached?
https://docs.aws.amazon.com/sdk-for-go/api/service/iam/#ListAttachedRolePoliciesOutput

@aleybovich
Copy link

aleybovich commented Nov 18, 2017 via email

@atsushi-ishibashi
Copy link
Contributor

@aleybovich
https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListRolePolicies.html

Lists the names of the inline policies that are embedded in the specified IAM role.
An IAM role can also have managed policies attached to it. To list the managed policies that are attached to a role, use ListAttachedRolePolicies.

Probably inline policies are still attached. For force_detach_policies, ListAttachedRolePolicies is used.

@aleybovich
Copy link

aleybovich commented Nov 20, 2017

@atsushi-ishibashi - the only inline policy that role has is the one I add in the same terraform template (terraform destroy should take care of that, I assume); all Turbot policies are attached.

@atsushi-ishibashi
Copy link
Contributor

@aleybovich I submitted PR to fix this👍

@aleybovich
Copy link

Thank you! Whats the usual turnaround for a pull request like this one?

@atsushi-ishibashi
Copy link
Contributor

atsushi-ishibashi commented Nov 21, 2017

Probably...
open issue -> anyone submit PR if needed
or
submit PR with details when you find and solve by yourself.

Refer CONTRIBUTING.md

@bflad bflad added this to the v1.7.0 milestone Jan 12, 2018
@bflad
Copy link
Contributor

bflad commented Jan 12, 2018

This has been released in terraform-provider-aws version 1.7.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 8, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
4 participants