handle NewSession() error

This commit is contained in:
Mitsuhiro Tanda 2017-06-06 22:02:23 +09:00
parent a1ddab463e
commit 64cef5cd05
1 changed files with 4 additions and 1 deletions

View File

@ -1128,7 +1128,10 @@ func (c *EC2SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err return err
} }
if c.Region == "" { if c.Region == "" {
sess := session.Must(session.NewSession()) sess, err := session.NewSession()
if err != nil {
return err
}
metadata := ec2metadata.New(sess) metadata := ec2metadata.New(sess)
region, err := metadata.Region() region, err := metadata.Region()
if err != nil { if err != nil {