Added API mapping and custom Domain
This commit is contained in:
27
master.tf
27
master.tf
@@ -194,6 +194,7 @@ resource "aws_lambda_function" "lambda_standout_redirect" {
|
||||
BUCKET_CONFIG = aws_s3_bucket.s3_standout_config.bucket,
|
||||
BUCKET_DATA = aws_s3_bucket.s3_standout.bucket
|
||||
GIT_VERSION = var.git_version
|
||||
API_VERSION = var.api_version
|
||||
env = var.env
|
||||
}
|
||||
}
|
||||
@@ -226,6 +227,7 @@ resource "aws_lambda_function" "lambda_standout_config" {
|
||||
BUCKET_DATA = aws_s3_bucket.s3_standout.bucket
|
||||
FUNCTION_URL = var.redirect_url
|
||||
GIT_VERSION = var.git_version
|
||||
API_VERSION = var.api_version
|
||||
ENV = var.env
|
||||
}
|
||||
}
|
||||
@@ -280,7 +282,6 @@ resource "aws_apigatewayv2_integration" "api_standout_integration" {
|
||||
|
||||
resource "aws_apigatewayv2_stage" "api_standout_lambda_stage" {
|
||||
api_id = aws_apigatewayv2_api.api_standout_gateway.id
|
||||
|
||||
name = var.env
|
||||
auto_deploy = true
|
||||
}
|
||||
@@ -288,10 +289,26 @@ resource "aws_apigatewayv2_stage" "api_standout_lambda_stage" {
|
||||
resource "aws_apigatewayv2_route" "api_standout_route" {
|
||||
api_id = aws_apigatewayv2_api.api_standout_gateway.id
|
||||
|
||||
route_key = "GET /api"
|
||||
route_key = "GET /${var.api_version}"
|
||||
target = "integrations/${aws_apigatewayv2_integration.api_standout_integration.id}"
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_domain_name" "api_standout_domain_name" {
|
||||
domain_name = var.domain_name
|
||||
|
||||
domain_name_configuration {
|
||||
certificate_arn = var.ssl_certificate
|
||||
endpoint_type = "REGIONAL"
|
||||
security_policy = "TLS_1_2"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_api_mapping" "api_standout_domain_mapping" {
|
||||
api_id = aws_apigatewayv2_api.api_standout_gateway.id
|
||||
domain_name = aws_apigatewayv2_domain_name.api_standout_domain_name.id
|
||||
stage = aws_apigatewayv2_stage.api_standout_lambda_stage.id
|
||||
}
|
||||
|
||||
resource "aws_lambda_permission" "api_lambda_permission" {
|
||||
statement_id = "AllowExecutionFromAPIGateway"
|
||||
action = "lambda:InvokeFunction"
|
||||
@@ -301,5 +318,7 @@ resource "aws_lambda_permission" "api_lambda_permission" {
|
||||
source_arn = "${aws_apigatewayv2_api.api_standout_gateway.execution_arn}/*/*"
|
||||
}
|
||||
|
||||
# create a route 53 configuration
|
||||
|
||||
# Output relevant variables
|
||||
output "api_mapping_domain_name" {
|
||||
value = aws_apigatewayv2_api_mapping.api_standout_domain_mapping
|
||||
}
|
||||
Reference in New Issue
Block a user