-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.tf
90 lines (81 loc) · 2.15 KB
/
main.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
90
resource "aws_kinesis_stream" "this" {
name = var.name
shard_count = var.shard_count
retention_period = var.retention_period
shard_level_metrics = var.shard_level_metrics
enforce_consumer_deletion = var.enforce_consumer_deletion
encryption_type = var.encryption_type
kms_key_id = var.kms_key_id
tags = var.tags
// Ignore future changes on the desired count value
lifecycle {
ignore_changes = [shard_count]
}
}
resource "aws_iam_policy" "read-only" {
count = var.create_policy_read_only == true ? 1 : 0
name = format("kinesis-stream-%s-read-only", var.name)
path = "/"
description = "Managed by Terraform"
policy = jsonencode({
Version = "2012-10-17",
Statement = concat([
{
Effect = "Allow"
Action = [
"kinesis:DescribeLimits",
"kinesis:DescribeStream",
"kinesis:GetRecords",
"kinesis:GetShardIterator",
"kinesis:SubscribeToShard",
"kinesis:ListShards"
]
Resource = [
aws_kinesis_stream.this.arn
]
}
])
})
}
resource "aws_iam_policy" "write-only" {
count = var.create_policy_write_only == true ? 1 : 0
name = format("kinesis-stream-%s-write-only", var.name)
path = "/"
description = "Managed by Terraform"
policy = jsonencode({
Version = "2012-10-17",
Statement = concat([
{
Effect = "Allow"
Action = [
"kinesis:DescribeStream",
"kinesis:PutRecord",
"kinesis:PutRecords",
]
Resource = [
aws_kinesis_stream.this.arn
]
}
])
})
}
resource "aws_iam_policy" "admin" {
count = var.create_policy_admin == true ? 1 : 0
name = format("kinesis-stream-%s-admin", var.name)
path = "/"
description = "Managed by Terraform"
policy = jsonencode({
Version = "2012-10-17",
Statement = concat([
{
Effect = "Allow"
Action = [
"kinesis:*",
]
Resource = [
aws_kinesis_stream.this.arn
]
}
])
})
}