This repository has been archived by the owner on Jun 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
/
lambda.tf
50 lines (43 loc) · 1.59 KB
/
lambda.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
resource "aws_lambda_function" "lambda" {
count = var.enabled ? 1 : 0
function_name = var.function_name
description = var.description
role = aws_iam_role.lambda[0].arn
handler = var.handler
memory_size = var.memory_size
reserved_concurrent_executions = var.reserved_concurrent_executions
runtime = var.runtime
layers = var.layers
timeout = local.timeout
publish = local.publish
tags = var.tags
# Use a generated filename to determine when the source code has changed.
filename = data.external.built[0].result.filename
depends_on = [null_resource.archive]
# Add dynamic blocks based on variables.
dynamic "dead_letter_config" {
for_each = var.dead_letter_config == null ? [] : [var.dead_letter_config]
content {
target_arn = dead_letter_config.value.target_arn
}
}
dynamic "environment" {
for_each = var.environment == null ? [] : [var.environment]
content {
variables = environment.value.variables
}
}
dynamic "tracing_config" {
for_each = var.tracing_config == null ? [] : [var.tracing_config]
content {
mode = tracing_config.value.mode
}
}
dynamic "vpc_config" {
for_each = var.vpc_config == null ? [] : [var.vpc_config]
content {
security_group_ids = vpc_config.value.security_group_ids
subnet_ids = vpc_config.value.subnet_ids
}
}
}