Skip to content

Commit

Permalink
Add MaxRetries setting for aws sdk to be used by AWS secret backend
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen0 committed Feb 14, 2018
1 parent 9f52633 commit 82c442d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/logical/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
func getRootConfig(ctx context.Context, s logical.Storage, clientType string) (*aws.Config, error) {
credsConfig := &awsutil.CredentialsConfig{}
var endpoint string
var MaxRetries int

entry, err := s.Get(ctx, "config/root")
if err != nil {
Expand All @@ -31,6 +32,7 @@ func getRootConfig(ctx context.Context, s logical.Storage, clientType string) (*
credsConfig.AccessKey = config.AccessKey
credsConfig.SecretKey = config.SecretKey
credsConfig.Region = config.Region
MaxRetries = config.MaxRetries
switch {
case clientType == "iam" && config.IAMEndpoint != "":
endpoint = *aws.String(config.IAMEndpoint)
Expand Down Expand Up @@ -61,6 +63,7 @@ func getRootConfig(ctx context.Context, s logical.Storage, clientType string) (*
Region: aws.String(credsConfig.Region),
Endpoint: &endpoint,
HTTPClient: cleanhttp.DefaultClient(),
MaxRetries: aws.Int(MaxRetries),
}, nil
}

Expand Down
7 changes: 7 additions & 0 deletions builtin/logical/aws/path_config_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func pathConfigRoot() *framework.Path {
Type: framework.TypeString,
Description: "Endpoint to custom STS server URL",
},
"max_retries": &framework.FieldSchema{
Type: framework.TypeInt,
Description: "Maximum number of retries for recoverable exceptions of AWS APIs",
},
},

Callbacks: map[logical.Operation]framework.OperationFunc{
Expand All @@ -48,13 +52,15 @@ func pathConfigRootWrite(ctx context.Context, req *logical.Request, data *framew
region := data.Get("region").(string)
iamendpoint := data.Get("iam_endpoint").(string)
stsendpoint := data.Get("sts_endpoint").(string)
maxretries := data.Get("max_retries").(int)

entry, err := logical.StorageEntryJSON("config/root", rootConfig{
AccessKey: data.Get("access_key").(string),
SecretKey: data.Get("secret_key").(string),
IAMEndpoint: iamendpoint,
STSEndpoint: stsendpoint,
Region: region,
MaxRetries: maxretries,
})
if err != nil {
return nil, err
Expand All @@ -73,6 +79,7 @@ type rootConfig struct {
IAMEndpoint string `json:"iam_endpoint"`
STSEndpoint string `json:"sts_endpoint"`
Region string `json:"region"`
MaxRetries int `json:"max_retries"`
}

const pathConfigRootHelpSyn = `
Expand Down

0 comments on commit 82c442d

Please sign in to comment.