Skip to content

Commit

Permalink
Adding passthrough behavior for API Gateway integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chan committed Jul 25, 2016
1 parent fcfb7f4 commit c8f8cba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
25 changes: 20 additions & 5 deletions builtin/providers/aws/resource_aws_api_gateway_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ func resourceAwsApiGatewayIntegration() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},

"passthrough_behavior": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "WHEN_NO_MATCH" && value != "WHEN_NO_TEMPLATE" && value != "NEVER" {
errors = append(errors, fmt.Errorf(
"%q must be one of 'WHEN_NO_MATCH', 'WHEN_NO_TEMPLATE', 'NEVER'", k))
}
return
},
},
},
}
}
Expand Down Expand Up @@ -119,11 +132,12 @@ func resourceAwsApiGatewayIntegrationCreate(d *schema.ResourceData, meta interfa
IntegrationHttpMethod: integrationHttpMethod,
Uri: uri,
// TODO reimplement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented
RequestParameters: aws.StringMap(parameters),
RequestTemplates: aws.StringMap(templates),
Credentials: credentials,
CacheNamespace: nil,
CacheKeyParameters: nil,
RequestParameters: aws.StringMap(parameters),
RequestTemplates: aws.StringMap(templates),
Credentials: credentials,
CacheNamespace: nil,
CacheKeyParameters: nil,
PassthroughBehavior: aws.String(d.Get("passthrough_behavior").(string)),
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Integration: %s", err)
Expand Down Expand Up @@ -163,6 +177,7 @@ func resourceAwsApiGatewayIntegrationRead(d *schema.ResourceData, meta interface
d.Set("type", integration.Type)
d.Set("uri", integration.Uri)
d.Set("request_parameters_in_json", aws.StringValueMap(integration.RequestParameters))
d.Set("passthrough_behavior", integration.PassthroughBehavior)

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ resource "aws_api_gateway_integration" "test" {
rest_api_id = "${aws_api_gateway_rest_api.test.id}"
resource_id = "${aws_api_gateway_resource.test.id}"
http_method = "${aws_api_gateway_method.test.http_method}"
passthrough_behavior = "WHEN_NO_MATCH"
request_templates = {
"application/json" = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The following arguments are supported:
Not all methods are compatible with all `AWS` integrations.
e.g. Lambda function [can only be invoked](https://github.com/awslabs/aws-apigateway-importer/issues/9#issuecomment-129651005) via `POST`.
* `request_templates` - (Optional) A map of the integration's request templates.
* `passthrough_behavior` - (Optional) The integration passthrough behavior (`WHEN_NO_MATCH`, `WHEN_NO_TEMPLATE`, `NEVER`). **Required** if `request_templates` is used.
* `request_parameters_in_json` - (Optional) A map written as a JSON string specifying
the request query string parameters and headers that should be passed to the
backend responder.
Expand Down

0 comments on commit c8f8cba

Please sign in to comment.