Skip to content

Commit b9b4b3d

Browse files
author
Ben Fortuna
committed
Added environment variable configuration
1 parent 952e470 commit b9b4b3d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ No requirements.
1919

2020
| Name | Description | Type | Default | Required |
2121
|------|-------------|------|---------|:--------:|
22+
| environment | Environment variables to configure the Lambda function | `map(string)` | `{}` | no |
2223
| function\_name | Name of the Lambda function | `any` | n/a | yes |
2324
| role | IAM role assumed by the Lambda function | `any` | n/a | yes |
2425
| runtime | A runtime to use for the function (leave blank to use default runtime) | `any` | `null` | no |

main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ resource "aws_lambda_function" "function" {
2222
handler = "${var.function_name}.${local.templates[var.template]["lambda_handler"]}"
2323
runtime = var.runtime != null ? var.runtime : local.templates[var.template]["default_runtime"]
2424
source_code_hash = data.archive_file.function.output_base64sha256
25+
dynamic "environment" {
26+
for_each = length(var.environment) > 0 ? [1] : []
27+
content {
28+
variables = var.environment
29+
}
30+
}
2531
}

vars.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ variable "runtime" {
1111
default = null
1212
}
1313

14+
variable "environment" {
15+
description = "Environment variables to configure the Lambda function"
16+
type = map(string)
17+
default = {}
18+
}
19+
1420
variable "role" {
1521
description = "IAM role assumed by the Lambda function"
1622
}

0 commit comments

Comments
 (0)