github.com/andresvia/terraform@v0.6.15-0.20160412045437-d51c75946785/examples/aws-cloudwatch-events/kinesis/main.tf (about) 1 provider "aws" { 2 region = "${var.aws_region}" 3 } 4 5 resource "aws_cloudwatch_event_rule" "foo" { 6 name = "${var.rule_name}" 7 event_pattern = <<PATTERN 8 { 9 "detail-type": [ 10 "AWS API Call via CloudTrail" 11 ], 12 "detail": { 13 "eventSource": [ 14 "autoscaling.amazonaws.com" 15 ] 16 } 17 } 18 PATTERN 19 role_arn = "${aws_iam_role.role.arn}" 20 } 21 22 resource "aws_iam_role" "role" { 23 name = "${var.iam_role_name}" 24 assume_role_policy = <<POLICY 25 { 26 "Version": "2012-10-17", 27 "Statement": [ 28 { 29 "Action": "sts:AssumeRole", 30 "Principal": { 31 "Service": "events.amazonaws.com" 32 }, 33 "Effect": "Allow", 34 "Sid": "" 35 } 36 ] 37 } 38 POLICY 39 } 40 41 resource "aws_iam_role_policy" "policy" { 42 name = "tf-example-policy" 43 role = "${aws_iam_role.role.id}" 44 policy = <<POLICY 45 { 46 "Version": "2012-10-17", 47 "Statement": [ 48 { 49 "Action": [ 50 "kinesis:PutRecord", 51 "kinesis:PutRecords" 52 ], 53 "Resource": [ 54 "*" 55 ], 56 "Effect": "Allow" 57 } 58 ] 59 } 60 POLICY 61 } 62 63 resource "aws_cloudwatch_event_target" "foobar" { 64 rule = "${aws_cloudwatch_event_rule.foo.name}" 65 target_id = "${var.target_name}" 66 arn = "${aws_kinesis_stream.foo.arn}" 67 } 68 69 resource "aws_kinesis_stream" "foo" { 70 name = "${var.stream_name}" 71 shard_count = 1 72 }