Skip to content

Commit

Permalink
Added vpc config and route variables
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanibn-nasar1-nhs committed Oct 18, 2024
1 parent 8b4c0ec commit 089dff1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
11 changes: 10 additions & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ resource "aws_lambda_function" "get_method_lambda" {
variables = var.lambda_environment_variables
}
}

dynamic "vpc_config" {
for_each = length(keys(var.lambda_vpc_config)) == 0 ? [] : [true]
content {
subnet_ids = var.lambda_vpc_config.subnet_ids
security_group_ids = var.lambda_vpc_config.security_group_ids
}
}

}

resource "aws_cloudwatch_log_group" "get_method_lambda_log_group" {
Expand All @@ -59,7 +68,7 @@ resource "aws_apigatewayv2_integration" "get_method_lambda_integration" {

resource "aws_apigatewayv2_route" "get_method_route" {
api_id = aws_apigatewayv2_api.get_method_api.id
route_key = "GET /"
route_key = "${var.api_route} /"
target = "integrations/${aws_apigatewayv2_integration.get_method_lambda_integration.id}"
}

Expand Down
18 changes: 18 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ variable "log_retention_days" {
description = "The number of days to retain log events in the CloudWatch Logs Log Group."
default = 14
}

variable "lambda_vpc_config" {
description = "VPC configuration for the Lambda function."
type = object({
security_group_ids = list(string)
subnet_ids = list(string)
})
default = {
security_group_ids = []
subnet_ids = []
}
}

variable "api_route" {
description = "The route for the API Gateway."
type = string
default = "GET"
}

0 comments on commit 089dff1

Please sign in to comment.