Skip to content

Commit d2b8124

Browse files
committed
Upgraded module to support Terraform 0.12
1 parent e032656 commit d2b8124

File tree

4 files changed

+64
-61
lines changed

4 files changed

+64
-61
lines changed

main.tf

+31-31
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
}

outputs.tf

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
output "elasticache_replication_group_id" {
2-
value = "${aws_elasticache_replication_group.default.id}"
2+
value = aws_elasticache_replication_group.default.id
33
description = "The ID of the ElastiCache Replication Group."
44
}
55

66
output "elasticache_replication_group_primary_endpoint_address" {
7-
value = "${aws_elasticache_replication_group.default.primary_endpoint_address}"
7+
value = aws_elasticache_replication_group.default.primary_endpoint_address
88
description = "The address of the endpoint for the primary node in the replication group."
99
}
1010

1111
output "elasticache_replication_group_member_clusters" {
12-
value = "${aws_elasticache_replication_group.default.member_clusters}"
12+
value = aws_elasticache_replication_group.default.member_clusters
1313
description = "The identifiers of all the nodes that are part of this replication group."
1414
}
1515

1616
output "elasticache_parameter_group_id" {
17-
value = "${aws_elasticache_parameter_group.default.id}"
17+
value = aws_elasticache_parameter_group.default.id
1818
description = "The ElastiCache parameter group name."
1919
}
2020

2121
output "security_group_id" {
22-
value = "${aws_security_group.default.id}"
22+
value = aws_security_group.default.id
2323
description = "The ID of the Redis ElastiCache security group."
2424
}
2525

2626
output "security_group_arn" {
27-
value = "${aws_security_group.default.arn}"
27+
value = aws_security_group.default.arn
2828
description = "The ARN of the Redis ElastiCache security group."
2929
}
3030

3131
output "security_group_vpc_id" {
32-
value = "${aws_security_group.default.vpc_id}"
32+
value = aws_security_group.default.vpc_id
3333
description = "The VPC ID of the Redis ElastiCache security group."
3434
}
3535

3636
output "security_group_owner_id" {
37-
value = "${aws_security_group.default.owner_id}"
37+
value = aws_security_group.default.owner_id
3838
description = "The owner ID of the Redis ElastiCache security group."
3939
}
4040

4141
output "security_group_name" {
42-
value = "${aws_security_group.default.name}"
42+
value = aws_security_group.default.name
4343
description = "The name of the Redis ElastiCache security group."
4444
}
4545

4646
output "security_group_description" {
47-
value = "${aws_security_group.default.description}"
47+
value = aws_security_group.default.description
4848
description = "The description of the Redis ElastiCache security group."
4949
}
5050

5151
output "security_group_ingress" {
52-
value = "${aws_security_group.default.ingress}"
52+
value = aws_security_group.default.ingress
5353
description = "The ingress rules of the Redis ElastiCache security group."
5454
}
5555

5656
output "security_group_egress" {
57-
value = "${aws_security_group.default.egress}"
57+
value = aws_security_group.default.egress
5858
description = "The egress rules of the Redis ElastiCache security group."
5959
}

variables.tf

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
variable "name" {
2-
type = "string"
2+
type = string
33
description = "The replication group identifier. This parameter is stored as a lowercase string."
44
}
55

66
variable "number_cache_clusters" {
7-
type = "string"
7+
type = string
88
description = "The number of cache clusters (primary and replicas) this replication group will have."
99
}
1010

1111
variable "node_type" {
12-
type = "string"
12+
type = string
1313
description = "The compute and memory capacity of the nodes in the node group."
1414
}
1515

1616
variable "subnet_ids" {
17-
type = "list"
17+
type = list(string)
1818
description = "List of VPC Subnet IDs for the cache subnet group."
1919
}
2020

2121
variable "vpc_id" {
22-
type = "string"
22+
type = string
2323
description = "VPC Id to associate with Redis ElastiCache."
2424
}
2525

2626
variable "ingress_cidr_blocks" {
27-
type = "list"
27+
type = list(string)
2828
description = "List of Ingress CIDR blocks."
2929
}
3030

3131
variable "engine_version" {
3232
default = "5.0.0"
33-
type = "string"
33+
type = string
3434
description = "The version number of the cache engine to be used for the cache clusters in this replication group."
3535
}
3636

3737
variable "port" {
3838
default = 6379
39-
type = "string"
39+
type = string
4040
description = "The port number on which each of the cache nodes will accept connections."
4141
}
4242

4343
variable "maintenance_window" {
4444
default = ""
45-
type = "string"
45+
type = string
4646
description = "Specifies the weekly time range for when maintenance on the cache cluster is performed."
4747
}
4848

4949
variable "snapshot_window" {
5050
default = ""
51-
type = "string"
51+
type = string
5252
description = "The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster."
5353
}
5454

5555
variable "snapshot_retention_limit" {
5656
default = "30"
57-
type = "string"
57+
type = string
5858
description = "The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them."
5959
}
6060

6161
variable "automatic_failover_enabled" {
6262
default = true
63-
type = "string"
63+
type = string
6464
description = "Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails."
6565
}
6666

6767
variable "at_rest_encryption_enabled" {
6868
default = true
69-
type = "string"
69+
type = string
7070
description = "Whether to enable encryption at rest."
7171
}
7272

7373
variable "transit_encryption_enabled" {
7474
default = true
75-
type = "string"
75+
type = string
7676
description = "Whether to enable encryption in transit."
7777
}
7878

7979
variable "apply_immediately" {
8080
default = false
81-
type = "string"
81+
type = string
8282
description = "Specifies whether any modifications are applied immediately, or during the next maintenance window."
8383
}
8484

8585
variable "family" {
8686
default = "redis5.0"
87-
type = "string"
87+
type = string
8888
description = "The family of the ElastiCache parameter group."
8989
}
9090

9191
variable "description" {
9292
default = "Managed by Terraform"
93-
type = "string"
93+
type = string
9494
description = "The description of the all resources."
9595
}
9696

9797
variable "tags" {
9898
default = {}
99-
type = "map"
99+
type = map(string)
100100
description = "A mapping of tags to assign to all resources."
101101
}

versions.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 0.12"
3+
}

0 commit comments

Comments
 (0)