Merge pull request #1787 from koendc/f-aws-max-retries
aws: make MaxRetries for API calls configurable
This commit is contained in:
commit
c8c0b02790
|
@ -23,6 +23,7 @@ type Config struct {
|
||||||
SecretKey string
|
SecretKey string
|
||||||
Token string
|
Token string
|
||||||
Region string
|
Region string
|
||||||
|
MaxRetries int
|
||||||
|
|
||||||
AllowedAccountIds []interface{}
|
AllowedAccountIds []interface{}
|
||||||
ForbiddenAccountIds []interface{}
|
ForbiddenAccountIds []interface{}
|
||||||
|
@ -64,6 +65,7 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
awsConfig := &aws.Config{
|
awsConfig := &aws.Config{
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
Region: c.Region,
|
Region: c.Region,
|
||||||
|
MaxRetries: c.MaxRetries,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("[INFO] Initializing ELB connection")
|
log.Println("[INFO] Initializing ELB connection")
|
||||||
|
@ -96,6 +98,7 @@ func (c *Config) Client() (interface{}, error) {
|
||||||
client.r53conn = route53.New(&aws.Config{
|
client.r53conn = route53.New(&aws.Config{
|
||||||
Credentials: creds,
|
Credentials: creds,
|
||||||
Region: "us-east-1",
|
Region: "us-east-1",
|
||||||
|
MaxRetries: c.MaxRetries,
|
||||||
})
|
})
|
||||||
|
|
||||||
log.Println("[INFO] Initializing Elasticache Connection")
|
log.Println("[INFO] Initializing Elasticache Connection")
|
||||||
|
|
|
@ -54,6 +54,13 @@ func Provider() terraform.ResourceProvider {
|
||||||
InputDefault: "us-east-1",
|
InputDefault: "us-east-1",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"max_retries": &schema.Schema{
|
||||||
|
Type: schema.TypeInt,
|
||||||
|
Optional: true,
|
||||||
|
Default: 11,
|
||||||
|
Description: descriptions["max_retries"],
|
||||||
|
},
|
||||||
|
|
||||||
"allowed_account_ids": &schema.Schema{
|
"allowed_account_ids": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Elem: &schema.Schema{Type: schema.TypeString},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
|
@ -132,6 +139,10 @@ func init() {
|
||||||
|
|
||||||
"token": "session token. A session token is only required if you are\n" +
|
"token": "session token. A session token is only required if you are\n" +
|
||||||
"using temporary security credentials.",
|
"using temporary security credentials.",
|
||||||
|
|
||||||
|
"max_retries": "The maximum number of times an AWS API request is\n" +
|
||||||
|
"being executed. If the API request still fails, an error is\n" +
|
||||||
|
"thrown.",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +152,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||||||
SecretKey: d.Get("secret_key").(string),
|
SecretKey: d.Get("secret_key").(string),
|
||||||
Token: d.Get("token").(string),
|
Token: d.Get("token").(string),
|
||||||
Region: d.Get("region").(string),
|
Region: d.Get("region").(string),
|
||||||
|
MaxRetries: d.Get("max_retries").(int),
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("allowed_account_ids"); ok {
|
if v, ok := d.GetOk("allowed_account_ids"); ok {
|
||||||
|
|
|
@ -43,6 +43,10 @@ The following arguments are supported in the `provider` block:
|
||||||
* `region` - (Required) This is the AWS region. It must be provided, but
|
* `region` - (Required) This is the AWS region. It must be provided, but
|
||||||
it can also be sourced from the `AWS_DEFAULT_REGION` environment variables.
|
it can also be sourced from the `AWS_DEFAULT_REGION` environment variables.
|
||||||
|
|
||||||
|
* `max_retries` - (Optional) This is the maximum number of times an API call is
|
||||||
|
being retried in case requests are being throttled or experience transient failures.
|
||||||
|
The delay between the subsequent API calls increases exponentially.
|
||||||
|
|
||||||
* `allowed_account_ids` - (Optional) List of allowed AWS account IDs (whitelist)
|
* `allowed_account_ids` - (Optional) List of allowed AWS account IDs (whitelist)
|
||||||
to prevent you mistakenly using a wrong one (and end up destroying live environment).
|
to prevent you mistakenly using a wrong one (and end up destroying live environment).
|
||||||
Conflicts with `forbidden_account_ids`.
|
Conflicts with `forbidden_account_ids`.
|
||||||
|
|
Loading…
Reference in New Issue