feat: update terraform configuration
All checks were successful
kinec.tech/airun-pathfinder-crud-pricing/pipeline/head This commit looks good
All checks were successful
kinec.tech/airun-pathfinder-crud-pricing/pipeline/head This commit looks good
- Updated main.tf with infrastructure changes - Updated outputs configuration
This commit is contained in:
@@ -133,3 +133,53 @@ resource "aws_iam_role_policy" "dynamodb_access" {
|
||||
locals {
|
||||
table_name = var.table_name != "" ? var.table_name : "pathfinder-${var.environment}-pricing"
|
||||
}
|
||||
|
||||
# API Gateway HTTP API
|
||||
resource "aws_apigatewayv2_api" "crud_pricing_api" {
|
||||
name = "airun-pathfinder-crud-pricing-${var.environment}"
|
||||
protocol_type = "HTTP"
|
||||
|
||||
cors_configuration {
|
||||
allow_origins = ["*"]
|
||||
allow_methods = ["GET", "POST", "PUT", "OPTIONS"]
|
||||
allow_headers = ["*"]
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "crud-pricing-api"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_stage" "default" {
|
||||
api_id = aws_apigatewayv2_api.crud_pricing_api.id
|
||||
name = "$default"
|
||||
auto_deploy = true
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_integration" "lambda" {
|
||||
api_id = aws_apigatewayv2_api.crud_pricing_api.id
|
||||
integration_type = "AWS_PROXY"
|
||||
integration_uri = aws_lambda_function.crud_pricing.invoke_arn
|
||||
integration_method = "POST"
|
||||
payload_format_version = "2.0"
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_route" "pricing_instance" {
|
||||
api_id = aws_apigatewayv2_api.crud_pricing_api.id
|
||||
route_key = "GET /pricing/{instanceType}"
|
||||
target = "integrations/${aws_apigatewayv2_integration.lambda.id}"
|
||||
}
|
||||
|
||||
resource "aws_apigatewayv2_route" "pricing_list" {
|
||||
api_id = aws_apigatewayv2_api.crud_pricing_api.id
|
||||
route_key = "GET /pricing"
|
||||
target = "integrations/${aws_apigatewayv2_integration.lambda.id}"
|
||||
}
|
||||
|
||||
resource "aws_lambda_permission" "api_gateway" {
|
||||
statement_id = "AllowAPIGatewayInvoke"
|
||||
action = "lambda:InvokeFunction"
|
||||
function_name = aws_lambda_function.crud_pricing.function_name
|
||||
principal = "apigateway.amazonaws.com"
|
||||
source_arn = "${aws_apigatewayv2_api.crud_pricing_api.execution_arn}/*/*"
|
||||
}
|
||||
|
||||
@@ -17,3 +17,8 @@ output "table_name" {
|
||||
description = "DynamoDB table name used by this Lambda"
|
||||
value = local.table_name
|
||||
}
|
||||
|
||||
output "api_gateway_endpoint" {
|
||||
description = "API Gateway endpoint URL"
|
||||
value = aws_apigatewayv2_api.crud_pricing_api.api_endpoint
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user