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

Gamelift: Migrate to AWS SDK v2 #38379

Merged
merged 33 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ba2e5c0
feat: Add managed_storage_configuration block to aws_ecs_cluster
acwwat Jun 12, 2024
abf9ed7
Cosmetics.
ewbankkit Jul 15, 2024
afd0b5a
gamelift: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
d3e280e
gopatch
mattburgess Jul 15, 2024
c3bc836
make gen
mattburgess Jul 15, 2024
f9e12cc
r/gamelift_alias: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
e0ede83
r/gamelift_build: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
db4f4da
r/gamelift_fleet: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
48335bc
r/gamelift_game_server_group: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
2b6ec3e
r/gamelift_game_session_queue: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
4927ab2
r/gamelift_script: Migrate to AWS SDK v2
mattburgess Jul 15, 2024
d5e4438
gamelift: helpers: migrate to AWS SDK v2
mattburgess Jul 15, 2024
3c73082
Merge branch 'main' into HEAD
ewbankkit Aug 8, 2024
2251e21
Run 'make fmt'.
ewbankkit Aug 8, 2024
16be244
r/aws_gamelift_alias: Reduce visibility.
ewbankkit Aug 8, 2024
fac9659
r/aws_gamelift_build: Reduce visibility.
ewbankkit Aug 8, 2024
137e33b
r/aws_gamelift_fleet: Reduce visibility.
ewbankkit Aug 8, 2024
5ae175c
r/aws_gamelift_fleet: Simplify.
ewbankkit Aug 8, 2024
b2e36ed
r/aws_gamelift_game_server_group: Reduce visibility.
ewbankkit Aug 9, 2024
88e9102
r/aws_gamelift_game_session_queue: Reduce visibility.
ewbankkit Aug 9, 2024
b1dfc42
r/aws_gamelift_script: Reduce visibility.
ewbankkit Aug 9, 2024
e774408
Use 'tfio.ReadFileContents'.
ewbankkit Aug 9, 2024
b7a1980
gamelift: Tidy up sweepers.
ewbankkit Aug 9, 2024
4c5969d
Fix semgrep 'ci.semgrep.aws.prefer-pointer-conversion-assignment'.
ewbankkit Aug 9, 2024
f037dac
Fix golangci-lint 'whitespace'.
ewbankkit Aug 9, 2024
d1d236f
Merge branch 'main' into HEAD
ewbankkit Aug 9, 2024
ac58ea9
gamelift: 'WINDOWS_2012' -> 'WINDOWS_2016' in acceptance tests.
ewbankkit Aug 9, 2024
137590d
Run 'make gen'.
ewbankkit Aug 9, 2024
6e679c1
Fix 'TestAccGameLiftGameSessionQueue_disappears'.
ewbankkit Aug 9, 2024
9693d4b
r/aws_gamelift_game_session_queue: Use 'resource.ParallelTest'.
ewbankkit Aug 9, 2024
f7d6259
Merge branch 'main' into HEAD
ewbankkit Aug 9, 2024
d88b903
Run 'make clean-tidy'.
ewbankkit Aug 9, 2024
c892542
Merge branch 'main' into HEAD
ewbankkit Aug 9, 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
1 change: 1 addition & 0 deletions .teamcity/scripts/provider_tests/acceptance_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TF_ACC=1 go test \
./internal/framework/... \
./internal/function/... \
./internal/generate/... \
./internal/io/... \
./internal/json/... \
./internal/logging/... \
./internal/maps/... \
Expand Down
1 change: 1 addition & 0 deletions .teamcity/scripts/provider_tests/unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go test \
./internal/framework/... \
./internal/function/... \
./internal/generate/... \
./internal/io/... \
./internal/json/... \
./internal/logging/... \
./internal/maps/... \
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/fis v1.26.3
github.com/aws/aws-sdk-go-v2/service/fms v1.35.3
github.com/aws/aws-sdk-go-v2/service/fsx v1.47.2
github.com/aws/aws-sdk-go-v2/service/gamelift v1.33.3
github.com/aws/aws-sdk-go-v2/service/glacier v1.24.3
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.27.0
github.com/aws/aws-sdk-go-v2/service/glue v1.93.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ github.com/aws/aws-sdk-go-v2/service/fms v1.35.3 h1:QeYAz3JhpkTxkS+fifDBfmgWFdSR
github.com/aws/aws-sdk-go-v2/service/fms v1.35.3/go.mod h1:GXASgVouW5X/bmEgOoV/tkzJkp5ib7ZeA+YxMc5piqs=
github.com/aws/aws-sdk-go-v2/service/fsx v1.47.2 h1:EDZ4UX4c8NJl5Zm2tj1OlbVdNA0wv2xNt55L6g38Va4=
github.com/aws/aws-sdk-go-v2/service/fsx v1.47.2/go.mod h1:OKCxqzNOd8LpwsIgoWIhjTkDONHuv3uLoObiT/fbS4Q=
github.com/aws/aws-sdk-go-v2/service/gamelift v1.33.3 h1:VPxT+CQtkd3KB2UHF851tDSUcfExpJCY/Jc/KuuZ1x0=
github.com/aws/aws-sdk-go-v2/service/gamelift v1.33.3/go.mod h1:qwK24U3+b0JBk154r1NkgAJzMfV3qUVktUB2WrBtFwc=
github.com/aws/aws-sdk-go-v2/service/glacier v1.24.3 h1:de8RU808VMx8km6t2wY3WDWigB6GqbNEcyVQRJFaIYs=
github.com/aws/aws-sdk-go-v2/service/glacier v1.24.3/go.mod h1:F/qjepwnxPHHUTK9ikZp14jLyrvB18kZ/22MmaPxtHE=
github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.27.0 h1:nlm6tZX8gwsVktDKTQe3IOagNVK1+6CGf9IpdWM6x+E=
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.

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

package io

import (
"os"

homedir "github.com/mitchellh/go-homedir"
)

// ReadFileContents reads the contents of a file into memory.
// Usually a call to this function is protected by an exclusive lock (per resource type)
// to prevent memory exhaustion (e.g. `conns.GlobalMutexKV.Lock`).
// See https://github.com/hashicorp/terraform/issues/9364.
func ReadFileContents(v string) ([]byte, error) {
filename, err := homedir.Expand(v)
if err != nil {
return nil, err
}

fileContent, err := os.ReadFile(filename)
if err != nil {
return nil, err
}

return fileContent, nil
}
10 changes: 10 additions & 0 deletions internal/service/autoscaling/exports.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package autoscaling

// Exports for use in other modules.
var (
FindGroupByName = findGroupByName
FindScalingPolicyByTwoPartKey = findScalingPolicyByTwoPartKey
)
2 changes: 0 additions & 2 deletions internal/service/autoscaling/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ var (

FindAttachmentByLoadBalancerName = findAttachmentByLoadBalancerName
FindAttachmentByTargetGroupARN = findAttachmentByTargetGroupARN
FindGroupByName = findGroupByName
FindInstanceRefreshes = findInstanceRefreshes
FindLaunchConfigurationByName = findLaunchConfigurationByName
FindLifecycleHookByTwoPartKey = findLifecycleHookByTwoPartKey
FindNotificationsByTwoPartKey = findNotificationsByTwoPartKey
FindScalingPolicyByTwoPartKey = findScalingPolicyByTwoPartKey
FindScheduleByTwoPartKey = findScheduleByTwoPartKey
FindTag = findTag
FindTrafficSourceAttachmentByThreePartKey = findTrafficSourceAttachmentByThreePartKey
Expand Down
6 changes: 2 additions & 4 deletions internal/service/autoscaling/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,8 @@ func resourcePolicyCreate(ctx context.Context, d *schema.ResourceData, meta inte

name := d.Get(names.AttrName).(string)
input, err := expandPutScalingPolicyInput(d)

if err != nil {
return sdkdiag.AppendErrorf(diags, "creating Auto Scaling Policy (%s): %s", name, err)
return sdkdiag.AppendFromErr(diags, err)
}

_, err = conn.PutScalingPolicy(ctx, input)
Expand Down Expand Up @@ -572,9 +571,8 @@ func resourcePolicyUpdate(ctx context.Context, d *schema.ResourceData, meta inte
conn := meta.(*conns.AWSClient).AutoScalingClient(ctx)

input, err := expandPutScalingPolicyInput(d)

if err != nil {
return sdkdiag.AppendErrorf(diags, "updating Auto Scaling Policy (%s): %s", d.Id(), err)
return sdkdiag.AppendFromErr(diags, err)
}

_, err = conn.PutScalingPolicy(ctx, input)
Expand Down
31 changes: 11 additions & 20 deletions internal/service/connect/contact_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"log"
"os"
"strings"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -19,10 +18,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
tfio "github.com/hashicorp/terraform-provider-aws/internal/io"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
"github.com/hashicorp/terraform-provider-aws/names"
"github.com/mitchellh/go-homedir"
)

const contactFlowMutexKey = `aws_connect_contact_flow`
Expand Down Expand Up @@ -120,11 +119,13 @@ func resourceContactFlowCreate(ctx context.Context, d *schema.ResourceData, meta
// See https://github.com/hashicorp/terraform/issues/9364
conns.GlobalMutexKV.Lock(contactFlowMutexKey)
defer conns.GlobalMutexKV.Unlock(contactFlowMutexKey)
file, err := resourceContactFlowLoadFileContent(filename)

file, err := tfio.ReadFileContents(filename)
if err != nil {
return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err)
return sdkdiag.AppendFromErr(diags, err)
}
input.Content = aws.String(file)

input.Content = aws.String(string(file))
} else if v, ok := d.GetOk(names.AttrContent); ok {
input.Content = aws.String(v.(string))
}
Expand Down Expand Up @@ -226,11 +227,13 @@ func resourceContactFlowUpdate(ctx context.Context, d *schema.ResourceData, meta
// See https://github.com/hashicorp/terraform/issues/9364
conns.GlobalMutexKV.Lock(contactFlowMutexKey)
defer conns.GlobalMutexKV.Unlock(contactFlowMutexKey)
file, err := resourceContactFlowLoadFileContent(filename)

file, err := tfio.ReadFileContents(filename)
if err != nil {
return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err)
return sdkdiag.AppendFromErr(diags, err)
}
updateContentInput.Content = aws.String(file)

updateContentInput.Content = aws.String(string(file))
} else if v, ok := d.GetOk(names.AttrContent); ok {
updateContentInput.Content = aws.String(v.(string))
}
Expand Down Expand Up @@ -281,15 +284,3 @@ func ContactFlowParseID(id string) (string, string, error) {

return parts[0], parts[1], nil
}

func resourceContactFlowLoadFileContent(filename string) (string, error) {
filename, err := homedir.Expand(filename)
if err != nil {
return "", err
}
fileContent, err := os.ReadFile(filename)
if err != nil {
return "", err
}
return string(fileContent), nil
}
31 changes: 11 additions & 20 deletions internal/service/connect/contact_flow_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"log"
"os"
"strings"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -19,10 +18,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
tfio "github.com/hashicorp/terraform-provider-aws/internal/io"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
"github.com/hashicorp/terraform-provider-aws/names"
"github.com/mitchellh/go-homedir"
)

const contactFlowModuleMutexKey = `aws_connect_contact_flow_module`
Expand Down Expand Up @@ -114,11 +113,13 @@ func resourceContactFlowModuleCreate(ctx context.Context, d *schema.ResourceData
// See https://github.com/hashicorp/terraform/issues/9364
conns.GlobalMutexKV.Lock(contactFlowModuleMutexKey)
defer conns.GlobalMutexKV.Unlock(contactFlowModuleMutexKey)
file, err := resourceContactFlowModuleLoadFileContent(filename)

file, err := tfio.ReadFileContents(filename)
if err != nil {
return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err)
return sdkdiag.AppendFromErr(diags, err)
}
input.Content = aws.String(file)

input.Content = aws.String(string(file))
} else if v, ok := d.GetOk(names.AttrContent); ok {
input.Content = aws.String(v.(string))
}
Expand Down Expand Up @@ -219,11 +220,13 @@ func resourceContactFlowModuleUpdate(ctx context.Context, d *schema.ResourceData
// See https://github.com/hashicorp/terraform/issues/9364
conns.GlobalMutexKV.Lock(contactFlowModuleMutexKey)
defer conns.GlobalMutexKV.Unlock(contactFlowModuleMutexKey)
file, err := resourceContactFlowModuleLoadFileContent(filename)

file, err := tfio.ReadFileContents(filename)
if err != nil {
return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err)
return sdkdiag.AppendFromErr(diags, err)
}
updateContentInput.Content = aws.String(file)

updateContentInput.Content = aws.String(string(file))
} else if v, ok := d.GetOk(names.AttrContent); ok {
updateContentInput.Content = aws.String(v.(string))
}
Expand Down Expand Up @@ -269,15 +272,3 @@ func ContactFlowModuleParseID(id string) (string, string, error) {

return parts[0], parts[1], nil
}

func resourceContactFlowModuleLoadFileContent(filename string) (string, error) {
filename, err := homedir.Expand(filename)
if err != nil {
return "", err
}
fileContent, err := os.ReadFile(filename)
if err != nil {
return "", err
}
return string(fileContent), nil
}
Loading
Loading