Skip to content

Commit

Permalink
Merge pull request #37548 from DanielRieske/f/migrate-transfer-sdkv2
Browse files Browse the repository at this point in the history
Migrate `transfer` resources to AWS Go SDKv2
  • Loading branch information
ewbankkit authored Jun 5, 2024
2 parents 48ac09e + 8cc5526 commit e5b4b69
Show file tree
Hide file tree
Showing 42 changed files with 1,371 additions and 1,544 deletions.
3 changes: 3 additions & 0 deletions .changelog/37548.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_transfer_ssh_key: Add `ssh_key_id` attribute
```
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.

13 changes: 13 additions & 0 deletions internal/flex/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ func ExpandInt64Set(configured *schema.Set) []*int64 {
return ExpandInt64List(configured.List())
}

// Takes the result of schema.Set of strings and returns a []int64
func ExpandInt64ValueSet(configured *schema.Set) []int64 {
return ExpandInt64ValueList(configured.List())
}

func FlattenInt64Set(list []*int64) *schema.Set {
return schema.NewSet(schema.HashInt, FlattenInt64List(list))
}
Expand All @@ -274,6 +279,14 @@ func FlattenInt32ValueSet(set []int32) *schema.Set {
return schema.NewSet(schema.HashInt, FlattenInt32ValueList(set))
}

// Takes the result of flatmap.Expand for an array of int64
// and returns a []int64
func ExpandInt64ValueList(configured []interface{}) []int64 {
return tfslices.ApplyToAll(configured, func(v any) int64 {
return int64(v.(int))
})
}

// Takes the result of flatmap.Expand for an array of int64
// and returns a []*int64
func ExpandInt64List(configured []interface{}) []*int64 {
Expand Down
2 changes: 2 additions & 0 deletions internal/service/ec2/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ var (
FindNetworkInterfacesByAttachmentInstanceOwnerIDAndDescriptionV2 = findNetworkInterfacesByAttachmentInstanceOwnerIDAndDescriptionV2
FindNetworkInterfacesV2 = findNetworkInterfacesV2
FindVPCByIDV2 = findVPCByIDV2
FindVPCEndpointByIDV2 = findVPCEndpointByIDV2
NewCustomFilterListFrameworkV2 = newCustomFilterListFrameworkV2
NewFilter = newFilter
NewFilterV2 = newFilterV2
VPCEndpointCreationTimeout = vpcEndpointCreationTimeout
WaitVPCEndpointAvailableV2 = waitVPCEndpointAvailableV2
)
1 change: 0 additions & 1 deletion internal/service/ec2/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ var (
FindRouteTableAssociationByIDV2 = findRouteTableAssociationByID
FindRouteTableByIDV2 = findRouteTableByID
FindVolumeAttachmentInstanceByID = findVolumeAttachmentInstanceByID
FindVPCEndpointByIDV2 = findVPCEndpointByIDV2
FindVPCEndpointConnectionByServiceIDAndVPCEndpointIDV2 = findVPCEndpointConnectionByServiceIDAndVPCEndpointIDV2
FindVPCEndpointConnectionNotificationByIDV2 = findVPCEndpointConnectionNotificationByIDV2
FindVPCEndpointRouteTableAssociationExistsV2 = findVPCEndpointRouteTableAssociationExistsV2
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func resourceVPCEndpointCreate(ctx context.Context, d *schema.ResourceData, meta
}
}

if _, err = waitVPCEndpointAvailableV2(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil {
if _, err := waitVPCEndpointAvailableV2(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for EC2 VPC Endpoint (%s) create: %s", serviceName, err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/service/ec2/waitv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func waitVPCEndpointAcceptedV2(ctx context.Context, conn *ec2.Client, vpcEndpoin
return nil, err
}

func waitVPCEndpointAvailableV2(ctx context.Context, conn *ec2.Client, vpcEndpointID string, timeout time.Duration) (*types.VpcEndpoint, error) { //nolint:unparam
func waitVPCEndpointAvailableV2(ctx context.Context, conn *ec2.Client, vpcEndpointID string, timeout time.Duration) (*types.VpcEndpoint, error) {
stateConf := &retry.StateChangeConf{
Pending: enum.Slice(vpcEndpointStatePending),
Target: enum.Slice(vpcEndpointStateAvailable, vpcEndpointStatePendingAcceptance),
Expand Down
6 changes: 3 additions & 3 deletions internal/service/transfer/acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"context"
"testing"

"github.com/aws/aws-sdk-go/service/transfer"
"github.com/aws/aws-sdk-go-v2/service/transfer"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
)

func testAccPreCheck(ctx context.Context, t *testing.T) {
conn := acctest.Provider.Meta().(*conns.AWSClient).TransferConn(ctx)
conn := acctest.Provider.Meta().(*conns.AWSClient).TransferClient(ctx)

input := &transfer.ListServersInput{}

_, err := conn.ListServersWithContext(ctx, input)
_, err := conn.ListServers(ctx, input)

if acctest.PreCheckSkipError(err) {
t.Skipf("skipping acceptance testing: %s", err)
Expand Down
Loading

0 comments on commit e5b4b69

Please sign in to comment.