diff --git a/CHANGELOG.md b/CHANGELOG.md index 330c2dfa7..11df71aee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,7 +125,8 @@ IMPROVEMENTS: * provider/aws: Allow setting a `poll_interval` on `aws_elastic_beanstalk_environment` [GH-7523] * provider/aws: Add support for Kinesis streams shard-level metrics [GH-7684] * provider/aws: Support create / update greater than twenty db parameters in `aws_db_parameter_group` [GH-7364] - * providers/aws: expose network interface id in `aws_instance` [GH-6751] + * provider/aws: expose network interface id in `aws_instance` [GH-6751] + * provider/aws: Adding passthrough behavior for API Gateway integration [GH-7801] * provider/azurerm: Add support for EnableIPForwarding to `azurerm_network_interface` [GH-6807] * provider/azurerm: Add support for exporting the `azurerm_storage_account` access keys [GH-6742] * provider/azurerm: The Azure SDK now exposes better error messages [GH-6976] diff --git a/builtin/providers/aws/resource_aws_api_gateway_integration.go b/builtin/providers/aws/resource_aws_api_gateway_integration.go index 68f9c50bf..d82d78e6d 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_integration.go +++ b/builtin/providers/aws/resource_aws_api_gateway_integration.go @@ -79,6 +79,12 @@ func resourceAwsApiGatewayIntegration() *schema.Resource { Type: schema.TypeString, Optional: true, }, + + "passthrough_behavior": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateApiGatewayIntegrationPassthroughBehavior, + }, }, } } @@ -106,6 +112,11 @@ func resourceAwsApiGatewayIntegrationCreate(d *schema.ResourceData, meta interfa } } + var passthroughBehavior *string + if v, ok := d.GetOk("passthrough_behavior"); ok { + passthroughBehavior = aws.String(v.(string)) + } + var credentials *string if val, ok := d.GetOk("credentials"); ok { credentials = aws.String(val.(string)) @@ -119,11 +130,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: passthroughBehavior, }) if err != nil { return fmt.Errorf("Error creating API Gateway Integration: %s", err) @@ -163,6 +175,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 } diff --git a/builtin/providers/aws/resource_aws_api_gateway_integration_test.go b/builtin/providers/aws/resource_aws_api_gateway_integration_test.go index 090bcf0a9..b33497c1f 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_integration_test.go +++ b/builtin/providers/aws/resource_aws_api_gateway_integration_test.go @@ -34,6 +34,8 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) { "aws_api_gateway_integration.test", "request_templates.application/json", ""), resource.TestCheckResourceAttr( "aws_api_gateway_integration.test", "request_templates.application/xml", "#set($inputRoot = $input.path('$'))\n{ }"), + resource.TestCheckResourceAttr( + "aws_api_gateway_integration.test", "passthrough_behavior", "WHEN_NO_MATCH"), ), }, @@ -48,6 +50,8 @@ func TestAccAWSAPIGatewayIntegration_basic(t *testing.T) { "aws_api_gateway_integration.test", "integration_http_method", ""), resource.TestCheckResourceAttr( "aws_api_gateway_integration.test", "uri", ""), + resource.TestCheckResourceAttr( + "aws_api_gateway_integration.test", "passthrough_behavior", "NEVER"), ), }, }, @@ -193,6 +197,7 @@ resource "aws_api_gateway_integration" "test" { type = "HTTP" uri = "https://www.google.de" integration_http_method = "GET" + passthrough_behavior = "WHEN_NO_MATCH" } ` @@ -230,5 +235,7 @@ resource "aws_api_gateway_integration" "test" { PARAMS type = "MOCK" + passthrough_behavior = "NEVER" + } ` diff --git a/builtin/providers/aws/validators.go b/builtin/providers/aws/validators.go index 234fe451e..75dd0d1d7 100644 --- a/builtin/providers/aws/validators.go +++ b/builtin/providers/aws/validators.go @@ -451,3 +451,12 @@ func validateDbEventSubscriptionName(v interface{}, k string) (ws []string, erro } return } + +func validateApiGatewayIntegrationPassthroughBehavior(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if value != "WHEN_NO_MATCH" && value != "WHEN_NO_TEMPLATES" && value != "NEVER" { + errors = append(errors, fmt.Errorf( + "%q must be one of 'WHEN_NO_MATCH', 'WHEN_NO_TEMPLATES', 'NEVER'", k)) + } + return +} diff --git a/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown b/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown index b6704bb74..fc7224d30 100644 --- a/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown +++ b/website/source/docs/providers/aws/r/api_gateway_integration.html.markdown @@ -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_TEMPLATES`, `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. diff --git a/website/source/docs/providers/aws/r/vpc.html.markdown b/website/source/docs/providers/aws/r/vpc.html.markdown index 0125ef3d2..d13ba043c 100644 --- a/website/source/docs/providers/aws/r/vpc.html.markdown +++ b/website/source/docs/providers/aws/r/vpc.html.markdown @@ -67,8 +67,8 @@ The following attributes are exported: ## Import -VPNs can be imported using the `vpn id`, e.g. +VPCs can be imported using the `vpc id`, e.g. ``` -$ terraform import aws_vpn.test_vpn vpc-a01106c2 -``` \ No newline at end of file +$ terraform import aws_vpc.test_vpc vpc-a01106c2 +``` diff --git a/website/source/docs/providers/terraform/d/remote_state.html.md b/website/source/docs/providers/terraform/d/remote_state.html.md index 683ba264e..5adc37170 100644 --- a/website/source/docs/providers/terraform/d/remote_state.html.md +++ b/website/source/docs/providers/terraform/d/remote_state.html.md @@ -22,7 +22,7 @@ data "terraform_remote_state" "vpc" { resource "aws_instance" "foo" { # ... - subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}" + subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" } ``` diff --git a/website/source/docs/providers/terraform/index.html.markdown b/website/source/docs/providers/terraform/index.html.markdown index 20a9dfee3..aba805349 100644 --- a/website/source/docs/providers/terraform/index.html.markdown +++ b/website/source/docs/providers/terraform/index.html.markdown @@ -26,6 +26,6 @@ data "terraform_remote_state" "vpc" { resource "aws_instance" "foo" { # ... - subnet_id = "${data.terraform_remote_state.vpc.output.subnet_id}" + subnet_id = "${data.terraform_remote_state.vpc.subnet_id}" } ```