-
Notifications
You must be signed in to change notification settings - Fork 34
/
main.tf
45 lines (38 loc) · 1.37 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
module "source" {
source = "../fixtures"
}
resource "aws_lambda_alias" "example" {
function_name = module.lambda.function_name
function_version = module.lambda.version
name = "prod"
}
module "lambda" {
source = "../../"
description = "Example usage for an AWS Lambda with Amazon EventBridge (CloudWatch Events) rules."
filename = module.source.output_path
function_name = "example-with-cloudwatch-events"
handler = "index.handler"
runtime = "nodejs20.x"
source_code_hash = module.source.output_base64sha256
cloudwatch_event_rules = {
scheduled = {
schedule_expression = "rate(1 minute)"
// optionally overwrite arguments like 'description'
// from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule
description = "Triggered by CloudTrail"
// optionally overwrite `cloudwatch_event_target_arn` in case an alias should be used for the event rule
cloudwatch_event_target_arn = aws_lambda_alias.example.arn
// optionally add `cloudwatch_event_target_input` for event input
cloudwatch_event_target_input = jsonencode({ "key" : "value" })
}
pattern = {
event_pattern = <<PATTERN
{
"detail-type": [
"AWS Console Sign In via CloudTrail"
]
}
PATTERN
}
}
}