Skip to content

feat!: Updates to support websocket API Gateway #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

bryantbiggs
Copy link
Member

@bryantbiggs bryantbiggs commented Sep 9, 2021

Description

Additional changes

  • Minimum supported Terraform AWS provider raised to v5.37.0 to support recent bug fixes in the provider
  • Default values for api_key_selection_expression, route_selection_expression variables set to null (still matches prior value v4.x version but is set as null now)
  • The input data structure for routes (was integrations) has been updated and now uses optional inputs

Added

  • Support for creating a websocket API endpoint
  • Support for creating Route53 alias records for custom domain names w/ support for multiple sub-domains using a wildcard API Gateway custom domain name
  • Support for creating ACM certificate for custom domain
  • Support for automatically deploying the stage when updates have been made (for Websocket, HTTP is always auto-deployed by the API)

Modified

  • Stage access log group settings are now embedded into the stage_access_log_settings variable
  • API mapping is created automatically when using a custom domain
  • Default values of 500 and 1000 have been set for throttling_burst_limit and throttling_rate_limit respectively to ensure users do not face errors when deploying APIs for the first time and not configuring these
  • Default values for the log group name ("/aws/apigateway/${var.name}/${var.stage_name}") and retention period (30) have been provided for the stage access logs log group

Removed

  • None

See UPGRADE-5.0.md for full list of changes and notes on upgrade path

Motivation and Context

  • updates for websocket support

Closes #7
Closes #8
Closes #42
Closes #46
Closes #61

Breaking Changes

  • Yes

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Looks pretty good, just minor comments to be consistent in examples.

@lllama
Copy link

lllama commented Sep 9, 2021

Not sure if this affects #46 at all. That PR had a working example of a websockets API. I can update if needed.

@antonbabenko
Copy link
Member

@lllama Thanks for the WebSocket example in #46!

I think it will be great if @bryantbiggs merges your example into this PR and update it to follow the rest of the examples we have.

bryantbiggs and others added 2 commits October 2, 2021 08:29
…way-v2 into chore/updates-for-websocket-support
Co-authored-by: Anton Babenko <[email protected]>
@bryantbiggs bryantbiggs marked this pull request as draft October 2, 2021 17:33
@bryantbiggs bryantbiggs force-pushed the chore/updates-for-websocket-support branch from cacb480 to 402fa78 Compare October 2, 2021 17:38
@bryantbiggs bryantbiggs force-pushed the chore/updates-for-websocket-support branch from 402fa78 to 0b888d9 Compare October 2, 2021 17:44
@bryantbiggs bryantbiggs force-pushed the chore/updates-for-websocket-support branch from f3bb532 to a57c321 Compare October 2, 2021 20:45
@bryantbiggs bryantbiggs marked this pull request as ready for review October 2, 2021 20:47
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Looks almost perfect. Could you also describe breaking changes and upgrade path in UPGRADE.md as we do in other modules already?

@bryantbiggs bryantbiggs marked this pull request as draft January 6, 2022 14:56
@choudharyac09
Copy link

Can We merge this pull request?

@bryantbiggs
Copy link
Member Author

Can We merge this pull request?

Its being worked on, its currently in draft mode

@bryantbiggs bryantbiggs force-pushed the chore/updates-for-websocket-support branch 2 times, most recently from b35afe7 to 781949b Compare May 13, 2024 23:53
@bryantbiggs bryantbiggs force-pushed the chore/updates-for-websocket-support branch from 781949b to 1690b9c Compare May 14, 2024 00:00
@bryantbiggs bryantbiggs marked this pull request as ready for review May 14, 2024 00:02
@bryantbiggs bryantbiggs requested a review from antonbabenko May 14, 2024 00:02
@bryantbiggs bryantbiggs removed the wip label May 14, 2024
@choudharyac09
Copy link

@antonbabenko Can you please review the pull request?

@antonbabenko
Copy link
Member

@antonbabenko Can you please review the pull request?

Yes, as soon as I can. Probably, tomorrow.

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Looks good, a few comments here and there. I didn't run examples though.

bryantbiggs and others added 3 commits May 20, 2024 11:59
@bryantbiggs bryantbiggs force-pushed the chore/updates-for-websocket-support branch from 182d16c to d6e694c Compare May 21, 2024 00:05
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

I ran it on my real project and found a few minor things here and there. LGTM after that :)

value = module.lambda_function.lambda_function_arn
output "test_curl_command" {
description = "Curl command to test API endpoint using mTLS"
value = "curl --key ./my-key.key --cert ./my-cert.pem https://customer1.${replace(var.domain_name, "*.", "")} | jq"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this can be used instead of external curl - https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http ?

This data source supports ca_cert_pem, but not key. It may be enough for this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was unable to get that data source to work without the key. This isn't required to run the example, but rather a helpful reminder of the syntax to call the API using the cert/key - and curl/jq are usually quite common on machines these days

variable "domain_name" {
description = "Custom domain name to use on API Gateway endpoint"
type = string
default = "*.terraform-aws-modules.modules.tf"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
default = "*.terraform-aws-modules.modules.tf"
default = "terraform-aws-modules.modules.tf"

Can we have it without a wildcard in the default_name? The description does not match the value :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted in 6154fc6

I also added a small section that demonstrates the use of wildcard custom domains and mapping subdomains to that wildcard domain in the readme

value = try(aws_apigatewayv2_stage.default[0].invoke_url, "")
}

output "default_apigatewayv2_stage_domain_name" {
Copy link
Member

Choose a reason for hiding this comment

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

Please revert this output. Such a striped domain name is needed for Cloudfront.

Copy link
Member Author

Choose a reason for hiding this comment

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

re-added in 6154fc6

variables.tf Outdated
data_trace_enabled = optional(bool, false)
detailed_metrics_enabled = optional(bool, false)
logging_level = optional(string)
throttling_burst_limit = optional(number, 500)
Copy link
Member

Choose a reason for hiding this comment

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

These throttling_burst_limit and throttling_rate_limit defaults are being used instead of the one specified in stage_default_route_settings.

I think we should not have these defaults here and just use the settings in stage_default_route_settings. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I would normally agree and normally not like to have to set arbitrary numbers either as a default value. However, when testing I kept getting errors only to discover that things were set to 0, and there are various upstream issues both in Terraform and other projects:

so its really a matter of - do we set nothing, and its up to users to set something if they get 429s due to a limit of 0, or do we set something so it works out of the box, but there is a cap that again would require users to set a value that suits their use case? I am ok either way, I don't know what the right way is - either set something (across the board) or set nothing (null - again, across the board)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for pointing out the issues. I've encountered this problem in the past, but I didn't realize the reason.

Can we not have a default number here (null) but then use coalesce() in the code to get the provided value (if specified) or the value from stage_default_route_settings? This way, it will be closer to the expected behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point - updated to coalesce these with the stage default route settings and removed defaults from the route section of the variable in 6154fc6

@bryantbiggs bryantbiggs requested a review from antonbabenko June 4, 2024 14:53
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for taking into account all my comments. I am active user of this module myself :)

@bryantbiggs bryantbiggs merged commit 30c9db0 into terraform-aws-modules:master Jun 4, 2024
8 checks passed
@bryantbiggs bryantbiggs deleted the chore/updates-for-websocket-support branch June 4, 2024 15:30
antonbabenko pushed a commit that referenced this pull request Jun 4, 2024
## [5.0.0](v4.0.0...v5.0.0) (2024-06-04)

### ⚠ BREAKING CHANGES

* Updates to support websocket API Gateway (#54)

### Features

* Updates to support websocket API Gateway ([#54](#54)) ([30c9db0](30c9db0))
@antonbabenko
Copy link
Member

This PR is included in version 5.0.0 🎉

Copy link

github-actions bot commented Jul 6, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
7 participants