Skip to content

Commit

Permalink
Reintroduce AWS credential check to cloudwatch output (influxdata#3587)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz authored and danielnelson committed Jan 3, 2018
1 parent a440ed8 commit 56be3d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/outputs/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/sts"

"github.com/influxdata/telegraf"
internalaws "github.com/influxdata/telegraf/internal/config/aws"
Expand Down Expand Up @@ -70,7 +71,20 @@ func (c *CloudWatch) Connect() error {
Token: c.Token,
}
configProvider := credentialConfig.Credentials()

stsService := sts.New(configProvider)

params := &sts.GetCallerIdentityInput{}

_, err := stsService.GetCallerIdentity(params)

if err != nil {
log.Printf("E! cloudwatch: Cannot use credentials to connect to AWS : %+v \n", err.Error())
return err
}

c.svc = cloudwatch.New(configProvider)

return nil
}

Expand Down

0 comments on commit 56be3d3

Please sign in to comment.