add support for profile

This commit is contained in:
Matthew Hooker 2017-06-09 11:24:30 -07:00
parent 3fb4162660
commit a619759bf7
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
1 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package common
import (
"fmt"
"log"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
@ -35,6 +37,12 @@ func (c *AccessConfig) Session() (*session.Session, error) {
return nil, err
}
if c.ProfileName != "" {
if err := os.Setenv("AWS_PROFILE", c.ProfileName); err != nil {
log.Printf("Set env error: %s", err)
}
}
config := aws.NewConfig().WithRegion(region).WithMaxRetries(11).WithCredentialsChainVerboseErrors(true)
if c.CustomEndpointEc2 != "" {