terraform-aws-modules / terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/apigateway-v2/aws
Apache License 2.0
144 stars 188 forks source link

feat: support authorization_type and authorizer_id on routes #17

Closed jdjkelly closed 3 years ago

jdjkelly commented 3 years ago

Description

Adds support for setting authorization_type and authorizer_id on the aws_apigatewayv2_route resource, like so:

integrations = {
    "GET /some-route" = {
      lambda_arn = module.some_function.this_lambda_function_arn
      payload_format_version = "2.0"
      authorization_type = "CUSTOM"
      authorizer_id = aws_apigatewayv2_authorizer.some_authorizer.id 
    }
  }

Motivation and Context

This module is helpful but limited by the lack of support for custom authorizers. This commit isn't perfect - it requires you to create an aws_apigatewayv2_authorizer independently, and then reference the id, but it's also immediately useful. If this isn't sufficient to merge, please let me know what you'd like to see in a commit and I'll see if I can match those expectations.

Defaults are set to what aws_apigatewayv2_route expects ("NONE", and null respectively).

Breaking Changes

None that I know of, but I haven't committed to these modules before, so merger beware!

How Has This Been Tested?

I tested this on a private source repository, and successfully deployed more or less the above example. I also tested deploying without these new parameters, successfully (observing authorization_type being set to NONE and authorizer_id being set to null).

Glen-Moonpig commented 3 years ago

I am developing a V2 API Gateway and require this feature to work. This will be the difference between using this module and going with the raw Terraform so would love to see it merged in. Please 🥺🙏

antonbabenko commented 3 years ago

@Glen-Moonpig I will do my best to review and finish this PR by the end of this week but meanwhile, you can use the fork of this module by @jdjkelly to use code from this PR if it is sufficient for your case.

antonbabenko commented 3 years ago

@Glen-Moonpig Thanks for this PR, I have updated the example code to show the authorizer in action.

v0.9.0 has been just released.

Glen-Moonpig commented 3 years ago

I didn't do the work, credit goes to @jdjkelly, I just want to use the change.

Thanks @jdjkelly and @antonbabenko for getting this added!

antonbabenko commented 3 years ago

Right :) Anyway, thanks to everyone for being involved in one way or another!

github-actions[bot] commented 1 year ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.