Skip to content

Commit

Permalink
Remove 'tls_config' attribute. It doesn't seem to do anything right now.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Mar 24, 2020
1 parent ac97c9d commit ffbce32
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 171 deletions.
48 changes: 0 additions & 48 deletions aws/resource_aws_apigatewayv2_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,6 @@ func resourceAwsApiGatewayV2Integration() *schema.Resource {
Default: 29000,
ValidateFunc: validation.IntBetween(50, 29000),
},
"tls_config": {
Type: schema.TypeList,
Optional: true,
MinItems: 0,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"server_name_to_verify": {
Type: schema.TypeString,
Optional: true,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -178,9 +164,6 @@ func resourceAwsApiGatewayV2IntegrationCreate(d *schema.ResourceData, meta inter
if v, ok := d.GetOk("timeout_milliseconds"); ok {
req.TimeoutInMillis = aws.Int64(int64(v.(int)))
}
if v, ok := d.GetOk("tls_config"); ok {
req.TlsConfig = expandApiGateway2TlsConfig(v.([]interface{}))
}

log.Printf("[DEBUG] Creating API Gateway v2 integration: %s", req)
resp, err := conn.CreateIntegration(req)
Expand Down Expand Up @@ -226,9 +209,6 @@ func resourceAwsApiGatewayV2IntegrationRead(d *schema.ResourceData, meta interfa
}
d.Set("template_selection_expression", resp.TemplateSelectionExpression)
d.Set("timeout_milliseconds", resp.TimeoutInMillis)
if err := d.Set("tls_config", flattenApiGateway2TlsConfig(resp.TlsConfig)); err != nil {
return fmt.Errorf("error setting tls_config: %s", err)
}

return nil
}
Expand Down Expand Up @@ -276,9 +256,6 @@ func resourceAwsApiGatewayV2IntegrationUpdate(d *schema.ResourceData, meta inter
if d.HasChange("timeout_milliseconds") {
req.TimeoutInMillis = aws.Int64(int64(d.Get("timeout_milliseconds").(int)))
}
if d.HasChange("tls_config") {
req.TlsConfig = expandApiGateway2TlsConfig(d.Get("tls_config").([]interface{}))
}

log.Printf("[DEBUG] Updating API Gateway v2 integration: %s", req)
_, err := conn.UpdateIntegration(req)
Expand Down Expand Up @@ -335,28 +312,3 @@ func resourceAwsApiGatewayV2IntegrationImport(d *schema.ResourceData, meta inter

return []*schema.ResourceData{d}, nil
}

func expandApiGateway2TlsConfig(vConfig []interface{}) *apigatewayv2.TlsConfigInput {
config := &apigatewayv2.TlsConfigInput{}

if len(vConfig) == 0 || vConfig[0] == nil {
return config
}
mConfig := vConfig[0].(map[string]interface{})

if vServerNameToVerify, ok := mConfig["server_name_to_verify"].(string); ok && vServerNameToVerify != "" {
config.ServerNameToVerify = aws.String(vServerNameToVerify)
}

return config
}

func flattenApiGateway2TlsConfig(config *apigatewayv2.TlsConfig) []interface{} {
if config == nil {
return []interface{}{}
}

return []interface{}{map[string]interface{}{
"server_name_to_verify": aws.StringValue(config.ServerNameToVerify),
}}
}
118 changes: 0 additions & 118 deletions aws/resource_aws_apigatewayv2_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestAccAWSAPIGatewayV2Integration_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "request_templates.%", "0"),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "29000"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "0"),
),
},
{
Expand Down Expand Up @@ -106,7 +105,6 @@ func TestAccAWSAPIGatewayV2Integration_IntegrationTypeHttp(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "request_templates.application/json", ""),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", "$request.body.name"),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "28999"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "0"),
),
},
{
Expand All @@ -129,7 +127,6 @@ func TestAccAWSAPIGatewayV2Integration_IntegrationTypeHttp(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "request_templates.application/xml", "#set($percent=$number/100)"),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", "$request.body.id"),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "51"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "0"),
),
},
{
Expand Down Expand Up @@ -172,72 +169,6 @@ func TestAccAWSAPIGatewayV2Integration_Lambda(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "request_templates.%", "0"),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "29000"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "0"),
),
},
{
ResourceName: resourceName,
ImportStateIdFunc: testAccAWSAPIGatewayV2IntegrationImportStateIdFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSAPIGatewayV2Integration_TlsConfig(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_tlsConfig(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", "Test HTTPS"),
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://www.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", "5001"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "tls_config.0.server_name_to_verify", "www.example.com"),
),
},
{
Config: testAccAWSAPIGatewayV2IntegrationConfig_tlsConfigUpdated(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", "Test HTTPS updated"),
resource.TestCheckResourceAttr(resourceName, "integration_method", "POST"),
resource.TestCheckResourceAttr(resourceName, "integration_response_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "integration_type", "HTTP_PROXY"),
resource.TestCheckResourceAttr(resourceName, "integration_uri", "https://www.example.org"),
resource.TestCheckResourceAttr(resourceName, "passthrough_behavior", ""),
resource.TestCheckResourceAttr(resourceName, "payload_format_version", "2.0"),
resource.TestCheckResourceAttr(resourceName, "request_templates.%", "0"),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "4999"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "1"),
resource.TestCheckResourceAttr(resourceName, "tls_config.0.server_name_to_verify", "www.example.org"),
),
},
{
Expand Down Expand Up @@ -280,7 +211,6 @@ func TestAccAWSAPIGatewayV2Integration_VpcLink(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "request_templates.%", "0"),
resource.TestCheckResourceAttr(resourceName, "template_selection_expression", ""),
resource.TestCheckResourceAttr(resourceName, "timeout_milliseconds", "12345"),
resource.TestCheckResourceAttr(resourceName, "tls_config.#", "0"),
),
},
{
Expand Down Expand Up @@ -381,15 +311,6 @@ 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 @@ -471,45 +392,6 @@ resource "aws_apigatewayv2_integration" "test" {
`, rName)
}

func testAccAWSAPIGatewayV2IntegrationConfig_tlsConfig(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"
connection_type = "INTERNET"
description = "Test HTTPS"
integration_method = "GET"
integration_uri = "https://www.example.com"
timeout_milliseconds = 5001
tls_config {
server_name_to_verify = "www.example.com"
}
}
`)
}

func testAccAWSAPIGatewayV2IntegrationConfig_tlsConfigUpdated(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"
connection_type = "INTERNET"
description = "Test HTTPS updated"
integration_method = "POST"
integration_uri = "https://www.example.org"
payload_format_version = "2.0"
timeout_milliseconds = 4999
tls_config = {
server_name_to_verify = "www.example.org"
}
}
`)
}

func testAccAWSAPIGatewayV2IntegrationConfig_vpcLink(rName string) string {
return testAccAWSAPIGatewayV2IntegrationConfig_apiWebSocket(rName) + fmt.Sprintf(`
data "aws_availability_zones" "available" {
Expand Down
5 changes: 0 additions & 5 deletions website/docs/r/apigatewayv2_integration.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ Valid values: `WHEN_NO_MATCH`, `WHEN_NO_TEMPLATES`, `NEVER`. Default is `WHEN_NO
* `request_templates` - (Optional) A map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client. Supported only for WebSocket APIs.
* `template_selection_expression` - (Optional) The [template selection expression](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-template-selection-expressions) for the integration.
* `timeout_milliseconds` - (Optional) Custom timeout between 50 and 29,000 milliseconds. The default value is 29,000 milliseconds or 29 seconds.
* `tls_config` - (Optional) The TLS configuration for a private integration. Supported only for HTTP APIs.

The `tls_config` object supports the following:

* `server_name_to_verify` - (Optional) If you specify a server name, API Gateway uses it to verify the hostname on the integration's certificate. The server name is also included in the TLS handshake to support Server Name Indication (SNI) or virtual hosting.

## Attribute Reference

Expand Down

0 comments on commit ffbce32

Please sign in to comment.