Skip to content

Commit 24b71db

Browse files
Merge pull request #9 from brunordias/master
Add whether to create IAM policies
2 parents ef311e5 + e431819 commit 24b71db

File tree

6 files changed

+67
-20
lines changed

6 files changed

+67
-20
lines changed

README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,29 @@ module "kinesis-stream" {
4343
## Inputs
4444

4545
| Name | Description | Type | Default | Required |
46-
|------|-------------|------|---------|:-----:|
47-
|name|A name to identify the stream. This is unique to the AWS account and region the Stream is created in.|string||yes|
48-
|shard_count|The number of shards that the stream will use|number|1|yes|
49-
|retention_period|Length of time data records are accessible after they are added to the stream. The maximum value of a stream's retention period is 168 hours. Minimum value is 24. Default is 24.|number|24|yes|
50-
|shard_level_metrics|"A list of shard-level CloudWatch metrics which can be enabled for the stream.|list(string)|[]|no|
51-
|enforce_consumer_deletion|A boolean that indicates all registered consumers should be deregistered from the stream so that the stream can be destroyed without error.|bool|false|no|
52-
|encryption_type|The encryption type to use. The only acceptable values are NONE or KMS.|string|"NONE"|no|
53-
|kms_key_id|The GUID for the customer-managed KMS key to use for encryption. You can also use a Kinesis-owned master key by specifying the alias alias/aws/kinesis.|string|""|no|
54-
|tags|A mapping of tags to assign to the resource|map|{}|no|
46+
|------|-------------|------|---------|:--------:|
47+
| create\_policy\_admin | Whether to create IAM Policy (ARN) admin of the Stream | `bool` | `true` | no |
48+
| create\_policy\_read\_only | Whether to create IAM Policy (ARN) read only of the Stream | `bool` | `true` | no |
49+
| create\_policy\_write\_only | Whether to create IAM Policy (ARN) write only of the Stream | `bool` | `true` | no |
50+
| encryption\_type | The encryption type to use. The only acceptable values are NONE or KMS. | `string` | `"NONE"` | no |
51+
| enforce\_consumer\_deletion | A boolean that indicates all registered consumers should be deregistered from the stream so that the stream can be destroyed without error. | `bool` | `false` | no |
52+
| kms\_key\_id | The GUID for the customer-managed KMS key to use for encryption. You can also use a Kinesis-owned master key by specifying the alias alias/aws/kinesis. | `string` | `""` | no |
53+
| name | A name to identify the stream. This is unique to the AWS account and region the Stream is created in. | `string` | n/a | yes |
54+
| retention\_period | Length of time data records are accessible after they are added to the stream. The maximum value of a stream's retention period is 168 hours. Minimum value is 24. Default is 24. | `number` | `24` | no |
55+
| shard\_count | The number of shards that the stream will use | `number` | `1` | no |
56+
| shard\_level\_metrics | A list of shard-level CloudWatch metrics which can be enabled for the stream. | `list(string)` | `[]` | no |
57+
| tags | A mapping of tags to assign to the resource. | `map` | n/a | yes |
5558

5659
## Outputs
5760

5861
| Name | Description |
5962
|------|-------------|
60-
|kinesis_stream_name|The unique Kinesis stream name|
61-
|kinesis_stream_shard_count|The count of shards for this Kinesis stream|
62-
|kinesis_stream_arn|The Amazon Resource Name (ARN) specifying the Kinesis stream|
63-
|kinesis_stream_iam_policy_read_only_arn|The IAM Policy (ARN) read only of the Stream|
64-
|kinesis_stream_iam_policy_write_arn|The IAM Policy (ARN) write only of the Stream|
65-
|kinesis_stream_iam_policy_admin_arn|The IAM Policy (ARN) admin of the Stream|
63+
| kinesis\_stream\_arn | The Amazon Resource Name (ARN) specifying the Stream |
64+
| kinesis\_stream\_iam\_policy\_admin\_arn | The IAM Policy (ARN) admin of the Stream |
65+
| kinesis\_stream\_iam\_policy\_read\_only\_arn | The IAM Policy (ARN) read only of the Stream |
66+
| kinesis\_stream\_iam\_policy\_write\_only\_arn | The IAM Policy (ARN) write only of the Stream |
67+
| kinesis\_stream\_name | The unique Kinesis stream name |
68+
| kinesis\_stream\_shard\_count | The count of shards for this Kinesis stream |
6669

6770
## Tests
6871

@@ -78,7 +81,7 @@ go test -v -timeout 30m
7881

7982
## Authors
8083

81-
Module is maintained by [Rodrigo Del Monte](https://github.com/rodrigodelmonte)
84+
Module is maintained by [Rodrigo Del Monte](https://github.com/rodrigodelmonte) and [Bruno R. Dias](https://github.com/brunordias)
8285

8386
## License
8487

example/example.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ module "kinesis_stream_example" {
1515
encryption_type = var.encryption_type
1616
kms_key_id = var.kms_key_id
1717
tags = var.tags
18-
18+
create_policy_read_only = var.create_policy_read_only
19+
create_policy_write_only = var.create_policy_write_only
20+
create_policy_admin = var.create_policy_admin
1921
}

example/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ variable "tags" {
4343
description = "A mapping of tags to assign to the resource."
4444
type = map
4545
}
46+
47+
variable "create_policy_read_only" {
48+
type = bool
49+
default = true
50+
description = "Whether to create IAM Policy (ARN) read only of the Stream"
51+
}
52+
53+
variable "create_policy_write_only" {
54+
type = bool
55+
default = true
56+
description = "Whether to create IAM Policy (ARN) write only of the Stream"
57+
}
58+
59+
variable "create_policy_admin" {
60+
type = bool
61+
default = true
62+
description = "Whether to create IAM Policy (ARN) admin of the Stream"
63+
}

main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ resource "aws_kinesis_stream" "this" {
1212
}
1313

1414
resource "aws_iam_policy" "read-only" {
15+
count = var.create_policy_read_only == true ? 1 : 0
16+
1517
name = format("kinesis-stream-%s-read-only", var.name)
1618
path = "/"
1719
description = "Managed by Terraform"
@@ -37,6 +39,8 @@ resource "aws_iam_policy" "read-only" {
3739
}
3840

3941
resource "aws_iam_policy" "write-only" {
42+
count = var.create_policy_write_only == true ? 1 : 0
43+
4044
name = format("kinesis-stream-%s-write-only", var.name)
4145
path = "/"
4246
description = "Managed by Terraform"
@@ -59,6 +63,8 @@ resource "aws_iam_policy" "write-only" {
5963
}
6064

6165
resource "aws_iam_policy" "admin" {
66+
count = var.create_policy_admin == true ? 1 : 0
67+
6268
name = format("kinesis-stream-%s-admin", var.name)
6369
path = "/"
6470
description = "Managed by Terraform"

outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ output "kinesis_stream_arn" {
1515

1616
output "kinesis_stream_iam_policy_read_only_arn" {
1717
description = "The IAM Policy (ARN) read only of the Stream"
18-
value = aws_iam_policy.read-only.arn
18+
value = concat(aws_iam_policy.read-only.*.arn, [""])[0]
1919
}
2020

2121
output "kinesis_stream_iam_policy_write_only_arn" {
2222
description = "The IAM Policy (ARN) write only of the Stream"
23-
value = aws_iam_policy.write-only.arn
23+
value = concat(aws_iam_policy.write-only.*.arn, [""])[0]
2424
}
2525

2626
output "kinesis_stream_iam_policy_admin_arn" {
2727
description = "The IAM Policy (ARN) admin of the Stream"
28-
value = aws_iam_policy.admin.arn
28+
value = concat(aws_iam_policy.admin.*.arn, [""])[0]
2929
}

variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ variable "tags" {
4343
description = "A mapping of tags to assign to the resource."
4444
type = map
4545
}
46+
47+
variable "create_policy_read_only" {
48+
type = bool
49+
default = true
50+
description = "Whether to create IAM Policy (ARN) read only of the Stream"
51+
}
52+
53+
variable "create_policy_write_only" {
54+
type = bool
55+
default = true
56+
description = "Whether to create IAM Policy (ARN) write only of the Stream"
57+
}
58+
59+
variable "create_policy_admin" {
60+
type = bool
61+
default = true
62+
description = "Whether to create IAM Policy (ARN) admin of the Stream"
63+
}

0 commit comments

Comments
 (0)