Skip to content

Commit

Permalink
Use default AWS credential chain under normal circumstances (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbergknoff-rival authored Sep 1, 2020
1 parent 2949343 commit 81f79b4
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions get_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,15 @@ func (g *S3Getter) getObject(ctx context.Context, client *s3.S3, dst, bucket, ke

func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.Credentials) *aws.Config {
conf := &aws.Config{}
if creds == nil {
// Grab the metadata URL
metadataURL := os.Getenv("AWS_METADATA_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254:80/latest"
}

metadataURLOverride := os.Getenv("AWS_METADATA_URL")
if creds == nil && metadataURLOverride != "" {
creds = credentials.NewChainCredentials(
[]credentials.Provider{
&credentials.EnvProvider{},
&credentials.SharedCredentialsProvider{Filename: "", Profile: ""},
&ec2rolecreds.EC2RoleProvider{
Client: ec2metadata.New(session.New(&aws.Config{
Endpoint: aws.String(metadataURL),
Endpoint: aws.String(metadataURLOverride),
})),
},
})
Expand All @@ -213,7 +208,7 @@ func (g *S3Getter) getAWSConfig(region string, url *url.URL, creds *credentials.
conf.Region = aws.String(region)
}

return conf
return conf.WithCredentialsChainVerboseErrors(true)
}

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

0 comments on commit 81f79b4

Please sign in to comment.