Skip to content

Commit

Permalink
Coerce profile string pointer to string using Amazon's helper
Browse files Browse the repository at this point in the history
When using the raw dereferenced pointer when attempting to get an AWS
session, it is possible that profile is a nil pointer, in which case the
application panics when trying to dereference it. Using AWS' helper
methods instead ensures an empty value is used instead.
  • Loading branch information
sleepdeprecation committed May 1, 2018
1 parent 46e603f commit c2add37
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aws_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func SetAwsConfig(region, profile *string, role *string) (err error) {
return nil
}

func setAwsConfig(region, profile *string, role *string) {
func setAwsConfig(region, profile, role *string) {
log.WithFields(log.Fields{"region": aws.StringValue(region), "profile": aws.StringValue(profile)}).Debug("Configure AWS")

sess := getAwsSession(region, profile, role)
Expand All @@ -50,7 +50,7 @@ func getAwsSession(region, profile, role *string) *session.Session {
sess := session.Must(session.NewSessionWithOptions(session.Options{
Config: config,
SharedConfigState: session.SharedConfigEnable,
Profile: *profile,
Profile: aws.StringValue(profile),
}))

// If a role is supplied, return a new session using STS-generated credentials
Expand Down

0 comments on commit c2add37

Please sign in to comment.