provider/aws: Allow bypassing region validation

This commit is contained in:
Radek Simko 2017-01-23 15:01:22 +00:00
parent 4fcc301b83
commit 6d8d596883
No known key found for this signature in database
GPG Key ID: 6823F3DCCE01BB19
3 changed files with 24 additions and 4 deletions

View File

@ -92,6 +92,7 @@ type Config struct {
Insecure bool
SkipCredsValidation bool
SkipRegionValidation bool
SkipRequestingAccountId bool
SkipMetadataApiCheck bool
S3ForcePathStyle bool
@ -153,10 +154,14 @@ type AWSClient struct {
func (c *Config) Client() (interface{}, error) {
// Get the auth and region. This can fail if keys/regions were not
// specified and we're attempting to use the environment.
log.Println("[INFO] Building AWS region structure")
err := c.ValidateRegion()
if err != nil {
return nil, err
if c.SkipRegionValidation {
log.Println("[INFO] Skipping region validation")
} else {
log.Println("[INFO] Building AWS region structure")
err := c.ValidateRegion()
if err != nil {
return nil, err
}
}
var client AWSClient

View File

@ -120,6 +120,13 @@ func Provider() terraform.ResourceProvider {
Description: descriptions["skip_credentials_validation"],
},
"skip_region_validation": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: descriptions["skip_region_validation"],
},
"skip_requesting_account_id": {
Type: schema.TypeBool,
Optional: true,
@ -441,6 +448,9 @@ func init() {
"skip_credentials_validation": "Skip the credentials validation via STS API. " +
"Used for AWS API implementations that do not have STS available/implemented.",
"skip_region_validation": "Skip static validation of region name. " +
"Used by users of alternative AWS-like APIs or users w/ access to regions that are not public (yet).",
"skip_requesting_account_id": "Skip requesting the account ID. " +
"Used for AWS API implementations that do not have IAM/STS API and/or metadata API.",
@ -475,6 +485,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
KinesisEndpoint: d.Get("kinesis_endpoint").(string),
Insecure: d.Get("insecure").(bool),
SkipCredsValidation: d.Get("skip_credentials_validation").(bool),
SkipRegionValidation: d.Get("skip_region_validation").(bool),
SkipRequestingAccountId: d.Get("skip_requesting_account_id").(bool),
SkipMetadataApiCheck: d.Get("skip_metadata_api_check").(bool),
S3ForcePathStyle: d.Get("s3_force_path_style").(bool),

View File

@ -188,6 +188,10 @@ The following arguments are supported in the `provider` block:
validation via the STS API. Useful for AWS API implementations that do
not have STS available or implemented.
* `skip_region_validation` - (Optional) Skip validation of provided region name.
Useful for AWS-like implementations that use their own region names
or to bypass the validation for regions that aren't publicly available yet.
* `skip_requesting_account_id` - (Optional) Skip requesting the account
ID. Useful for AWS API implementations that do not have the IAM, STS
API, or metadata API. When set to `true`, prevents you from managing