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_iot_policy.X: VersionsLimitExceededException: The policy X already has the maximum number of versions (5) #9540

Closed
jeandek opened this issue Jul 29, 2019 · 7 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/iot Issues and PRs that pertain to the iot service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@jeandek
Copy link
Contributor

jeandek commented Jul 29, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.14
provider.aws v2.21.1

Affected Resource(s)

  • aws_iot_policy

Terraform Configuration Files

terraform {}

provider "aws" {}

resource "aws_iot_policy" "test" {
  name = "testJean"

  policy = <<POLICY
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:Publish",
      "Resource": "arn:aws:iot:*:*:topic/topic6"
    }
  ]
}
POLICY
}

Output

1 error occurred:
* aws_iot_policy.test: 1 error occurred:
* aws_iot_policy.test: VersionsLimitExceededException: The policy testJean already has the maximum number of versions (5)
status code: 409, request id: 34c184cc-b256-11e9-8ec0-a331a0a34c0e

Expected Behavior

I would expect the same behaviour as with aws_iam_policy. The oldest non-default policy version should be deleted to make room for the new one.

Steps to Reproduce

Just copy and paste the TF configuration I posted above and run terraform apply six times. (You can change the topic number, for instance.)

References

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 29, 2019
@jeandek
Copy link
Contributor Author

jeandek commented Jul 29, 2019

I've started work on a pull request and I'll create a WIP later today.

@nywilken nywilken added enhancement Requests to existing resources that expand the functionality or scope. service/iot Issues and PRs that pertain to the iot service. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 30, 2019
@nywilken
Copy link
Contributor

Hi @jeandek thanks for taking the lead on this. Please feel free to reach out if you find you need help.

@jeandek
Copy link
Contributor Author

jeandek commented Jul 30, 2019

Thanks @nywilken!

I think I've managed on my own, but my new acceptance test takes quite a while to run. This might be normal because there are quite a few steps, but feel free to have a look at my pull request if you have the spare time.

@Sytten
Copy link

Sytten commented Dec 1, 2019

I hit a bug related to this issue. When you get the 409, terraform assumes that the policy has changed and update its internal state. So if you try to apply again, it will not detect a diff.

@jeandek
Copy link
Contributor Author

jeandek commented Dec 2, 2019

@Sytten : I think your problem probably deserves its own issue. While my PR would prevent it from occurring, the root cause is very different since it's related to how/what Terraform records in its resource graph.

@github-actions
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Nov 21, 2021
@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/iot Issues and PRs that pertain to the iot service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
3 participants