Skip to content

Commit

Permalink
Minor regional/edge API gateway implementation tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
handcraftedbits committed Apr 6, 2018
1 parent 2ddacfe commit 4e95621
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions aws/resource_aws_api_gateway_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)

func resourceAwsApiGatewayRestApi() *schema.Resource {
Expand Down Expand Up @@ -61,10 +62,13 @@ func resourceAwsApiGatewayRestApi() *schema.Resource {
},

"endpoint_type": {
Type: schema.TypeString,
Optional: true,
Default: "EDGE",
ValidateFunc: validateAwsApiGatewayEndpointType,
Type: schema.TypeString,
Optional: true,
Default: apigateway.EndpointTypeEdge,
ValidateFunc: validation.StringInSlice([]string{
apigateway.EndpointTypeEdge,
apigateway.EndpointTypeRegional,
}, false),
},
},
}
Expand Down Expand Up @@ -294,17 +298,3 @@ func resourceAwsApiGatewayRestApiDelete(d *schema.ResourceData, meta interface{}
return resource.NonRetryableError(err)
})
}

func validateAwsApiGatewayEndpointType(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
types := map[string]bool{
apigateway.EndpointTypeRegional: true,
apigateway.EndpointTypeEdge: true,
}

if !types[value] {
errors = append(errors, fmt.Errorf("Endpoint type %s is invalid. Valid types are 'EDGE' and 'REGIONAL'", value))
}

return
}

0 comments on commit 4e95621

Please sign in to comment.