Skip to content

Commit

Permalink
Added lambda mem size default to 512M
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronaldo Macapobre committed Nov 15, 2024
1 parent fc1e0da commit 0c9a517
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/aws-template-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
TF_VAR_environment: ${{ vars.ENVIRONMENT_NAME }}
TF_VAR_kms_key_name: ${{ vars.KMS_KEY_NAME }}
TF_VAR_vpc_id: ${{ vars.VPC_ID }}
TF_VAR_lambda_memory_size: ${{ var.LAMBDA_MEMORY_SIZE }}
needs: [check_changes, scan]
steps:
- name: Checkout repository
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/cloud/environments/dev/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ variable "cert_domain_name" {
description = "The BCGov provisioned certificate domain name"
type = string
}

variable "lambda_memory_size" {
description = "The Lambda Function default Memory Size"
type = number
}
3 changes: 2 additions & 1 deletion infrastructure/cloud/environments/dev/webapp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ module "lambda" {
apigw_execution_arn = module.apigw.apigw_execution_arn
lambda_ecr_repo_url = data.aws_ecr_repository.lambda_ecr_repo.repository_url
mtls_secret_name = module.secrets_manager.mtls_secret_name
lambda_memory_size = var.lambda_memory_size
functions = {
"authorizer" = {
http_method = "*"
resource_path = "/*"
resource_path = ""
env_variables = {
VERIFY_SECRET_NAME = module.secrets_manager.api_authorizer_secret.name
}
Expand Down
11 changes: 6 additions & 5 deletions infrastructure/cloud/modules/Lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ locals {
lambda_functions = {
for k, v in merge(local.default_functions, var.functions) : k => {
name = k
memory_size = lookup(v, "memory_size", 2048)
timeout = lookup(v, "timeout", 30)
memory_size = coalesce(lookup(v, "memory_size", null), var.lambda_memory_size)
timeout = coalesce(lookup(v, "timeout", null), var.lambda_timeout)
http_method = v.http_method
resource_path = v.resource_path
statement_id_prefix = lookup(v, "statement_id_prefix", "AllowAPIGatewayInvoke")
principal = lookup(v, "principal", "apigateway.amazonaws.com")
env_variables = lookup(v, "env_variables", {})
source_arn = lookup(v, "source_arn", "${var.apigw_execution_arn}/*/${v.http_method}${v.resource_path}")
statement_id_prefix = coalesce(lookup(v, "statement_id_prefix", null), "AllowAPIGatewayInvoke")
principal = coalesce(lookup(v, "principal", null), "apigateway.amazonaws.com")
env_variables = coalesce(lookup(v, "env_variables", null), {})
source_arn = coalesce(lookup(v, "source_arn", null), "${var.apigw_execution_arn}/*/${v.http_method}${v.resource_path}")
}
}

Expand Down
15 changes: 13 additions & 2 deletions infrastructure/cloud/modules/Lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ variable "functions" {
http_method = string
resource_path = string
env_variables = optional(map(string), {})
timeout = optional(number, 300)
memory_size = optional(number, 2048)
timeout = optional(number, null)
memory_size = optional(number, null)
statement_id_prefix = optional(string, "AllowAPIGatewayInvoke")
principal = optional(string, "apigateway.amazonaws.com")
source_arn = optional(string, null)
Expand All @@ -42,3 +42,14 @@ variable "mtls_secret_name" {
description = "The secret name of mTLS Cert in Secrets Manager"
type = string
}

variable "lambda_memory_size" {
description = "The Lambda Function default Memory Size"
type = number
}

variable "lambda_timeout" {
description = "The Lambda Fucntion default timeout"
type = number
default = 30
}

0 comments on commit 0c9a517

Please sign in to comment.