Skip to content

Commit 52e8dff

Browse files
Merge pull request #13062 from acburdine/r/apigatewayv2_integration_diff
r/aws_apigatewayv2_integration: suppress diff for passthrough_behavior
2 parents a4d4c2e + 18c4819 commit 52e8dff

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

aws/resource_aws_apigatewayv2_integration.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ func resourceAwsApiGatewayV2Integration() *schema.Resource {
9292
apigatewayv2.PassthroughBehaviorNever,
9393
apigatewayv2.PassthroughBehaviorWhenNoTemplates,
9494
}, false),
95+
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
96+
// PassthroughBehavior not set for HTTP APIs
97+
if old == "" && new == apigatewayv2.PassthroughBehaviorWhenNoMatch {
98+
return true
99+
}
100+
101+
return false
102+
},
95103
},
96104
"payload_format_version": {
97105
Type: schema.TypeString,

aws/resource_aws_apigatewayv2_integration_test.go

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1212
)
1313

14-
func TestAccAWSAPIGatewayV2Integration_basic(t *testing.T) {
14+
func TestAccAWSAPIGatewayV2Integration_basicWebSocket(t *testing.T) {
1515
var apiId string
1616
var v apigatewayv2.GetIntegrationOutput
1717
resourceName := "aws_apigatewayv2_integration.test"
@@ -52,6 +52,47 @@ func TestAccAWSAPIGatewayV2Integration_basic(t *testing.T) {
5252
})
5353
}
5454

55+
func TestAccAWSAPIGatewayV2Integration_basicHttp(t *testing.T) {
56+
var apiId string
57+
var v apigatewayv2.GetIntegrationOutput
58+
resourceName := "aws_apigatewayv2_integration.test"
59+
rName := acctest.RandomWithPrefix("tf-acc-test")
60+
61+
resource.ParallelTest(t, resource.TestCase{
62+
PreCheck: func() { testAccPreCheck(t) },
63+
Providers: testAccProviders,
64+
CheckDestroy: testAccCheckAWSAPIGatewayV2IntegrationDestroy,
65+
Steps: []resource.TestStep{
66+
{
67+
Config: testAccAWSAPIGatewayV2IntegrationConfig_httpProxy(rName),
68+
Check: resource.ComposeTestCheckFunc(
69+
testAccCheckAWSAPIGatewayV2IntegrationExists(resourceName, &apiId, &v),
70+
resource.TestCheckResourceAttr(resourceName, "connection_id", ""),
71+
resource.TestCheckResourceAttr(resourceName, "connection_type", "INTERNET"),
72+
resource.TestCheckResourceAttr(resourceName, "content_handling_strategy", ""),
73+
resource.TestCheckResourceAttr(resourceName, "credentials_arn", ""),
74+
resource.TestCheckResourceAttr(resourceName, "description", ""),
75+
resource.TestCheckResourceAttr(resourceName, "integration_method", "GET"),
76+
resource.TestCheckResourceAttr(resourceName, "integration_response_selection_expression", ""),
77+
resource.TestCheckResourceAttr(resourceName, "integration_type", "HTTP_PROXY"),
78+
resource.TestCheckResourceAttr(resourceName, "integration_uri", "https://example.com"),
79+
resource.TestCheckResourceAttr(resourceName, "passthrough_behavior", ""),
80+
resource.TestCheckResourceAttr(resourceName, "payload_format_version", "1.0"),
81+
resource.TestCheckResourceAttr(resourceName, "request_templates.%", "0"),
82+
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", ""),
83+
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "29000"),
84+
),
85+
},
86+
{
87+
ResourceName: resourceName,
88+
ImportStateIdFunc: testAccAWSAPIGatewayV2IntegrationImportStateIdFunc(resourceName),
89+
ImportState: true,
90+
ImportStateVerify: true,
91+
},
92+
},
93+
})
94+
}
95+
5596
func TestAccAWSAPIGatewayV2Integration_disappears(t *testing.T) {
5697
var apiId string
5798
var v apigatewayv2.GetIntegrationOutput
@@ -311,6 +352,15 @@ resource "aws_apigatewayv2_api" "test" {
311352
`, rName)
312353
}
313354

355+
func testAccAWSAPIGatewayV2IntegrationConfig_apiHttp(rName string) string {
356+
return fmt.Sprintf(`
357+
resource "aws_apigatewayv2_api" "test" {
358+
name = %[1]q
359+
protocol_type = "HTTP"
360+
}
361+
`, rName)
362+
}
363+
314364
func testAccAWSAPIGatewayV2IntegrationConfig_basic(rName string) string {
315365
return testAccAWSAPIGatewayV2IntegrationConfig_apiWebSocket(rName) + `
316366
resource "aws_apigatewayv2_integration" "test" {
@@ -392,6 +442,18 @@ resource "aws_apigatewayv2_integration" "test" {
392442
`, rName)
393443
}
394444

445+
func testAccAWSAPIGatewayV2IntegrationConfig_httpProxy(rName string) string {
446+
return testAccAWSAPIGatewayV2IntegrationConfig_apiHttp(rName) + fmt.Sprintf(`
447+
resource "aws_apigatewayv2_integration" "test" {
448+
api_id = "${aws_apigatewayv2_api.test.id}"
449+
integration_type = "HTTP_PROXY"
450+
451+
integration_method = "GET"
452+
integration_uri = "https://example.com"
453+
}
454+
`)
455+
}
456+
395457
func testAccAWSAPIGatewayV2IntegrationConfig_vpcLink(rName string) string {
396458
return testAccAWSAPIGatewayV2IntegrationConfig_apiWebSocket(rName) + fmt.Sprintf(`
397459
data "aws_availability_zones" "available" {

0 commit comments

Comments
 (0)