Skip to content

Commit

Permalink
Merge pull request #56 from sanathkr/develop
Browse files Browse the repository at this point in the history
Don't set region if not configured in CLI. Fixes #48
  • Loading branch information
PaulMaddox authored Aug 16, 2017
2 parents a07d167 + a686243 commit 92900aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ func getSessionOrDefaultCreds() map[string]string {
// Obtain AWS credentials and pass them through to the container runtime via env variables
if sess, err := session.NewSession(); err == nil {
if creds, err := sess.Config.Credentials.Get(); err == nil {
result["region"] = *sess.Config.Region
if *sess.Config.Region != "" {
result["region"] = *sess.Config.Region
}

result["key"] = creds.AccessKeyID
result["secret"] = creds.SecretAccessKey
result["sessiontoken"] = creds.SessionToken
Expand Down Expand Up @@ -454,6 +457,7 @@ func getEnvironmentVariables(function resources.AWSServerlessFunction, overrides
// Variables available in Lambda execution environment for all functions (AWS_* variables)
env := map[string]string{
"AWS_SAM_LOCAL": "true",
"AWS_REGION": creds["region"],
"AWS_DEFAULT_REGION": creds["region"],
"AWS_ACCESS_KEY_ID": creds["key"],
"AWS_SECRET_ACCESS_KEY": creds["secret"],
Expand Down

0 comments on commit 92900aa

Please sign in to comment.