Skip to content

Commit a0bccdb

Browse files
authored
Merge pull request tmknom#11 from tmknom/upgrade-terraform-0.12
Upgraded module to support Terraform 0.12
2 parents e032656 + 455e938 commit a0bccdb

File tree

8 files changed

+100
-97
lines changed

8 files changed

+100
-97
lines changed

examples/complete/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ module "elasticache_redis" {
1616
family = "redis5.0"
1717
description = "This is example"
1818

19-
subnet_ids = ["${module.vpc.public_subnet_ids}"]
20-
vpc_id = "${module.vpc.vpc_id}"
21-
ingress_cidr_blocks = ["${module.vpc.vpc_cidr_block}"]
19+
subnet_ids = [module.vpc.public_subnet_ids]
20+
vpc_id = module.vpc.vpc_id
21+
ingress_cidr_blocks = [module.vpc.vpc_cidr_block]
2222

2323
tags = {
2424
Environment = "prod"
@@ -27,10 +27,10 @@ module "elasticache_redis" {
2727

2828
module "vpc" {
2929
source = "git::https://github.com/tmknom/terraform-aws-vpc.git?ref=tags/1.0.0"
30-
cidr_block = "${local.cidr_block}"
30+
cidr_block = local.cidr_block
3131
name = "vpc-elasticache-redis"
32-
public_subnet_cidr_blocks = ["${cidrsubnet(local.cidr_block, 8, 0)}", "${cidrsubnet(local.cidr_block, 8, 1)}"]
33-
public_availability_zones = ["${data.aws_availability_zones.available.names}"]
32+
public_subnet_cidr_blocks = [cidrsubnet(local.cidr_block, 8, 0), cidrsubnet(local.cidr_block, 8, 1)]
33+
public_availability_zones = [data.aws_availability_zones.available.names]
3434
}
3535

3636
locals {

examples/complete/outputs.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
output "elasticache_replication_group_id" {
2-
value = "${module.elasticache_redis.elasticache_replication_group_id}"
2+
value = module.elasticache_redis.elasticache_replication_group_id
33
}
44

55
output "elasticache_replication_group_primary_endpoint_address" {
6-
value = "${module.elasticache_redis.elasticache_replication_group_primary_endpoint_address}"
6+
value = module.elasticache_redis.elasticache_replication_group_primary_endpoint_address
77
}
88

99
output "elasticache_replication_group_member_clusters" {
10-
value = "${module.elasticache_redis.elasticache_replication_group_member_clusters}"
10+
value = module.elasticache_redis.elasticache_replication_group_member_clusters
1111
}
1212

1313
output "elasticache_parameter_group_id" {
14-
value = "${module.elasticache_redis.elasticache_parameter_group_id}"
14+
value = module.elasticache_redis.elasticache_parameter_group_id
1515
}
1616

1717
output "security_group_id" {
18-
value = "${module.elasticache_redis.security_group_id}"
18+
value = module.elasticache_redis.security_group_id
1919
}
2020

2121
output "security_group_arn" {
22-
value = "${module.elasticache_redis.security_group_arn}"
22+
value = module.elasticache_redis.security_group_arn
2323
}
2424

2525
output "security_group_vpc_id" {
26-
value = "${module.elasticache_redis.security_group_vpc_id}"
26+
value = module.elasticache_redis.security_group_vpc_id
2727
}
2828

2929
output "security_group_owner_id" {
30-
value = "${module.elasticache_redis.security_group_owner_id}"
30+
value = module.elasticache_redis.security_group_owner_id
3131
}
3232

3333
output "security_group_name" {
34-
value = "${module.elasticache_redis.security_group_name}"
34+
value = module.elasticache_redis.security_group_name
3535
}
3636

3737
output "security_group_description" {
38-
value = "${module.elasticache_redis.security_group_description}"
38+
value = module.elasticache_redis.security_group_description
3939
}
4040

4141
output "security_group_ingress" {
42-
value = "${module.elasticache_redis.security_group_ingress}"
42+
value = module.elasticache_redis.security_group_ingress
4343
}
4444

4545
output "security_group_egress" {
46-
value = "${module.elasticache_redis.security_group_egress}"
46+
value = module.elasticache_redis.security_group_egress
4747
}

examples/minimal/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ module "elasticache_redis" {
44
number_cache_clusters = 2
55
node_type = "cache.m3.medium"
66

7-
subnet_ids = ["${module.vpc.public_subnet_ids}"]
8-
vpc_id = "${module.vpc.vpc_id}"
9-
ingress_cidr_blocks = ["${module.vpc.vpc_cidr_block}"]
7+
subnet_ids = [module.vpc.public_subnet_ids]
8+
vpc_id = module.vpc.vpc_id
9+
ingress_cidr_blocks = [module.vpc.vpc_cidr_block]
1010
}
1111

1212
module "vpc" {
1313
source = "git::https://github.com/tmknom/terraform-aws-vpc.git?ref=tags/1.0.0"
14-
cidr_block = "${local.cidr_block}"
14+
cidr_block = local.cidr_block
1515
name = "vpc-elasticache-redis"
16-
public_subnet_cidr_blocks = ["${cidrsubnet(local.cidr_block, 8, 0)}", "${cidrsubnet(local.cidr_block, 8, 1)}"]
17-
public_availability_zones = ["${data.aws_availability_zones.available.names}"]
16+
public_subnet_cidr_blocks = [cidrsubnet(local.cidr_block, 8, 0), cidrsubnet(local.cidr_block, 8, 1)]
17+
public_availability_zones = [data.aws_availability_zones.available.names]
1818
}
1919

2020
locals {

examples/minimal/outputs.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
output "elasticache_replication_group_id" {
2-
value = "${module.elasticache_redis.elasticache_replication_group_id}"
2+
value = module.elasticache_redis.elasticache_replication_group_id
33
}
44

55
output "elasticache_replication_group_primary_endpoint_address" {
6-
value = "${module.elasticache_redis.elasticache_replication_group_primary_endpoint_address}"
6+
value = module.elasticache_redis.elasticache_replication_group_primary_endpoint_address
77
}
88

99
output "elasticache_replication_group_member_clusters" {
10-
value = "${module.elasticache_redis.elasticache_replication_group_member_clusters}"
10+
value = module.elasticache_redis.elasticache_replication_group_member_clusters
1111
}
1212

1313
output "elasticache_parameter_group_id" {
14-
value = "${module.elasticache_redis.elasticache_parameter_group_id}"
14+
value = module.elasticache_redis.elasticache_parameter_group_id
1515
}
1616

1717
output "security_group_id" {
18-
value = "${module.elasticache_redis.security_group_id}"
18+
value = module.elasticache_redis.security_group_id
1919
}
2020

2121
output "security_group_arn" {
22-
value = "${module.elasticache_redis.security_group_arn}"
22+
value = module.elasticache_redis.security_group_arn
2323
}
2424

2525
output "security_group_vpc_id" {
26-
value = "${module.elasticache_redis.security_group_vpc_id}"
26+
value = module.elasticache_redis.security_group_vpc_id
2727
}
2828

2929
output "security_group_owner_id" {
30-
value = "${module.elasticache_redis.security_group_owner_id}"
30+
value = module.elasticache_redis.security_group_owner_id
3131
}
3232

3333
output "security_group_name" {
34-
value = "${module.elasticache_redis.security_group_name}"
34+
value = module.elasticache_redis.security_group_name
3535
}
3636

3737
output "security_group_description" {
38-
value = "${module.elasticache_redis.security_group_description}"
38+
value = module.elasticache_redis.security_group_description
3939
}
4040

4141
output "security_group_ingress" {
42-
value = "${module.elasticache_redis.security_group_ingress}"
42+
value = module.elasticache_redis.security_group_ingress
4343
}
4444

4545
output "security_group_egress" {
46-
value = "${module.elasticache_redis.security_group_egress}"
46+
value = module.elasticache_redis.security_group_egress
4747
}

main.tf

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# https://www.terraform.io/docs/providers/aws/r/elasticache_replication_group.html
66
resource "aws_elasticache_replication_group" "default" {
77
engine = "redis"
8-
parameter_group_name = "${aws_elasticache_parameter_group.default.name}"
9-
subnet_group_name = "${aws_elasticache_subnet_group.default.name}"
10-
security_group_ids = ["${aws_security_group.default.id}"]
8+
parameter_group_name = aws_elasticache_parameter_group.default.name
9+
subnet_group_name = aws_elasticache_subnet_group.default.name
10+
security_group_ids = [aws_security_group.default.id]
1111

1212
# The replication group identifier. This parameter is stored as a lowercase string.
1313
#
@@ -17,100 +17,100 @@ resource "aws_elasticache_replication_group" "default" {
1717
# - Cannot end with a hyphen.
1818
#
1919
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.Create.CON.Redis.html
20-
replication_group_id = "${var.name}"
20+
replication_group_id = var.name
2121

2222
# The number of clusters this replication group initially has.
2323
# If automatic_failover_enabled is true, the value of this parameter must be at least 2.
2424
# The maximum permitted value for number_cache_clusters is 6 (1 primary plus 5 replicas).
2525
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Scaling.RedisReplGrps.html
26-
number_cache_clusters = "${var.number_cache_clusters}"
26+
number_cache_clusters = var.number_cache_clusters
2727

2828
# The compute and memory capacity of the nodes in the node group (shard).
2929
# Generally speaking, the current generation types provide more memory and computational power at lower cost
3030
# when compared to their equivalent previous generation counterparts.
3131
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheNodes.SupportedTypes.html
32-
node_type = "${var.node_type}"
32+
node_type = var.node_type
3333

3434
# The version number of the cache engine to be used for the clusters in this replication group.
3535
# You can upgrade to a newer engine version, but you cannot downgrade to an earlier engine version.
3636
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/supported-engine-versions.html
37-
engine_version = "${var.engine_version}"
37+
engine_version = var.engine_version
3838

3939
# The port number on which each member of the replication group accepts connections.
4040
# Redis default port is 6379.
41-
port = "${var.port}"
41+
port = var.port
4242

4343
# Every cluster and replication group has a weekly maintenance window during which any system changes are applied.
4444
# Specifies the weekly time range during which maintenance on the cluster is performed.
4545
# It is specified as a range in the format ddd:hh24:mi-ddd:hh24:mi. (Example: "sun:23:00-mon:01:30")
4646
# The minimum maintenance window is a 60 minute period.
4747
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/maintenance-window.html
48-
maintenance_window = "${var.maintenance_window}"
48+
maintenance_window = var.maintenance_window
4949

5050
# A period during each day when ElastiCache will begin creating a backup.
5151
# The minimum length for the backup window is 60 minutes.
5252
# If you do not specify a backup window, ElastiCache will assign one automatically.
5353
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/backups-automatic.html
54-
snapshot_window = "${var.snapshot_window}"
54+
snapshot_window = var.snapshot_window
5555

5656
# The number of days the backup will be retained in Amazon S3.
5757
# The maximum backup retention limit is 35 days.
5858
# If the backup retention limit is set to 0, automatic backups are disabled for the cluster.
5959
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/backups-automatic.html
60-
snapshot_retention_limit = "${var.snapshot_retention_limit}"
60+
snapshot_retention_limit = var.snapshot_retention_limit
6161

6262
# You can enable Multi-AZ with Automatic Failover only on Redis (cluster mode disabled) clusters that have at least
6363
# one available read replica. Clusters without read replicas do not provide high availability or fault tolerance.
6464
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/AutoFailover.html
65-
automatic_failover_enabled = "${var.automatic_failover_enabled}"
65+
automatic_failover_enabled = var.automatic_failover_enabled
6666

6767
# Redis at-rest encryption is an optional feature to increase data security by encrypting on-disk data during sync
6868
# and backup or snapshot operations. Because there is some processing needed to encrypt and decrypt the data,
6969
# enabling at-rest encryption can have some performance impact during these operations.
7070
# You should benchmark your data with and without at-rest encryption to determine the performance impact for your use cases.
7171
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/at-rest-encryption.html
72-
at_rest_encryption_enabled = "${var.at_rest_encryption_enabled}"
72+
at_rest_encryption_enabled = var.at_rest_encryption_enabled
7373

7474
# ElastiCache in-transit encryption is an optional feature that allows you to increase the security of your data at
7575
# its most vulnerable points—when it is in transit from one location to another. Because there is some processing
7676
# needed to encrypt and decrypt the data at the endpoints, enabling in-transit encryption can have some performance impact.
7777
# You should benchmark your data with and without in-transit encryption to determine the performance impact for your use cases.
7878
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/in-transit-encryption.html
79-
transit_encryption_enabled = "${var.transit_encryption_enabled}"
79+
transit_encryption_enabled = var.transit_encryption_enabled
8080

8181
# If true, this parameter causes the modifications in this request and any pending modifications to be applied,
8282
# asynchronously and as soon as possible, regardless of the maintenance_window setting for the replication group.
8383
# apply_immediately applies only to modifications in node type, engine version, and changing the number of nodes in a cluster.
8484
# Other modifications, such as changing the maintenance window, are applied immediately.
8585
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.Modify.html
86-
apply_immediately = "${var.apply_immediately}"
86+
apply_immediately = var.apply_immediately
8787

8888
# A user-created description for the replication group.
89-
replication_group_description = "${var.description}"
89+
replication_group_description = var.description
9090

9191
# A mapping of tags to assign to the resource.
92-
tags = "${merge(map("Name", var.name), var.tags)}"
92+
tags = merge({ "Name" = var.name }, var.tags)
9393
}
9494

9595
# https://www.terraform.io/docs/providers/aws/r/elasticache_parameter_group.html
9696
resource "aws_elasticache_parameter_group" "default" {
97-
name = "${var.name}"
98-
family = "${var.family}"
99-
description = "${var.description}"
97+
name = var.name
98+
family = var.family
99+
description = var.description
100100
}
101101

102102
# https://www.terraform.io/docs/providers/aws/r/elasticache_subnet_group.html
103103
resource "aws_elasticache_subnet_group" "default" {
104-
name = "${var.name}"
105-
subnet_ids = ["${var.subnet_ids}"]
106-
description = "${var.description}"
104+
name = var.name
105+
subnet_ids = var.subnet_ids
106+
description = var.description
107107
}
108108

109109
# https://www.terraform.io/docs/providers/aws/r/security_group.html
110110
resource "aws_security_group" "default" {
111-
name = "${local.security_group_name}"
112-
vpc_id = "${var.vpc_id}"
113-
tags = "${merge(map("Name", local.security_group_name), var.tags)}"
111+
name = local.security_group_name
112+
vpc_id = var.vpc_id
113+
tags = merge({ "Name" = local.security_group_name }, var.tags)
114114
}
115115

116116
locals {
@@ -120,11 +120,11 @@ locals {
120120
# https://www.terraform.io/docs/providers/aws/r/security_group_rule.html
121121
resource "aws_security_group_rule" "ingress" {
122122
type = "ingress"
123-
from_port = "${var.port}"
124-
to_port = "${var.port}"
123+
from_port = var.port
124+
to_port = var.port
125125
protocol = "tcp"
126-
cidr_blocks = ["${var.ingress_cidr_blocks}"]
127-
security_group_id = "${aws_security_group.default.id}"
126+
cidr_blocks = var.ingress_cidr_blocks
127+
security_group_id = aws_security_group.default.id
128128
}
129129

130130
resource "aws_security_group_rule" "egress" {
@@ -133,5 +133,5 @@ resource "aws_security_group_rule" "egress" {
133133
to_port = 0
134134
protocol = "-1"
135135
cidr_blocks = ["0.0.0.0/0"]
136-
security_group_id = "${aws_security_group.default.id}"
136+
security_group_id = aws_security_group.default.id
137137
}

0 commit comments

Comments
 (0)