Skip to content

Commit 2a479bb

Browse files
author
Jarl Törnroos
authored
Merge pull request #2 from cxcloud/tf-0.12
support for terraform client ver. 0.12
2 parents 8e00b6b + e79f9c9 commit 2a479bb

File tree

11 files changed

+125
-119
lines changed

11 files changed

+125
-119
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ The following table list the output variables
4848

4949
### Example
5050

51-
The following example show how the module can be used. In this example release 1.0.0 is used.
51+
The following example show how the module can be used. In this example release 1.1.0 is used.
52+
53+
Note that release 1.1.0 requires terraform client ver 0.12 or above. Use release 1.0.0 for terraform versions below 0.12.
5254

5355
```console
5456
module "kinesis-firehose-elasticsearch" {
55-
source = "github.com/cxcloud/terraform-kinesis-firehose-elasticsearch?ref=v1.0.0"
57+
source = "github.com/cxcloud/terraform-kinesis-firehose-elasticsearch?ref=v1.1.0"
5658
region = "eu-west-1"
5759
es_name = "cxcloud"
5860
es_ver = 6.5

main.tf

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ data "aws_caller_identity" "current" {}
33
# AWS Elasticsearch
44
module "es" {
55
source = "./modules/es"
6-
name = "${var.es_name}"
7-
region = "${var.region}"
8-
account_id = "${data.aws_caller_identity.current.account_id}"
9-
es_ver = "${var.es_ver}"
10-
instance_type = "${var.es_instance_type}"
11-
instance_count = "${var.es_instance_count}"
12-
dedicated_master_enabled = "${var.es_dedicated_master_enabled}"
13-
ebs_size = "${var.es_ebs_size}"
14-
snapshot_start_hour = "${var.es_snapshot_start_hour}"
15-
name_tag = "${var.es_name_tag}"
16-
stream_name = "${var.stream_name}"
17-
whitelisted_ips = ["${var.es_whitelisted_ips}"]
6+
name = var.es_name
7+
region = var.region
8+
account_id = data.aws_caller_identity.current.account_id
9+
es_ver = var.es_ver
10+
instance_type = var.es_instance_type
11+
instance_count = var.es_instance_count
12+
dedicated_master_enabled = var.es_dedicated_master_enabled
13+
ebs_size = var.es_ebs_size
14+
snapshot_start_hour = var.es_snapshot_start_hour
15+
name_tag = var.es_name_tag
16+
stream_name = var.stream_name
17+
whitelisted_ips = var.es_whitelisted_ips
1818
}
1919

2020
# Kinesis Firehose
2121
module "kinesis-firehose" {
2222
source = "./modules/kinesis-firehose"
23-
stream_name = "${var.stream_name}"
24-
account_id = "${data.aws_caller_identity.current.account_id}"
25-
region = "${var.region}"
26-
bucket = "${var.s3_bucket}"
27-
es_arn = "${module.es.arn}"
28-
s3_buffer_size = "${var.s3_buffer_size}"
29-
s3_buffer_interval = "${var.s3_buffer_interval}"
30-
s3_compression_format = "${var.s3_compression_format}"
31-
es_index_name = "${var.es_index_name}"
32-
es_type_name = "${var.es_type_name}"
33-
es_buffering_size = "${var.es_buffering_size}"
34-
es_buffering_interval = "${var.es_buffering_interval}"
35-
s3_backup_mode = "${var.s3_backup_mode}"
36-
whitelisted_aws_account_arns = ["${var.whitelisted_aws_account_arns}"]
23+
stream_name = var.stream_name
24+
account_id = data.aws_caller_identity.current.account_id
25+
region = var.region
26+
bucket = var.s3_bucket
27+
es_arn = module.es.arn
28+
s3_buffer_size = var.s3_buffer_size
29+
s3_buffer_interval = var.s3_buffer_interval
30+
s3_compression_format = var.s3_compression_format
31+
es_index_name = var.es_index_name
32+
es_type_name = var.es_type_name
33+
es_buffering_size = var.es_buffering_size
34+
es_buffering_interval = var.es_buffering_interval
35+
s3_backup_mode = var.s3_backup_mode
36+
whitelisted_aws_account_arns = var.whitelisted_aws_account_arns
3737
}

modules/es/main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ data "aws_iam_policy_document" "es_policy" {
66
"arn:aws:es:${var.region}:${var.account_id}:domain/${var.name}/*",
77
]
88

9-
principals = {
9+
principals {
1010
type = "AWS"
1111
identifiers = ["*"]
1212
}
1313

1414
condition {
1515
test = "IpAddress"
1616
variable = "aws:SourceIp"
17-
values = "${var.whitelisted_ips}"
17+
values = var.whitelisted_ips
1818
}
1919
}
2020

@@ -25,7 +25,7 @@ data "aws_iam_policy_document" "es_policy" {
2525
"arn:aws:es:${var.region}:${var.account_id}:domain/${var.name}/*",
2626
]
2727

28-
principals = {
28+
principals {
2929
type = "AWS"
3030
identifiers = ["*"]
3131
}
@@ -39,28 +39,28 @@ data "aws_iam_policy_document" "es_policy" {
3939
}
4040

4141
resource "aws_elasticsearch_domain" "cxcloud" {
42-
domain_name = "${var.name}"
43-
elasticsearch_version = "${var.es_ver}"
42+
domain_name = var.name
43+
elasticsearch_version = var.es_ver
4444

4545
cluster_config {
46-
instance_type = "${var.instance_type}"
47-
instance_count = "${var.instance_count}"
48-
dedicated_master_enabled = "${var.dedicated_master_enabled}"
46+
instance_type = var.instance_type
47+
instance_count = var.instance_count
48+
dedicated_master_enabled = var.dedicated_master_enabled
4949
}
5050

5151
ebs_options {
5252
ebs_enabled = true
5353
volume_type = "gp2"
54-
volume_size = "${var.ebs_size}"
54+
volume_size = var.ebs_size
5555
}
5656

5757
snapshot_options {
58-
automated_snapshot_start_hour = "${var.snapshot_start_hour}"
58+
automated_snapshot_start_hour = var.snapshot_start_hour
5959
}
6060

6161
tags = {
62-
Name = "${var.name_tag}"
62+
Name = var.name_tag
6363
}
6464

65-
access_policies = "${data.aws_iam_policy_document.es_policy.json}"
65+
access_policies = data.aws_iam_policy_document.es_policy.json
6666
}

modules/es/outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
output "arn" {
22
description = "ES ARN"
3-
value = "${aws_elasticsearch_domain.cxcloud.arn}"
3+
value = aws_elasticsearch_domain.cxcloud.arn
44
}
55

66
output "endpoint" {
77
description = "ES Endpoint"
8-
value = "${aws_elasticsearch_domain.cxcloud.endpoint}"
8+
value = aws_elasticsearch_domain.cxcloud.endpoint
99
}
1010

1111
output "domain_id" {
1212
description = "ES ARN"
13-
value = "${aws_elasticsearch_domain.cxcloud.domain_id}"
13+
value = aws_elasticsearch_domain.cxcloud.domain_id
1414
}
1515

1616
output "domain_name" {
1717
description = "ES ARN"
18-
value = "${aws_elasticsearch_domain.cxcloud.domain_name}"
18+
value = aws_elasticsearch_domain.cxcloud.domain_name
1919
}

modules/es/variables.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
variable "name" {
2-
type = "string"
2+
type = string
33
description = "Domain name for Elasticsearch"
44
default = "cxcloud"
55
}
66

77
variable "region" {
8-
type = "string"
8+
type = string
99
description = "AWS Region"
1010
}
1111

1212
variable "account_id" {
13-
type = "string"
13+
type = string
1414
description = "AWS Account ID"
1515
}
1616

1717
variable "es_ver" {
18-
type = "string"
18+
type = string
1919
description = "Elasticsearch Version"
2020
default = 6.5
2121
}
2222

2323
variable "instance_type" {
24-
type = "string"
24+
type = string
2525
description = "Instance type for ES"
2626
}
2727

2828
variable "instance_count" {
29-
type = "string"
29+
type = string
3030
description = "Amount of ES nodes"
3131
default = 1
3232
}
3333

3434
variable "dedicated_master_enabled" {
35-
type = "string"
35+
type = string
3636
description = "Use dedicated master"
3737
default = false
3838
}
3939

4040
variable "ebs_size" {
41-
type = "string"
41+
type = string
4242
description = "Size of EBS volume per instance"
4343
}
4444

4545
variable "snapshot_start_hour" {
46-
type = "string"
46+
type = string
4747
description = "Start time of snapshot"
4848
default = 23
4949
}
5050

5151
variable "name_tag" {
52-
type = "string"
52+
type = string
5353
description = "name tag"
5454
default = "cxcloud"
5555
}
5656

5757
variable "stream_name" {
58-
type = "string"
58+
type = string
5959
description = "Kinesis delivery stream name"
6060
default = "cxcloud"
6161
}
6262

6363
variable "whitelisted_ips" {
64-
type = "list"
64+
type = list(string)
6565
description = "Whitelisted IPs to access ES"
6666
}

modules/kinesis-firehose/main.tf

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_s3_bucket" "logs" {
2-
bucket = "${var.bucket}"
2+
bucket = var.bucket
33
acl = "private"
44
}
55

@@ -24,8 +24,8 @@ POLICY
2424
}
2525

2626
resource "aws_iam_policy" "firehose_delivery_policy" {
27-
name = "firehose-delivery-policy"
28-
path = "/"
27+
name = "firehose-delivery-policy"
28+
path = "/"
2929
description = "Kinesis Firehose delivery policy"
3030

3131
policy = <<POLICY
@@ -101,50 +101,50 @@ POLICY
101101
}
102102

103103
resource "aws_iam_role_policy_attachment" "attach_delivery_policy" {
104-
role = "${aws_iam_role.firehose_delivery_role.name}"
105-
policy_arn = "${aws_iam_policy.firehose_delivery_policy.arn}"
104+
role = aws_iam_role.firehose_delivery_role.name
105+
policy_arn = aws_iam_policy.firehose_delivery_policy.arn
106106
}
107107

108108
data "aws_iam_policy_document" "assume_kinesis_firehose" {
109109
statement {
110110
actions = ["sts:AssumeRole"]
111111

112-
principals = {
112+
principals {
113113
type = "AWS"
114-
identifiers = "${var.whitelisted_aws_account_arns}"
114+
identifiers = var.whitelisted_aws_account_arns
115115
}
116116
}
117117
}
118118

119119
resource "aws_iam_role" "assume_kinesis_firehose" {
120120
name = "KinesisFirehose"
121-
assume_role_policy = "${data.aws_iam_policy_document.assume_kinesis_firehose.json}"
121+
assume_role_policy = data.aws_iam_policy_document.assume_kinesis_firehose.json
122122
}
123123

124124
resource "aws_iam_role_policy_attachment" "attach_kinesis_firehose" {
125-
role = "${aws_iam_role.assume_kinesis_firehose.name}"
125+
role = aws_iam_role.assume_kinesis_firehose.name
126126
policy_arn = "arn:aws:iam::aws:policy/AmazonKinesisFirehoseFullAccess"
127127
}
128128

129129
resource "aws_kinesis_firehose_delivery_stream" "cxcloud" {
130-
name = "${var.stream_name}"
130+
name = var.stream_name
131131
destination = "elasticsearch"
132132

133133
s3_configuration {
134-
role_arn = "${aws_iam_role.firehose_delivery_role.arn}"
135-
bucket_arn = "${aws_s3_bucket.logs.arn}"
136-
buffer_size = "${var.s3_buffer_size}"
137-
buffer_interval = "${var.s3_buffer_interval}"
138-
compression_format = "${var.s3_compression_format}"
134+
role_arn = aws_iam_role.firehose_delivery_role.arn
135+
bucket_arn = aws_s3_bucket.logs.arn
136+
buffer_size = var.s3_buffer_size
137+
buffer_interval = var.s3_buffer_interval
138+
compression_format = var.s3_compression_format
139139
}
140140

141141
elasticsearch_configuration {
142-
domain_arn = "${var.es_arn}"
143-
role_arn = "${aws_iam_role.firehose_delivery_role.arn}"
144-
index_name = "${var.es_index_name}"
145-
type_name = "${var.es_type_name}"
146-
buffering_size = "${var.es_buffering_size}"
147-
buffering_interval = "${var.es_buffering_interval}"
148-
s3_backup_mode = "${var.s3_backup_mode}"
142+
domain_arn = var.es_arn
143+
role_arn = aws_iam_role.firehose_delivery_role.arn
144+
index_name = var.es_index_name
145+
type_name = var.es_type_name
146+
buffering_size = var.es_buffering_size
147+
buffering_interval = var.es_buffering_interval
148+
s3_backup_mode = var.s3_backup_mode
149149
}
150150
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
output "arn" {
22
description = "Kineses Firehose Stream ARN"
3-
value = "${aws_kinesis_firehose_delivery_stream.cxcloud.arn}"
3+
value = aws_kinesis_firehose_delivery_stream.cxcloud.arn
44
}

0 commit comments

Comments
 (0)