forked from terraform-module/terraform-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
68 lines (59 loc) · 2.09 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
resource aws_lambda_function this {
function_name = format("%s", var.function_name)
filename = var.filename
description = var.description
role = var.role_arn
handler = var.handler
runtime = var.runtime
publish = var.publish
memory_size = var.memory_size
reserved_concurrent_executions = var.concurrency
timeout = var.lambda_timeout
tags = var.tags
source_code_hash = var.source_code_hash
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
}
}
dynamic "tracing_config" {
for_each = var.tracing_config == null ? [] : [var.tracing_config]
content {
mode = tracing_config.value.mode
}
}
dynamic "environment" {
for_each = var.environment == null ? [] : [var.environment]
content {
variables = var.environment
}
}
lifecycle {
ignore_changes = [
filename,
]
}
depends_on = [aws_cloudwatch_log_group.this]
}
resource aws_lambda_function_event_invoke_config this {
function_name = aws_lambda_function.this.function_name
qualifier = aws_lambda_function.this.version
maximum_event_age_in_seconds = var.event_age_in_seconds
maximum_retry_attempts = var.retry_attempts
}
resource aws_lambda_function_event_invoke_config latest {
function_name = aws_lambda_function.this.function_name
qualifier = "$LATEST"
maximum_event_age_in_seconds = var.event_age_in_seconds
maximum_retry_attempts = var.retry_attempts
}
# Cloud watch
resource aws_cloudwatch_log_group this {
name = format("/aws/lambda/%s", var.function_name)
retention_in_days = var.log_retention
tags = merge(var.tags,
{ Function = format("%s", var.function_name) }
)
}