17 lines
388 B
HCL
17 lines
388 B
HCL
resource "aws_cloudwatch_event_rule" "instance_state" {
|
|
name = "instance-state-events"
|
|
|
|
event_pattern = <<EOF
|
|
{
|
|
"source": ["aws.ec2"],
|
|
"detail-type": ["EC2 Instance State-change Notification"]
|
|
}
|
|
EOF
|
|
}
|
|
|
|
resource "aws_cloudwatch_event_target" "sns" {
|
|
rule = aws_cloudwatch_event_rule.instance_state.name
|
|
target_id = "SendToSNS"
|
|
arn = aws_sns_topic.ec2_events.arn
|
|
}
|