Skip to content

r/aws_apigatewayv2_authorizer: Support Lambda authorization options for HTTP APIs#15232

Merged
breathingdust merged 4 commits into
hashicorp:masterfrom
ewbankkit:f-aws_apigatewayv2_authorizer-lambda-iam-authorizers
Sep 23, 2020
Merged

r/aws_apigatewayv2_authorizer: Support Lambda authorization options for HTTP APIs#15232
breathingdust merged 4 commits into
hashicorp:masterfrom
ewbankkit:f-aws_apigatewayv2_authorizer-lambda-iam-authorizers

Conversation

@ewbankkit

@ewbankkit ewbankkit commented Sep 19, 2020

Copy link
Copy Markdown
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #15126.
Closes #15181.
Relates #13527.
Relates #14601.

Release note for CHANGELOG:

resource/aws_apigatewayv2_authorizer: Add `authorizer_payload_format_version`, `authorizer_result_ttl_in_seconds` and `enable_simple_responses` attribute to support Lambda authorizers for HTTP APIs
resource/aws_apigatewayv2_authorizer: Change `identity_sources` to an optional attribute

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:59: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (50.06s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (72.89s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer (87.77s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (100.85s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (110.88s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	110.928s

…or HTTP APIs.

Acceptance test output:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:59: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (50.06s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (72.89s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer (87.77s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (100.85s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (110.88s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	110.928s
@ewbankkit ewbankkit requested a review from a team September 19, 2020 22:06
@ghost ghost added size/L Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Sep 19, 2020
Comment thread website/docs/r/apigatewayv2_authorizer.html.markdown Outdated
Acceptance test output:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (58.65s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:58: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (70.72s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (86.07s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (93.11s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer (98.31s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	98.353s

@DrFaust92 DrFaust92 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment, otherwise tests are passing

--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (76.72s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (69.58s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (165.78s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (123.90s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer (119.70s)

Comment thread aws/resource_aws_apigatewayv2_authorizer.go
Acceptance test output:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:58: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (57.32s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (65.45s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (86.23s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (91.33s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer (92.73s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	92.780s
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Sep 22, 2020
@ewbankkit

Copy link
Copy Markdown
Contributor Author

@DrFaust92 Could you please re-review? Thanks.

@DrFaust92 DrFaust92 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still an issue with zero value on create.

Comment thread aws/resource_aws_apigatewayv2_authorizer.go Outdated
…alues for cache TTL.

Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_' ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 2 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (39.77s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL (88.17s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL (73.00s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (86.61s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (90.80s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:58: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (37.71s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	212.532s
@ewbankkit

Copy link
Copy Markdown
Contributor Author

@DrFaust92 And again please 😄.

@DrFaust92 DrFaust92 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎸

--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (81.37s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (79.41s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (174.93s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (123.23s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL (176.62s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL (127.48s)

@breathingdust

Copy link
Copy Markdown
Member

LGTM! 🚀 Thanks @ewbankkit

Verified Acceptance Tests Commercial (us-west-2)

make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (56.83s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (60.69s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL (67.68s)
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:58: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (73.71s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL (94.86s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (100.59s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	107.746s

Verified Acceptance Tests GovCloud (us-gov-west-1)

make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2Authorizer_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Authorizer_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Authorizer_basic
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_basic
=== RUN   TestAccAWSAPIGatewayV2Authorizer_disappears
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_disappears
=== RUN   TestAccAWSAPIGatewayV2Authorizer_Credentials
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_Credentials
=== RUN   TestAccAWSAPIGatewayV2Authorizer_JWT
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_JWT
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== RUN   TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== PAUSE TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== CONT  TestAccAWSAPIGatewayV2Authorizer_basic
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL
=== CONT  TestAccAWSAPIGatewayV2Authorizer_JWT
=== CONT  TestAccAWSAPIGatewayV2Authorizer_Credentials
=== CONT  TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL
=== CONT  TestAccAWSAPIGatewayV2Authorizer_disappears
    resource_aws_apigatewayv2_authorizer_test.go:58: [INFO] Got non-empty plan, as expected
--- PASS: TestAccAWSAPIGatewayV2Authorizer_disappears (28.26s)
2020/09/23 11:21:29 [WARN] Truncating attribute path of 0 diagnostics for TypeSet
--- PASS: TestAccAWSAPIGatewayV2Authorizer_basic (47.08s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialMissingCacheTTL (61.40s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_Credentials (62.84s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_HttpApiLambdaRequestAuthorizer_InitialZeroCacheTTL (64.01s)
--- PASS: TestAccAWSAPIGatewayV2Authorizer_JWT (71.93s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	78.498s

@breathingdust breathingdust added this to the v3.8.0 milestone Sep 23, 2020
@breathingdust breathingdust merged commit ad6c63b into hashicorp:master Sep 23, 2020
breathingdust added a commit that referenced this pull request Sep 23, 2020
@ewbankkit ewbankkit deleted the f-aws_apigatewayv2_authorizer-lambda-iam-authorizers branch September 23, 2020 18:58
@ghost

ghost commented Sep 24, 2020

Copy link
Copy Markdown

This has been released in version 3.8.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost

ghost commented Oct 24, 2020

Copy link
Copy Markdown

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

documentation Introduces or discusses updates to documentation. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

4 participants