Skip to content

Commit

Permalink
add support for zero ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Apr 2, 2020
1 parent 4b425d2 commit 3216226
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws/resource_aws_api_gateway_authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 29 additions & 0 deletions aws/resource_aws_api_gateway_authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 3216226

Please # to comment.