From f972863f496e3752ca14e942172d90608c65983b Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 26 Nov 2015 13:21:38 +0900 Subject: [PATCH] add credential setting to handleDescribeInstances --- pkg/api/cloudwatch/cloudwatch.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/api/cloudwatch/cloudwatch.go b/pkg/api/cloudwatch/cloudwatch.go index 6311d62f43e..739d9aad4c9 100644 --- a/pkg/api/cloudwatch/cloudwatch.go +++ b/pkg/api/cloudwatch/cloudwatch.go @@ -126,8 +126,16 @@ func handleListMetrics(req *cwRequest, c *middleware.Context) { } func handleDescribeInstances(req *cwRequest, c *middleware.Context) { + creds := credentials.NewChainCredentials( + []credentials.Provider{ + &credentials.EnvProvider{}, + &credentials.SharedCredentialsProvider{Filename: "", Profile: req.DataSource.Database}, + &ec2rolecreds.EC2RoleProvider{ExpiryWindow: 5 * time.Minute}, + }) + cfg := &aws.Config{ - Region: aws.String(req.Region), + Region: aws.String(req.Region), + Credentials: creds, } svc := ec2.New(session.New(cfg), cfg)