Skip to content

Commit

Permalink
Merge pull request #37288 from hashicorp/td-migrate-dynamodb-to-aws-s…
Browse files Browse the repository at this point in the history
…dk-v2

Migrate `dynamodb` resources to AWS SDK for Go v2
  • Loading branch information
ewbankkit authored May 9, 2024
2 parents d0c8c1e + 9230fcf commit ba69996
Show file tree
Hide file tree
Showing 43 changed files with 1,947 additions and 2,052 deletions.
3 changes: 3 additions & 0 deletions .changelog/37288.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_dynamodb_table_export: Add plan-time validation of `table_arn`
```
11 changes: 0 additions & 11 deletions internal/conns/awsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
aws_sdkv1 "github.com/aws/aws-sdk-go/aws"
session_sdkv1 "github.com/aws/aws-sdk-go/aws/session"
directoryservice_sdkv1 "github.com/aws/aws-sdk-go/service/directoryservice"
dynamodb_sdkv1 "github.com/aws/aws-sdk-go/service/dynamodb"
efs_sdkv1 "github.com/aws/aws-sdk-go/service/efs"
opsworks_sdkv1 "github.com/aws/aws-sdk-go/service/opsworks"
rds_sdkv1 "github.com/aws/aws-sdk-go/service/rds"
Expand Down Expand Up @@ -64,16 +63,6 @@ func (c *AWSClient) AwsConfig(context.Context) aws_sdkv2.Config { // nosemgrep:c
return c.awsConfig.Copy()
}

// DynamoDBConnForRegion returns an AWS SDK For Go v1 DynamoDB API client for the specified AWS Region.
// If the specified region is not the default a new "simple" client is created.
// This new client does not use any configured endpoint override.
func (c *AWSClient) DynamoDBConnForRegion(ctx context.Context, region string) *dynamodb_sdkv1.DynamoDB {
if region == c.Region {
return c.DynamoDBConn(ctx)
}
return dynamodb_sdkv1.New(c.session, aws_sdkv1.NewConfig().WithRegion(region))
}

// DSConnForRegion returns an AWS SDK For Go v1 DS API client for the specified AWS Region.
// If the specified region is not the default a new "simple" client is created.
// This new client does not use any configured endpoint override.
Expand Down
5 changes: 0 additions & 5 deletions internal/conns/awsclient_gen.go

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

14 changes: 14 additions & 0 deletions internal/maps/maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ func ApplyToAllValues[M ~map[K]V1, K comparable, V1, V2 any](m M, f func(V1) V2)
return n
}

func ApplyToAllValuesWithError[M ~map[K]V1, K comparable, V1, V2 any](m M, f func(V1) (V2, error)) (map[K]V2, error) {
n := make(map[K]V2, len(m))

for k, v1 := range m {
v2, err := f(v1)
if err != nil {
return nil, err
}
n[k] = v2
}

return n, nil
}

// Keys returns the keys of the map `m`.
// The keys will be in an indeterminate order.
func Keys[M ~map[K]V, K comparable, V any](m M) []K {
Expand Down
8 changes: 4 additions & 4 deletions internal/service/dynamodb/arn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ package dynamodb
import (
"strings"

"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go-v2/aws/arn"
)

func ARNForNewRegion(rn string, newRegion string) (string, error) {
func arnForNewRegion(rn string, newRegion string) (string, error) {
parsedARN, err := arn.Parse(rn)
if err != nil {
return "", err
Expand All @@ -20,7 +20,7 @@ func ARNForNewRegion(rn string, newRegion string) (string, error) {
return parsedARN.String(), nil
}

func RegionFromARN(rn string) (string, error) {
func regionFromARN(rn string) (string, error) {
parsedARN, err := arn.Parse(rn)
if err != nil {
return "", err
Expand All @@ -29,7 +29,7 @@ func RegionFromARN(rn string) (string, error) {
return parsedARN.Region, nil
}

func TableNameFromARN(rn string) (string, error) {
func tableNameFromARN(rn string) (string, error) {
parsedARN, err := arn.Parse(rn)
if err != nil {
return "", err
Expand Down
28 changes: 0 additions & 28 deletions internal/service/dynamodb/backup.go

This file was deleted.

Loading

0 comments on commit ba69996

Please sign in to comment.