forked from claranet/terraform-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda.tf
58 lines (50 loc) · 1.8 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
51
52
53
54
55
56
57
58
resource "aws_lambda_function" "lambda" {
count = var.enabled ? 1 : 0
function_name = var.function_name
architectures = var.architectures
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 "ephemeral_storage" {
for_each = var.ephemeral_storage_size == null ? [] : [1]
content {
size = var.ephemeral_storage_size
}
}
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
}
}
}