Skip to content

Commit

Permalink
feat: update payload version in http api gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Aatishsharma77 committed Jan 24, 2024
1 parent 737aaef commit 6e353f9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
10 changes: 5 additions & 5 deletions _examples/complete/http-api-gateway/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ provider "aws" {
locals {
name = "api"
environment = "test"
domain_name = "clouddrove.ca"
domain_name = "tech-tycoons.clouddrove.ca"
region = "us-east-1"
}
####----------------------------------------------------------------------------------
Expand Down Expand Up @@ -74,10 +74,10 @@ module "api_gateway" {

name = local.name
environment = local.environment
domain_name = "clouddrove.ca"
domain_name = "api.tech-tycoons.clouddrove.ca"
domain_name_certificate_arn = module.acm.arn
integration_uri = module.lambda.invoke_arn
zone_id = "Z01564602K369Xxxxxxx"
zone_id = "Z08295059QJZ2CJCU2HZ"
auto_deploy = true
stage_name = "$default"
create_vpc_link_enabled = false
Expand All @@ -91,11 +91,11 @@ module "api_gateway" {
"ANY /" = {
lambda_arn = module.lambda.arn
payload_format_version = "2.0"
timeout_milliseconds = 12000
timeout_milliseconds = 30000
}
"GET /some-route-with-authorizer" = {
lambda_arn = module.lambda.arn
payload_format_version = "2.0"
payload_format_version = "1.0"
authorizer_key = "cognito"
}
"POST /start-step-function" = {
Expand Down
32 changes: 23 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,36 @@ resource "aws_apigatewayv2_route" "default" {
model_selection_expression = try(each.value.model_selection_expression, null)
operation_name = try(each.value.operation_name, null)
route_response_selection_expression = try(each.value.route_response_selection_expression, null)
target = "integrations/${join("", aws_apigatewayv2_integration.default[*].id)}"
target = "integrations/${(aws_apigatewayv2_integration.default[each.key].id)}"
}

##----------------------------------------------------------------------------------
## Below resource will Manages an Amazon API Gateway Version 2 integration.
##----------------------------------------------------------------------------------
# resource "aws_apigatewayv2_integration" "default" {
# count = var.enabled && var.create_routes_and_integrations_enabled && var.create_http_api ? 1 : 0

# api_id = join("", aws_apigatewayv2_api.default[*].id)
# integration_type = var.integration_type
# connection_type = var.connection_type
# description = var.integration_description
# integration_method = var.integration_method
# integration_uri = var.integration_uri
# passthrough_behavior = var.passthrough_behavior
# payload_format_version = var.payload_version #"2.0"
# }

resource "aws_apigatewayv2_integration" "default" {
count = var.enabled && var.create_routes_and_integrations_enabled && var.create_http_api ? 1 : 0
for_each = var.enabled && var.create_routes_and_integrations_enabled && var.create_http_api ? var.integrations : {}

api_id = join("", aws_apigatewayv2_api.default[*].id)
integration_type = var.integration_type
connection_type = var.connection_type
description = var.integration_description
integration_method = var.integration_method
integration_uri = var.integration_uri
passthrough_behavior = var.passthrough_behavior
api_id = join("", aws_apigatewayv2_api.default[*].id)
integration_type = var.integration_type
connection_type = var.connection_type
description = var.integration_description
integration_method = var.integration_method
integration_uri = var.integration_uri
passthrough_behavior = var.passthrough_behavior
payload_format_version = try(each.value.payload_format_version, null)
}

##----------------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ variable "enabled" {
description = "Flag to control the api creation."
}

variable "payload_version" {

Check warning on line 40 in variables.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

variable "payload_version" is declared but not used
type = string
default = ""
description = "(optional) describe your variable"
}


variable "create_http_api" {
type = bool
default = false
Expand Down

0 comments on commit 6e353f9

Please sign in to comment.