Skip to content

Commit 1ce74f1

Browse files
committed
add environment variables
1 parent 606300e commit 1ce74f1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ resource "aws_lambda_function" "api_lambda" {
250250
runtime = var.runtime
251251
publish = true
252252

253+
dynamic "environment" {
254+
for_each = var.environment_variables != null ? [1] : []
255+
content {
256+
variables = var.environment_variables
257+
}
258+
}
259+
253260
vpc_config {
254261
subnet_ids = var.private_subnet_ids
255262
security_group_ids = concat([aws_security_group.lambda_sg.id], var.security_groups)

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ variable "runtime" {
2828
description = "Lambda runtime"
2929
}
3030

31+
variable "environment_variables" {
32+
type = map(string)
33+
description = "A map that defines environment variables for the Lambda function."
34+
default = null
35+
}
36+
3137
variable "hosted_zone" {
3238
type = object({
3339
name = string,

0 commit comments

Comments
 (0)