-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathmain.tf
More file actions
97 lines (79 loc) · 2.99 KB
/
Copy pathmain.tf
File metadata and controls
97 lines (79 loc) · 2.99 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
locals {
handler = "index.handler"
runtime = "nodejs22.x"
}
module "fixtures" {
source = "../fixtures"
}
module "logs_subscription" {
source = "../../"
description = "Example usage for an AWS Lambda with CloudWatch logs subscription filters and advanced log configuration using a custom log group name."
filename = module.fixtures.output_path
function_name = module.fixtures.output_function_name
handler = local.handler
runtime = local.runtime
source_code_hash = module.fixtures.output_base64sha256
// configure module managed log group
cloudwatch_logs_log_group_class = "STANDARD"
cloudwatch_logs_retention_in_days = 7
cloudwatch_logs_skip_destroy = false
// advanced logging config including a custom CloudWatch log group managed by the module
logging_config = {
application_log_level = "INFO"
log_format = "JSON"
log_group = "/custom/${module.fixtures.output_function_name}"
system_log_level = "WARN"
}
// register log subscription filters for the functions log group
cloudwatch_log_subscription_filters = {
sub_1 = {
destination_arn = module.sub_1.arn
filter_pattern = "%Lambda%"
}
sub_2 = {
destination_arn = module.sub_2.arn
}
}
}
data "archive_file" "subscription_handler" {
type = "zip"
source_file = "${path.module}/handler/index.js"
output_path = "${path.module}/handler.zip"
output_file_mode = "0666"
}
resource "aws_cloudwatch_log_group" "existing" {
name = "/existing/${module.fixtures.output_function_name}"
retention_in_days = 1
}
module "sub_1" {
source = "../../"
description = "Example usage of a log subscription Lambda function with advanced log configuration."
filename = data.archive_file.subscription_handler.output_path
function_name = "${module.fixtures.output_function_name}-sub-1"
handler = local.handler
runtime = local.runtime
source_code_hash = data.archive_file.subscription_handler.output_base64sha256
cloudwatch_logs_retention_in_days = 1
create_cloudwatch_log_group = false
// advanced logging config using an external CloudWatch log group
logging_config = {
log_format = "Text"
log_group = aws_cloudwatch_log_group.existing.name
}
}
module "sub_2" {
source = "../../"
description = "Example usage of a log subscription Lambda function with advanced log configuration."
filename = data.archive_file.subscription_handler.output_path
function_name = "${module.fixtures.output_function_name}-sub-2"
handler = local.handler
runtime = local.runtime
source_code_hash = data.archive_file.subscription_handler.output_base64sha256
cloudwatch_logs_retention_in_days = 1
create_cloudwatch_log_group = false
// advanced logging config using an external CloudWatch log group
logging_config = {
log_format = "Text"
log_group = aws_cloudwatch_log_group.existing.name
}
}