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