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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# Lambda layers ==============================================================
resource "aws_lambda_layer_version" "this" {
for_each = var.layers
layer_name = each.value.name
description = each.value.description
filename = each.value.filename
s3_bucket = each.value.s3_bucket
s3_key = each.value.s3_key
compatible_runtimes = each.value.compatible_runtimes
compatible_architectures = each.value.compatible_architectures
}
# Lambda functions ===========================================================
resource "aws_lambda_function" "this" {
for_each = var.functions
function_name = each.value.name
description = each.value.description
runtime = each.value.image_uri == null ? each.value.runtime : null
handler = each.value.image_uri == null ? each.value.handler : null
role = each.value.role_arn
filename = each.value.filename
s3_bucket = each.value.s3_bucket
s3_key = each.value.s3_key
s3_object_version = each.value.s3_object_version
image_uri = each.value.image_uri
architectures = each.value.architectures
memory_size = each.value.memory_size
timeout = each.value.timeout
reserved_concurrent_executions = each.value.reserved_concurrent_executions
publish = each.value.publish
kms_key_arn = each.value.kms_key_arn
layers = each.value.layers
dynamic "environment" {
for_each = length(each.value.environment) > 0 ? [each.value.environment] : []
content {
variables = environment.value
}
}
dynamic "vpc_config" {
for_each = length(each.value.subnet_ids) > 0 ? [true] : []
content {
subnet_ids = each.value.subnet_ids
security_group_ids = each.value.security_group_ids
}
}
tracing_config {
mode = each.value.tracing_mode
}
tags = local.tags
}
# Event source mappings ======================================================
resource "aws_lambda_event_source_mapping" "this" {
for_each = local.event_source_map
function_name = aws_lambda_function.this[each.value.fn_key].arn
event_source_arn = each.value.es.event_source_arn
batch_size = each.value.es.batch_size
starting_position = each.value.es.starting_position
bisect_batch_on_function_error = each.value.es.bisect_on_function_error
function_response_types = length(each.value.es.function_response_types) > 0 ? each.value.es.function_response_types : null
}
|