From a179532ef706b67c87686f5dd7d4c34a99008212 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Wed, 16 Dec 2020 10:23:46 -0800 Subject: [PATCH 1/5] feature/ec2/imds: Move ec2imds module to feature folder --- {ec2imds => feature/ec2/imds}/LICENSE.txt | 0 {ec2imds => feature/ec2/imds}/api_client.go | 0 {ec2imds => feature/ec2/imds}/api_client_test.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetDynamicData.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetDynamicData_test.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetIAMInfo.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetIAMInfo_test.go | 0 .../ec2/imds}/api_op_GetInstanceIdentityDocument.go | 0 .../ec2/imds}/api_op_GetInstanceIdentityDocument_test.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetMetadata.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetMetadata_test.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetRegion.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetRegion_test.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetToken.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetToken_test.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetUserData.go | 0 {ec2imds => feature/ec2/imds}/api_op_GetUserData_test.go | 0 {ec2imds => feature/ec2/imds}/doc.go | 0 {ec2imds => feature/ec2/imds}/go.mod | 0 {ec2imds => feature/ec2/imds}/go.sum | 0 {ec2imds => feature/ec2/imds}/integration_test.go | 0 {ec2imds => feature/ec2/imds}/request_middleware.go | 0 {ec2imds => feature/ec2/imds}/request_middleware_test.go | 0 {ec2imds => feature/ec2/imds}/shared_test.go | 0 {ec2imds => feature/ec2/imds}/token_provider.go | 0 25 files changed, 0 insertions(+), 0 deletions(-) rename {ec2imds => feature/ec2/imds}/LICENSE.txt (100%) rename {ec2imds => feature/ec2/imds}/api_client.go (100%) rename {ec2imds => feature/ec2/imds}/api_client_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetDynamicData.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetDynamicData_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetIAMInfo.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetIAMInfo_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetInstanceIdentityDocument.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetInstanceIdentityDocument_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetMetadata.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetMetadata_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetRegion.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetRegion_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetToken.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetToken_test.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetUserData.go (100%) rename {ec2imds => feature/ec2/imds}/api_op_GetUserData_test.go (100%) rename {ec2imds => feature/ec2/imds}/doc.go (100%) rename {ec2imds => feature/ec2/imds}/go.mod (100%) rename {ec2imds => feature/ec2/imds}/go.sum (100%) rename {ec2imds => feature/ec2/imds}/integration_test.go (100%) rename {ec2imds => feature/ec2/imds}/request_middleware.go (100%) rename {ec2imds => feature/ec2/imds}/request_middleware_test.go (100%) rename {ec2imds => feature/ec2/imds}/shared_test.go (100%) rename {ec2imds => feature/ec2/imds}/token_provider.go (100%) diff --git a/ec2imds/LICENSE.txt b/feature/ec2/imds/LICENSE.txt similarity index 100% rename from ec2imds/LICENSE.txt rename to feature/ec2/imds/LICENSE.txt diff --git a/ec2imds/api_client.go b/feature/ec2/imds/api_client.go similarity index 100% rename from ec2imds/api_client.go rename to feature/ec2/imds/api_client.go diff --git a/ec2imds/api_client_test.go b/feature/ec2/imds/api_client_test.go similarity index 100% rename from ec2imds/api_client_test.go rename to feature/ec2/imds/api_client_test.go diff --git a/ec2imds/api_op_GetDynamicData.go b/feature/ec2/imds/api_op_GetDynamicData.go similarity index 100% rename from ec2imds/api_op_GetDynamicData.go rename to feature/ec2/imds/api_op_GetDynamicData.go diff --git a/ec2imds/api_op_GetDynamicData_test.go b/feature/ec2/imds/api_op_GetDynamicData_test.go similarity index 100% rename from ec2imds/api_op_GetDynamicData_test.go rename to feature/ec2/imds/api_op_GetDynamicData_test.go diff --git a/ec2imds/api_op_GetIAMInfo.go b/feature/ec2/imds/api_op_GetIAMInfo.go similarity index 100% rename from ec2imds/api_op_GetIAMInfo.go rename to feature/ec2/imds/api_op_GetIAMInfo.go diff --git a/ec2imds/api_op_GetIAMInfo_test.go b/feature/ec2/imds/api_op_GetIAMInfo_test.go similarity index 100% rename from ec2imds/api_op_GetIAMInfo_test.go rename to feature/ec2/imds/api_op_GetIAMInfo_test.go diff --git a/ec2imds/api_op_GetInstanceIdentityDocument.go b/feature/ec2/imds/api_op_GetInstanceIdentityDocument.go similarity index 100% rename from ec2imds/api_op_GetInstanceIdentityDocument.go rename to feature/ec2/imds/api_op_GetInstanceIdentityDocument.go diff --git a/ec2imds/api_op_GetInstanceIdentityDocument_test.go b/feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go similarity index 100% rename from ec2imds/api_op_GetInstanceIdentityDocument_test.go rename to feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go diff --git a/ec2imds/api_op_GetMetadata.go b/feature/ec2/imds/api_op_GetMetadata.go similarity index 100% rename from ec2imds/api_op_GetMetadata.go rename to feature/ec2/imds/api_op_GetMetadata.go diff --git a/ec2imds/api_op_GetMetadata_test.go b/feature/ec2/imds/api_op_GetMetadata_test.go similarity index 100% rename from ec2imds/api_op_GetMetadata_test.go rename to feature/ec2/imds/api_op_GetMetadata_test.go diff --git a/ec2imds/api_op_GetRegion.go b/feature/ec2/imds/api_op_GetRegion.go similarity index 100% rename from ec2imds/api_op_GetRegion.go rename to feature/ec2/imds/api_op_GetRegion.go diff --git a/ec2imds/api_op_GetRegion_test.go b/feature/ec2/imds/api_op_GetRegion_test.go similarity index 100% rename from ec2imds/api_op_GetRegion_test.go rename to feature/ec2/imds/api_op_GetRegion_test.go diff --git a/ec2imds/api_op_GetToken.go b/feature/ec2/imds/api_op_GetToken.go similarity index 100% rename from ec2imds/api_op_GetToken.go rename to feature/ec2/imds/api_op_GetToken.go diff --git a/ec2imds/api_op_GetToken_test.go b/feature/ec2/imds/api_op_GetToken_test.go similarity index 100% rename from ec2imds/api_op_GetToken_test.go rename to feature/ec2/imds/api_op_GetToken_test.go diff --git a/ec2imds/api_op_GetUserData.go b/feature/ec2/imds/api_op_GetUserData.go similarity index 100% rename from ec2imds/api_op_GetUserData.go rename to feature/ec2/imds/api_op_GetUserData.go diff --git a/ec2imds/api_op_GetUserData_test.go b/feature/ec2/imds/api_op_GetUserData_test.go similarity index 100% rename from ec2imds/api_op_GetUserData_test.go rename to feature/ec2/imds/api_op_GetUserData_test.go diff --git a/ec2imds/doc.go b/feature/ec2/imds/doc.go similarity index 100% rename from ec2imds/doc.go rename to feature/ec2/imds/doc.go diff --git a/ec2imds/go.mod b/feature/ec2/imds/go.mod similarity index 100% rename from ec2imds/go.mod rename to feature/ec2/imds/go.mod diff --git a/ec2imds/go.sum b/feature/ec2/imds/go.sum similarity index 100% rename from ec2imds/go.sum rename to feature/ec2/imds/go.sum diff --git a/ec2imds/integration_test.go b/feature/ec2/imds/integration_test.go similarity index 100% rename from ec2imds/integration_test.go rename to feature/ec2/imds/integration_test.go diff --git a/ec2imds/request_middleware.go b/feature/ec2/imds/request_middleware.go similarity index 100% rename from ec2imds/request_middleware.go rename to feature/ec2/imds/request_middleware.go diff --git a/ec2imds/request_middleware_test.go b/feature/ec2/imds/request_middleware_test.go similarity index 100% rename from ec2imds/request_middleware_test.go rename to feature/ec2/imds/request_middleware_test.go diff --git a/ec2imds/shared_test.go b/feature/ec2/imds/shared_test.go similarity index 100% rename from ec2imds/shared_test.go rename to feature/ec2/imds/shared_test.go diff --git a/ec2imds/token_provider.go b/feature/ec2/imds/token_provider.go similarity index 100% rename from ec2imds/token_provider.go rename to feature/ec2/imds/token_provider.go From 05d6a8e2a8dff27d18be6a87733f87fe4ff691e4 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Wed, 16 Dec 2020 10:27:37 -0800 Subject: [PATCH 2/5] update ec2/imds package name --- feature/ec2/imds/api_client.go | 2 +- feature/ec2/imds/api_client_test.go | 2 +- feature/ec2/imds/api_op_GetDynamicData.go | 2 +- feature/ec2/imds/api_op_GetDynamicData_test.go | 2 +- feature/ec2/imds/api_op_GetIAMInfo.go | 2 +- feature/ec2/imds/api_op_GetIAMInfo_test.go | 2 +- feature/ec2/imds/api_op_GetInstanceIdentityDocument.go | 2 +- feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go | 2 +- feature/ec2/imds/api_op_GetMetadata.go | 2 +- feature/ec2/imds/api_op_GetMetadata_test.go | 2 +- feature/ec2/imds/api_op_GetRegion.go | 2 +- feature/ec2/imds/api_op_GetRegion_test.go | 2 +- feature/ec2/imds/api_op_GetToken.go | 2 +- feature/ec2/imds/api_op_GetToken_test.go | 2 +- feature/ec2/imds/api_op_GetUserData.go | 2 +- feature/ec2/imds/api_op_GetUserData_test.go | 2 +- feature/ec2/imds/doc.go | 4 ++-- feature/ec2/imds/go.mod | 4 ++-- feature/ec2/imds/integration_test.go | 2 +- feature/ec2/imds/request_middleware.go | 2 +- feature/ec2/imds/request_middleware_test.go | 2 +- feature/ec2/imds/shared_test.go | 2 +- feature/ec2/imds/token_provider.go | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) diff --git a/feature/ec2/imds/api_client.go b/feature/ec2/imds/api_client.go index c1ff19e2ade..55388645c9f 100644 --- a/feature/ec2/imds/api_client.go +++ b/feature/ec2/imds/api_client.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_client_test.go b/feature/ec2/imds/api_client_test.go index 6b2dc5a91af..3d688f7521f 100644 --- a/feature/ec2/imds/api_client_test.go +++ b/feature/ec2/imds/api_client_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "bytes" diff --git a/feature/ec2/imds/api_op_GetDynamicData.go b/feature/ec2/imds/api_op_GetDynamicData.go index 06a2b90e418..67dab86f1a9 100644 --- a/feature/ec2/imds/api_op_GetDynamicData.go +++ b/feature/ec2/imds/api_op_GetDynamicData.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetDynamicData_test.go b/feature/ec2/imds/api_op_GetDynamicData_test.go index cd501cb6937..dc2e2cda63d 100644 --- a/feature/ec2/imds/api_op_GetDynamicData_test.go +++ b/feature/ec2/imds/api_op_GetDynamicData_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "bytes" diff --git a/feature/ec2/imds/api_op_GetIAMInfo.go b/feature/ec2/imds/api_op_GetIAMInfo.go index a953a49f8f2..47d577f943c 100644 --- a/feature/ec2/imds/api_op_GetIAMInfo.go +++ b/feature/ec2/imds/api_op_GetIAMInfo.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetIAMInfo_test.go b/feature/ec2/imds/api_op_GetIAMInfo_test.go index aceb5a9cea9..02c05c60935 100644 --- a/feature/ec2/imds/api_op_GetIAMInfo_test.go +++ b/feature/ec2/imds/api_op_GetIAMInfo_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetInstanceIdentityDocument.go b/feature/ec2/imds/api_op_GetInstanceIdentityDocument.go index 75b6bcbc459..e7652075d70 100644 --- a/feature/ec2/imds/api_op_GetInstanceIdentityDocument.go +++ b/feature/ec2/imds/api_op_GetInstanceIdentityDocument.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go b/feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go index 05c6761ca66..35e3f7a0b3e 100644 --- a/feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go +++ b/feature/ec2/imds/api_op_GetInstanceIdentityDocument_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetMetadata.go b/feature/ec2/imds/api_op_GetMetadata.go index c00e050ee7a..9555639f462 100644 --- a/feature/ec2/imds/api_op_GetMetadata.go +++ b/feature/ec2/imds/api_op_GetMetadata.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetMetadata_test.go b/feature/ec2/imds/api_op_GetMetadata_test.go index a3729de957a..01417371e32 100644 --- a/feature/ec2/imds/api_op_GetMetadata_test.go +++ b/feature/ec2/imds/api_op_GetMetadata_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "bytes" diff --git a/feature/ec2/imds/api_op_GetRegion.go b/feature/ec2/imds/api_op_GetRegion.go index 70b65334060..fc59c2aca33 100644 --- a/feature/ec2/imds/api_op_GetRegion.go +++ b/feature/ec2/imds/api_op_GetRegion.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetRegion_test.go b/feature/ec2/imds/api_op_GetRegion_test.go index f9fd9a36221..a37c38f120e 100644 --- a/feature/ec2/imds/api_op_GetRegion_test.go +++ b/feature/ec2/imds/api_op_GetRegion_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetToken.go b/feature/ec2/imds/api_op_GetToken.go index 94dcc9bb623..d5924624c9a 100644 --- a/feature/ec2/imds/api_op_GetToken.go +++ b/feature/ec2/imds/api_op_GetToken.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetToken_test.go b/feature/ec2/imds/api_op_GetToken_test.go index 4d3977b2d16..7bf5a67e5f3 100644 --- a/feature/ec2/imds/api_op_GetToken_test.go +++ b/feature/ec2/imds/api_op_GetToken_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetUserData.go b/feature/ec2/imds/api_op_GetUserData.go index 17991ece71a..dd50ccfde79 100644 --- a/feature/ec2/imds/api_op_GetUserData.go +++ b/feature/ec2/imds/api_op_GetUserData.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/api_op_GetUserData_test.go b/feature/ec2/imds/api_op_GetUserData_test.go index 96f88099373..49f57ec0f6c 100644 --- a/feature/ec2/imds/api_op_GetUserData_test.go +++ b/feature/ec2/imds/api_op_GetUserData_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "bytes" diff --git a/feature/ec2/imds/doc.go b/feature/ec2/imds/doc.go index 925be68a67f..9ae608291c1 100644 --- a/feature/ec2/imds/doc.go +++ b/feature/ec2/imds/doc.go @@ -1,6 +1,6 @@ -// Package ec2imds provides the API client for interacting with the Amazon EC2 +// Package imds provides the API client for interacting with the Amazon EC2 // Instance Metadata Service. // // See the EC2 IMDS user guide for more information on using the API. // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html -package ec2imds +package imds diff --git a/feature/ec2/imds/go.mod b/feature/ec2/imds/go.mod index e7a3230b7fe..14a4c354247 100644 --- a/feature/ec2/imds/go.mod +++ b/feature/ec2/imds/go.mod @@ -1,4 +1,4 @@ -module github.com/aws/aws-sdk-go-v2/ec2imds +module github.com/aws/aws-sdk-go-v2/feature/ec2/imds go 1.15 @@ -8,4 +8,4 @@ require ( github.com/google/go-cmp v0.5.4 ) -replace github.com/aws/aws-sdk-go-v2 => ../ +replace github.com/aws/aws-sdk-go-v2 => ../../../ diff --git a/feature/ec2/imds/integration_test.go b/feature/ec2/imds/integration_test.go index 0d12b725091..096fa2fadf9 100644 --- a/feature/ec2/imds/integration_test.go +++ b/feature/ec2/imds/integration_test.go @@ -1,6 +1,6 @@ // +build integration,ec2env -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/request_middleware.go b/feature/ec2/imds/request_middleware.go index 22164efb7a0..d69ac548051 100644 --- a/feature/ec2/imds/request_middleware.go +++ b/feature/ec2/imds/request_middleware.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" diff --git a/feature/ec2/imds/request_middleware_test.go b/feature/ec2/imds/request_middleware_test.go index b00a13a6503..946882b4fb3 100644 --- a/feature/ec2/imds/request_middleware_test.go +++ b/feature/ec2/imds/request_middleware_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "bytes" diff --git a/feature/ec2/imds/shared_test.go b/feature/ec2/imds/shared_test.go index 38c58d87112..0ed85b7d136 100644 --- a/feature/ec2/imds/shared_test.go +++ b/feature/ec2/imds/shared_test.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "net/http" diff --git a/feature/ec2/imds/token_provider.go b/feature/ec2/imds/token_provider.go index dea621a9e0b..3cd05fe692e 100644 --- a/feature/ec2/imds/token_provider.go +++ b/feature/ec2/imds/token_provider.go @@ -1,4 +1,4 @@ -package ec2imds +package imds import ( "context" From 7aa259b282c1884b94468f85dbbac1b9ef090dd0 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Wed, 16 Dec 2020 10:36:28 -0800 Subject: [PATCH 3/5] update packages depending on feature/ec2/imds --- config/go.mod | 4 ++-- config/load_options.go | 9 +++++---- config/resolve_credentials.go | 4 ++-- credentials/ec2rolecreds/doc.go | 12 ++++++------ credentials/ec2rolecreds/provider.go | 14 +++++++------- credentials/ec2rolecreds/provider_test.go | 10 +++++----- credentials/go.mod | 4 ++-- example/service/s3/listObjects/go.mod | 2 +- feature/s3/manager/go.mod | 2 +- service/internal/integrationtest/go.mod | 2 +- service/s3/internal/configtesting/go.mod | 2 +- 11 files changed, 33 insertions(+), 32 deletions(-) diff --git a/config/go.mod b/config/go.mod index f948976a19d..0856bb7dc51 100644 --- a/config/go.mod +++ b/config/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go-v2 v0.30.0 github.com/aws/aws-sdk-go-v2/credentials v0.1.5 - github.com/aws/aws-sdk-go-v2/ec2imds v0.1.5 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v0.0.0-20201216182737-05d6a8e2a8df github.com/aws/aws-sdk-go-v2/service/sts v0.30.0 github.com/awslabs/smithy-go v0.4.1-0.20201208232924-b8cdbaa577ff github.com/google/go-cmp v0.5.4 @@ -14,6 +14,6 @@ require ( replace ( github.com/aws/aws-sdk-go-v2 => ../ github.com/aws/aws-sdk-go-v2/credentials => ../credentials/ - github.com/aws/aws-sdk-go-v2/ec2imds => ../ec2imds/ + github.com/aws/aws-sdk-go-v2/feature/ec2/imds => ../feature/ec2/imds/ github.com/aws/aws-sdk-go-v2/service/sts => ../service/sts/ ) diff --git a/config/load_options.go b/config/load_options.go index 6b5ee8d2cac..480f22f95c2 100644 --- a/config/load_options.go +++ b/config/load_options.go @@ -2,9 +2,10 @@ package config import ( "context" - "github.com/aws/aws-sdk-go-v2/ec2imds" "io" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds" "github.com/aws/aws-sdk-go-v2/credentials/endpointcreds" @@ -211,7 +212,7 @@ func WithCustomCABundle(v io.Reader) LoadOptionsFunc { // from the EC2 Metadata service. type UseEC2IMDSRegion struct { // If unset will default to generic EC2 IMDS client. - Client *ec2imds.Client + Client *imds.Client } // getRegion attempts to retrieve the region from EC2 Metadata service. @@ -222,7 +223,7 @@ func (p *UseEC2IMDSRegion) getRegion(ctx context.Context) (string, bool, error) client := p.Client if client == nil { - client = ec2imds.New(ec2imds.Options{}) + client = imds.New(imds.Options{}) } result, err := p.Client.GetRegion(ctx, nil) @@ -235,7 +236,7 @@ func (p *UseEC2IMDSRegion) getRegion(ctx context.Context) (string, bool, error) return "", false, nil } -// getEC2IMDSRegion returns the value of ec2imds region. +// getEC2IMDSRegion returns the value of EC2 IMDS region. func (o LoadOptions) getEC2IMDSRegion(ctx context.Context) (string, bool, error) { if o.UseEC2IMDSRegion == nil { return "", false, nil diff --git a/config/resolve_credentials.go b/config/resolve_credentials.go index 76710407701..ddadc54ef11 100644 --- a/config/resolve_credentials.go +++ b/config/resolve_credentials.go @@ -12,7 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/credentials/endpointcreds" "github.com/aws/aws-sdk-go-v2/credentials/processcreds" "github.com/aws/aws-sdk-go-v2/credentials/stscreds" - "github.com/aws/aws-sdk-go-v2/ec2imds" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/service/sts" ) @@ -258,7 +258,7 @@ func resolveEC2RoleCredentials(ctx context.Context, cfg *aws.Config, configs con optFns = append(optFns, func(o *ec2rolecreds.Options) { // Only define a client from config if not already defined. if o.Client != nil { - o.Client = ec2imds.New(ec2imds.Options{ + o.Client = imds.New(imds.Options{ HTTPClient: cfg.HTTPClient, Retryer: cfg.Retryer, }) diff --git a/credentials/ec2rolecreds/doc.go b/credentials/ec2rolecreds/doc.go index 5a23edf8f8a..0bec6526b58 100644 --- a/credentials/ec2rolecreds/doc.go +++ b/credentials/ec2rolecreds/doc.go @@ -30,7 +30,7 @@ // it with the CredentialsCache before assigning the provider to the Amazon S3 API // client's Credentials option. // -// provider := ec2imds.New(ec2imds.Options{}) +// provider := imds.New(imds.Options{}) // // // Create the service client value configured for credentials. // svc := s3.New(s3.Options{ @@ -38,12 +38,12 @@ // }) // // If you need more control, you can set the configuration options on the -// credentials provider using the ec2imds.Options type to configure the EC2 IMDS +// credentials provider using the imds.Options type to configure the EC2 IMDS // API Client and ExpiryWindow of the retrieved credentials. // -// provider := ec2imds.New(ec2imds.Options{ -// // See ec2imds.Options type's documentation for more options available. -// Client: ec2imds.New(Options{ +// provider := imds.New(imds.Options{ +// // See imds.Options type's documentation for more options available. +// Client: imds.New(Options{ // HTTPClient: customHTTPClient, // }), // @@ -53,6 +53,6 @@ // // EC2 IMDS API Client // -// See the github.com/aws/aws-sdk-go-v2/ec2imds module for more details on +// See the github.com/aws/aws-sdk-go-v2/feature/ec2/imds module for more details on // configuring the client, and options available. package ec2rolecreds diff --git a/credentials/ec2rolecreds/provider.go b/credentials/ec2rolecreds/provider.go index 6eceafa7300..083ac5e48ce 100644 --- a/credentials/ec2rolecreds/provider.go +++ b/credentials/ec2rolecreds/provider.go @@ -10,7 +10,7 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/ec2imds" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/awslabs/smithy-go" ) @@ -20,7 +20,7 @@ const ProviderName = "EC2RoleProvider" // GetMetadataAPIClient provides the interface for an EC2 IMDS API client for the // GetMetadata operation. type GetMetadataAPIClient interface { - GetMetadata(context.Context, *ec2imds.GetMetadataInput, ...func(*ec2imds.Options)) (*ec2imds.GetMetadataOutput, error) + GetMetadata(context.Context, *imds.GetMetadataInput, ...func(*imds.Options)) (*imds.GetMetadataOutput, error) } // A Provider retrieves credentials from the EC2 service, and keeps track if @@ -29,7 +29,7 @@ type GetMetadataAPIClient interface { // The New function must be used to create the Provider. // // p := &ec2rolecreds.New(ec2rolecreds.Options{ -// Client: ec2imds.New(ec2imds.Options{}), +// Client: imds.New(imds.Options{}), // // // Expire the credentials 10 minutes before IAM states they should. // // Proactively refreshing the credentials. @@ -44,7 +44,7 @@ type Options struct { // The API client that will be used by the provider to make GetMetadata API // calls to EC2 IMDS. // - // If nil, the provider will default to the ec2imds client. + // If nil, the provider will default to the EC2 IMDS client. Client GetMetadataAPIClient } @@ -58,7 +58,7 @@ func New(optFns ...func(*Options)) *Provider { } if options.Client == nil { - options.Client = ec2imds.New(ec2imds.Options{}) + options.Client = imds.New(imds.Options{}) } return &Provider{ @@ -119,7 +119,7 @@ const iamSecurityCredsPath = "/iam/security-credentials/" // there are no credentials, or there is an error making or receiving the // request func requestCredList(ctx context.Context, client GetMetadataAPIClient) ([]string, error) { - resp, err := client.GetMetadata(ctx, &ec2imds.GetMetadataInput{ + resp, err := client.GetMetadata(ctx, &imds.GetMetadataInput{ Path: iamSecurityCredsPath, }) if err != nil { @@ -145,7 +145,7 @@ func requestCredList(ctx context.Context, client GetMetadataAPIClient) ([]string // If the credentials cannot be found, or there is an error reading the response // and error will be returned. func requestCred(ctx context.Context, client GetMetadataAPIClient, credsName string) (ec2RoleCredRespBody, error) { - resp, err := client.GetMetadata(ctx, &ec2imds.GetMetadataInput{ + resp, err := client.GetMetadata(ctx, &imds.GetMetadataInput{ Path: path.Join(iamSecurityCredsPath, credsName), }) if err != nil { diff --git a/credentials/ec2rolecreds/provider_test.go b/credentials/ec2rolecreds/provider_test.go index a80a1d149fb..4c5d3292fd8 100644 --- a/credentials/ec2rolecreds/provider_test.go +++ b/credentials/ec2rolecreds/provider_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/aws/aws-sdk-go-v2/ec2imds" + "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" "github.com/aws/aws-sdk-go-v2/internal/sdk" "github.com/awslabs/smithy-go" ) @@ -38,13 +38,13 @@ type mockClient struct { } func (c mockClient) GetMetadata( - ctx context.Context, params *ec2imds.GetMetadataInput, optFns ...func(*ec2imds.Options), + ctx context.Context, params *imds.GetMetadataInput, optFns ...func(*imds.Options), ) ( - *ec2imds.GetMetadataOutput, error, + *imds.GetMetadataOutput, error, ) { switch params.Path { case iamSecurityCredsPath: - return &ec2imds.GetMetadataOutput{ + return &imds.GetMetadataOutput{ Content: ioutil.NopCloser(strings.NewReader(c.roleName)), }, nil @@ -55,7 +55,7 @@ func (c mockClient) GetMetadata( } else { fmt.Fprintf(&w, credsRespTmpl, c.expireOn) } - return &ec2imds.GetMetadataOutput{ + return &imds.GetMetadataOutput{ Content: ioutil.NopCloser(strings.NewReader(w.String())), }, nil default: diff --git a/credentials/go.mod b/credentials/go.mod index c87b853d94e..0bb4e6155c6 100644 --- a/credentials/go.mod +++ b/credentials/go.mod @@ -4,13 +4,13 @@ go 1.15 require ( github.com/aws/aws-sdk-go-v2 v0.30.0 - github.com/aws/aws-sdk-go-v2/ec2imds v0.1.5 + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v0.0.0-20201216182737-05d6a8e2a8df github.com/aws/aws-sdk-go-v2/service/sts v0.30.0 github.com/awslabs/smithy-go v0.4.1-0.20201208232924-b8cdbaa577ff ) replace ( github.com/aws/aws-sdk-go-v2 => ../ - github.com/aws/aws-sdk-go-v2/ec2imds => ../ec2imds/ + github.com/aws/aws-sdk-go-v2/feature/ec2/imds => ../feature/ec2/imds/ github.com/aws/aws-sdk-go-v2/service/sts => ../service/sts/ ) diff --git a/example/service/s3/listObjects/go.mod b/example/service/s3/listObjects/go.mod index e786e70972e..e11c3cdd294 100644 --- a/example/service/s3/listObjects/go.mod +++ b/example/service/s3/listObjects/go.mod @@ -15,7 +15,7 @@ replace github.com/aws/aws-sdk-go-v2 => ../../../../ replace github.com/aws/aws-sdk-go-v2/credentials => ../../../../credentials/ -replace github.com/aws/aws-sdk-go-v2/ec2imds => ../../../../ec2imds/ +replace github.com/aws/aws-sdk-go-v2/feature/ec2/imds => ../../../../feature/ec2/imds/ replace github.com/aws/aws-sdk-go-v2/service/sts => ../../../../service/sts/ diff --git a/feature/s3/manager/go.mod b/feature/s3/manager/go.mod index b25721de9e0..db147c4262c 100644 --- a/feature/s3/manager/go.mod +++ b/feature/s3/manager/go.mod @@ -18,7 +18,7 @@ replace github.com/aws/aws-sdk-go-v2/service/s3 => ../../../service/s3/ replace github.com/aws/aws-sdk-go-v2/credentials => ../../../credentials/ -replace github.com/aws/aws-sdk-go-v2/ec2imds => ../../../ec2imds/ +replace github.com/aws/aws-sdk-go-v2/feature/ec2/imds => ../../../feature/ec2/imds/ replace github.com/aws/aws-sdk-go-v2/service/sts => ../../../service/sts/ diff --git a/service/internal/integrationtest/go.mod b/service/internal/integrationtest/go.mod index 8cd940a616c..ebd4ce44f49 100644 --- a/service/internal/integrationtest/go.mod +++ b/service/internal/integrationtest/go.mod @@ -258,7 +258,7 @@ replace github.com/aws/aws-sdk-go-v2/service/workspaces => ../../../service/work replace github.com/aws/aws-sdk-go-v2/credentials => ../../../credentials/ -replace github.com/aws/aws-sdk-go-v2/ec2imds => ../../../ec2imds/ +replace github.com/aws/aws-sdk-go-v2/feature/ec2/imds => ../../../feature/ec2/imds/ replace github.com/aws/aws-sdk-go-v2/service/internal/s3shared => ../../../service/internal/s3shared/ diff --git a/service/s3/internal/configtesting/go.mod b/service/s3/internal/configtesting/go.mod index 7a5f1eeb0ac..87a2a20dc24 100644 --- a/service/s3/internal/configtesting/go.mod +++ b/service/s3/internal/configtesting/go.mod @@ -15,7 +15,7 @@ replace ( replace github.com/aws/aws-sdk-go-v2/credentials => ../../../../credentials/ -replace github.com/aws/aws-sdk-go-v2/ec2imds => ../../../../ec2imds/ +replace github.com/aws/aws-sdk-go-v2/feature/ec2/imds => ../../../../feature/ec2/imds/ replace github.com/aws/aws-sdk-go-v2/service/internal/s3shared => ../../../../service/internal/s3shared/ From d483d0c25864d4c7583dec317811f92b19f06490 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Wed, 16 Dec 2020 11:19:20 -0800 Subject: [PATCH 4/5] add changelog --- .../credentials-feature-1608146309206308000.json | 9 +++++++++ .../feature.ec2.imds-feature-1608146342526841000.json | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 .changes/next-release/credentials-feature-1608146309206308000.json create mode 100644 .changes/next-release/feature.ec2.imds-feature-1608146342526841000.json diff --git a/.changes/next-release/credentials-feature-1608146309206308000.json b/.changes/next-release/credentials-feature-1608146309206308000.json new file mode 100644 index 00000000000..0efce9720e0 --- /dev/null +++ b/.changes/next-release/credentials-feature-1608146309206308000.json @@ -0,0 +1,9 @@ +{ + "ID": "credentials-feature-1608146309206308000", + "SchemaVersion": 1, + "Module": "credentials", + "Type": "feature", + "Description": "Update ec2rolecreds to depend on /feature/ec2/imds module", + "MinVersion": "", + "AffectedModules": null +} \ No newline at end of file diff --git a/.changes/next-release/feature.ec2.imds-feature-1608146342526841000.json b/.changes/next-release/feature.ec2.imds-feature-1608146342526841000.json new file mode 100644 index 00000000000..0740100c2dc --- /dev/null +++ b/.changes/next-release/feature.ec2.imds-feature-1608146342526841000.json @@ -0,0 +1,9 @@ +{ + "ID": "feature.ec2.imds-feature-1608146342526841000", + "SchemaVersion": 1, + "Module": "feature/ec2/imds", + "Type": "feature", + "Description": "Move ec2imds module to feature/ec2/imds", + "MinVersion": "", + "AffectedModules": null +} \ No newline at end of file From ec764466d11323ae32d0fd1a43ffb39c45ce6f1f Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Wed, 16 Dec 2020 11:22:34 -0800 Subject: [PATCH 5/5] add config changelog --- .../next-release/config-feature-1608146507258154000.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changes/next-release/config-feature-1608146507258154000.json diff --git a/.changes/next-release/config-feature-1608146507258154000.json b/.changes/next-release/config-feature-1608146507258154000.json new file mode 100644 index 00000000000..6752526768c --- /dev/null +++ b/.changes/next-release/config-feature-1608146507258154000.json @@ -0,0 +1,9 @@ +{ + "ID": "config-feature-1608146507258154000", + "SchemaVersion": 1, + "Module": "config", + "Type": "feature", + "Description": "Update to use moved feature/ec2/imds module", + "MinVersion": "", + "AffectedModules": null +} \ No newline at end of file