Merge pull request #11358 from radeksimko/f-aws-skip-region-validation

provider/aws: Allow bypassing region validation
This commit is contained in:
Radek Simko 2017-01-23 21:31:52 +00:00 committed by GitHub
commit 6791735790
3 changed files with 24 additions and 4 deletions

View File

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

View File

@ -120,6 +120,13 @@ func Provider() terraform.ResourceProvider {
Description: descriptions["skip_credentials_validation"], Description: descriptions["skip_credentials_validation"],
}, },
"skip_region_validation": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: descriptions["skip_region_validation"],
},
"skip_requesting_account_id": { "skip_requesting_account_id": {
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
@ -441,6 +448,9 @@ func init() {
"skip_credentials_validation": "Skip the credentials validation via STS API. " + "skip_credentials_validation": "Skip the credentials validation via STS API. " +
"Used for AWS API implementations that do not have STS available/implemented.", "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. " + "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.", "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), KinesisEndpoint: d.Get("kinesis_endpoint").(string),
Insecure: d.Get("insecure").(bool), Insecure: d.Get("insecure").(bool),
SkipCredsValidation: d.Get("skip_credentials_validation").(bool), SkipCredsValidation: d.Get("skip_credentials_validation").(bool),
SkipRegionValidation: d.Get("skip_region_validation").(bool),
SkipRequestingAccountId: d.Get("skip_requesting_account_id").(bool), SkipRequestingAccountId: d.Get("skip_requesting_account_id").(bool),
SkipMetadataApiCheck: d.Get("skip_metadata_api_check").(bool), SkipMetadataApiCheck: d.Get("skip_metadata_api_check").(bool),
S3ForcePathStyle: d.Get("s3_force_path_style").(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 validation via the STS API. Useful for AWS API implementations that do
not have STS available or implemented. 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 * `skip_requesting_account_id` - (Optional) Skip requesting the account
ID. Useful for AWS API implementations that do not have the IAM, STS 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 API, or metadata API. When set to `true`, prevents you from managing