Skip to content

Commit 2cb20bd

Browse files
Merge pull request #1 from ekomi-ltd/terraformv0.12.6
Upgraded to latest terraform 0.12.6 syntax.
2 parents adbf0e4 + 4e2c85a commit 2cb20bd

File tree

4 files changed

+41
-41
lines changed

4 files changed

+41
-41
lines changed

main.tf

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
data "aws_vpc" "vpc" {
2-
id = "${var.vpc_id}"
2+
id = var.vpc_id
33
}
44

55
resource "random_id" "salt" {
66
byte_length = 8
77
}
88

99
resource "aws_elasticache_replication_group" "redis" {
10-
replication_group_id = "${format("%.20s", "${var.name}-${var.env}")}"
10+
replication_group_id = format("%.20s", "${var.name}-${var.env}")
1111
replication_group_description = "Terraform-managed ElastiCache replication group for ${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}"
12-
number_cache_clusters = "${var.redis_clusters}"
13-
node_type = "${var.redis_node_type}"
14-
automatic_failover_enabled = "${var.redis_failover}"
15-
engine_version = "${var.redis_version}"
16-
port = "${var.redis_port}"
17-
parameter_group_name = "${aws_elasticache_parameter_group.redis_parameter_group.id}"
18-
subnet_group_name = "${aws_elasticache_subnet_group.redis_subnet_group.id}"
19-
security_group_ids = ["${aws_security_group.redis_security_group.id}"]
20-
apply_immediately = "${var.apply_immediately}"
21-
maintenance_window = "${var.redis_maintenance_window}"
22-
snapshot_window = "${var.redis_snapshot_window}"
23-
snapshot_retention_limit = "${var.redis_snapshot_retention_limit}"
24-
tags = "${merge(map("Name", format("tf-elasticache-%s-%s", var.name, lookup(data.aws_vpc.vpc.tags, "Name", ""))), var.tags)}"
12+
number_cache_clusters = var.redis_clusters
13+
node_type = var.redis_node_type
14+
automatic_failover_enabled = var.redis_failover
15+
engine_version = var.redis_version
16+
port = var.redis_port
17+
parameter_group_name = aws_elasticache_parameter_group.redis_parameter_group.id
18+
subnet_group_name = aws_elasticache_subnet_group.redis_subnet_group.id
19+
security_group_ids = [aws_security_group.redis_security_group.id]
20+
apply_immediately = var.apply_immediately
21+
maintenance_window = var.redis_maintenance_window
22+
snapshot_window = var.redis_snapshot_window
23+
snapshot_retention_limit = var.redis_snapshot_retention_limit
24+
tags = merge(map("Name", format("tf-elasticache-%s-%s", var.name, lookup(data.aws_vpc.vpc.tags, "Name", ""))), var.tags)
2525
}
2626

2727
resource "aws_elasticache_parameter_group" "redis_parameter_group" {
28-
name = "${replace(format("%.255s", lower(replace("tf-redis-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}-${random_id.salt.hex}", "_", "-"))), "/\\s/", "-")}"
28+
name = replace(format("%.255s", lower(replace("tf-redis-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}-${random_id.salt.hex}", "_", "-"))), "/\\s/", "-")
2929

3030
description = "Terraform-managed ElastiCache parameter group for ${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}"
3131

3232
# Strip the patch version from redis_version var
33-
family = "redis${replace(var.redis_version, "/\\.[\\d]+$/", "")}"
33+
family = "redis${replace(var.redis_version, "/\\.[\\d]+$/", "")}"
3434
dynamic "parameter" {
3535
for_each = var.redis_parameters
3636
content {
37-
name = parameter.value.name
37+
name = parameter.value.name
3838
value = parameter.value.value
3939
}
4040
}
@@ -45,6 +45,6 @@ resource "aws_elasticache_parameter_group" "redis_parameter_group" {
4545
}
4646

4747
resource "aws_elasticache_subnet_group" "redis_subnet_group" {
48-
name = "${replace(format("%.255s", lower(replace("tf-redis-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}", "_", "-"))), "/\\s/", "-")}"
49-
subnet_ids = "${var.subnets}"
48+
name = replace(format("%.255s", lower(replace("tf-redis-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}", "_", "-"))), "/\\s/", "-")
49+
subnet_ids = var.subnets
5050
}

outputs.tf

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
output "redis_security_group_id" {
2-
value = "${aws_security_group.redis_security_group.id}"
2+
value = aws_security_group.redis_security_group.id
33
}
44

55
output "parameter_group" {
6-
value = "${aws_elasticache_parameter_group.redis_parameter_group.id}"
6+
value = aws_elasticache_parameter_group.redis_parameter_group.id
77
}
88

99
output "redis_subnet_group_name" {
10-
value = "${aws_elasticache_subnet_group.redis_subnet_group.name}"
10+
value = aws_elasticache_subnet_group.redis_subnet_group.name
1111
}
1212

1313
output "id" {
14-
value = "${aws_elasticache_replication_group.redis.id}"
14+
value = aws_elasticache_replication_group.redis.id
1515
}
1616

1717
output "port" {
18-
value = "${var.redis_port}"
18+
value = var.redis_port
1919
}
2020

2121
output "endpoint" {
22-
value = "${aws_elasticache_replication_group.redis.primary_endpoint_address}"
22+
value = aws_elasticache_replication_group.redis.primary_endpoint_address
2323
}

security_groups.tf

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
resource "aws_security_group" "redis_security_group" {
2-
name = "${format("%.255s", "tf-sg-ec-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}")}"
2+
name = format("%.255s", "tf-sg-ec-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}")
33
description = "Terraform-managed ElastiCache security group for ${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}"
4-
vpc_id = "${data.aws_vpc.vpc.id}"
4+
vpc_id = data.aws_vpc.vpc.id
55

66
tags = {
77
Name = "tf-sg-ec-${var.name}-${var.env}-${data.aws_vpc.vpc.tags["Name"]}"
88
}
99
}
1010

1111
resource "aws_security_group_rule" "redis_ingress" {
12-
count = "${length(var.allowed_security_groups)}"
12+
count = length(var.allowed_security_groups)
1313
type = "ingress"
14-
from_port = "${var.redis_port}"
15-
to_port = "${var.redis_port}"
14+
from_port = var.redis_port
15+
to_port = var.redis_port
1616
protocol = "tcp"
17-
source_security_group_id = "${element(var.allowed_security_groups, count.index)}"
18-
security_group_id = "${aws_security_group.redis_security_group.id}"
17+
source_security_group_id = element(var.allowed_security_groups, count.index)
18+
security_group_id = aws_security_group.redis_security_group.id
1919
}
2020

2121
resource "aws_security_group_rule" "redis_networks_ingress" {
2222
type = "ingress"
23-
from_port = "${var.redis_port}"
24-
to_port = "${var.redis_port}"
23+
from_port = var.redis_port
24+
to_port = var.redis_port
2525
protocol = "tcp"
26-
cidr_blocks = "${var.allowed_cidr}"
27-
security_group_id = "${aws_security_group.redis_security_group.id}"
26+
cidr_blocks = var.allowed_cidr
27+
security_group_id = aws_security_group.redis_security_group.id
2828
}

variables.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ variable "apply_immediately" {
2020
}
2121

2222
variable "allowed_cidr" {
23-
type = "list"
23+
type = list
2424
default = ["127.0.0.1/32"]
2525
description = "A list of Security Group ID's to allow access to."
2626
}
2727

2828
variable "allowed_security_groups" {
29-
type = "list"
29+
type = list
3030
default = []
3131
description = "A list of Security Group ID's to allow access to."
3232
}
@@ -57,7 +57,7 @@ variable "redis_port" {
5757
}
5858

5959
variable "subnets" {
60-
type = "list"
60+
type = list
6161
description = "List of VPC Subnet IDs for the cache subnet group"
6262
}
6363

@@ -72,7 +72,7 @@ variable "vpc_id" {
7272
}
7373

7474
variable "redis_parameters" {
75-
type = list(object({name = string, value = string}))
75+
type = list(object({ name = string, value = string }))
7676
description = "additional parameters modifyed in parameter group"
7777
default = []
7878
}

0 commit comments

Comments
 (0)