Skip to content

Commit

Permalink
Merge pull request hashicorp#36652 from mattburgess/autoscaling-plans…
Browse files Browse the repository at this point in the history
…-awssdkv2-migration

autoscalingplans: Migrate to AWS SDK v2
  • Loading branch information
johnsonaj authored Apr 3, 2024
2 parents 5a9d0cb + 4b490c5 commit eb930bb
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 200 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/apprunner v1.28.4
github.com/aws/aws-sdk-go-v2/service/athena v1.40.4
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.32.4
github.com/aws/aws-sdk-go-v2/service/autoscalingplans v1.20.4
github.com/aws/aws-sdk-go-v2/service/batch v1.36.1
github.com/aws/aws-sdk-go-v2/service/bedrock v1.7.5
github.com/aws/aws-sdk-go-v2/service/bedrockagent v1.5.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ github.com/aws/aws-sdk-go-v2/service/athena v1.40.4 h1:tiHIjFXSyb5DbNfnu3ql2r86s
github.com/aws/aws-sdk-go-v2/service/athena v1.40.4/go.mod h1:6OHesqDfYPNzYI+VaXtmylYLyppuUy9SwRk4CH/pQA4=
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.32.4 h1:45+KYpnG8ZKoqLkQSIg8hnU52rbBRyIYHqaSf+02P3I=
github.com/aws/aws-sdk-go-v2/service/auditmanager v1.32.4/go.mod h1:WHURzIps29VZSUz9jxpGeShOhGuf/SqQmNJLs3Ytfns=
github.com/aws/aws-sdk-go-v2/service/autoscalingplans v1.20.4 h1:LIQN+2GGZHwWksR6cVQtEF7xdLZUEsmUqy+4fStrZcE=
github.com/aws/aws-sdk-go-v2/service/autoscalingplans v1.20.4/go.mod h1:5orNWB4auLR1UJ6MUrRpAwne7uZ84Y6cq/0sB6F6LA4=
github.com/aws/aws-sdk-go-v2/service/batch v1.36.1 h1:OY9+Dt4FkK6q2VHKAB8zY4nEKOhkziVOtxCPnS94leM=
github.com/aws/aws-sdk-go-v2/service/batch v1.36.1/go.mod h1:JuPGVm7DzXD73vZBQsZwlDzoJeZewN08swLBGiU47K8=
github.com/aws/aws-sdk-go-v2/service/bedrock v1.7.5 h1:lTJX3uTdi3CdJ6xEUbgMeJC5iPpY1EH2zzEqwZQbr4Q=
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.

21 changes: 9 additions & 12 deletions internal/service/autoscalingplans/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ package autoscalingplans
import (
"context"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/autoscalingplans"
"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/service/autoscalingplans"
awstypes "github.com/aws/aws-sdk-go-v2/service/autoscalingplans/types"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
)

func FindScalingPlanByNameAndVersion(ctx context.Context, conn *autoscalingplans.AutoScalingPlans, scalingPlanName string, scalingPlanVersion int) (*autoscalingplans.ScalingPlan, error) {
func FindScalingPlanByNameAndVersion(ctx context.Context, conn *autoscalingplans.Client, scalingPlanName string, scalingPlanVersion int) (*awstypes.ScalingPlan, error) {
input := &autoscalingplans.DescribeScalingPlansInput{
ScalingPlanNames: aws.StringSlice([]string{scalingPlanName}),
ScalingPlanNames: []string{scalingPlanName},
ScalingPlanVersion: aws.Int64(int64(scalingPlanVersion)),
}

output, err := conn.DescribeScalingPlansWithContext(ctx, input)
output, err := conn.DescribeScalingPlans(ctx, input)

if tfawserr.ErrCodeEquals(err, autoscalingplans.ErrCodeObjectNotFoundException) {
if errs.IsA[*awstypes.ObjectNotFoundException](err) {
return nil, &retry.NotFoundError{
LastError: err,
LastRequest: input,
Expand All @@ -32,9 +33,5 @@ func FindScalingPlanByNameAndVersion(ctx context.Context, conn *autoscalingplans
return nil, err
}

if output == nil || len(output.ScalingPlans) == 0 || output.ScalingPlans[0] == nil {
return nil, tfresource.NewEmptyResultError(input)
}

return output.ScalingPlans[0], nil
return tfresource.AssertSingleValueResult(output.ScalingPlans)
}
2 changes: 1 addition & 1 deletion internal/service/autoscalingplans/generate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

//go:generate go run ../../generate/listpages/main.go -ListOps=DescribeScalingPlans
//go:generate go run ../../generate/listpages/main.go -AWSSDKVersion=2 -ListOps=DescribeScalingPlans
//go:generate go run ../../generate/servicepackage/main.go
// ONLY generate directives and package declaration! Do not add anything else to this file.

Expand Down
13 changes: 6 additions & 7 deletions internal/service/autoscalingplans/list_pages_gen.go

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

Loading

0 comments on commit eb930bb

Please sign in to comment.