-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use shared AWS credential configuration. * Cloudwatch dimension wilcards * Allow configuring cache_ttl for cloudwatch metrics. * Allow for wildcard in dimension values to select all available metrics. * Use internal.Duration for CacheTTL and go fmt * Refactor to not use embedded structs for config. * Update AWS plugin READMEs with credentials details, update Changelog. * Fix changelog after rebasing to master and 0.13.1 release. * Fix changelog after rebase.
- Loading branch information
1 parent
6351aa5
commit 5f3a91b
Showing
8 changed files
with
283 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package aws | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/client" | ||
"github.com/aws/aws-sdk-go/aws/credentials" | ||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
) | ||
|
||
type CredentialConfig struct { | ||
Region string | ||
AccessKey string | ||
SecretKey string | ||
RoleARN string | ||
Profile string | ||
Filename string | ||
Token string | ||
} | ||
|
||
func (c *CredentialConfig) Credentials() client.ConfigProvider { | ||
if c.RoleARN != "" { | ||
return c.assumeCredentials() | ||
} else { | ||
return c.rootCredentials() | ||
} | ||
} | ||
|
||
func (c *CredentialConfig) rootCredentials() client.ConfigProvider { | ||
config := &aws.Config{ | ||
Region: aws.String(c.Region), | ||
} | ||
if c.AccessKey != "" || c.SecretKey != "" { | ||
config.Credentials = credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token) | ||
} else if c.Profile != "" || c.Filename != "" { | ||
config.Credentials = credentials.NewSharedCredentials(c.Filename, c.Profile) | ||
} | ||
|
||
return session.New(config) | ||
} | ||
|
||
func (c *CredentialConfig) assumeCredentials() client.ConfigProvider { | ||
rootCredentials := c.rootCredentials() | ||
config := &aws.Config{ | ||
Region: aws.String(c.Region), | ||
} | ||
config.Credentials = stscreds.NewCredentials(rootCredentials, c.RoleARN) | ||
return session.New(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.