hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.2k forks source link

Add resource aws_ecr_account_setting #40219

Open lvthillo opened 1 day ago

lvthillo commented 1 day ago

Description

To be honest, I have my doubts about this PR. There’s no way to delete the configuration. There’s only PutAccountSetting and GetAccountSetting. It’s also possible to assign a name, but if I understand correctly, it can only have the value BASIC_SCAN_TYPE_VERSION. That’s why the test is a bit vague. I’ll set the PR to draft mode to potentially get input from others.

Relations

Closes #40140

References

Output from Acceptance Testing

$ make testacc TESTS=TestAccECRAccountSetting_serial PKG=ecr
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/ecr/... -v -count 1 -parallel 20 -run='TestAccAccountSetting_serial'  -timeout 360m
2024/11/20 21:44:35 Initializing Terraform AWS Provider...
=== RUN   TestAccAccountSetting_serial
=== PAUSE TestAccAccountSetting_serial
=== CONT  TestAccAccountSetting_serial
=== RUN   TestAccAccountSetting_serial/basic
--- PASS: TestAccAccountSetting_serial (30.28s)
    --- PASS: TestAccAccountSetting_serial/basic (30.28s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecr        45.900s
...

Examples using local provider:

resource "aws_ecr_account_setting" "test" {
  name  = "BASIC_SCAN_TYPE_VERSION"
  value  = "AWS_NATIVE"
}

Apply:

  # aws_ecr_account_setting.test will be created
  + resource "aws_ecr_account_setting" "test" {
      + id    = (known after apply)
      + name  = "BASIC_SCAN_TYPE_VERSION"
      + value = "AWS_NATIVE"
    }

Check w CLI

$ aws ecr get-account-setting --name BASIC_SCAN_TYPE_VERSION
{
    "name": "BASIC_SCAN_TYPE_VERSION",
    "value": "AWS_NATIVE"
}

Switch to `CLAIR``

Terraform will perform the following actions:

  # aws_ecr_account_setting.test will be updated in-place
  ~ resource "aws_ecr_account_setting" "test" {
        id    = "BASIC_SCAN_TYPE_VERSION"
        name  = "BASIC_SCAN_TYPE_VERSION"
      ~ value = "AWS_NATIVE" -> "CLAIR"
    }

Plan: 0 to add, 1 to change, 0 to destroy.

CLI output

{
    "name": "BASIC_SCAN_TYPE_VERSION",
    "value": "CLAIR"
}

Destroy

Terraform will perform the following actions:

  # aws_ecr_account_setting.test will be destroyed
  - resource "aws_ecr_account_setting" "test" {
      - id    = "BASIC_SCAN_TYPE_VERSION" -> null
      - name  = "BASIC_SCAN_TYPE_VERSION" -> null
      - value = "CLAIR" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Check CLI. Setting remains on last value

{
    "name": "BASIC_SCAN_TYPE_VERSION",
    "value": "CLAIR"
}
github-actions[bot] commented 1 day ago

Community Note

Voting for Prioritization

For Submitters