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

upgrade to aws-sdk-go-v2 #742

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ GINKGO = $(BIN_DIR)/ginkgo
GUM = $(BIN_DIR)/gum
GH = $(BIN_DIR)/gh
GOLICENSES = $(BIN_DIR)/go-licenses
HELM_BASE_OPTS ?= --set aws.region=${AWS_REGION},serviceAccount.name=${SERVICE_ACCOUNT_NAME},serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${SERVICE_ACCOUNT_ROLE_ARN}
HELM_BASE_OPTS ?= --set aws.region=${AWS_REGION},serviceAccount.name=${SERVICE_ACCOUNT_NAME},serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=${SERVICE_ACCOUNT_ROLE_ARN} \
--set-string serviceAccount.annotations.eks\\.amazonaws\\.com/sts-regional-endpoints=true
GINKGO_BASE_OPTS ?= -r --coverpkg $(shell head -n 1 $(PROJECT_DIR)/go.mod | cut -s -d ' ' -f 2)/pkg/...
KODATA = \
cmd/controller/kodata/HEAD \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ helm upgrade \
--create-namespace \
--set aws.region=<AWS REGION> \
--set serviceAccount.name="nth-service-account" \
--set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=<SERVICE ACCOUNT ROLE ARN>
--set serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn=<SERVICE ACCOUNT ROLE ARN> \
--set-string serviceAccount.annotations.eks\\.amazonaws\\.com/sts-regional-endpoints=true
```

For a full list of inputs see the Helm chart `README.md`.
Expand Down
21 changes: 18 additions & 3 deletions THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,23 @@
- github.com/PuerkitoBio/purell v1.1.1 [BSD-3-Clause](https://github.com/PuerkitoBio/purell/blob/v1.1.1/LICENSE)
- github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 [BSD-3-Clause](https://github.com/PuerkitoBio/urlesc/blob/de5bf2ad4578/LICENSE)
- github.com/aws/aws-node-termination-handler Unknown [Apache-2.0](https://github.com/aws/aws-node-termination-handler/blob/HEAD/LICENSE)
- github.com/aws/aws-sdk-go v1.38.55 [Apache-2.0](https://github.com/aws/aws-sdk-go/blob/v1.38.55/LICENSE.txt)
- github.com/aws/aws-sdk-go/internal/sync/singleflight v1.38.55 [BSD-3-Clause](https://github.com/aws/aws-sdk-go/blob/v1.38.55/internal/sync/singleflight/LICENSE)
- github.com/aws/aws-sdk-go-v2 v1.17.1 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/v1.17.1/LICENSE.txt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file get updated automatically by some part of the build system?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not automatic. Have to run make third-party-licenses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good too. Just as long as we don't have to do it manually. 😀

- github.com/aws/aws-sdk-go-v2/config v1.18.3 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/config/v1.18.3/config/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/credentials v1.13.3 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/credentials/v1.13.3/credentials/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/feature/ec2/imds/v1.12.19/feature/ec2/imds/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/internal/configsources/v1.1.25/internal/configsources/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/internal/endpoints/v2.4.19/internal/endpoints/v2/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/internal/ini/v1.3.26/internal/ini/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/internal/sync/singleflight v1.17.1 [BSD-3-Clause](https://github.com/aws/aws-sdk-go-v2/blob/v1.17.1/internal/sync/singleflight/LICENSE)
- github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/autoscaling/v1.24.3/service/autoscaling/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/ec2/v1.74.0/service/ec2/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/internal/presigned-url/v1.9.19/service/internal/presigned-url/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/sqs/v1.19.15/service/sqs/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/sso/v1.11.25/service/sso/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/ssooidc/v1.13.8/service/ssooidc/LICENSE.txt)
- github.com/aws/aws-sdk-go-v2/service/sts v1.17.5 [Apache-2.0](https://github.com/aws/aws-sdk-go-v2/blob/service/sts/v1.17.5/service/sts/LICENSE.txt)
- github.com/aws/smithy-go v1.13.4 [Apache-2.0](https://github.com/aws/smithy-go/blob/v1.13.4/LICENSE)
- github.com/aws/smithy-go/internal/sync/singleflight v1.13.4 [BSD-3-Clause](https://github.com/aws/smithy-go/blob/v1.13.4/internal/sync/singleflight/LICENSE)
- github.com/beorn7/perks/quantile v1.0.1 [MIT](https://github.com/beorn7/perks/blob/v1.0.1/LICENSE)
- github.com/blang/semver/v4 v4.0.0 [MIT](https://github.com/blang/semver/blob/v4.0.0/v4/LICENSE)
- github.com/blendle/zapdriver v1.3.1 [ISC](https://github.com/blendle/zapdriver/blob/v1.3.1/LICENSE)
Expand All @@ -39,7 +54,7 @@
- github.com/golang/groupcache/lru v0.0.0-20210331224755-41bb18bfe9da [Apache-2.0](https://github.com/golang/groupcache/blob/41bb18bfe9da/LICENSE)
- github.com/golang/protobuf v1.5.2 [BSD-3-Clause](https://github.com/golang/protobuf/blob/v1.5.2/LICENSE)
- github.com/google/btree v1.0.1 [Apache-2.0](https://github.com/google/btree/blob/v1.0.1/LICENSE)
- github.com/google/go-cmp/cmp v0.5.6 [BSD-3-Clause](https://github.com/google/go-cmp/blob/v0.5.6/LICENSE)
- github.com/google/go-cmp/cmp v0.5.8 [BSD-3-Clause](https://github.com/google/go-cmp/blob/v0.5.8/LICENSE)
- github.com/google/gofuzz v1.2.0 [Apache-2.0](https://github.com/google/gofuzz/blob/v1.2.0/LICENSE)
- github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 [Apache-2.0](https://github.com/google/shlex/blob/e7afc7fbc510/COPYING)
- github.com/google/uuid v1.3.0 [BSD-3-Clause](https://github.com/google/uuid/blob/v1.3.0/LICENSE)
Expand Down
60 changes: 14 additions & 46 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"context"
"flag"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -59,13 +58,10 @@ import (
terminatoradapter "github.com/aws/aws-node-termination-handler/pkg/terminator/adapter"
"github.com/aws/aws-node-termination-handler/pkg/webhook"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/sqs"
awscfg "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
"github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/sqs"

"github.com/go-logr/zapr"
//+kubebuilder:scaffold:imports
Expand All @@ -91,12 +87,12 @@ func init() {

func main() {
options := parseOptions()
config := ctrl.GetConfigOrDie()
config.UserAgent = "aws-node-termination-handler"
ctx, startInformers := knativeinjection.EnableInjectionOrDie(signals.NewContext(), config)
ctrlConfig := ctrl.GetConfigOrDie()
ctrlConfig.UserAgent = "aws-node-termination-handler"
ctx, startInformers := knativeinjection.EnableInjectionOrDie(signals.NewContext(), ctrlConfig)
logger, atomicLevel := sharedmain.SetupLoggerOrDie(ctx, componentName)
ctx = logging.WithLogger(ctx, logger)
clientSet := kubernetes.NewForConfigOrDie(config)
clientSet := kubernetes.NewForConfigOrDie(ctrlConfig)
cmw := informer.NewInformedWatcher(clientSet, system.Namespace())

ctrl.SetLogger(zapr.NewLogger(logger.Desugar()))
Expand All @@ -108,7 +104,7 @@ func main() {
}
startInformers()

mgr, err := ctrl.NewManager(config, ctrl.Options{
mgr, err := ctrl.NewManager(ctrlConfig, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: options.MetricsAddress,
Port: 9443,
Expand All @@ -128,19 +124,19 @@ func main() {
}
kubeClient := mgr.GetClient()

awsSession, err := newAWSSession(options.AWSRegion)
awsConfig, err := awscfg.LoadDefaultConfig(ctx, awscfg.WithRegion(options.AWSRegion))
if err != nil {
logger.With("error", err).Fatal("failed to initialize AWS session")
logger.With("error", err).Fatal("failed to load AWS configuration")
}
sqsClient := sqs.New(awsSession)
sqsClient := sqs.NewFromConfig(awsConfig)
if sqsClient == nil {
logger.Fatal("failed to create SQS client")
}
asgClient := autoscaling.New(awsSession)
asgClient := autoscaling.NewFromConfig(awsConfig)
if asgClient == nil {
logger.Fatal("failed to create ASG client")
}
ec2Client := ec2.New(awsSession)
ec2Client := ec2.NewFromConfig(awsConfig)
if ec2Client == nil {
logger.Fatal("failed to create EC2 client")
}
Expand Down Expand Up @@ -212,34 +208,6 @@ func parseOptions() Options {
return options
}

func newAWSSession(awsRegion string) (*session.Session, error) {
config := aws.NewConfig().
WithRegion(awsRegion).
WithSTSRegionalEndpoint(endpoints.RegionalSTSEndpoint)
sess, err := session.NewSessionWithOptions(session.Options{
Config: *config,
SharedConfigState: session.SharedConfigEnable,
})
if err != nil {
return nil, fmt.Errorf("failed to create AWS session: %w", err)
}

if sess.Config.Region == nil || *sess.Config.Region == "" {
awsRegion, err := ec2metadata.New(sess).Region()
if err != nil {
return nil, fmt.Errorf("failed to get AWS region: %w", err)
}
sess.Config.Region = aws.String(awsRegion)
}

_, err = sess.Config.Credentials.Get()
if err != nil {
return nil, fmt.Errorf("failed to get AWS session credentials: %w", err)
}

return sess, nil
}

func indexNodeName(ctx context.Context, indexer client.FieldIndexer) error {
return indexer.IndexField(ctx, &v1.Pod{}, "spec.nodeName", func(o client.Object) []string {
if o == nil {
Expand Down
18 changes: 16 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module github.com/aws/aws-node-termination-handler
go 1.19

require (
github.com/aws/aws-sdk-go v1.38.55
github.com/aws/aws-sdk-go-v2 v1.17.1
github.com/aws/aws-sdk-go-v2/config v1.18.3
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3
github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0
github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15
github.com/aws/smithy-go v1.13.4
github.com/go-logr/zapr v0.4.0
github.com/onsi/ginkgo/v2 v2.1.3
github.com/onsi/gomega v1.18.1
Expand Down Expand Up @@ -31,6 +36,15 @@ require (
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.17.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
Expand All @@ -55,7 +69,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand Down
33 changes: 32 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,36 @@ github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:l
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.38.55 h1:1Wv5CE1Zy0hJ6MJUQ1ekFiCsNKBK5W69+towYQ1P4Vs=
github.com/aws/aws-sdk-go v1.38.55/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go-v2 v1.17.1 h1:02c72fDJr87N8RAC2s3Qu0YuvMRZKNZJ9F+lAehCazk=
github.com/aws/aws-sdk-go-v2 v1.17.1/go.mod h1:JLnGeGONAyi2lWXI1p0PCIOIy333JMVK1U7Hf0aRFLw=
github.com/aws/aws-sdk-go-v2/config v1.18.3 h1:3kfBKcX3votFX84dm00U8RGA1sCCh3eRMOGzg5dCWfU=
github.com/aws/aws-sdk-go-v2/config v1.18.3/go.mod h1:BYdrbeCse3ZnOD5+2/VE/nATOK8fEUpBtmPMdKSyhMU=
github.com/aws/aws-sdk-go-v2/credentials v1.13.3 h1:ur+FHdp4NbVIv/49bUjBW+FE7e57HOo03ELodttmagk=
github.com/aws/aws-sdk-go-v2/credentials v1.13.3/go.mod h1:/rOMmqYBcFfNbRPU0iN9IgGqD5+V2yp3iWNmIlz0wI4=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19 h1:E3PXZSI3F2bzyj6XxUXdTIfvp425HHhwKsFvmzBwHgs=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19/go.mod h1:VihW95zQpeKQWVPGkwT+2+WJNQV8UXFfMTWdU6VErL8=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25 h1:nBO/RFxeq/IS5G9Of+ZrgucRciie2qpLy++3UGZ+q2E=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25/go.mod h1:Zb29PYkf42vVYQY6pvSyJCJcFHlPIiY+YKdPtwnvMkY=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19 h1:oRHDrwCTVT8ZXi4sr9Ld+EXk7N/KGssOr2ygNeojEhw=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19/go.mod h1:6Q0546uHDp421okhmmGfbxzq2hBqbXFNpi4k+Q1JnQA=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26 h1:Mza+vlnZr+fPKFKRq/lKGVvM6B/8ZZmNdEopOwSQLms=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26/go.mod h1:Y2OJ+P+MC1u1VKnavT+PshiEuGPyh/7DqxoDNij4/bg=
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3 h1:VnxU0zK4CNqsy1GiBz/UcWl9J6Qd6YrY34lT+/9Pzsk=
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.24.3/go.mod h1:1ioJeG7kmYYuqmA8Wsh5AXwjPn9mRKL6F8OOwt/uyBQ=
github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0 h1:5MCRd9q1yrGoRdYZDxK6y048VNmQ6gKLdCFr+TZsvTY=
github.com/aws/aws-sdk-go-v2/service/ec2 v1.74.0/go.mod h1:zul71QqzR4D1a90/5FloZiAnZ1CtuIjVH7R9MP997+A=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19 h1:GE25AWCdNUPh9AOJzI9KIJnja7IwUc1WyUqz/JTyJ/I=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19/go.mod h1:02CP6iuYP+IVnBX5HULVdSAku/85eHB2Y9EsFhrkEwU=
github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15 h1:5PgOVgJWObGxve+0qU7T/C0reU6RxqpNwbuunLT9Vlc=
github.com/aws/aws-sdk-go-v2/service/sqs v1.19.15/go.mod h1:DKX/7/ZiAzHO6p6AhArnGdrV4r+d461weby8KeVtvC4=
github.com/aws/aws-sdk-go-v2/service/sso v1.11.25 h1:GFZitO48N/7EsFDt8fMa5iYdmWqkUDDB3Eje6z3kbG0=
github.com/aws/aws-sdk-go-v2/service/sso v1.11.25/go.mod h1:IARHuzTXmj1C0KS35vboR0FeJ89OkEy1M9mWbK2ifCI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8 h1:jcw6kKZrtNfBPJkaHrscDOZoe5gvi9wjudnxvozYFJo=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8/go.mod h1:er2JHN+kBY6FcMfcBBKNGCT3CarImmdFzishsqBmSRI=
github.com/aws/aws-sdk-go-v2/service/sts v1.17.5 h1:60SJ4lhvn///8ygCzYy2l53bFW/Q15bVfyjyAWo6zuw=
github.com/aws/aws-sdk-go-v2/service/sts v1.17.5/go.mod h1:bXcN3koeVYiJcdDU89n3kCYILob7Y34AeLopUbZgLT4=
github.com/aws/smithy-go v1.13.4 h1:/RN2z1txIJWeXeOkzX+Hk/4Uuvv7dWtCjbmVJcrskyk=
github.com/aws/smithy-go v1.13.4/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -361,8 +391,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v27 v27.0.6/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down
16 changes: 7 additions & 9 deletions pkg/event/asgterminate/lifecycleaction/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import (
"context"
"errors"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go-v2/aws"
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
)

type (
ASGLifecycleActionCompleter interface {
CompleteLifecycleActionWithContext(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error)
CompleteLifecycleAction(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error)
}

Input struct {
Expand All @@ -40,16 +39,15 @@ type (
)

func Complete(ctx context.Context, completer ASGLifecycleActionCompleter, input Input) (bool, error) {
if _, err := completer.CompleteLifecycleActionWithContext(ctx, &autoscaling.CompleteLifecycleActionInput{
if _, err := completer.CompleteLifecycleAction(ctx, &autoscaling.CompleteLifecycleActionInput{
AutoScalingGroupName: aws.String(input.AutoScalingGroupName),
LifecycleActionResult: aws.String("CONTINUE"),
LifecycleHookName: aws.String(input.LifecycleHookName),
LifecycleActionToken: aws.String(input.LifecycleActionToken),
InstanceId: aws.String(input.EC2InstanceID),
}); err != nil {
var f awserr.RequestFailure
return errors.As(err, &f) && f.StatusCode() != 400, err
e := &awshttp.ResponseError{}
return errors.As(err, &e) && e.HTTPStatusCode() != 400, err
}

return false, nil
}
8 changes: 4 additions & 4 deletions pkg/event/asgterminate/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package v1

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/autoscaling"
"context"

"github.com/aws/aws-sdk-go-v2/service/autoscaling"
)

type ASGLifecycleActionCompleter interface {
CompleteLifecycleActionWithContext(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error)
CompleteLifecycleAction(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error)
}
8 changes: 4 additions & 4 deletions pkg/event/asgterminate/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package v2

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/autoscaling"
"context"

"github.com/aws/aws-sdk-go-v2/service/autoscaling"
)

type ASGLifecycleActionCompleter interface {
CompleteLifecycleActionWithContext(aws.Context, *autoscaling.CompleteLifecycleActionInput, ...request.Option) (*autoscaling.CompleteLifecycleActionOutput, error)
CompleteLifecycleAction(context.Context, *autoscaling.CompleteLifecycleActionInput, ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error)
}
10 changes: 3 additions & 7 deletions pkg/logging/sqs/deletemessageinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,20 @@ limitations under the License.
package sqs

import (
awssqs "github.com/aws/aws-sdk-go/service/sqs"
awssqs "github.com/aws/aws-sdk-go-v2/service/sqs"

"go.uber.org/zap/zapcore"
)

type deleteMessageInputMarshaler struct {
*awssqs.DeleteMessageInput
awssqs.DeleteMessageInput
}

func NewDeleteMessageInputMarshaler(input *awssqs.DeleteMessageInput) zapcore.ObjectMarshaler {
func NewDeleteMessageInputMarshaler(input awssqs.DeleteMessageInput) zapcore.ObjectMarshaler {
return deleteMessageInputMarshaler{DeleteMessageInput: input}
}

func (d deleteMessageInputMarshaler) MarshalLogObject(enc zapcore.ObjectEncoder) error {
if d.DeleteMessageInput == nil {
return nil
}

if d.QueueUrl != nil {
enc.AddString("queueUrl", *d.QueueUrl)
}
Expand Down
Loading