Skip to content

Commit 30b38ee

Browse files
committed
Fix "Interpolation-only expressions are deprecated" warning
1 parent d96ad34 commit 30b38ee

File tree

19 files changed

+139
-139
lines changed

19 files changed

+139
-139
lines changed

modules/bastion/iam.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "aws_iam_instance_profile" "s3_readonly" {
22
name = "${var.name}-s3-readonly"
3-
role = "${aws_iam_role.s3_readonly.name}"
3+
role = aws_iam_role.s3_readonly.name
44
}
55

66
resource "aws_iam_role" "s3_readonly" {
@@ -25,7 +25,7 @@ EOF
2525

2626
resource "aws_iam_role_policy" "s3_readonly_policy" {
2727
name = "${var.name}-s3-readonly-policy"
28-
role = "${aws_iam_role.s3_readonly.id}"
28+
role = aws_iam_role.s3_readonly.id
2929

3030
policy = <<EOF
3131
{
@@ -38,7 +38,7 @@ resource "aws_iam_role_policy" "s3_readonly_policy" {
3838
"s3:Get*"
3939
],
4040
"Resource": [
41-
"${var.s3_bucket_arn}",
41+
var.s3_bucket_arn,
4242
"${var.s3_bucket_arn}/*"
4343
]
4444
}

modules/bastion/main.tf

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
resource "aws_security_group" "bastion" {
2-
name = "${var.name}"
3-
vpc_id = "${var.vpc_id}"
2+
name = var.name
3+
vpc_id = var.vpc_id
44
description = "Bastion security group (only SSH inbound access is allowed)"
55

66
tags {
7-
Name = "${var.name}"
7+
Name = var.name
88
}
99

1010
ingress {
1111
protocol = "tcp"
1212
from_port = 22
1313
to_port = 22
1414

15-
cidr_blocks = "${var.allow_ssh_cidrs}"
15+
cidr_blocks = var.allow_ssh_cidrs
1616
}
1717

1818
egress {
@@ -31,48 +31,48 @@ resource "aws_security_group" "bastion" {
3131
}
3232

3333
data "template_file" "user_data" {
34-
template = "${file("${path.module}/user-data/user-data.sh")}"
35-
36-
vars {
37-
s3_bucket_name = "${var.s3_bucket_name}"
38-
s3_bucket_uri = "${var.s3_bucket_uri}"
39-
ssh_user = "${var.ssh_user}"
40-
keys_update_frequency = "${var.keys_update_frequency}"
41-
enable_hourly_cron_updates = "${var.enable_hourly_cron_updates}"
42-
additional_user_data_script = "${var.additional_user_data_script}"
34+
template = file("${path.module}/user-data/user-data.sh")
35+
36+
vars = {
37+
s3_bucket_name = var.s3_bucket_name
38+
s3_bucket_uri = var.s3_bucket_uri
39+
ssh_user = var.ssh_user
40+
keys_update_frequency = var.keys_update_frequency
41+
enable_hourly_cron_updates = var.enable_hourly_cron_updates
42+
additional_user_data_script = var.additional_user_data_script
4343
}
4444
}
4545

4646
resource "aws_launch_configuration" "bastion" {
47-
name_prefix = "${var.name}"
48-
image_id = "${var.ami}"
49-
instance_type = "${var.instance_type}"
50-
key_name = "${var.keypair}"
51-
user_data = "${data.template_file.user_data.rendered}"
52-
associate_public_ip_address = "${var.associate_public_ip_address}"
47+
name_prefix = var.name
48+
image_id = var.ami
49+
instance_type = var.instance_type
50+
key_name = var.keypair
51+
user_data = data.template_file.user_data.rendered
52+
associate_public_ip_address = var.associate_public_ip_address
5353

5454
security_groups = [
55-
"${compact(concat(list(aws_security_group.bastion.id), split(",", "${var.security_group_ids}")))}",
55+
compact(concat(list(aws_security_group.bastion.id), split(",", var.security_group_ids))),
5656
]
5757

58-
iam_instance_profile = "${aws_iam_instance_profile.s3_readonly.name}"
58+
iam_instance_profile = aws_iam_instance_profile.s3_readonly.name
5959

6060
lifecycle {
6161
create_before_destroy = true
6262
}
6363
}
6464

6565
resource "aws_autoscaling_group" "bastion" {
66-
name = "${var.name}"
67-
vpc_zone_identifier = ["${split(",", var.subnet_ids)}"]
66+
name = var.name
67+
vpc_zone_identifier = [split(",", var.subnet_ids)]
6868
desired_capacity = "1"
6969
min_size = "1"
7070
max_size = "1"
7171
health_check_grace_period = "60"
7272
health_check_type = "EC2"
7373
force_delete = false
7474
wait_for_capacity_timeout = 0
75-
launch_configuration = "${aws_launch_configuration.bastion.name}"
75+
launch_configuration = aws_launch_configuration.bastion.name
7676

7777
enabled_metrics = [
7878
"GroupMinSize",
@@ -87,13 +87,13 @@ resource "aws_autoscaling_group" "bastion" {
8787

8888
tag {
8989
key = "Name"
90-
value = "${var.name}"
90+
value = var.name
9191
propagate_at_launch = true
9292
}
9393

9494
tag {
9595
key = "EIP"
96-
value = "${var.eip}"
96+
value = var.eip
9797
propagate_at_launch = true
9898
}
9999

modules/bastion/output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
output "ssh_user" {
2-
value = "${var.ssh_user}"
2+
value = var.ssh_user
33
}
44

55
output "security_group_id" {
6-
value = "${aws_security_group.bastion.id}"
6+
value = aws_security_group.bastion.id
77
}

modules/nat/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
resource "aws_eip" "nat" {
22
vpc = true
33

4-
count = "${length(var.azs)}" # Comment out count to only have 1 NAT
4+
count = length(var.azs) # Comment out count to only have 1 NAT
55

66
lifecycle {
77
create_before_destroy = true
88
}
99
}
1010

1111
resource "aws_nat_gateway" "nat" {
12-
count = "${length(var.azs)}" # Comment out count to only have 1 NAT
12+
count = length(var.azs) # Comment out count to only have 1 NAT
1313

14-
allocation_id = "${element(aws_eip.nat.*.id, count.index)}"
15-
subnet_id = "${element(split(",", var.public_subnet_ids), count.index)}"
14+
allocation_id = element(aws_eip.nat.*.id, count.index)
15+
subnet_id = element(split(",", var.public_subnet_ids), count.index)
1616

1717
lifecycle {
1818
create_before_destroy = true

modules/nat/output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
output "nat_gateway_ids" {
2-
value = "${join(",", aws_nat_gateway.nat.*.id)}"
2+
value = join(",", aws_nat_gateway.nat.*.id)
33
}
44

55
output "public_ip" {
6-
value = "${aws_eip.nat.public_ip}"
6+
value = aws_eip.nat.public_ip
77
}

modules/network-acl/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "aws_network_acl" "acl" {
2-
vpc_id = "${var.vpc_id}"
3-
subnet_ids = ["${concat(split(",", var.public_subnet_ids), split(",", var.private_app_subnet_ids))}"]
2+
vpc_id = var.vpc_id
3+
subnet_ids = [concat(split(",", var.public_subnet_ids), split(",", var.private_app_subnet_ids))]
44

55
ingress {
66
protocol = "-1"
@@ -21,6 +21,6 @@ resource "aws_network_acl" "acl" {
2121
}
2222

2323
tags {
24-
Name = "${var.name}"
24+
Name = var.name
2525
}
2626
}

modules/network-acl/output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
output "network_acl_id" {
2-
value = "${aws_network_acl.acl.id}"
2+
value = aws_network_acl.acl.id
33
}

modules/network.tf

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -83,100 +83,100 @@ module "vpc" {
8383
source = "./vpc"
8484

8585
name = "${var.name}-vpc"
86-
vpc_cidr = "${var.vpc_cidr}"
86+
vpc_cidr = var.vpc_cidr
8787
}
8888

8989
module "public_subnet" {
9090
source = "./public-subnet"
9191

9292
name = "${var.name}-public"
93-
vpc_id = "${module.vpc.vpc_id}"
94-
public_subnets = "${var.public_subnets}"
95-
azs = "${var.azs}"
93+
vpc_id = module.vpc.vpc_id
94+
public_subnets = var.public_subnets
95+
azs = var.azs
9696
}
9797

9898
module "nat" {
9999
source = "./nat"
100100

101101
name = "${var.name}-nat"
102-
azs = "${var.azs}"
103-
public_subnet_ids = "${module.public_subnet.subnet_ids}"
102+
azs = var.azs
103+
public_subnet_ids = module.public_subnet.subnet_ids
104104
}
105105

106106
module "private_app_subnet" {
107107
source = "./private-app-subnet"
108108

109109
name = "${var.name}-private-app"
110-
vpc_id = "${module.vpc.vpc_id}"
111-
private_app_subnets = "${var.private_app_subnets}"
112-
azs = "${var.azs}"
110+
vpc_id = module.vpc.vpc_id
111+
private_app_subnets = var.private_app_subnets
112+
azs = var.azs
113113

114-
nat_gateway_ids = "${module.nat.nat_gateway_ids}"
114+
nat_gateway_ids = module.nat.nat_gateway_ids
115115
}
116116

117117
module "private_persistence_subnet" {
118118
source = "./private-persistence-subnet"
119119

120120
name = "${var.name}-private-persistence"
121-
vpc_id = "${module.vpc.vpc_id}"
122-
private_persistence_subnets = "${var.private_persistence_subnets}"
123-
azs = "${var.azs}"
121+
vpc_id = module.vpc.vpc_id
122+
private_persistence_subnets = var.private_persistence_subnets
123+
azs = var.azs
124124
}
125125

126126
module "spare_subnet" {
127127
source = "./spare-subnet"
128128

129129
name = "${var.name}-spare"
130-
vpc_id = "${module.vpc.vpc_id}"
131-
spare_subnets = "${var.spare_subnets}"
132-
azs = "${var.azs}"
130+
vpc_id = module.vpc.vpc_id
131+
spare_subnets = var.spare_subnets
132+
azs = var.azs
133133
}
134134

135135
module "network_acl" {
136136
source = "./network-acl"
137137

138138
name = "${var.name}-acl"
139-
vpc_id = "${module.vpc.vpc_id}"
140-
public_subnet_ids = "${module.public_subnet.subnet_ids}"
141-
private_app_subnet_ids = "${module.private_app_subnet.subnet_ids}"
139+
vpc_id = module.vpc.vpc_id
140+
public_subnet_ids = module.public_subnet.subnet_ids
141+
private_app_subnet_ids = module.private_app_subnet.subnet_ids
142142
}
143143

144144
##### VPC-PEERING
145145
module "vpc-peering" {
146146
source = "./vpc-peering"
147147
name = "${var.name}-vpc-peering"
148148

149-
root_vpc_id = "${module.vpc.vpc_id}"
150-
root_vpc_cidr = "${module.vpc.vpc_cidr}"
151-
root_route_table_ids = "${module.private_app_subnet.route_table_ids}"
149+
root_vpc_id = module.vpc.vpc_id
150+
root_vpc_cidr = module.vpc.vpc_cidr
151+
root_route_table_ids = module.private_app_subnet.route_table_ids
152152

153153
# workaround: using number of availability_zones for the number of routes to be added in the route table
154154
# https://github.com/hashicorp/terraform/issues/3888
155-
root_route_table_ids_count = "${length(var.azs)}"
155+
root_route_table_ids_count = length(var.azs)
156156

157-
peer_route_table_ids = "${var.peer_private_app_route_table_ids}"
157+
peer_route_table_ids = var.peer_private_app_route_table_ids
158158

159159
# workaround: using number of availability_zones for the number of routes to be added in the route table
160160
# https://github.com/hashicorp/terraform/issues/3888
161-
peer_route_table_ids_count = "${length(var.azs)}"
161+
peer_route_table_ids_count = length(var.azs)
162162

163-
peer_owner_id = "${var.peer_owner_id}"
164-
peer_vpc_id = "${var.peer_vpc_id}"
165-
peer_vpc_cidr = "${var.peer_vpc_cidr}"
163+
peer_owner_id = var.peer_owner_id
164+
peer_vpc_id = var.peer_vpc_id
165+
peer_vpc_cidr = var.peer_vpc_cidr
166166
}
167167

168168
module "bastion-host" {
169169
name = "${var.name}-bastion-host"
170170
source = "./bastion"
171171
instance_type = "t2.nano"
172-
keypair = "${var.bastion_host_keypair}"
173-
allow_ssh_cidrs = "${var.bastion_host_allow_ssh_cidrs}"
174-
ami = "${var.bastion_host_ami_id}"
175-
region = "${var.aws_region}"
172+
keypair = var.bastion_host_keypair
173+
allow_ssh_cidrs = var.bastion_host_allow_ssh_cidrs
174+
ami = var.bastion_host_ami_id
175+
region = var.aws_region
176176
s3_bucket_uri = "s3://${var.config_bucket_name}/keypairs"
177-
s3_bucket_arn = "${var.config_bucket_arn}"
178-
vpc_id = "${module.vpc.vpc_id}"
179-
subnet_ids = "${module.public_subnet.subnet_ids}"
177+
s3_bucket_arn = var.config_bucket_arn
178+
vpc_id = module.vpc.vpc_id
179+
subnet_ids = module.public_subnet.subnet_ids
180180
keys_update_frequency = "5,20,35,50 * * * *"
181181
additional_user_data_script = "date"
182182
}
@@ -186,40 +186,40 @@ module "bastion-host" {
186186
######################
187187
# VPC
188188
output "vpc_id" {
189-
value = "${module.vpc.vpc_id}"
189+
value = module.vpc.vpc_id
190190
}
191191

192192
output "vpc_cidr" {
193-
value = "${module.vpc.vpc_cidr}"
193+
value = module.vpc.vpc_cidr
194194
}
195195

196196
# Subnets
197197
output "public_subnet_ids" {
198-
value = "${module.public_subnet.subnet_ids}"
198+
value = module.public_subnet.subnet_ids
199199
}
200200

201201
output "private_app_subnet_ids" {
202-
value = "${module.private_app_subnet.subnet_ids}"
202+
value = module.private_app_subnet.subnet_ids
203203
}
204204

205205
output "private_persistence_subnet_ids" {
206-
value = "${module.private_persistence_subnet.subnet_ids}"
206+
value = module.private_persistence_subnet.subnet_ids
207207
}
208208

209209
# Route Tables
210210
output "private_app_route_table_ids" {
211-
value = "${module.private_app_subnet.route_table_ids}"
211+
value = module.private_app_subnet.route_table_ids
212212
}
213213

214214
output "public_route_table_ids" {
215-
value = "${module.public_subnet.route_table_ids}"
215+
value = module.public_subnet.route_table_ids
216216
}
217217

218218
# NAT
219219
output "nat_gateway_ids" {
220-
value = "${module.nat.nat_gateway_ids}"
220+
value = module.nat.nat_gateway_ids
221221
}
222222

223223
output "nat_public_ip" {
224-
value = "${module.nat.public_ip}"
224+
value = module.nat.public_ip
225225
}

0 commit comments

Comments
 (0)