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

resource/aws_iot_policy: Delete oldest policy version when max number of versions is reached #9541

Closed
wants to merge 3 commits into from

Conversation

jeandek
Copy link
Contributor

@jeandek jeandek commented Jul 29, 2019

  • This change adds a function call that deletes the oldest non-default IoT policy version when the creation of a new version would result in a breach of the max number of versions (5).
  • Note that due to a bug in the Go SDK (+ CLI + Python SDK), all versions of the policy have the same creation date. Thus, I could not use it to find the oldest version (like in the aws_iam_policy resource) and I decided to use the version IDs instead.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes #9540.
Closes #30314.
Closes #24979.

Release note for CHANGELOG:

resource/aws_iot_policy: Prune oldest non-default version of IoT policies when required to create a new version

Output from acceptance testing:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSIoTPolicy'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSIoTPolicy -timeout 120m
=== RUN   TestAccAWSIoTPolicy_basic
=== PAUSE TestAccAWSIoTPolicy_basic
=== RUN   TestAccAWSIoTPolicy_invalidJson
=== PAUSE TestAccAWSIoTPolicy_invalidJson
=== RUN   TestAccAWSIoTPolicy_update
=== PAUSE TestAccAWSIoTPolicy_update
=== CONT  TestAccAWSIoTPolicy_basic
=== CONT  TestAccAWSIoTPolicy_update
=== CONT  TestAccAWSIoTPolicy_invalidJson
--- PASS: TestAccAWSIoTPolicy_invalidJson (10.78s)
--- PASS: TestAccAWSIoTPolicy_basic (22.19s)
--- PASS: TestAccAWSIoTPolicy_update (109.06s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       109.101s

@jeandek jeandek requested a review from a team July 29, 2019 23:42
@ghost ghost added size/S Managed by automation to categorize the size of a PR. service/iot Issues and PRs that pertain to the iot service. labels Jul 29, 2019
@ghost ghost added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/L Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Jul 30, 2019
@jeandek jeandek changed the title [WIP] resource/aws_iot_policy: Delete oldest policy version when max number of versions is reached resource/aws_iot_policy: Delete oldest policy version when max number of versions is reached Jul 30, 2019
@jeandek
Copy link
Contributor Author

jeandek commented Jul 30, 2019

The pull request's code is now working as expected and contains a proper acceptance test. However, it's rather long to run. This is most likely due to the number of steps in the test case, since we have to update the resource 6 times to replicate the issue/fix...

If there's some way to optimize it, I'm all ears and willing to learn !

@aeschright aeschright added the enhancement Requests to existing resources that expand the functionality or scope. label Sep 12, 2019
@yerida
Copy link

yerida commented Apr 13, 2020

When is this issue released?

@jeandek
Copy link
Contributor Author

jeandek commented Apr 13, 2020

I'm not sure. I haven't had any feedback for over 6 months...

I'm not doing IoT work anymore, so I'm in no hurry I guess.

@ewbankkit ewbankkit self-assigned this Jun 10, 2020
@ewbankkit ewbankkit removed their assignment Jul 19, 2020
Base automatically changed from master to main January 23, 2021 00:56
@breathingdust breathingdust requested a review from a team as a code owner January 23, 2021 00:56
@zhelding
Copy link
Contributor

Pull request #21306 has significantly refactored the AWS Provider codebase. As a result, most PRs opened prior to the refactor now have merge conflicts that must be resolved before proceeding.

Specifically, PR #21306 relocated the code for all AWS resources and data sources from a single aws directory to a large number of separate directories in internal/service, each corresponding to a particular AWS service. This separation of code has also allowed for us to simplify the names of underlying functions -- while still avoiding namespace collisions.

We recognize that many pull requests have been open for some time without yet being addressed by our maintainers. Therefore, we want to make it clear that resolving these conflicts in no way affects the prioritization of a particular pull request. Once a pull request has been prioritized for review, the necessary changes will be made by a maintainer -- either directly or in collaboration with the pull request author.

For a more complete description of this refactor, including examples of how old filepaths and function names correspond to their new counterparts: please refer to issue #20000.

For a quick guide on how to amend your pull request to resolve the merge conflicts resulting from this refactor and bring it in line with our new code patterns: please refer to our Service Package Refactor Pull Request Guide.

@github-actions github-actions bot added pre-service-packages Includes pre-Service Packages aspects. and removed service/iot Issues and PRs that pertain to the iot service. labels Nov 10, 2023
@ewbankkit
Copy link
Contributor

@jeandek Thanks for the contribution 🎉 👏.
This functionality has been included in #34329.

Copy link

I'm going to lock this pull request 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 related to this change, 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 Dec 14, 2023
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. pre-service-packages Includes pre-Service Packages aspects. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
5 participants