Skip to content
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

feat!: Updates to support websocket API Gateway #54

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8bd0adb
chore: updates to support websocket API Gateway
bryantbiggs Sep 9, 2021
665781f
chore: add variable for default stage name
bryantbiggs Sep 9, 2021
f5b064a
Fixed docs
antonbabenko Sep 9, 2021
da05c40
Merge branch 'master' of github.com:bryantbiggs/terraform-aws-apigate…
bryantbiggs Oct 2, 2021
7016f1d
Update main.tf
bryantbiggs Oct 2, 2021
0b888d9
chore: stash work in progress
bryantbiggs Oct 2, 2021
cfc7b2e
chore: it works so far
bryantbiggs Oct 2, 2021
a57c321
chore: cleanup and doc updates
bryantbiggs Oct 2, 2021
a34b3c5
Merge branch 'master' of github.com:terraform-aws-modules/terraform-a…
bryantbiggs Nov 19, 2021
a0967ac
chore: update pre-commit
bryantbiggs Nov 19, 2021
e866133
Merge branch 'master' of github.com:bryantbiggs/terraform-aws-apigate…
bryantbiggs Jan 6, 2022
b5fee7b
chore: update release configs based on EKS findings
bryantbiggs Jan 6, 2022
7430d4b
chore: updating examples
bryantbiggs Jan 6, 2022
d4cd83a
refactor: update output value names
bryantbiggs Jan 6, 2022
97d1c28
chore: update variables
bryantbiggs Jan 6, 2022
c362535
fix: set throttling limits to default to `-1` to avoid traffic disrup…
bryantbiggs Jan 6, 2022
0f322e7
chore: updating variables and adding new attributes
bryantbiggs Jan 6, 2022
47859af
Merge branch 'master' of github.com:terraform-aws-modules/terraform-a…
bryantbiggs Jan 12, 2022
7664421
Merge branch 'master' of github.com:bryantbiggs/terraform-aws-apigate…
bryantbiggs Apr 10, 2023
dbef0a8
chore: Re-order examples
bryantbiggs Apr 10, 2023
71ee0ed
feat: Update to align with current provider
bryantbiggs Apr 10, 2023
b6ebb5d
chore: Update websocket example lambda functions
bryantbiggs Apr 10, 2023
524c291
chore: Update versions
bryantbiggs Aug 23, 2023
7bed76a
Merge branch 'master' of github.com:bryantbiggs/terraform-aws-apigate…
bryantbiggs May 10, 2024
7ae31f3
fix: We are going to get this across the line once and for all!
bryantbiggs May 10, 2024
4d58196
fix: Step function execution of example works
bryantbiggs May 11, 2024
49b1638
fix: Correct custom domain use; add support for multiple subdomains w…
bryantbiggs May 11, 2024
01010b8
fix: Websocket example is working; I hate javascript
bryantbiggs May 11, 2024
6ba213e
fix: Update upgrade template; only deploy when not an `HTTP` API
bryantbiggs May 11, 2024
1690b9c
chore: Update upgrade guide
bryantbiggs May 13, 2024
95fcb7a
feat: Add tag
bryantbiggs May 14, 2024
1908469
Update main.tf
bryantbiggs May 20, 2024
f0be2e4
Update UPGRADE-5.0.md
bryantbiggs May 20, 2024
d6e694c
feat: Updates from PR review
bryantbiggs May 20, 2024
6154fc6
chore: Updates from PR review feedback
bryantbiggs Jun 4, 2024
3fc2d44
fix: Wrapper pre-commit hook still hates Linux machines
bryantbiggs Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- master

env:
TERRAFORM_DOCS_VERSION: v0.16.0
TERRAFORM_DOCS_VERSION: v0.17.0
TFLINT_VERSION: v0.50.3

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ terraform.rc

# Zip archive
*.zip
builds

.DS_Store
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.88.2
rev: v1.90.0
hooks:
- id: terraform_fmt
- id: terraform_wrapper_module_for_each
Expand All @@ -22,10 +22,9 @@ repos:
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- '--args=--only=terraform_unused_required_providers'
- id: terraform_validate
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
Expand Down
286 changes: 169 additions & 117 deletions README.md

Large diffs are not rendered by default.

215 changes: 215 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# Upgrade from v4.x to v5.x

Please consult the `examples` directory for reference example configurations. If you find a bug, please open an issue with supporting configuration to reproduce.

## List of backwards incompatible changes

- Minimum supported Terraform version increased to `v1.3` to support Terraform state `moved` blocks as well as other advanced features
- The `apigatewayv2_` and `default_apigatewayv2_` prefixes has been removed from the output names
- When a custom domain is used, the execution endpoint is disabled automatically; this is to ensure that requests are sent via the custom domain
- For `authorizers`, the `audience` and `issuer` properties are now nested under `jwt_configuration` to better match the upstream API

## 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

### Variable and output changes

1. Removed variables:

- `create_api_gateway`
antonbabenko marked this conversation as resolved.
Show resolved Hide resolved
- `create_default_stage_api_mapping`
- `create_default_stage_access_log_group` -> replaced by `create_log_group` set within `stage_access_log_settings`
- `default_stage_access_log_*` -> replaced by setting values within `stage_access_log_settings`
- `create_vpc_link`
- `default_stage_access_log_destination_arn`
- `domain_name_tags`

2. Renamed variables:

- `integrations` -> `routes`
- `create_default_stage` -> `create_stage`
- `create_api_domain_name` -> `create_domain_name`
- `default_route_settings` -> `stage_default_route_settings`
- `default_stage_tags` -> `stage_tags`

3. Added variables:

- `create_domain_name`
- `create_domain_records`
- `subdomains`
- `create_certificate`
- `stage_access_log_settings`
- `stage_client_certificate_id`
- `stage_description`
- `stage_name`
- `stage_variables`
- `deploy_stage`

4. Removed outputs:

- `default_apigatewayv2_stage_domain_name`
- `aws_apigatewayv2_api_mapping`
- `apigatewayv2_vpc_link_id` -> replaced by `vpc_links`
- `apigatewayv2_vpc_link_arn` -> replaced by `vpc_links`
- `apigatewayv2_authorizer_id` -> replaced by `authorizers`

5. Renamed outputs:

- `apigatewayv2_api_` -> prefix replaced with `api_`
- `default_apigatewayv2_stage_` prefix replaced with `stage_`
- `apigatewayv2_domain_` prefix replaced with `domain_`

6. Added outputs:

- `acm_certificate_arn`
- `integrations`
- `routes`
- `stage_access_logs_cloudwatch_log_group_name`
- `stage_access_logs_cloudwatch_log_group_arn`

## Upgrade Migrations

### Diff of Before (v4.0) vs After (v5.0)

```diff
module "apigateway_v2" {
source = "terraform-aws-modules/apigateway-v2/aws"
- version = "~> 4.0"
+ version = "~> 5.0"

- create_default_stage_access_log_group = true
- default_stage_access_log_format = "$context.identity.sourceIp"
+ stage_access_log_settings = {
+ create_log_group = true
+ format = "$context.identity.sourceIp"
+ }

authorizers = {
"cognito" = {
authorizer_type = "JWT"
identity_sources = "$request.header.Authorization"
name = "cognito"

- audience = ["d6a38afd-45d6-4874-d1aa-3c5c558aqcc2"]
- issuer = "https://${aws_cognito_user_pool.this.endpoint}"
jwt_configuration = {
+ audience = ["d6a38afd-45d6-4874-d1aa-3c5c558aqcc2"]
+ issuer = "https://${aws_cognito_user_pool.this.endpoint}"
}
}
}

- integrations = {
+ routes = {
"POST /start-step-function" = {
- integration_type = "AWS_PROXY"
- integration_subtype = "StepFunctions-StartExecution"
- credentials_arn = module.step_function.role_arn

- request_parameters = jsonencode({
- StateMachineArn = module.step_function.state_machine_arn
- })

- payload_format_version = "1.0"
- timeout_milliseconds = 12000

+ integration = {
+ type = "AWS_PROXY"
+ subtype = "StepFunctions-StartExecution"
+ credentials_arn = module.step_function.role_arn

+ request_parameters = {
+ StateMachineArn = module.step_function.state_machine_arn
+ }

+ payload_format_version = "1.0"
+ timeout_milliseconds = 12000
+ }
}

"GET /some-route-with-authorizer-and-scope" = {
- lambda_arn = module.lambda_function.lambda_function_arn
- payload_format_version = "2.0"
- authorization_type = "JWT"
- authorizer_key = "cognito"
- authorization_scopes = "tf/something.relevant.read,tf/something.relevant.write"

+ authorization_type = "JWT"
+ authorizer_key = "cognito"
+ authorization_scopes = ["tf/something.relevant.read", "tf/something.relevant.write"]

+ integration = {
+ uri = module.lambda_function.lambda_function_arn
+ payload_format_version = "2.0"
+ }
}

"$default" = {
- lambda_arn = module.lambda_function.lambda_function_arn
- tls_config = jsonencode({
- server_name_to_verify = local.domain_name
- })

- response_parameters = jsonencode([
- {
- status_code = 500
- mappings = {
- "append:header.header1" = "$context.requestId"
- "overwrite:statuscode" = "403"
- }
- },
- {
- status_code = 404
- mappings = {
- "append:header.error" = "$stageVariables.environmentId"
- }
- }
- ])

+ integration = {
+ uri = module.lambda_function.lambda_function_arn
+ tls_config = jsonencode({
+ server_name_to_verify = local.domain_name
+ })

+ response_parameters = [
+ {
+ status_code = 500
+ mappings = {
+ "append:header.header1" = "$context.requestId"
+ "overwrite:statuscode" = "403"
+ }
+ },
+ {
+ status_code = 404
+ mappings = {
+ "append:header.error" = "$stageVariables.environmentId"
+ }
+ }
+ ]
+ }
}
}
}
```
8 changes: 8 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Examples

Please note - the examples provided serve two primary means:

1. Show users working examples of the various ways in which the module can be configured and features supported
2. A means of testing/validating module changes

Please do not mistake the examples provided as "best practices". It is up to users to consult the AWS service documentation for best practices, usage recommendations, etc.
Loading