Hi,
I am trying to create a aws api gateway with the resource structured like this,
/
/{proxy+}
ANY
However my code is producing it like,
/
ANY
/{proxy+}
I would much appreciate if someone could look at the code and advise on the problem.
resource "aws_api_gateway_rest_api" "api_gateway" {
api_key_source = "HEADER"
binary_media_types = []
description = "${var.project_name} CRM Feeds API"
disable_execute_api_endpoint = false
minimum_compression_size = -1
name = "${var.project_name}_CRM_Feeds"
put_rest_api_mode = "overwrite"
tags = {}
tags_all = {}
endpoint_configuration {
types = [
"REGIONAL",
]
}
}
resource "aws_api_gateway_resource" "api_resource" {
rest_api_id = aws_api_gateway_rest_api.api_gateway.id
parent_id = aws_api_gateway_rest_api.api_gateway.root_resource_id
path_part = "{proxy+}"
}
resource "aws_api_gateway_integration" "api_intergration" {
cache_key_parameters = [
"method.request.path.proxy",
]
connection_id = aws_api_gateway_vpc_link.vpc_link.id
connection_type = "VPC_LINK"
http_method = "ANY"
integration_http_method = "ANY"
passthrough_behavior = "WHEN_NO_MATCH"
request_parameters = {
"integration.request.path.proxy" = "method.request.path.proxy"
}
request_templates = {}
resource_id = aws_api_gateway_rest_api.api_gateway.root_resource_id
rest_api_id = aws_api_gateway_rest_api.api_gateway.id
timeout_milliseconds = 29000
type = "HTTP_PROXY"
uri = "https://${var.host_name}.xxxxx.com/xxxx/xxxxx/{proxy}"
}
resource "aws_api_gateway_method" "api_method" {
api_key_required = true
authorization = "NONE"
authorization_scopes = []
http_method = "ANY"
request_models = {}
request_parameters = {
"method.request.path.proxy" = true
}
resource_id = aws_api_gateway_rest_api.api_gateway.root_resource_id
rest_api_id = aws_api_gateway_rest_api.api_gateway.id
}
resource "aws_api_gateway_deployment" "api_deploy" {
rest_api_id = aws_api_gateway_rest_api.api_gateway.id
triggers = {
# NOTE: The configuration below will satisfy ordering considerations,
# but not pick up all future REST API changes. More advanced patterns
# are possible, such as using the filesha1() function against the
# Terraform configuration file(s) or removing the .id references to
# calculate a hash against whole resources. Be aware that using whole
# resources will show a difference after the initial implementation.
# It will stabilize to only change when resources change afterwards.
redeployment = sha1(jsonencode([
aws_api_gateway_rest_api.api_gateway.root_resource_id,
aws_api_gateway_resource.api_resource.id,
aws_api_gateway_method.api_method.id,
aws_api_gateway_integration.api_intergration.id,
]))
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_api_gateway_stage" "api_stage" {
cache_cluster_enabled = false
cache_cluster_size = "0.5"
deployment_id = aws_api_gateway_deployment.api_deploy.id
description = "test"
rest_api_id = aws_api_gateway_rest_api.api_gateway.id
stage_name = "test"
tags = {}
tags_all = {}
variables = {}
xray_tracing_enabled = false
}
resource "aws_api_gateway_usage_plan" "api_plan" {
name = "${var.project_name}_CRM"
tags = {}
tags_all = {}
api_stages {
api_id = aws_api_gateway_rest_api.api_gateway.id
stage = aws_api_gateway_stage.api_stage.stage_name
}
}
resource "aws_api_gateway_api_key" "api_key" {
name = "${var.project_name} CRM key"
}
resource "aws_api_gateway_usage_plan_key" "api_key" {
key_id = aws_api_gateway_api_key.api_key.id
key_type = "API_KEY"
usage_plan_id = aws_api_gateway_usage_plan.api_plan.id
}
resource "aws_api_gateway_vpc_link" "vpc_link" {
name = "VPC-LINK-${var.project_name}-FEED-API"
description = "VPC Link for ${var.project_name} Feed API Access"
target_arns = [aws_lb.nlb.arn]
}