Skip to content

Commit

Permalink
add session token support in AWS creds. Closes #329 (#339)
Browse files Browse the repository at this point in the history
* add session token support in AWS creds. Closes #329

* update README
  • Loading branch information
mthenw authored Oct 25, 2017
1 parent df7243d commit 1e49f35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ JSON object:
- `arn` - `string` - required, AWS ARN identifier
- `region` - `string` - required, region name
- `awsAccessKeyID` - `string` - optional, AWS API key ID. By default credentials from the [environment](http://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials) are used.
- `awsSecretAccessKey` - `string` - optional, AWS API key. By default credentials from the [environment](http://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials) are used.
- `awsSecretAccessKey` - `string` - optional, AWS API access key. By default credentials from the [environment](http://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials) are used.
- `awsSessionToken` - `string` - optional, AWS session token
- for HTTP function:
- `type` - `string` - required, provider type: `http`
- `url` - `string` - required, the URL of an http or https remote endpoint
Expand Down Expand Up @@ -440,6 +441,7 @@ JSON object:
- `region` - `string` - required, region name
- `awsAccessKeyID` - `string` - optional, AWS API key ID
- `awsSecretAccessKey` - `string` - optional, AWS API key
- `awsSessionToken` - `string` - optional, AWS session token
- for HTTP function:
- `type` - `string` - required, provider type: `http`
- `url` - `string` - required, the URL of an http or https remote endpoint
Expand Down
3 changes: 2 additions & 1 deletion functions/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Provider struct {
Region string `json:"region,omitempty"`
AWSAccessKeyID string `json:"awsAccessKeyID,omitempty"`
AWSSecretAccessKey string `json:"awsSecretAccessKey,omitempty"`
AWSSessionToken string `json:"awsSessionToken,omitempty"`

// Group weighted function
Weighted WeightedFunctions `json:"weighted,omitempty"`
Expand Down Expand Up @@ -128,7 +129,7 @@ func (w WeightedFunctions) Choose() (FunctionID, error) {
func (f *Function) callAWSLambda(payload []byte) ([]byte, error) {
config := aws.NewConfig().WithRegion(f.Provider.Region)
if f.Provider.AWSAccessKeyID != "" && f.Provider.AWSSecretAccessKey != "" {
config = config.WithCredentials(credentials.NewStaticCredentials(f.Provider.AWSAccessKeyID, f.Provider.AWSSecretAccessKey, ""))
config = config.WithCredentials(credentials.NewStaticCredentials(f.Provider.AWSAccessKeyID, f.Provider.AWSSecretAccessKey, f.Provider.AWSSessionToken))
}

awslambda := lambda.New(session.New(config))
Expand Down

0 comments on commit 1e49f35

Please sign in to comment.