Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_apigatewayv2_integration: suppress diff for passthrough_behavior #13062

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) + fmt.Sprintf(`
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