Skip to content

Commit 81f79b4

Browse files
Use default AWS credential chain under normal circumstances (#218)
1 parent 2949343 commit 81f79b4

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

get_s3.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,15 @@ func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, ke
181181

182182
func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config {
183183
conf := &aws.Config{}
184-
if creds == nil {
185-
// Grab the metadata URL
186-
metadataURL := os.Getenv("AWS_METADATA_URL")
187-
if metadataURL == "" {
188-
metadataURL = "http://169.254.169.254:80/latest"
189-
}
190-
184+
metadataURLOverride := os.Getenv("AWS_METADATA_URL")
185+
if creds == nil && metadataURLOverride != "" {
191186
creds = credentials.NewChainCredentials(
192187
[]credentials.Provider{
193188
&credentials.EnvProvider{},
194189
&credentials.SharedCredentialsProvider{Filename: "", Profile: ""},
195190
&ec2rolecreds.EC2RoleProvider{
196191
Client: ec2metadata.New(session.New(&aws.Config{
197-
Endpoint: aws.String(metadataURL),
192+
Endpoint: aws.String(metadataURLOverride),
198193
})),
199194
},
200195
})
@@ -213,7 +208,7 @@ func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.
213208
conf.Region = aws.String(region)
214209
}
215210

216-
return conf
211+
return conf.WithCredentialsChainVerboseErrors(true)
217212
}
218213

219214
func (g *S3Getter) parseUrl(u *url.URL) (region, bucket, path, version string, creds *credentials.Credentials, err error) {

0 commit comments

Comments
 (0)