Skip to content

Instantly share code, notes, and snippets.

@knakayama
Created May 20, 2016 11:02
Show Gist options
  • Save knakayama/611063f9641fc194daa1b5218b820857 to your computer and use it in GitHub Desktop.
Save knakayama/611063f9641fc194daa1b5218b820857 to your computer and use it in GitHub Desktop.
variable "region" {
default = "us-east-1"
}
provider "aws" {
region = "${var.region}"
}
resource "aws_cloudwatch_event_rule" "console" {
name = "capture-aws-sign-in"
description = "Capture each AWS Console Sign In"
event_pattern = <<EOT
{
"detail-type": [
"AWS Console Sign In via CloudTrail"
]
}
EOT
}
resource "aws_sns_topic" "aws_logins" {
name = "aws-console-logins"
}
resource "aws_cloudwatch_event_target" "sns" {
rule = "${aws_cloudwatch_event_rule.console.name}"
target_id = "SendToSNS"
arn = "${aws_sns_topic.aws_logins.arn}"
}
output "aws_sns_topic_arn" {
value = "${aws_sns_topic.aws_logins.arn}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment