-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventbridge.tf
More file actions
22 lines (20 loc) · 889 Bytes
/
eventbridge.tf
File metadata and controls
22 lines (20 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
resource "aws_lambda_permission" "eventbridge_invoke_lambda" {
statement_id = "AllowExecutionFromEventBridge"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.deployment_automation.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.ecs_deployment_event_pattern.arn
}
resource "aws_cloudwatch_event_rule" "ecs_deployment_event_pattern" {
name = "${var.app_name}-deploybot-${var.environment}"
description = "ECS Deployment Event Rule"
event_pattern = jsonencode({
"source": ["aws.ecs"],
"detail-type": ["ECS Deployment State Change"]
})
}
resource "aws_cloudwatch_event_target" "target_lambda" {
rule = aws_cloudwatch_event_rule.ecs_deployment_event_pattern.name
target_id = "target-lambda"
arn = aws_lambda_function.deployment_automation.arn
}