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

[Bug]: aws_iam_role_policy_attachments_exclusive policies cannot be deleted or recreated #40665

Open
nwsparks opened this issue Dec 20, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. service/iam Issues and PRs that pertain to the iam service.

Comments

@nwsparks
Copy link
Contributor

Terraform Core Version

1.10.0

AWS Provider Version

5.80.0

Affected Resource(s)

  • aws_iam_role_policy_attachments_exclusive
  • aws_iam_role_policy_attachment

Expected Behavior

I should be able to delete or recreate the policy that is attached to the iam role.

Actual Behavior

│ Error: deleting IAM Policy (arn:aws:iam::123123:policy/tftest-123): operation error IAM: DeletePolicy, https response error StatusCode: 409, RequestID: , DeleteConflict: Cannot delete a policy attached to entities.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

locals {
  name = "tftest-123"
}

resource "aws_iam_role" "this" {
  name = local.name

  assume_role_policy = <<-EOF
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "Service": "ec2.amazonaws.com"
          },
          "Action": "sts:AssumeRole"
        }
      ]
    }
  EOF
}

resource "aws_iam_policy" "this" {
  name = local.name

  policy = <<-EOF
    {
      "Version": "2012-10-17",
      "Statement": [
        {
            "Effect": "Allow",
            "Action": [
              "cloudwatch:list*"
            ],
            "Resource": [
              "*"
            ]
        }
      ]
    }
  EOF
}

resource "aws_iam_role_policy_attachments_exclusive" "attached_policies" {
  role_name = aws_iam_role.this.name
  policy_arns = [aws_iam_policy.this.arn]
}

Steps to Reproduce

apply this
run terraform taint aws_iam_policy.this or comment out the policy
apply again and youll hit the error

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

a few other related issues

#10945
#32906

Would you like to implement a fix?

No

@nwsparks nwsparks added the bug Addresses a defect in current functionality. label Dec 20, 2024
@github-actions github-actions bot added the service/iam Issues and PRs that pertain to the iam service. label Dec 20, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

No branches or pull requests

1 participant