Skip to content

Commit ff9abea

Browse files
Merge pull request #1451 from wakeful/bump-aws-sdk-to-v2
migrate to AWS SDKv2, updating only singnatures and making sure tests are passing
2 parents d54ee08 + f5425c1 commit ff9abea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+974
-826
lines changed

examples/packer-docker-example/app.rb

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
set :port, server_port
1414
set :bind, '0.0.0.0'
15+
set :server, 'puma'
1516

1617
get '/' do
1718
server_text

examples/packer-docker-example/configure-sinatra-app.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sudo apt-get update
1111
sudo apt-get install -y make zlib1g-dev build-essential ruby ruby-dev
1212

1313
echo "Installing Sinatra"
14-
sudo gem install sinatra json rackup
14+
sudo gem install sinatra json rackup puma
1515

1616
echo "Moving $APP_RB_SRC to $APP_RB_DST"
1717
mkdir -p "$(dirname "$APP_RB_DST")"

examples/terraform-aws-rds-example/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ provider "aws" {
99

1010
terraform {
1111
# This module is now only being tested with Terraform 0.13.x. However, to make upgrading easier, we are setting
12-
# 0.12.26 as the minimum version, as that version added support for required_providers with source URLs, making it
12+
# 0.12.31 as the minimum version, as that version added support for required_providers with source URLs, making it
1313
# forwards compatible with 0.13.x code.
14-
required_version = ">= 0.12.26"
14+
required_version = ">= 0.12.31"
1515

1616
required_providers {
1717
aws = {

examples/terraform-packer-example/main.tf

+8-17
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ provider "aws" {
2424
# ---------------------------------------------------------------------------------------------------------------------
2525

2626
resource "aws_instance" "example" {
27-
ami = var.ami_id
28-
instance_type = var.instance_type
29-
user_data = data.template_file.user_data.rendered
27+
ami = var.ami_id
28+
instance_type = var.instance_type
29+
30+
user_data = templatefile("${path.module}/user-data/user-data.sh", {
31+
instance_text = var.instance_text
32+
instance_port = var.instance_port
33+
})
34+
3035
vpc_security_group_ids = [aws_security_group.example.id]
3136

3237
tags = {
@@ -51,17 +56,3 @@ resource "aws_security_group" "example" {
5156
cidr_blocks = ["0.0.0.0/0"]
5257
}
5358
}
54-
55-
# ---------------------------------------------------------------------------------------------------------------------
56-
# CREATE THE USER DATA SCRIPT THAT WILL RUN DURING BOOT ON THE EC2 INSTANCE
57-
# ---------------------------------------------------------------------------------------------------------------------
58-
59-
data "template_file" "user_data" {
60-
template = file("${path.module}/user-data/user-data.sh")
61-
62-
vars = {
63-
instance_text = var.instance_text
64-
instance_port = var.instance_port
65-
}
66-
}
67-

go.mod

+38-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
1212
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
1313
github.com/aws/aws-lambda-go v1.47.0
14-
github.com/aws/aws-sdk-go v1.44.122
14+
github.com/aws/aws-sdk-go v1.44.122 // indirect
1515
github.com/ghodss/yaml v1.0.0
1616
github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0 // indirect
1717
github.com/go-sql-driver/mysql v1.8.1
@@ -48,7 +48,28 @@ require (
4848

4949
require (
5050
cloud.google.com/go/cloudbuild v1.19.0
51-
github.com/gogo/protobuf v1.3.2
51+
github.com/aws/aws-sdk-go-v2 v1.32.5
52+
github.com/aws/aws-sdk-go-v2/config v1.28.5
53+
github.com/aws/aws-sdk-go-v2/credentials v1.17.46
54+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.41
55+
github.com/aws/aws-sdk-go-v2/service/acm v1.30.6
56+
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.51.0
57+
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.44.0
58+
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.37.1
59+
github.com/aws/aws-sdk-go-v2/service/ec2 v1.193.0
60+
github.com/aws/aws-sdk-go-v2/service/ecr v1.36.6
61+
github.com/aws/aws-sdk-go-v2/service/ecs v1.52.0
62+
github.com/aws/aws-sdk-go-v2/service/iam v1.38.1
63+
github.com/aws/aws-sdk-go-v2/service/kms v1.37.6
64+
github.com/aws/aws-sdk-go-v2/service/lambda v1.69.0
65+
github.com/aws/aws-sdk-go-v2/service/rds v1.91.0
66+
github.com/aws/aws-sdk-go-v2/service/route53 v1.46.2
67+
github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0
68+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.6
69+
github.com/aws/aws-sdk-go-v2/service/sns v1.33.6
70+
github.com/aws/aws-sdk-go-v2/service/sqs v1.37.1
71+
github.com/aws/aws-sdk-go-v2/service/ssm v1.56.0
72+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1
5273
github.com/gonvenience/ytbx v1.4.4
5374
github.com/homeport/dyff v1.6.0
5475
github.com/jackc/pgx/v5 v5.7.1
@@ -77,6 +98,20 @@ require (
7798
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1 // indirect
7899
github.com/agext/levenshtein v1.2.3 // indirect
79100
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
101+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
102+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect
103+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect
104+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect
105+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
106+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.24 // indirect
107+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
108+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.5 // indirect
109+
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.5 // indirect
110+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect
111+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5 // indirect
112+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 // indirect
113+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 // indirect
114+
github.com/aws/smithy-go v1.22.1 // indirect
80115
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
81116
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
82117
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
@@ -99,6 +134,7 @@ require (
99134
github.com/go-openapi/jsonpointer v0.19.6 // indirect
100135
github.com/go-openapi/jsonreference v0.20.2 // indirect
101136
github.com/go-openapi/swag v0.22.3 // indirect
137+
github.com/gogo/protobuf v1.3.2 // indirect
102138
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
103139
github.com/golang/protobuf v1.5.4 // indirect
104140
github.com/gonvenience/bunt v1.3.5 // indirect

go.sum

+72
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,78 @@ github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1s
254254
github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
255255
github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo=
256256
github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
257+
github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo=
258+
github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U=
259+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8=
260+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc=
261+
github.com/aws/aws-sdk-go-v2/config v1.28.5 h1:Za41twdCXbuyyWv9LndXxZZv3QhTG1DinqlFsSuvtI0=
262+
github.com/aws/aws-sdk-go-v2/config v1.28.5/go.mod h1:4VsPbHP8JdcdUDmbTVgNL/8w9SqOkM5jyY8ljIxLO3o=
263+
github.com/aws/aws-sdk-go-v2/credentials v1.17.46 h1:AU7RcriIo2lXjUfHFnFKYsLCwgbz1E7Mm95ieIRDNUg=
264+
github.com/aws/aws-sdk-go-v2/credentials v1.17.46/go.mod h1:1FmYyLGL08KQXQ6mcTlifyFXfJVCNJTVGuQP4m0d/UA=
265+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 h1:sDSXIrlsFSFJtWKLQS4PUWRvrT580rrnuLydJrCQ/yA=
266+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20/go.mod h1:WZ/c+w0ofps+/OUqMwWgnfrgzZH1DZO1RIkktICsqnY=
267+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.41 h1:hqcxMc2g/MwwnRMod9n6Bd+t+9Nf7d5qRg7RaXKPd6o=
268+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.41/go.mod h1:d1eH0VrttvPmrCraU68LOyNdu26zFxQFjrVSb5vdhog=
269+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 h1:4usbeaes3yJnCFC7kfeyhkdkPtoRYPa/hTmCqMpKpLI=
270+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24/go.mod h1:5CI1JemjVwde8m2WG3cz23qHKPOxbpkq0HaoreEgLIY=
271+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 h1:N1zsICrQglfzaBnrfM0Ys00860C+QFwu6u/5+LomP+o=
272+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24/go.mod h1:dCn9HbJ8+K31i8IQ8EWmWj0EiIk0+vKiHNMxTTYveAg=
273+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ=
274+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc=
275+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.24 h1:JX70yGKLj25+lMC5Yyh8wBtvB01GDilyRuJvXJ4piD0=
276+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.24/go.mod h1:+Ln60j9SUTD0LEwnhEB0Xhg61DHqplBrbZpLgyjoEHg=
277+
github.com/aws/aws-sdk-go-v2/service/acm v1.30.6 h1:fDg0RlN30Xf/yYzEUL/WXqhmgFsjVb/I3230oCfyI5w=
278+
github.com/aws/aws-sdk-go-v2/service/acm v1.30.6/go.mod h1:zRR6jE3v/TcbfO8C2P+H0Z+kShiKKVaVyoIl8NQRjyg=
279+
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.51.0 h1:1KzQVZi7OTixxaVJ8fWaJAUBjme+iQ3zBOCZhE4RgxQ=
280+
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.51.0/go.mod h1:I1+/2m+IhnK5qEbhS3CrzjeiVloo9sItE/2K+so0fkU=
281+
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.44.0 h1:OREVd94+oXW5a+3SSUAo4K0L5ci8cucCLu+PSiek8OU=
282+
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.44.0/go.mod h1:Qbr4yfpNqVNl69l/GEDK+8wxLf/vHi0ChoiSDzD7thU=
283+
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.37.1 h1:vucMirlM6D+RDU8ncKaSZ/5dGrXNajozVwpmWNPn2gQ=
284+
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.37.1/go.mod h1:fceORfs010mNxZbQhfqUjUeHlTwANmIT4mvHamuUaUg=
285+
github.com/aws/aws-sdk-go-v2/service/ec2 v1.193.0 h1:RhSoBFT5/8tTmIseJUXM6INTXTQDF8+0oyxWBnozIms=
286+
github.com/aws/aws-sdk-go-v2/service/ec2 v1.193.0/go.mod h1:mzj8EEjIHSN2oZRXiw1Dd+uB4HZTl7hC8nBzX9IZMWw=
287+
github.com/aws/aws-sdk-go-v2/service/ecr v1.36.6 h1:zg+3FGHA0PBs0KM25qE/rOf2o5zsjNa1g/Qq83+SDI0=
288+
github.com/aws/aws-sdk-go-v2/service/ecr v1.36.6/go.mod h1:ZSq54Z9SIsOTf1Efwgw1msilSs4XVEfVQiP9nYVnKpM=
289+
github.com/aws/aws-sdk-go-v2/service/ecs v1.52.0 h1:7/vgFWplkusJN/m+3QOa+W9FNRqa8ujMPNmdufRaJpg=
290+
github.com/aws/aws-sdk-go-v2/service/ecs v1.52.0/go.mod h1:dPTOvmjJQ1T7Q+2+Xs2KSPrMvx+p0rpyV+HsQVnUK4o=
291+
github.com/aws/aws-sdk-go-v2/service/iam v1.38.1 h1:hfkzDZHBp9jAT4zcd5mtqckpU4E3Ax0LQaEWWk1VgN8=
292+
github.com/aws/aws-sdk-go-v2/service/iam v1.38.1/go.mod h1:u36ahDtZcQHGmVm/r+0L1sfKX4fzLEMdCqiKRKkUMVM=
293+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y=
294+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE=
295+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.5 h1:gvZOjQKPxFXy1ft3QnEyXmT+IqneM9QAUWlM3r0mfqw=
296+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.5/go.mod h1:DLWnfvIcm9IET/mmjdxeXbBKmTCm0ZB8p1za9BVteM8=
297+
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.5 h1:3Y457U2eGukmjYjeHG6kanZpDzJADa2m0ADqnuePYVQ=
298+
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.5/go.mod h1:CfwEHGkTjYZpkQ/5PvcbEtT7AJlG68KkEvmtwU8z3/U=
299+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwrSbwhECWQoI/g6WM9zqCcSpHDJIWSbMLOu4=
300+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E=
301+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5 h1:P1doBzv5VEg1ONxnJss1Kh5ZG/ewoIE4MQtKKc6Crgg=
302+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5/go.mod h1:NOP+euMW7W3Ukt28tAxPuoWao4rhhqJD3QEBk7oCg7w=
303+
github.com/aws/aws-sdk-go-v2/service/kms v1.37.6 h1:CZImQdb1QbU9sGgJ9IswhVkxAcjkkD1eQTMA1KHWk+E=
304+
github.com/aws/aws-sdk-go-v2/service/kms v1.37.6/go.mod h1:YJDdlK0zsyxVBxGU48AR/Mi8DMrGdc1E3Yij4fNrONA=
305+
github.com/aws/aws-sdk-go-v2/service/lambda v1.69.0 h1:BXt75frE/FYtAmEDBJRBa2HexOw+oAZWZl6QknZEFgg=
306+
github.com/aws/aws-sdk-go-v2/service/lambda v1.69.0/go.mod h1:guz2K3x4FKSdDaoeB+TPVgJNU9oj2gftbp5cR8ela1A=
307+
github.com/aws/aws-sdk-go-v2/service/rds v1.91.0 h1:eqHz3Uih+gb0vLE5Cc4Xf733vOxsxDp6GFUUVQU4d7w=
308+
github.com/aws/aws-sdk-go-v2/service/rds v1.91.0/go.mod h1:h2jc7IleH3xHY7y+h8FH7WAZcz3IVLOB6/jXotIQ/qU=
309+
github.com/aws/aws-sdk-go-v2/service/route53 v1.46.2 h1:wmt05tPp/CaRZpPV5B4SaJ5TwkHKom07/BzHoLdkY1o=
310+
github.com/aws/aws-sdk-go-v2/service/route53 v1.46.2/go.mod h1:d+K9HESMpGb1EU9/UmmpInbGIUcAkwmcY6ZO/A3zZsw=
311+
github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0 h1:Q2ax8S21clKOnHhhr933xm3JxdJebql+R7aNo7p7GBQ=
312+
github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0/go.mod h1:ralv4XawHjEMaHOWnTFushl0WRqim/gQWesAMF6hTow=
313+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.6 h1:1KDMKvOKNrpD667ORbZ/+4OgvUoaok1gg/MLzrHF9fw=
314+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.6/go.mod h1:DmtyfCfONhOyVAJ6ZMTrDSFIeyCBlEO93Qkfhxwbxu0=
315+
github.com/aws/aws-sdk-go-v2/service/sns v1.33.6 h1:lEUtRHICiXsd7VRwRjXaY7MApT2X4Ue0Mrwe6XbyBro=
316+
github.com/aws/aws-sdk-go-v2/service/sns v1.33.6/go.mod h1:SODr0Lu3lFdT0SGsGX1TzFTapwveBrT5wztVoYtppm8=
317+
github.com/aws/aws-sdk-go-v2/service/sqs v1.37.1 h1:39WvSrVq9DD6UHkD+fx5x19P5KpRQfNdtgReDVNbelc=
318+
github.com/aws/aws-sdk-go-v2/service/sqs v1.37.1/go.mod h1:3gwPzC9LER/BTQdQZ3r6dUktb1rSjABF1D3Sr6nS7VU=
319+
github.com/aws/aws-sdk-go-v2/service/ssm v1.56.0 h1:mADKqoZaodipGgiZfuAjtlcr4IVBtXPZKVjkzUZCCYM=
320+
github.com/aws/aws-sdk-go-v2/service/ssm v1.56.0/go.mod h1:l9qF25TzH95FhcIak6e4vt79KE4I7M2Nf59eMUVjj6c=
321+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM=
322+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y=
323+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8=
324+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5/go.mod h1:ORITg+fyuMoeiQFiVGoqB3OydVTLkClw/ljbblMq6Cc=
325+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLbc2iVROyaNEwBHbU=
326+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg=
327+
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
328+
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
257329
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
258330
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
259331
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=

modules/aws/account.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package aws
22

33
import (
4+
"context"
45
"errors"
56
"strings"
67

7-
"github.com/aws/aws-sdk-go/aws"
8-
"github.com/aws/aws-sdk-go/service/sts"
8+
"github.com/aws/aws-sdk-go-v2/aws"
9+
"github.com/aws/aws-sdk-go-v2/service/sts"
910

1011
"github.com/gruntwork-io/terratest/modules/testing"
1112
)
@@ -26,12 +27,12 @@ func GetAccountIdE(t testing.TestingT) (string, error) {
2627
return "", err
2728
}
2829

29-
identity, err := stsClient.GetCallerIdentity(&sts.GetCallerIdentityInput{})
30+
identity, err := stsClient.GetCallerIdentity(context.Background(), &sts.GetCallerIdentityInput{})
3031
if err != nil {
3132
return "", err
3233
}
3334

34-
return aws.StringValue(identity.Account), nil
35+
return aws.ToString(identity.Account), nil
3536
}
3637

3738
// An IAM arn is of the format arn:aws:iam::123456789012:user/test. The account id is the number after arn:aws:iam::,
@@ -47,10 +48,10 @@ func extractAccountIDFromARN(arn string) (string, error) {
4748
}
4849

4950
// NewStsClientE creates a new STS client.
50-
func NewStsClientE(t testing.TestingT, region string) (*sts.STS, error) {
51+
func NewStsClientE(t testing.TestingT, region string) (*sts.Client, error) {
5152
sess, err := NewAuthenticatedSession(region)
5253
if err != nil {
5354
return nil, err
5455
}
55-
return sts.New(sess), nil
56+
return sts.NewFromConfig(*sess), nil
5657
}

modules/aws/acm.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package aws
22

33
import (
4-
"github.com/aws/aws-sdk-go/service/acm"
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/acm"
57

68
"github.com/gruntwork-io/terratest/modules/testing"
79
)
@@ -22,7 +24,7 @@ func GetAcmCertificateArnE(t testing.TestingT, awsRegion string, certDomainName
2224
return "", err
2325
}
2426

25-
result, err := acmClient.ListCertificates(&acm.ListCertificatesInput{})
27+
result, err := acmClient.ListCertificates(context.Background(), &acm.ListCertificatesInput{})
2628
if err != nil {
2729
return "", err
2830
}
@@ -37,7 +39,7 @@ func GetAcmCertificateArnE(t testing.TestingT, awsRegion string, certDomainName
3739
}
3840

3941
// NewAcmClient create a new ACM client.
40-
func NewAcmClient(t testing.TestingT, region string) *acm.ACM {
42+
func NewAcmClient(t testing.TestingT, region string) *acm.Client {
4143
client, err := NewAcmClientE(t, region)
4244
if err != nil {
4345
t.Fatal(err)
@@ -46,11 +48,11 @@ func NewAcmClient(t testing.TestingT, region string) *acm.ACM {
4648
}
4749

4850
// NewAcmClientE creates a new ACM client.
49-
func NewAcmClientE(t testing.TestingT, awsRegion string) (*acm.ACM, error) {
51+
func NewAcmClientE(t testing.TestingT, awsRegion string) (*acm.Client, error) {
5052
sess, err := NewAuthenticatedSession(awsRegion)
5153
if err != nil {
5254
return nil, err
5355
}
5456

55-
return acm.New(sess), nil
57+
return acm.NewFromConfig(*sess), nil
5658
}

modules/aws/ami.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package aws
22

33
import (
4+
"context"
45
"fmt"
56
"sort"
67
"time"
78

8-
"github.com/aws/aws-sdk-go/aws"
9-
"github.com/aws/aws-sdk-go/service/ec2"
9+
"github.com/aws/aws-sdk-go-v2/aws"
10+
"github.com/aws/aws-sdk-go-v2/service/ec2"
11+
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
1012
"github.com/gruntwork-io/terratest/modules/logger"
1113
"github.com/gruntwork-io/terratest/modules/testing"
1214
)
@@ -57,17 +59,17 @@ func GetEbsSnapshotsForAmi(t testing.TestingT, region string, ami string) []stri
5759
return snapshots
5860
}
5961

60-
// GetEbsSnapshotsForAmi retrieves the EBS snapshots which back the given AMI
62+
// GetEbsSnapshotsForAmiE retrieves the EBS snapshots which back the given AMI
6163
func GetEbsSnapshotsForAmiE(t testing.TestingT, region string, ami string) ([]string, error) {
6264
logger.Default.Logf(t, "Retrieving EBS snapshots backing AMI %s", ami)
6365
ec2Client, err := NewEc2ClientE(t, region)
6466
if err != nil {
6567
return nil, err
6668
}
6769

68-
images, err := ec2Client.DescribeImages(&ec2.DescribeImagesInput{
69-
ImageIds: []*string{
70-
aws.String(ami),
70+
images, err := ec2Client.DescribeImages(context.Background(), &ec2.DescribeImagesInput{
71+
ImageIds: []string{
72+
ami,
7173
},
7274
})
7375
if err != nil {
@@ -78,7 +80,7 @@ func GetEbsSnapshotsForAmiE(t testing.TestingT, region string, ami string) ([]st
7880
for _, image := range images.Images {
7981
for _, mapping := range image.BlockDeviceMappings {
8082
if mapping.Ebs != nil && mapping.Ebs.SnapshotId != nil {
81-
snapshots = append(snapshots, aws.StringValue(mapping.Ebs.SnapshotId))
83+
snapshots = append(snapshots, aws.ToString(mapping.Ebs.SnapshotId))
8284
}
8385
}
8486
}
@@ -106,18 +108,18 @@ func GetMostRecentAmiIdE(t testing.TestingT, region string, ownerId string, filt
106108
return "", err
107109
}
108110

109-
ec2Filters := []*ec2.Filter{}
111+
var ec2Filters []types.Filter
110112
for name, values := range filters {
111-
ec2Filters = append(ec2Filters, &ec2.Filter{Name: aws.String(name), Values: aws.StringSlice(values)})
113+
ec2Filters = append(ec2Filters, types.Filter{Name: aws.String(name), Values: values})
112114
}
113115

114116
input := ec2.DescribeImagesInput{
115117
Filters: ec2Filters,
116118
IncludeDeprecated: aws.Bool(true),
117-
Owners: []*string{aws.String(ownerId)},
119+
Owners: []string{ownerId},
118120
}
119121

120-
out, err := ec2Client.DescribeImages(&input)
122+
out, err := ec2Client.DescribeImages(context.Background(), &input)
121123
if err != nil {
122124
return "", err
123125
}
@@ -127,11 +129,11 @@ func GetMostRecentAmiIdE(t testing.TestingT, region string, ownerId string, filt
127129
}
128130

129131
mostRecentImage := mostRecentAMI(out.Images)
130-
return aws.StringValue(mostRecentImage.ImageId), nil
132+
return aws.ToString(mostRecentImage.ImageId), nil
131133
}
132134

133135
// Image sorting code borrowed from: https://github.com/hashicorp/packer/blob/7f4112ba229309cfc0ebaa10ded2abdfaf1b22c8/builder/amazon/common/step_source_ami_info.go
134-
type imageSort []*ec2.Image
136+
type imageSort []types.Image
135137

136138
func (a imageSort) Len() int { return len(a) }
137139
func (a imageSort) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
@@ -142,7 +144,7 @@ func (a imageSort) Less(i, j int) bool {
142144
}
143145

144146
// mostRecentAMI returns the most recent AMI out of a slice of images.
145-
func mostRecentAMI(images []*ec2.Image) *ec2.Image {
147+
func mostRecentAMI(images []types.Image) types.Image {
146148
sortedImages := images
147149
sort.Sort(imageSort(sortedImages))
148150
return sortedImages[len(sortedImages)-1]

0 commit comments

Comments
 (0)