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

b/Config Service rule: Prevent duplication on name change #15136

Merged
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
041e73c
Config Service rule: Prevent duplication on name change
FaHeymann Sep 13, 2020
c899095
Revert "Config Service rule: Prevent duplication on name change"
ewbankkit Feb 20, 2024
1c6c263
Merge branch 'main' into HEAD
ewbankkit Feb 20, 2024
320729d
configservice: Use AWS SDK for Go v2.
ewbankkit Feb 20, 2024
aa1b485
Run 'make gen'.
ewbankkit Feb 20, 2024
e644e55
Run 'go get github.com/aws/aws-sdk-go-v2/service/configservice@v1.45.…
ewbankkit Feb 20, 2024
a06a14d
r/aws_config_configuration_recorder: Migrate to AWS SDK for Go v2.
ewbankkit Feb 20, 2024
b9a7478
Add CHANGELOG entry.
ewbankkit Feb 20, 2024
886c01b
r/aws_config_configuration_recorder_status: Migrate to AWS SDK for Go…
ewbankkit Feb 20, 2024
f167a3b
r/aws_config_delivery_channel: Migrate to AWS SDK for Go v2.
ewbankkit Feb 20, 2024
4cdc96e
r/aws_config_conformance_pack: Migrate to AWS SDK for Go v2.
ewbankkit Feb 21, 2024
a87dde8
r/aws_config_aggregate_authorization: Migrate to AWS SDK for Go v2.
ewbankkit Feb 21, 2024
c884140
r/aws_config_configuration_aggregator: Migrate to AWS SDK for Go v2.
ewbankkit Feb 21, 2024
27ad354
r/aws_config_remediation_configuration: Migrate to AWS SDK for Go v2.
ewbankkit Feb 21, 2024
858a2a4
r/aws_config_config_rule: Migrate to AWS SDK for Go v2.
ewbankkit Feb 21, 2024
56b96ec
r/aws_config_organization_conformance_pack: Migrate to AWS SDK for Go…
ewbankkit Feb 22, 2024
5ec3154
r/aws_config_organization_managed_rule: Migrate to AWS SDK for Go v2.
ewbankkit Feb 22, 2024
966cedd
r/aws_config_organization_custom_rule: Migrate to AWS SDK for Go v2.
ewbankkit Feb 22, 2024
a3bae74
r/aws_config_organization_custom_policy_rule: Migrate to AWS SDK for …
ewbankkit Feb 22, 2024
84b37c4
configservice: Migrate sweepers to AWS SDK for Go v2.
ewbankkit Feb 22, 2024
efd63c9
Merge branch 'main' into HEAD
ewbankkit Feb 22, 2024
0a9cc35
Tidy up some service paclage AWS SDK for Go v2 client factories.
ewbankkit Feb 23, 2024
12cee57
cloudhsmv2: Custom API client factory.
ewbankkit Feb 23, 2024
c26d239
configservice: Retry Organization resource creation.
ewbankkit Feb 23, 2024
232a7cd
Acceptance test output:
ewbankkit Feb 23, 2024
ab8641a
configservice: Migrate acceptance tests to AWS SDK for Go v2.
ewbankkit Feb 23, 2024
3c58a17
r/aws_config_configuration_recorder_status: Fix 'NoSuchConfigurationR…
ewbankkit Feb 23, 2024
6f34a69
r/aws_config_delivery_channel: Fix 'NoSuchDeliveryChannelException' e…
ewbankkit Feb 23, 2024
86200eb
r/aws_config_configuration_recorder: Correct sweeper.
ewbankkit Feb 23, 2024
cec34f6
r/aws_config_config_rule: Fix 'NoSuchConfigRuleException' error when …
ewbankkit Feb 23, 2024
cef7310
Sweepers: Configure Adaptive retry mode.
ewbankkit Feb 23, 2024
1d821be
Add 'aws_config_config_rule' and 'aws_config_remediation_configuratio…
ewbankkit Feb 23, 2024
63fd578
Fix 'testAccConfigRuleConfig_customLambda'.
ewbankkit Feb 23, 2024
9ab7705
r/aws_config_conformance_pack: Add sweeper.
ewbankkit Feb 23, 2024
8606998
r/aws_config_remediation_configuration: Fix 'NoSuchRemediationConfigu…
ewbankkit Feb 23, 2024
61f42cf
Remove 'testAccRemediationConfiguration_migrateParameters' (fails due…
ewbankkit Feb 23, 2024
d780784
configservice: Better error handling when not in Organization.
ewbankkit Feb 24, 2024
89a3806
configservice: Better error handling when deleting Organization Confi…
ewbankkit Feb 24, 2024
9711ad7
r/aws_config_organization_custom_policy_rule: Run acceptance tests as…
ewbankkit Feb 24, 2024
77d0e78
configservice: Tweak creation of Organization resources.
ewbankkit Feb 26, 2024
c4006a8
Pause between acceptance test cases.
ewbankkit Feb 26, 2024
a4f7479
r/aws_config_organization_conformance_pack: Make waiters similar to O…
ewbankkit Feb 26, 2024
6cc979d
configservice: Tweak deletion of Organization resources.
ewbankkit Feb 26, 2024
cfca002
r/aws_config_rule: Change 'name' to ForceNew.
ewbankkit Feb 26, 2024
58bf0a4
configservice: Even more Organization retries.
ewbankkit Feb 26, 2024
9fb6936
Merge branch 'main' into HEAD
ewbankkit Feb 26, 2024
3960a2b
Acceptance test output:
ewbankkit Feb 26, 2024
e42128d
r/aws_config_aggregate_authorization: Restore acceptance tests.
ewbankkit Feb 26, 2024
1c452eb
Acceptance test output:
ewbankkit Feb 26, 2024
dca9617
r/aws_config_aggregate_authorization: Tweak acceptance tests.
ewbankkit Feb 27, 2024
ea8fc65
Fix golangci-lint 'whitespace'.
ewbankkit Feb 27, 2024
ba41d3b
Fix golangci-lint 'unparam'.
ewbankkit Feb 27, 2024
143552f
r/aws_config_retention_configuration: New resource.
ewbankkit Feb 27, 2024
1c41529
Correct 'testAccCheckRemediationConfigurationDestroy'.
ewbankkit Feb 27, 2024
7813f69
Acceptance test output:
ewbankkit Feb 27, 2024
45ad658
r/aws_config_retention_configuration: Add acceptance tests.
ewbankkit Feb 27, 2024
9e190f3
Add 'context.Context' to 'acctest.(Parallel)Test'.
ewbankkit Feb 27, 2024
288fc8c
Add 'context.Context' to 'acctest.ProviderMeta'.
ewbankkit Feb 27, 2024
558edba
r/aws_config_rule: Fix `InvalidParameterValueException: PolicyText is…
ewbankkit Feb 27, 2024
159e45d
Acceptance test output:
ewbankkit Feb 27, 2024
a37622a
r/aws_config_configuration_aggregator: No need to call 'PutConfigurat…
ewbankkit Feb 27, 2024
1a2b956
Acceptance test output:
ewbankkit Feb 27, 2024
668d194
Update 15136.txt
ewbankkit Feb 27, 2024
65ff05b
Fix golangci-lint 'unparam'.
ewbankkit Feb 27, 2024
3ff58fd
Fix golangci-lint 'contextcheck'.
ewbankkit Feb 27, 2024
45dd46d
Merge commit '3ff58fd5b295f728dbba995353e9c2cb81f339e1' into HEAD
ewbankkit Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changelog/15136.txt
@@ -0,0 +1,19 @@
```release-note:bug
resource/aws_config_configuration_recorder: Fix `panic: interface conversion: interface {} is nil, not map[string]interface {}` when `recording_group.exclusion_by_resource_types` is empty
```

```release-note:enhancement
resource/aws_config_configuration_recorder: Add plan-time validation of `aws_config_organization_custom_rule.lambda_function_arn`
```

```release-note:bug
resource/aws_config_rule: Change `name` to [ForceNew](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#forcenew)
```

```release-note:new-resource
aws_config_retention_configuration
```

```release-note:bug
resource/aws_config_rule: Fix `InvalidParameterValueException: PolicyText is required when Owner is CUSTOM_POLICY` errors on resource Update
```
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -49,6 +49,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/codestarnotifications v1.22.1
github.com/aws/aws-sdk-go-v2/service/comprehend v1.31.1
github.com/aws/aws-sdk-go-v2/service/computeoptimizer v1.33.1
github.com/aws/aws-sdk-go-v2/service/configservice v1.46.1
github.com/aws/aws-sdk-go-v2/service/connectcases v1.15.1
github.com/aws/aws-sdk-go-v2/service/controltower v1.13.1
github.com/aws/aws-sdk-go-v2/service/costoptimizationhub v1.4.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -120,6 +120,8 @@ github.com/aws/aws-sdk-go-v2/service/comprehend v1.31.1 h1:CAoDG5wkvJ8x/woXDxsnS
github.com/aws/aws-sdk-go-v2/service/comprehend v1.31.1/go.mod h1:tWhHJ9LUWQEdX5wwopa00xsTkYrOgi1sDwUxNuFYMfI=
github.com/aws/aws-sdk-go-v2/service/computeoptimizer v1.33.1 h1:rQpdG0ooVj8GhQDJSpXnFJRiUCSfftT4O4AI0zqNsBA=
github.com/aws/aws-sdk-go-v2/service/computeoptimizer v1.33.1/go.mod h1:3dkJ/DPuEmKrFcbqNuBbhmFWe/6D8I5sOwCO5OZFEXk=
github.com/aws/aws-sdk-go-v2/service/configservice v1.46.1 h1:emsv8VBtQkrBm2OJ4qT80e03KCtJj6zfKuWnDYqwtNE=
github.com/aws/aws-sdk-go-v2/service/configservice v1.46.1/go.mod h1:cuYIudpyQM/SiVg/P/UZBzThfq1IbXnswiyYDBFcTY4=
github.com/aws/aws-sdk-go-v2/service/connectcases v1.15.1 h1:CQg3/P8gT7Kg2mYBM/V6oGyW88QrC2wYlPG9/mGJ5rc=
github.com/aws/aws-sdk-go-v2/service/connectcases v1.15.1/go.mod h1:MyqG3o70o57M1M7Bw0X7hffxp8DhPKp4bgvovzwxNOA=
github.com/aws/aws-sdk-go-v2/service/controltower v1.13.1 h1:+ADMUxi3W7Wq+f2XQPpZiKBAylHZkjk8NLwYXM3VerY=
Expand Down
6 changes: 3 additions & 3 deletions internal/acctest/acctest.go
Expand Up @@ -2301,7 +2301,7 @@ resource "aws_vpc" "vpc_for_lambda" {
assign_generated_ipv6_cidr_block = true

tags = {
Name = "terraform-testacc-lambda-function"
Name = %[3]q
}
}

Expand All @@ -2313,7 +2313,7 @@ resource "aws_subnet" "subnet_for_lambda" {
assign_ipv6_address_on_creation = true

tags = {
Name = "tf-acc-lambda-function-1"
Name = %[3]q
}
}

Expand All @@ -2327,7 +2327,7 @@ resource "aws_subnet" "subnet_for_lambda_az2" {
assign_ipv6_address_on_creation = true

tags = {
Name = "tf-acc-lambda-function-2"
Name = %[3]q
}
}

Expand Down
13 changes: 6 additions & 7 deletions internal/acctest/vcr.go
Expand Up @@ -78,7 +78,7 @@
)

// ProviderMeta returns the current provider's state (AKA "meta" or "conns.AWSClient").
func ProviderMeta(t *testing.T) *conns.AWSClient {
func ProviderMeta(_ context.Context, t *testing.T) *conns.AWSClient {
t.Helper()

providerMetas.Lock()
Expand Down Expand Up @@ -383,15 +383,14 @@
}

// closeVCRRecorder closes the VCR recorder, saving the cassette and randomness seed.
func closeVCRRecorder(t *testing.T) {
func closeVCRRecorder(ctx context.Context, t *testing.T) {
t.Helper()

// Don't close the recorder if we're running because of a panic.
if p := recover(); p != nil {
panic(p)
}

ctx := context.TODO() // nosemgrep:ci.semgrep.migrate.context-todo
testName := t.Name()
providerMetas.Lock()
meta, ok := providerMetas[testName]
Expand Down Expand Up @@ -428,24 +427,24 @@
}

// ParallelTest wraps resource.ParallelTest, initializing VCR if enabled.
func ParallelTest(t *testing.T, c resource.TestCase) {
func ParallelTest(ctx context.Context, t *testing.T, c resource.TestCase) {
t.Helper()

if isVCREnabled() {
c.ProtoV5ProviderFactories = vcrEnabledProtoV5ProviderFactories(t, c.ProtoV5ProviderFactories)

Check failure on line 434 in internal/acctest/vcr.go

View workflow job for this annotation

GitHub Actions / 2 of 2

Function `vcrEnabledProtoV5ProviderFactories->vcrEnabledProtoV5ProviderFactories$1` should pass the context parameter (contextcheck)
defer closeVCRRecorder(t)
defer closeVCRRecorder(ctx, t)
}

resource.ParallelTest(t, c)
}

// Test wraps resource.Test, initializing VCR if enabled.
func Test(t *testing.T, c resource.TestCase) {
func Test(ctx context.Context, t *testing.T, c resource.TestCase) {
t.Helper()

if isVCREnabled() {
c.ProtoV5ProviderFactories = vcrEnabledProtoV5ProviderFactories(t, c.ProtoV5ProviderFactories)

Check failure on line 446 in internal/acctest/vcr.go

View workflow job for this annotation

GitHub Actions / 2 of 2

Function `vcrEnabledProtoV5ProviderFactories->vcrEnabledProtoV5ProviderFactories$1` should pass the context parameter (contextcheck)
defer closeVCRRecorder(t)
defer closeVCRRecorder(ctx, t)
}

resource.Test(t, c)
Expand Down
8 changes: 6 additions & 2 deletions internal/acctest/vcr_test.go
Expand Up @@ -10,12 +10,14 @@ import (
)

func TestRandInt(t *testing.T) {
ctx := acctest.Context(t)

t.Setenv("VCR_PATH", t.TempDir())

t.Setenv("VCR_MODE", "RECORDING")
rec1 := acctest.RandInt(t)
rec2 := acctest.RandInt(t)
acctest.CloseVCRRecorder(t)
acctest.CloseVCRRecorder(ctx, t)

t.Setenv("VCR_MODE", "REPLAYING")
rep1 := acctest.RandInt(t)
Expand All @@ -30,12 +32,14 @@ func TestRandInt(t *testing.T) {
}

func TestRandomWithPrefix(t *testing.T) {
ctx := acctest.Context(t)

t.Setenv("VCR_PATH", t.TempDir())

t.Setenv("VCR_MODE", "RECORDING")
rec1 := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
rec2 := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
acctest.CloseVCRRecorder(t)
acctest.CloseVCRRecorder(ctx, t)

t.Setenv("VCR_MODE", "REPLAYING")
rep1 := acctest.RandomWithPrefix(t, acctest.ResourcePrefix)
Expand Down
6 changes: 3 additions & 3 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 20 additions & 11 deletions internal/service/cloudhsmv2/service_package.go
Expand Up @@ -6,19 +6,28 @@ package cloudhsmv2
import (
"context"

aws_sdkv1 "github.com/aws/aws-sdk-go/aws"
request_sdkv1 "github.com/aws/aws-sdk-go/aws/request"
cloudhsmv2_sdkv1 "github.com/aws/aws-sdk-go/service/cloudhsmv2"
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/service/cloudhsmv2"
"github.com/aws/aws-sdk-go-v2/service/cloudhsmv2/types"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
)

// CustomizeConn customizes a new AWS SDK for Go v1 client for this service package's AWS API.
func (p *servicePackage) CustomizeConn(ctx context.Context, conn *cloudhsmv2_sdkv1.CloudHSMV2) (*cloudhsmv2_sdkv1.CloudHSMV2, error) {
conn.Handlers.Retry.PushBack(func(r *request_sdkv1.Request) {
if tfawserr.ErrMessageContains(r.Error, cloudhsmv2_sdkv1.ErrCodeCloudHsmInternalFailureException, "request was rejected because of an AWS CloudHSM internal failure") {
r.Retryable = aws_sdkv1.Bool(true)
// NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API.
func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*cloudhsmv2.Client, error) {
cfg := *(config["aws_sdkv2_config"].(*aws.Config))

return cloudhsmv2.NewFromConfig(cfg, func(o *cloudhsmv2.Options) {
if endpoint := config["endpoint"].(string); endpoint != "" {
o.BaseEndpoint = aws.String(endpoint)
}
})

return conn, nil
o.Retryer = conns.AddIsErrorRetryables(cfg.Retryer().(aws.RetryerV2), retry.IsErrorRetryableFunc(func(err error) aws.Ternary {
if errs.IsAErrorMessageContains[*types.CloudHsmInternalFailureException](err, "request was rejected because of an AWS CloudHSM internal failure") {
return aws.TrueTernary
}
return aws.UnknownTernary // Delegate to configured Retryer.
}))
}), nil
}
13 changes: 0 additions & 13 deletions internal/service/cloudhsmv2/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/service/codestarnotifications/sweep.go
Expand Up @@ -41,7 +41,7 @@ func sweepNotificationRules(region string) error {
}

if err != nil {
return fmt.Errorf("error listingCodeStar Notification Rules (%s): %w", region, err)
return fmt.Errorf("error listing CodeStar Notification Rules (%s): %w", region, err)
}

for _, v := range page.NotificationRules {
Expand Down