Skip to content

Commit

Permalink
Merge pull request #13062 from acburdine/r/apigatewayv2_integration_diff
Browse files Browse the repository at this point in the history
r/aws_apigatewayv2_integration: suppress diff for passthrough_behavior
  • Loading branch information
breathingdust authored Jul 20, 2020
2 parents a4d4c2e + 18c4819 commit 52e8dff
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
8 changes: 8 additions & 0 deletions aws/resource_aws_apigatewayv2_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ func resourceAwsApiGatewayV2Integration() *schema.Resource {
apigatewayv2.PassthroughBehaviorNever,
apigatewayv2.PassthroughBehaviorWhenNoTemplates,
}, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// PassthroughBehavior not set for HTTP APIs
if old == "" && new == apigatewayv2.PassthroughBehaviorWhenNoMatch {
return true
}

return false
},
},
"payload_format_version": {
Type: schema.TypeString,
Expand Down
64 changes: 63 additions & 1 deletion aws/resource_aws_apigatewayv2_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccAWSAPIGatewayV2Integration_basic(t *testing.T) {
func TestAccAWSAPIGatewayV2Integration_basicWebSocket(t *testing.T) {
var apiId string
var v apigatewayv2.GetIntegrationOutput
resourceName := "aws_apigatewayv2_integration.test"
Expand Down Expand Up @@ -52,6 +52,47 @@ func TestAccAWSAPIGatewayV2Integration_basic(t *testing.T) {
})
}

func TestAccAWSAPIGatewayV2Integration_basicHttp(t *testing.T) {
var apiId string
var v apigatewayv2.GetIntegrationOutput
resourceName := "aws_apigatewayv2_integration.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayV2IntegrationDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayV2IntegrationConfig_httpProxy(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayV2IntegrationExists(resourceName, &apiId, &v),
resource.TestCheckResourceAttr(resourceName, "connection_id", ""),
resource.TestCheckResourceAttr(resourceName, "connection_type", "INTERNET"),
resource.TestCheckResourceAttr(resourceName, "content_handling_strategy", ""),
resource.TestCheckResourceAttr(resourceName, "credentials_arn", ""),
resource.TestCheckResourceAttr(resourceName, "description", ""),
resource.TestCheckResourceAttr(resourceName, "integration_method", "GET"),
resource.TestCheckResourceAttr(resourceName, "integration_response_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "integration_type", "HTTP_PROXY"),
resource.TestCheckResourceAttr(resourceName, "integration_uri", "https://example.com"),
resource.TestCheckResourceAttr(resourceName, "passthrough_behavior", ""),
resource.TestCheckResourceAttr(resourceName, "payload_format_version", "1.0"),
resource.TestCheckResourceAttr(resourceName, "request_templates.%", "0"),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "29000"),
),
},
{
ResourceName: resourceName,
ImportStateIdFunc: testAccAWSAPIGatewayV2IntegrationImportStateIdFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSAPIGatewayV2Integration_disappears(t *testing.T) {
var apiId string
var v apigatewayv2.GetIntegrationOutput
Expand Down Expand Up @@ -311,6 +352,15 @@ resource "aws_apigatewayv2_api" "test" {
`, rName)
}

func testAccAWSAPIGatewayV2IntegrationConfig_apiHttp(rName string) string {
return fmt.Sprintf(`
resource "aws_apigatewayv2_api" "test" {
name = %[1]q
protocol_type = "HTTP"
}
`, rName)
}

func testAccAWSAPIGatewayV2IntegrationConfig_basic(rName string) string {
return testAccAWSAPIGatewayV2IntegrationConfig_apiWebSocket(rName) + `
resource "aws_apigatewayv2_integration" "test" {
Expand Down Expand Up @@ -392,6 +442,18 @@ resource "aws_apigatewayv2_integration" "test" {
`, rName)
}

func testAccAWSAPIGatewayV2IntegrationConfig_httpProxy(rName string) string {
return testAccAWSAPIGatewayV2IntegrationConfig_apiHttp(rName) + fmt.Sprintf(`
resource "aws_apigatewayv2_integration" "test" {
api_id = "${aws_apigatewayv2_api.test.id}"
integration_type = "HTTP_PROXY"
integration_method = "GET"
integration_uri = "https://example.com"
}
`)
}

func testAccAWSAPIGatewayV2IntegrationConfig_vpcLink(rName string) string {
return testAccAWSAPIGatewayV2IntegrationConfig_apiWebSocket(rName) + fmt.Sprintf(`
data "aws_availability_zones" "available" {
Expand Down

0 comments on commit 52e8dff

Please sign in to comment.