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 : ECR scanning configuration empty rules #31449

Conversation

sousmangoosta
Copy link
Contributor

@sousmangoosta sousmangoosta commented May 17, 2023

Description

More context

If we only send to the API the scan_type without empty rule when we remove all rules, the API consider that there is no changes needed.
This PR then remove the nil check so an empty list is sent when there is no rules anymore.

Relations

Closes #31423.

Output from Acceptance Testing

before the nil removal

$ make testacc TESTS='TestAccECRScanningConfiguration_serial' PKG=ecr
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccECRScanningConfiguration_serial'  -timeout 180m
=== RUN   TestAccECRScanningConfiguration_serial
=== PAUSE TestAccECRScanningConfiguration_serial
=== CONT  TestAccECRScanningConfiguration_serial
=== RUN   TestAccECRScanningConfiguration_serial/update
    registry_scanning_configuration_test.go:60: Step 5/6 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # aws_ecr_registry_scanning_configuration.test will be updated in-place
          ~ resource "aws_ecr_registry_scanning_configuration" "test" {
                id          = "1234567890"
                # (2 unchanged attributes hidden)
        
              - rule {
                  - scan_frequency = "SCAN_ON_PUSH" -> null
        
                  - repository_filter {
                      - filter      = "*" -> null
                      - filter_type = "WILDCARD" -> null
                    }
                }
              - rule {
                  - scan_frequency = "CONTINUOUS_SCAN" -> null
        
                  - repository_filter {
                      - filter      = "example" -> null
                      - filter_type = "WILDCARD" -> null
                    }
                }
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccECRScanningConfiguration_serial (49.95s)
    --- FAIL: TestAccECRScanningConfiguration_serial/update (49.95s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/ecr        50.131s
FAIL
make: *** [testacc] Error 1
$

With the nil removal

$ make testacc TESTS='TestAccECRScanningConfiguration_serial' PKG=ecr
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccECRScanningConfiguration_serial'  -timeout 180m
=== RUN   TestAccECRScanningConfiguration_serial
=== PAUSE TestAccECRScanningConfiguration_serial
=== CONT  TestAccECRScanningConfiguration_serial
=== RUN   TestAccECRScanningConfiguration_serial/basic
=== RUN   TestAccECRScanningConfiguration_serial/update
--- PASS: TestAccECRScanningConfiguration_serial (71.87s)
    --- PASS: TestAccECRScanningConfiguration_serial/basic (19.38s)
    --- PASS: TestAccECRScanningConfiguration_serial/update (52.49s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        72.052s
$

@github-actions
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 service/ecr Issues and PRs that pertain to the ecr service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XS Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. labels May 17, 2023
@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 17, 2023
@ewbankkit ewbankkit self-assigned this Aug 11, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Aug 11, 2023
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=TestAccECRScanningConfiguration_serial' PKG=ecr
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecr/... -v -count 1 -parallel 20  -run=TestAccECRScanningConfiguration_serial -timeout 180m
=== RUN   TestAccECRScanningConfiguration_serial
=== PAUSE TestAccECRScanningConfiguration_serial
=== CONT  TestAccECRScanningConfiguration_serial
=== RUN   TestAccECRScanningConfiguration_serial/basic
=== RUN   TestAccECRScanningConfiguration_serial/update
--- PASS: TestAccECRScanningConfiguration_serial (88.60s)
    --- PASS: TestAccECRScanningConfiguration_serial/basic (24.01s)
    --- PASS: TestAccECRScanningConfiguration_serial/update (64.60s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecr	93.811s

@ewbankkit
Copy link
Contributor

@sousmangoosta Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 42c03b9 into hashicorp:main Aug 11, 2023
34 checks passed
@github-actions github-actions bot added this to the v5.13.0 milestone Aug 11, 2023
@github-actions github-actions bot removed the bug Addresses a defect in current functionality. label Aug 18, 2023
@github-actions
Copy link

This functionality has been released in v5.13.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!

@github-actions
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 Sep 18, 2023
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
@sousmangoosta sousmangoosta deleted the b-ecr_scanning_configuration-fix_allrules_delete branch February 22, 2024 08:24
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. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/ecr Issues and PRs that pertain to the ecr 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
3 participants