From 3216226e0847e93a0b6f343e3526447bb8bf76f8 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Thu, 2 Apr 2020 22:58:16 +0300 Subject: [PATCH] add support for zero ttl --- aws/resource_aws_api_gateway_authorizer.go | 2 +- ...esource_aws_api_gateway_authorizer_test.go | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_api_gateway_authorizer.go b/aws/resource_aws_api_gateway_authorizer.go index b37a6f6bf589..a49bd23dbe8f 100644 --- a/aws/resource_aws_api_gateway_authorizer.go +++ b/aws/resource_aws_api_gateway_authorizer.go @@ -109,7 +109,7 @@ func resourceAwsApiGatewayAuthorizerCreate(d *schema.ResourceData, meta interfac if v, ok := d.GetOk("authorizer_credentials"); ok { input.AuthorizerCredentials = aws.String(v.(string)) } - if v, ok := d.GetOk("authorizer_result_ttl_in_seconds"); ok { + if v, ok := d.GetOkExists("authorizer_result_ttl_in_seconds"); ok { input.AuthorizerResultTtlInSeconds = aws.Int64(int64(v.(int))) } if v, ok := d.GetOk("identity_validation_expression"); ok { diff --git a/aws/resource_aws_api_gateway_authorizer_test.go b/aws/resource_aws_api_gateway_authorizer_test.go index d4e0b6732d99..008709b7b085 100644 --- a/aws/resource_aws_api_gateway_authorizer_test.go +++ b/aws/resource_aws_api_gateway_authorizer_test.go @@ -247,6 +247,35 @@ func TestAccAWSAPIGatewayAuthorizer_authTypeValidation(t *testing.T) { }) } +func TestAccAWSAPIGatewayAuthorizer_zero_ttl(t *testing.T) { + var conf apigateway.Authorizer + apiGatewayName := acctest.RandomWithPrefix("tf-acctest-apigw") + authorizerName := acctest.RandomWithPrefix("tf-acctest-igw-authorizer") + lambdaName := acctest.RandomWithPrefix("tf-acctest-igw-auth-lambda") + resourceName := "aws_api_gateway_authorizer.acctest" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSAPIGatewayAuthorizerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAPIGatewayAuthorizerConfig_lambdaNoCache(apiGatewayName, authorizerName, lambdaName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAPIGatewayAuthorizerExists(resourceName, &conf), + resource.TestCheckResourceAttr(resourceName, "authorizer_result_ttl_in_seconds", "0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateIdFunc: testAccAWSAPIGatewayAuthorizerImportStateIdFunc(resourceName), + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAWSAPIGatewayAuthorizer_disappears(t *testing.T) { var conf apigateway.Authorizer apiGatewayName := acctest.RandomWithPrefix("tf-acctest-apigw")