Skip to content

Commit a4aef78

Browse files
authored
Merge pull request hashicorp#9205 from kwilczynski/feature/add-ANY-aws_api_gateway_method
provider/aws: Add new "ANY" as valid HTTP method to API Gateway validator.
2 parents f0ee1d5 + 1260b3a commit a4aef78

6 files changed

Lines changed: 19 additions & 7 deletions

File tree

builtin/providers/aws/validators.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,21 @@ func validateCIDRNetworkAddress(v interface{}, k string) (ws []string, errors []
343343

344344
func validateHTTPMethod(v interface{}, k string) (ws []string, errors []error) {
345345
value := v.(string)
346-
if value != "GET" && value != "HEAD" && value != "OPTIONS" && value != "PUT" && value != "POST" && value != "PATCH" && value != "DELETE" {
346+
347+
validMethods := map[string]bool{
348+
"ANY": true,
349+
"DELETE": true,
350+
"GET": true,
351+
"HEAD": true,
352+
"OPTIONS": true,
353+
"PATCH": true,
354+
"POST": true,
355+
"PUT": true,
356+
}
357+
358+
if _, ok := validMethods[value]; !ok {
347359
errors = append(errors, fmt.Errorf(
348-
"%q must be one of 'GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'PATCH', 'DELETE'", k))
360+
"%q must be one of 'GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'PATCH', 'DELETE', or 'ANY'", k))
349361
}
350362
return
351363
}

builtin/providers/aws/validators_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func TestValidateCIDRNetworkAddress(t *testing.T) {
276276
}
277277

278278
func TestValidateHTTPMethod(t *testing.T) {
279-
validCases := []string{"GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH"}
279+
validCases := []string{"GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "ANY"}
280280
for i, method := range validCases {
281281
_, errs := validateHTTPMethod(method, "foo")
282282
if len(errs) != 0 {

website/source/docs/providers/aws/r/api_gateway_integration.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The following arguments are supported:
4545

4646
* `rest_api_id` - (Required) The ID of the associated REST API
4747
* `resource_id` - (Required) The API resource ID
48-
* `http_method` - (Required) The HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`)
48+
* `http_method` - (Required) The HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`)
4949
* `type` - (Required) The integration input's type (HTTP, MOCK, AWS, AWS_PROXY, HTTP_PROXY)
5050
* `uri` - (Optional) The input's URI (HTTP, AWS). **Required** if `type` is `HTTP` or `AWS`.
5151
For HTTP integrations, the URI must be a fully formed, encoded HTTP(S) URL according to the RFC-3986 specification . For AWS integrations, the URI should be of the form `arn:aws:apigateway:{region}:{subdomain.service|service}:{path|action}/{service_api}`. `region`, `subdomain` and `service` are used to determine the right endpoint.

website/source/docs/providers/aws/r/api_gateway_integration_response.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The following arguments are supported:
6262

6363
* `rest_api_id` - (Required) The ID of the associated REST API
6464
* `resource_id` - (Required) The API resource ID
65-
* `http_method` - (Required) The HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`)
65+
* `http_method` - (Required) The HTTP method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`)
6666
* `status_code` - (Required) The HTTP status code
6767
* `selection_pattern` - (Optional) Specifies the regular expression pattern used to choose
6868
an integration response based on the response from the backend.

website/source/docs/providers/aws/r/api_gateway_method.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The following arguments are supported:
3838

3939
* `rest_api_id` - (Required) The ID of the associated REST API
4040
* `resource_id` - (Required) The API resource ID
41-
* `http_method` - (Required) The HTTP Method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`)
41+
* `http_method` - (Required) The HTTP Method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`)
4242
* `authorization` - (Required) The type of authorization used for the method (`NONE`, `CUSTOM`)
4343
* `authorizer_id` - (Optional) The authorizer id to be used when the authorization is `CUSTOM`
4444
* `api_key_required` - (Optional) Specify if the method requires an API key

website/source/docs/providers/aws/r/api_gateway_method_response.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The following arguments are supported:
5252

5353
* `rest_api_id` - (Required) The ID of the associated REST API
5454
* `resource_id` - (Required) The API resource ID
55-
* `http_method` - (Required) The HTTP Method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`)
55+
* `http_method` - (Required) The HTTP Method (`GET`, `POST`, `PUT`, `DELETE`, `HEAD`, `OPTION`, `ANY`)
5656
* `status_code` - (Required) The HTTP status code
5757
* `response_models` - (Optional) A map of the API models used for the response's content type
5858
* `response_parameters` - (Optional) A map of response parameters that can be sent to the caller.

0 commit comments

Comments
 (0)