From 7b5c0900ef53018783d295cfca1177a52432b120 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 7 Dec 2017 11:12:57 -0800 Subject: [PATCH] Correctly set aws region if given in template along with a profile. --- builder/amazon/common/access_config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builder/amazon/common/access_config.go b/builder/amazon/common/access_config.go index 73e50b862..1ecd9dcdb 100644 --- a/builder/amazon/common/access_config.go +++ b/builder/amazon/common/access_config.go @@ -40,7 +40,9 @@ func (c *AccessConfig) Session() (*session.Session, error) { if err := os.Setenv("AWS_PROFILE", c.ProfileName); err != nil { return nil, fmt.Errorf("Set env error: %s", err) } - } else if c.RawRegion != "" { + } + + if c.RawRegion != "" { config = config.WithRegion(c.RawRegion) } else if region := c.metadataRegion(); region != "" { config = config.WithRegion(region)