provider/aws: Unify custom endpoint fields in provider schema (#11768)

This commit is contained in:
Radek Simko 2017-02-08 13:08:59 +00:00 committed by GitHub
parent 6a44f258e6
commit d3c9a4b265
1 changed files with 28 additions and 8 deletions

View File

@ -91,17 +91,21 @@ func Provider() terraform.ResourceProvider {
},
"dynamodb_endpoint": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["dynamodb_endpoint"],
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["dynamodb_endpoint"],
Deprecated: "Use `dynamodb` inside `endpoints` block instead",
ConflictsWith: []string{"endpoints.0.dynamodb"},
},
"kinesis_endpoint": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["kinesis_endpoint"],
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["kinesis_endpoint"],
Deprecated: "Use `kinesis` inside `endpoints` block instead",
ConflictsWith: []string{"endpoints.0.kinesis"},
},
"endpoints": endpointsSchema(),
@ -530,9 +534,11 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
for _, endpointsSetI := range endpointsSet.List() {
endpoints := endpointsSetI.(map[string]interface{})
config.DynamoDBEndpoint = endpoints["dynamodb"].(string)
config.IamEndpoint = endpoints["iam"].(string)
config.Ec2Endpoint = endpoints["ec2"].(string)
config.ElbEndpoint = endpoints["elb"].(string)
config.KinesisEndpoint = endpoints["kinesis"].(string)
config.S3Endpoint = endpoints["s3"].(string)
}
@ -602,6 +608,12 @@ func endpointsSchema() *schema.Schema {
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"dynamodb": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["dynamodb_endpoint"],
},
"iam": {
Type: schema.TypeString,
Optional: true,
@ -622,6 +634,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["elb_endpoint"],
},
"kinesis": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["kinesis_endpoint"],
},
"s3": {
Type: schema.TypeString,
Optional: true,
@ -637,9 +655,11 @@ func endpointsSchema() *schema.Schema {
func endpointsToHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["dynamodb"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["iam"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["ec2"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["elb"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["kinesis"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["s3"].(string)))
return hashcode.String(buf.String())