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

Tech debt: Migrateevents resources to AWS SDK for Go v2 #36932

Merged
merged 36 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
73afde8
Use AWS SDK for Go v2 for events service.
ewbankkit Apr 14, 2024
1a534f5
Add 'names.EventsEndpointID'.
ewbankkit Apr 14, 2024
d76b166
events: Generate AWS SDK for Go v2 tagging code.
ewbankkit Apr 14, 2024
0c04edb
Run 'make gen'.
ewbankkit Apr 14, 2024
107633b
Run 'go get github.com/aws/aws-sdk-go-v2/service/[email protected]
ewbankkit Apr 14, 2024
bb3be81
r/aws_cloudwatch_event_api_destination: Migrate to AWS SDK for Go v2.
ewbankkit Apr 14, 2024
052c0e5
r/aws_cloudwatch_event_archive: Migrate to AWS SDK for Go v2.
ewbankkit Apr 14, 2024
5f25454
r/aws_cloudwatch_event_bus: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
5b412dc
d/aws_cloudwatch_event_bus: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
32ab277
r/aws_cloudwatch_event_bus_policy: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
23aa9fa
r/aws_cloudwatch_event_connection: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
e83627e
d/aws_cloudwatch_event_connection: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
ea5b294
r/aws_cloudwatch_event_endpoint: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
485e18d
r/aws_cloudwatch_event_permission: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
a5462fb
r/aws_cloudwatch_event_rule: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
c419855
d/aws_cloudwatch_event_source: Migrate to AWS SDK for Go v2.
ewbankkit Apr 15, 2024
6d9e85d
Add 'errs.APIError'.
ewbankkit Apr 15, 2024
1198fb3
Tweak 'appconfig.NewClient'.
ewbankkit Apr 15, 2024
1ce7a11
r/aws_cloudwatch_event_target: Migrate to AWS SDK for Go v2.
ewbankkit Apr 16, 2024
fa8fb7f
'verify.MapLenBetween' -> 'verify.MapSizeBetween'.
ewbankkit Apr 16, 2024
8690755
Add 'verify.MapSizeAtMost'.
ewbankkit Apr 16, 2024
f55f4ac
Add 'verify.MapKeyNoMatch'.
ewbankkit Apr 16, 2024
95717aa
r/aws_cloudwatch_event_target: Use 'verify.MapKeyNoMatch'.
ewbankkit Apr 16, 2024
2225d08
events: Generate additional listers.
ewbankkit Apr 16, 2024
ac24c00
events: Tidy up sweepers.
ewbankkit Apr 16, 2024
91a0ae1
Merge branch 'main' into td-migrate-events-to-aws-sdk-v2
ewbankkit Apr 16, 2024
f70d0d0
Run 'make cleantidy'.
ewbankkit Apr 16, 2024
5f825b1
Exclude 'list_pages_gen.go' from '-in-func-name' semgrep check.
ewbankkit Apr 16, 2024
f7001ac
Run 'make gen'.
ewbankkit Apr 16, 2024
ea6467c
Fix semgrep 'ci.events-in-func-name'.
ewbankkit Apr 16, 2024
1745afd
events: Fix sweepers.
ewbankkit Apr 16, 2024
9b68856
Fix golangci-lint 'staticcheck/SA4023'.
ewbankkit Apr 16, 2024
5346361
Cosmetics.
ewbankkit Apr 16, 2024
fe4c614
Fix 'TestAccEventsRule_state'.
ewbankkit Apr 16, 2024
d5d5eac
Tidy up 'testAccTargetConfig_ecsPlacementStrategy'.
ewbankkit Apr 16, 2024
23d1281
Fix 'TestAccEventsTarget_Input_transformer'.
ewbankkit Apr 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 142 additions & 14 deletions .ci/.semgrep-service-name0.yml

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions .ci/.semgrep-service-name1.yml

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions .ci/.semgrep-service-name2.yml

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions .ci/.semgrep-service-name3.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.30.5
github.com/aws/aws-sdk-go-v2/service/emr v1.39.5
github.com/aws/aws-sdk-go-v2/service/emrserverless v1.17.5
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.30.4
github.com/aws/aws-sdk-go-v2/service/evidently v1.19.4
github.com/aws/aws-sdk-go-v2/service/finspace v1.24.1
github.com/aws/aws-sdk-go-v2/service/firehose v1.28.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ github.com/aws/aws-sdk-go-v2/service/emr v1.39.5 h1:ni+E9GfbQ8CzjYSlJ+WbNYX7SAsL
github.com/aws/aws-sdk-go-v2/service/emr v1.39.5/go.mod h1:7WusX+O5pwTnx2yobUO/P1C5HlBibmrQb5gKEPFjTYM=
github.com/aws/aws-sdk-go-v2/service/emrserverless v1.17.5 h1:w7hZ1/CRiKvzAtkzlv7tcP/wqxh9kdm5nWj4fq6/+RE=
github.com/aws/aws-sdk-go-v2/service/emrserverless v1.17.5/go.mod h1:TZrahLcSXIN/kO96kvxUzfLNLH8E6t3xodv8Zv5DHGs=
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.30.4 h1:Vz4ilZcVXCR9yatX5yfMrkBldYggtkih3h7woHvzu5Q=
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.30.4/go.mod h1:aIINXlt2xXhMeRsyCsLDUDohI8AdDm92gY9nIB6pv0M=
github.com/aws/aws-sdk-go-v2/service/evidently v1.19.4 h1:DcRQTdvIQs+v+rQJ598v7WmgLSsla9C90mY4J+rccrU=
github.com/aws/aws-sdk-go-v2/service/evidently v1.19.4/go.mod h1:ajhW/0n1t1jQKd2Kn46/99wcMj41TSPBJ3vSWocTvdE=
github.com/aws/aws-sdk-go-v2/service/finspace v1.24.1 h1:1syXGgya/121hPyOlzi4RvV1lrtIGEHLlrYUiRsZbXo=
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.

16 changes: 16 additions & 0 deletions internal/errs/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package errs

import (
smithy "github.com/aws/smithy-go"
)

// APIError returns a new error suitable for checking via aws-sdk-go-base/tfawserr.
func APIError(code, message string) smithy.APIError {
return &smithy.GenericAPIError{
Code: code,
Message: message,
}
}
2 changes: 2 additions & 0 deletions internal/generate/servicesemgrep/service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
paths:
include:
- internal/service/{{ .ProviderPackage }}
exclude:
- internal/service/{{ .ProviderPackage }}/list_pages_gen.go
patterns:
- pattern: func $NAME( ... ) { ... }
- metavariable-pattern:
Expand Down
13 changes: 5 additions & 8 deletions internal/service/appconfig/service_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package appconfig

import (
"context"
"errors"

aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws"
retry_sdkv2 "github.com/aws/aws-sdk-go-v2/aws/retry"
Expand All @@ -28,13 +27,11 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (
// if ongoing deployments are in-progress, thus we handle them
// here for the service client.
o.Retryer = conns.AddIsErrorRetryables(cfg.Retryer().(aws_sdkv2.RetryerV2), retry_sdkv2.IsErrorRetryableFunc(func(err error) aws_sdkv2.Ternary {
if err != nil {
var oe *smithy.OperationError
if errors.As(err, &oe) {
if oe.OperationName == "StartDeployment" {
if errs.IsA[*awstypes.ConflictException](err) {
return aws_sdkv2.TrueTernary
}
if v, ok := errs.As[*smithy.OperationError](err); ok {
switch v.OperationName {
case "StartDeployment":
if errs.IsA[*awstypes.ConflictException](err) {
return aws_sdkv2.TrueTernary
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/ebs_fast_snapshot_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *ebsFastSnapshotRestoreResource) Create(ctx context.Context, request res
output, err := conn.EnableFastSnapshotRestores(ctx, input)

if err == nil && output != nil {
err = EnableFastSnapshotRestoreItemsError(output.Unsuccessful)
err = enableFastSnapshotRestoreItemsError(output.Unsuccessful)
}

if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions internal/service/ec2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
)

const (
Expand Down Expand Up @@ -193,31 +194,31 @@ func UnsuccessfulItemsError(apiObjects []*ec2.UnsuccessfulItem) error {
return errors.Join(errs...)
}

func EnableFastSnapshotRestoreStateItemError(apiObject *awstypes.EnableFastSnapshotRestoreStateError) error {
func enableFastSnapshotRestoreStateItemError(apiObject *awstypes.EnableFastSnapshotRestoreStateError) error {
if apiObject == nil {
return nil
}

return awserr.New(aws_sdkv2.ToString(apiObject.Code), aws_sdkv2.ToString(apiObject.Message), nil)
return errs.APIError(aws_sdkv2.ToString(apiObject.Code), aws_sdkv2.ToString(apiObject.Message))
}

func EnableFastSnapshotRestoreStateItemsError(apiObjects []awstypes.EnableFastSnapshotRestoreStateErrorItem) error {
func enableFastSnapshotRestoreStateItemsError(apiObjects []awstypes.EnableFastSnapshotRestoreStateErrorItem) error {
var errs []error

for _, apiObject := range apiObjects {
if err := EnableFastSnapshotRestoreStateItemError(apiObject.Error); err != nil {
if err := enableFastSnapshotRestoreStateItemError(apiObject.Error); err != nil {
errs = append(errs, fmt.Errorf("%s: %w", aws_sdkv2.ToString(apiObject.AvailabilityZone), err))
}
}

return errors.Join(errs...)
}

func EnableFastSnapshotRestoreItemsError(apiObjects []awstypes.EnableFastSnapshotRestoreErrorItem) error {
func enableFastSnapshotRestoreItemsError(apiObjects []awstypes.EnableFastSnapshotRestoreErrorItem) error {
var errs []error

for _, apiObject := range apiObjects {
if err := EnableFastSnapshotRestoreStateItemsError(apiObject.FastSnapshotRestoreStateErrors); err != nil {
if err := enableFastSnapshotRestoreStateItemsError(apiObject.FastSnapshotRestoreStateErrors); err != nil {
errs = append(errs, fmt.Errorf("%s: %w", aws_sdkv2.ToString(apiObject.SnapshotId), err))
}
}
Expand Down
Loading
Loading