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

fix: convert insight_type to set type to address element order issue in aws_cloudtrail #37591

Merged

Conversation

acwwat
Copy link
Contributor

@acwwat acwwat commented May 20, 2024

Description

This PR is to convert the insight_selector argument type from List to Set for the aws_cloudtrail resource, so that it accounts for the unordered nature of this element in the AWS API response.

Note that in the acceptance case, TestAccCloudTrail_serial/Trail/migrateV0 is failing because the ID is set to the ARN and not the name. I am not sure if it's due to my development environment having the override to use a compiled version of the provider or something else. Since it's unrelated to the changes in the PR, I will still check in the code as-is.

Relations

Closes #37525

References

Referred to PR #33040 for similar fix.

Output from Acceptance Testing

$ make testacc TESTS=TestAccCloudTrail_serial/Trail PKG=cloudtrail
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/cloudtrail/... -v -count 1 -parallel 20 -run='TestAccCloudTrail_serial/Trail'  -timeout 360m
=== RUN   TestAccCloudTrail_serial
=== PAUSE TestAccCloudTrail_serial
=== CONT  TestAccCloudTrail_serial
=== RUN   TestAccCloudTrail_serial/Trail
=== RUN   TestAccCloudTrail_serial/Trail/tags
=== RUN   TestAccCloudTrail_serial/Trail/eventSelectorDynamoDB
=== RUN   TestAccCloudTrail_serial/Trail/eventSelectorExclude
=== RUN   TestAccCloudTrail_serial/Trail/advancedEventSelector
=== RUN   TestAccCloudTrail_serial/Trail/cloudwatch
=== RUN   TestAccCloudTrail_serial/Trail/multiRegion
=== RUN   TestAccCloudTrail_serial/Trail/basic
=== RUN   TestAccCloudTrail_serial/Trail/logValidation
=== RUN   TestAccCloudTrail_serial/Trail/eventSelector
=== RUN   TestAccCloudTrail_serial/Trail/disappears
=== RUN   TestAccCloudTrail_serial/Trail/enableLogging
=== RUN   TestAccCloudTrail_serial/Trail/globalServiceEvents
=== RUN   TestAccCloudTrail_serial/Trail/insightSelector
=== RUN   TestAccCloudTrail_serial/Trail/migrateV0
    cloudtrail_test.go:773: Step 1/2 error: Check failed: Check 4/4 error: aws_cloudtrail.test: Attribute 'id' expected "tf-acc-test-527020262212493675", got "arn:aws:cloudtrail:us-west-1:100180206982:trail/tf-acc-test-527020262212493675"
=== RUN   TestAccCloudTrail_serial/Trail/organization
    cloudtrail_test.go:262: this AWS account must be the management account of an AWS Organization
=== RUN   TestAccCloudTrail_serial/Trail/kmsKey
--- FAIL: TestAccCloudTrail_serial (658.02s)
    --- FAIL: TestAccCloudTrail_serial/Trail (658.02s)
        --- PASS: TestAccCloudTrail_serial/Trail/tags (53.35s)
        --- PASS: TestAccCloudTrail_serial/Trail/eventSelectorDynamoDB (27.60s)
        --- PASS: TestAccCloudTrail_serial/Trail/eventSelectorExclude (56.43s)
        --- PASS: TestAccCloudTrail_serial/Trail/advancedEventSelector (24.78s)
        --- PASS: TestAccCloudTrail_serial/Trail/cloudwatch (56.42s)
        --- PASS: TestAccCloudTrail_serial/Trail/multiRegion (53.49s)
        --- PASS: TestAccCloudTrail_serial/Trail/basic (41.93s)
        --- PASS: TestAccCloudTrail_serial/Trail/logValidation (38.70s)
        --- PASS: TestAccCloudTrail_serial/Trail/eventSelector (84.30s)
        --- PASS: TestAccCloudTrail_serial/Trail/disappears (23.52s)
        --- PASS: TestAccCloudTrail_serial/Trail/enableLogging (57.38s)
        --- PASS: TestAccCloudTrail_serial/Trail/globalServiceEvents (24.46s)
        --- PASS: TestAccCloudTrail_serial/Trail/insightSelector (67.89s)
        --- FAIL: TestAccCloudTrail_serial/Trail/migrateV0 (20.63s)
        --- SKIP: TestAccCloudTrail_serial/Trail/organization (0.78s)
        --- PASS: TestAccCloudTrail_serial/Trail/kmsKey (26.36s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/cloudtrail 658.214s
FAIL
make: *** [GNUmakefile:438: testacc] Error 1

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XS Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/cloudtrail Issues and PRs that pertain to the cloudtrail service. labels May 20, 2024
@terraform-aws-provider terraform-aws-provider bot added needs-triage Waiting for first response or review from a maintainer. external-maintainer Contribution from a trusted external contributor. labels May 20, 2024
@acwwat acwwat force-pushed the b-aws_cloudtrail-insight_type_list_to_set branch from 735b84f to 533228a Compare May 20, 2024 01:49
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels May 20, 2024
@ewbankkit ewbankkit requested a review from a team as a code owner July 17, 2024 14:39
@ewbankkit ewbankkit self-assigned this Jul 17, 2024
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccCloudTrail_serial' PKG=cloudtrail
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.5 test ./internal/service/cloudtrail/... -v -count 1 -parallel 20  -run=TestAccCloudTrail_serial -timeout 360m
=== RUN   TestAccCloudTrail_serial
=== PAUSE TestAccCloudTrail_serial
=== CONT  TestAccCloudTrail_serial
=== RUN   TestAccCloudTrail_serial/Trail
=== RUN   TestAccCloudTrail_serial/Trail/kmsKey
=== RUN   TestAccCloudTrail_serial/Trail/eventSelectorDynamoDB
=== RUN   TestAccCloudTrail_serial/Trail/disappears
=== RUN   TestAccCloudTrail_serial/Trail/multiRegion
=== RUN   TestAccCloudTrail_serial/Trail/organization
    cloudtrail_test.go:262: this AWS account must be the management account of an AWS Organization
=== RUN   TestAccCloudTrail_serial/Trail/logValidation
=== RUN   TestAccCloudTrail_serial/Trail/eventSelector
=== RUN   TestAccCloudTrail_serial/Trail/insightSelector
=== RUN   TestAccCloudTrail_serial/Trail/advancedEventSelector
=== RUN   TestAccCloudTrail_serial/Trail/basic
=== RUN   TestAccCloudTrail_serial/Trail/tags
=== RUN   TestAccCloudTrail_serial/Trail/cloudwatch
=== RUN   TestAccCloudTrail_serial/Trail/enableLogging
    acctest.go:1617: skipping test for aws/us-west-2: Error running apply: exit status 1
        
        Error: stopping CloudTrail Trail (arn:aws:cloudtrail:us-west-2:123456789012:trail/tf-acc-test-4360788095264194152) logging: operation error CloudTrail: StopLogging, https response error StatusCode: 400, RequestID: f397adaf-6c4c-4006-9814-c6b89536a32d, api error AccessDeniedException: User: arn:aws:sts::123456789012:assumed-role/terraform_team1_dev-developer/kewbank@hashicorp.com is not authorized to perform: cloudtrail:StopLogging on resource: arn:aws:cloudtrail:us-west-2:123456789012:trail/tf-acc-test-4360788095264194152 with an explicit deny in a service control policy
        
          with aws_cloudtrail.test,
          on terraform_plugin_test.tf line 61, in resource "aws_cloudtrail" "test":
          61: resource "aws_cloudtrail" "test" {
        
=== RUN   TestAccCloudTrail_serial/Trail/globalServiceEvents
=== RUN   TestAccCloudTrail_serial/Trail/eventSelectorExclude
=== RUN   TestAccCloudTrail_serial/Trail/migrateV0
--- PASS: TestAccCloudTrail_serial (525.19s)
    --- PASS: TestAccCloudTrail_serial/Trail (525.19s)
        --- PASS: TestAccCloudTrail_serial/Trail/kmsKey (21.60s)
        --- PASS: TestAccCloudTrail_serial/Trail/eventSelectorDynamoDB (22.89s)
        --- PASS: TestAccCloudTrail_serial/Trail/disappears (18.21s)
        --- PASS: TestAccCloudTrail_serial/Trail/multiRegion (40.53s)
        --- SKIP: TestAccCloudTrail_serial/Trail/organization (0.63s)
        --- PASS: TestAccCloudTrail_serial/Trail/logValidation (29.78s)
        --- PASS: TestAccCloudTrail_serial/Trail/eventSelector (68.24s)
        --- PASS: TestAccCloudTrail_serial/Trail/insightSelector (52.06s)
        --- PASS: TestAccCloudTrail_serial/Trail/advancedEventSelector (19.12s)
        --- PASS: TestAccCloudTrail_serial/Trail/basic (32.76s)
        --- PASS: TestAccCloudTrail_serial/Trail/tags (40.36s)
        --- PASS: TestAccCloudTrail_serial/Trail/cloudwatch (47.70s)
        --- SKIP: TestAccCloudTrail_serial/Trail/enableLogging (24.69s)
        --- PASS: TestAccCloudTrail_serial/Trail/globalServiceEvents (19.05s)
        --- PASS: TestAccCloudTrail_serial/Trail/eventSelectorExclude (42.92s)
        --- PASS: TestAccCloudTrail_serial/Trail/migrateV0 (44.66s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/cloudtrail	530.191s

@ewbankkit
Copy link
Contributor

@acwwat Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 734cccc into hashicorp:main Jul 17, 2024
45 checks passed
@github-actions github-actions bot added this to the v5.59.0 milestone Jul 17, 2024
Copy link

This functionality has been released in v5.59.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@acwwat acwwat deleted the b-aws_cloudtrail-insight_type_list_to_set branch July 20, 2024 19:07
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 Aug 20, 2024
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. external-maintainer Contribution from a trusted external contributor. service/cloudtrail Issues and PRs that pertain to the cloudtrail service. size/XS 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
Development

Successfully merging this pull request may close these issues.

[Bug]: aws_cloudtrail always shows changes due to switching insight_type values
3 participants