-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3_firehose.tf
89 lines (81 loc) · 2.26 KB
/
s3_firehose.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# create an S3 bucket
resource "aws_s3_bucket" "firehose_destination_bucket" {
bucket = var.bucket_name
acl = "private"
force_destroy = true
}
resource "aws_s3_bucket" "firehose_elasticsearch_destination_bucket" {
bucket = "tdk-bd-es.io"
acl = "private"
force_destroy = true
}
# create an IAM role to allow firehose to access the S3 bucket
resource "aws_iam_role" "firehose_s3_role" {
name = "firehose_s3_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "firehose.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
# create permissions to allow firehose to read/write and list objects in the S3 bucket
resource "aws_iam_role_policy" "firehose_s3_role_policy" {
name = "firehose_s3_role_policy"
role = "${aws_iam_role.firehose_s3_role.id}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": [
"arn:aws:s3:::${aws_s3_bucket.firehose_destination_bucket.bucket}",
"arn:aws:s3:::${aws_s3_bucket.firehose_elasticsearch_destination_bucket.bucket}"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": "s3:*Object",
"Resource": ["arn:aws:s3:::${aws_s3_bucket.firehose_destination_bucket.bucket}/*"]
},
{
"Sid": "",
"Effect": "Allow",
"Action": "lambda:*",
"Resource": ["*"]
}
]
}
EOF
}
# create the kinesis firehose
resource "aws_kinesis_firehose_delivery_stream" "PurchaseLogs_s3_firehose_stream" {
name = var.kinesis_firehose_name
destination = "extended_s3"
extended_s3_configuration {
role_arn = "${aws_iam_role.firehose_s3_role.arn}"
bucket_arn = "${aws_s3_bucket.firehose_destination_bucket.arn}"
buffer_interval = var.firehose_buffer_interval
}
}
resource "aws_kinesis_stream" "CadabraOrders_s3_kinesis_data_stream" {
name = var.kinesis_datastream_name
shard_count = 1
}
resource "aws_kinesis_stream" "OrderRateAlarms_kinesis_data_stream" {
name = var.kinesis_alarm_datastream_name
shard_count = 1
}