diff --git a/aws_alb/main.tf b/aws_alb/main.tf index 1f8b1b2..afc3b9a 100644 --- a/aws_alb/main.tf +++ b/aws_alb/main.tf @@ -1,61 +1,62 @@ provider "aws" { - region = "${var.aws_region}" + region = var.aws_region } -data "aws_availability_zones" "all" {} +data "aws_availability_zones" "all" { +} resource "aws_vpc" "default" { cidr_block = "20.0.0.0/16" enable_dns_hostnames = true - tags { + tags = { Name = "hapee_test_vpc" } } resource "aws_subnet" "tf_test_subnet" { - count = "${var.aws_az_count}" - vpc_id = "${aws_vpc.default.id}" - cidr_block = "${cidrsubnet(aws_vpc.default.cidr_block, 8, count.index)}" - availability_zone = "${data.aws_availability_zones.all.names[count.index]}" + count = var.aws_az_count + vpc_id = aws_vpc.default.id + cidr_block = cidrsubnet(aws_vpc.default.cidr_block, 8, count.index) + availability_zone = data.aws_availability_zones.all.names[count.index] map_public_ip_on_launch = true - tags { + tags = { Name = "hapee_test_subnet" } } resource "aws_internet_gateway" "gw" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id - tags { + tags = { Name = "hapee_test_ig" } } resource "aws_route_table" "r" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id route { cidr_block = "0.0.0.0/0" - gateway_id = "${aws_internet_gateway.gw.id}" + gateway_id = aws_internet_gateway.gw.id } - tags { + tags = { Name = "aws_route_table" } } resource "aws_route_table_association" "a" { - count = "${var.aws_az_count}" - subnet_id = "${element(aws_subnet.tf_test_subnet.*.id, count.index)}" - route_table_id = "${aws_route_table.r.id}" + count = var.aws_az_count + subnet_id = element(aws_subnet.tf_test_subnet.*.id, count.index) + route_table_id = aws_route_table.r.id } resource "aws_security_group" "instance_sg1" { name = "instance_sg1" description = "Instance (HAPEE/Web node) SG to pass tcp/22 by default" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 22 @@ -77,20 +78,20 @@ resource "aws_security_group" "instance_sg1" { resource "aws_security_group" "instance_sg2" { name = "instance_sg2" description = "Instance (HAPEE/Web node) SG to pass ELB traffic by default" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 80 to_port = 80 protocol = "tcp" - security_groups = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.alb.id}"] + security_groups = [aws_security_group.instance_sg1.id, aws_security_group.alb.id] } ingress { from_port = 8080 to_port = 8080 protocol = "tcp" - security_groups = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.alb.id}"] + security_groups = [aws_security_group.instance_sg1.id, aws_security_group.alb.id] } } @@ -98,7 +99,7 @@ resource "aws_security_group" "alb" { name = "alb_sg" description = "Used in the terraform" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 80 @@ -114,7 +115,7 @@ resource "aws_security_group" "alb" { cidr_blocks = ["0.0.0.0/0"] } - depends_on = ["aws_internet_gateway.gw"] + depends_on = [aws_internet_gateway.gw] } resource "aws_lb" "hapee_alb" { @@ -122,10 +123,10 @@ resource "aws_lb" "hapee_alb" { internal = false - subnets = ["${aws_subnet.tf_test_subnet.*.id}"] - security_groups = ["${aws_security_group.alb.id}"] + subnets = aws_subnet.tf_test_subnet.*.id + security_groups = [aws_security_group.alb.id] - tags { + tags = { Name = "hapee_alb" } } @@ -133,7 +134,7 @@ resource "aws_lb" "hapee_alb" { resource "aws_lb_target_group" "hapee_alb_target" { name = "hapee-test-alb-tg" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id port = 80 protocol = "HTTP" @@ -149,72 +150,88 @@ resource "aws_lb_target_group" "hapee_alb_target" { matcher = "200,202" } - tags { + tags = { Name = "hapee_alb_tg" } } resource "aws_lb_listener" "hapee_alb_listener" { - load_balancer_arn = "${aws_lb.hapee_alb.arn}" + load_balancer_arn = aws_lb.hapee_alb.arn port = 80 protocol = "HTTP" default_action { - target_group_arn = "${aws_lb_target_group.hapee_alb_target.arn}" + target_group_arn = aws_lb_target_group.hapee_alb_target.arn type = "forward" } } resource "aws_lb_target_group_attachment" "hapee_alb_target_att" { - count = "${var.hapee_cluster_size * var.aws_az_count}" + count = var.hapee_cluster_size * var.aws_az_count - target_group_arn = "${aws_lb_target_group.hapee_alb_target.arn}" - target_id = "${element(aws_instance.hapee_node.*.id, count.index)}" + target_group_arn = aws_lb_target_group.hapee_alb_target.arn + target_id = element(aws_instance.hapee_node.*.id, count.index) port = 80 } resource "aws_instance" "web_node" { - count = "${var.web_cluster_size * var.aws_az_count}" + count = var.web_cluster_size * var.aws_az_count - instance_type = "${var.aws_web_instance_type}" + instance_type = var.aws_web_instance_type - ami = "${lookup(var.ubuntu_aws_amis, var.aws_region)}" + ami = var.ubuntu_aws_amis[var.aws_region] - key_name = "${var.key_name}" + key_name = var.key_name - vpc_security_group_ids = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.instance_sg2.id}"] - subnet_id = "${element(aws_subnet.tf_test_subnet.*.id, count.index / var.web_cluster_size)}" - user_data = "${file("web-userdata.sh")}" + vpc_security_group_ids = [aws_security_group.instance_sg1.id, aws_security_group.instance_sg2.id] + subnet_id = element( + aws_subnet.tf_test_subnet.*.id, + // count.index / var.web_cluster_size, + count.index + ) + user_data = file("web-userdata.sh") - tags { + tags = { Name = "web_node_${count.index}" } } data "template_file" "hapee-userdata" { - template = "${file("hapee-userdata.sh.tpl")}" + template = file("hapee-userdata.sh.tpl") - vars { - serverlist = "${join("\n", formatlist(" server app-%v %v:80 cookie app-%v check", aws_instance.web_node.*.id, aws_instance.web_node.*.private_ip, aws_instance.web_node.*.id))}" + vars = { + serverlist = join( + "\n", + formatlist( + " server app-%v %v:80 cookie app-%v check", + aws_instance.web_node.*.id, + aws_instance.web_node.*.private_ip, + aws_instance.web_node.*.id, + ), + ) } } resource "aws_instance" "hapee_node" { - count = "${var.hapee_cluster_size * var.aws_az_count}" + count = var.hapee_cluster_size * var.aws_az_count - instance_type = "${var.aws_hapee_instance_type}" + instance_type = var.aws_hapee_instance_type - ami = "${lookup(var.hapee_aws_amis, var.aws_region)}" + ami = var.hapee_aws_amis[var.aws_region] - key_name = "${var.key_name}" + key_name = var.key_name - vpc_security_group_ids = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.instance_sg2.id}"] - subnet_id = "${element(aws_subnet.tf_test_subnet.*.id, count.index / var.hapee_cluster_size)}" - user_data = "${data.template_file.hapee-userdata.rendered}" + vpc_security_group_ids = [aws_security_group.instance_sg1.id, aws_security_group.instance_sg2.id] + subnet_id = element( + aws_subnet.tf_test_subnet.*.id, + // count.index / var.hapee_cluster_size, + count.index, + ) + user_data = data.template_file.hapee-userdata.rendered - tags { + tags = { Name = "hapee_node_${count.index}" } } diff --git a/aws_alb/outputs.tf b/aws_alb/outputs.tf index f7851c1..e6bab7f 100644 --- a/aws_alb/outputs.tf +++ b/aws_alb/outputs.tf @@ -1,23 +1,49 @@ -output "AWS availability zones in use" { - value = "${aws_subnet.tf_test_subnet.*.availability_zone}" +output "aws_availability_zones_in_use" { + description = "AWS availability zones in use" + value = aws_subnet.tf_test_subnet.*.availability_zone } -output "HAPEE nodes" { - value = "${formatlist("%s, private IP: %s, public IP: %s, AZ: %s", aws_instance.hapee_node.*.id, aws_instance.hapee_node.*.private_ip, aws_instance.hapee_node.*.public_ip, aws_instance.hapee_node.*.availability_zone)}" +output "hapee_nodes" { + description = "HAPEE nodes" + value = formatlist( + "%s, private IP: %s, public IP: %s, AZ: %s", + aws_instance.hapee_node.*.id, + aws_instance.hapee_node.*.private_ip, + aws_instance.hapee_node.*.public_ip, + aws_instance.hapee_node.*.availability_zone, + ) } -output "Web node private IPs" { - value = "${formatlist("%s, private IP: %s, public IP: %s, AZ: %s", aws_instance.web_node.*.id, aws_instance.web_node.*.private_ip, aws_instance.web_node.*.public_ip, aws_instance.web_node.*.availability_zone)}" +output "web_node_private_ips" { + description = "Web node private IPs" + value = formatlist( + "%s, private IP: %s, public IP: %s, AZ: %s", + aws_instance.web_node.*.id, + aws_instance.web_node.*.private_ip, + aws_instance.web_node.*.public_ip, + aws_instance.web_node.*.availability_zone, + ) } -output "ALB DNS address" { - value = "${aws_lb.hapee_alb.dns_name}" +output "alb_dns_address" { + description = "ALB DNS address" + value = aws_lb.hapee_alb.dns_name } -output "ALB target group" { - value = "${aws_instance.hapee_node.*.id}" +output "alb_target_group" { + description = "ALB target group" + value = aws_instance.hapee_node.*.id } -output "HAPEE backend server list" { - value = "${join("\n", formatlist(" server app-%v %v:80 cookie app-%v check", aws_instance.web_node.*.id, aws_instance.web_node.*.private_ip, aws_instance.web_node.*.id))}" +output "hapee_backend_server_list" { + description = "HAPEE backend server list" + value = join( + "\n", + formatlist( + " server app-%v %v:80 cookie app-%v check", + aws_instance.web_node.*.id, + aws_instance.web_node.*.private_ip, + aws_instance.web_node.*.id, + ), + ) } diff --git a/aws_alb/variables.tf b/aws_alb/variables.tf index 6460b34..a44037f 100644 --- a/aws_alb/variables.tf +++ b/aws_alb/variables.tf @@ -1,35 +1,42 @@ variable "aws_region" { description = "Home AWS region" + type = string default = "us-east-1" } variable "aws_az_count" { description = "Number of AZs to cover in a given AWS region" - default = "2" + type = number + default = 2 } variable "aws_hapee_instance_type" { description = "Default AWS instance type for HAPEE nodes" + type = string default = "t3.small" } variable "aws_web_instance_type" { description = "Default AWS instance type for Web nodes" + type = string default = "t3.small" } variable "key_name" { description = "SSH key pair to use in AWS" + type = string default = "hapee-test" } variable "hapee_cluster_size" { description = "Size of HAPEE nodes cluster" + type = number default = 2 } variable "web_cluster_size" { description = "Size of Web nodes cluster" + type = number default = 3 } diff --git a/aws_alb/versions.tf b/aws_alb/versions.tf new file mode 100644 index 0000000..d9b6f79 --- /dev/null +++ b/aws_alb/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/aws_elb/main.tf b/aws_elb/main.tf index 1ec3d84..cddc2bb 100644 --- a/aws_elb/main.tf +++ b/aws_elb/main.tf @@ -1,56 +1,56 @@ provider "aws" { - region = "${var.aws_region}" + region = var.aws_region } resource "aws_vpc" "default" { cidr_block = "20.0.0.0/16" enable_dns_hostnames = true - tags { + tags = { Name = "hapee_test_vpc" } } resource "aws_subnet" "tf_test_subnet" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id cidr_block = "20.0.0.0/24" map_public_ip_on_launch = true - tags { + tags = { Name = "hapee_test_subnet" } } resource "aws_internet_gateway" "gw" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id - tags { + tags = { Name = "hapee_test_ig" } } resource "aws_route_table" "r" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id route { cidr_block = "0.0.0.0/0" - gateway_id = "${aws_internet_gateway.gw.id}" + gateway_id = aws_internet_gateway.gw.id } - tags { + tags = { Name = "aws_route_table" } } resource "aws_route_table_association" "a" { - subnet_id = "${aws_subnet.tf_test_subnet.id}" - route_table_id = "${aws_route_table.r.id}" + subnet_id = aws_subnet.tf_test_subnet.id + route_table_id = aws_route_table.r.id } resource "aws_security_group" "instance_sg1" { name = "instance_sg1" description = "Instance (HAPEE/Web node) SG to pass tcp/22 by default" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 22 @@ -72,20 +72,20 @@ resource "aws_security_group" "instance_sg1" { resource "aws_security_group" "instance_sg2" { name = "instance_sg2" description = "Instance (HAPEE/Web node) SG to pass ELB traffic by default" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 80 to_port = 80 protocol = "tcp" - security_groups = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.elb.id}"] + security_groups = [aws_security_group.instance_sg1.id, aws_security_group.elb.id] } ingress { from_port = 8080 to_port = 8080 protocol = "tcp" - security_groups = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.elb.id}"] + security_groups = [aws_security_group.instance_sg1.id, aws_security_group.elb.id] } } @@ -93,7 +93,7 @@ resource "aws_security_group" "elb" { name = "elb_sg" description = "Used in the terraform" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 80 @@ -109,15 +109,15 @@ resource "aws_security_group" "elb" { cidr_blocks = ["0.0.0.0/0"] } - depends_on = ["aws_internet_gateway.gw"] + depends_on = [aws_internet_gateway.gw] } resource "aws_elb" "hapee_elb" { name = "hapee-test-elb" - subnets = ["${aws_subnet.tf_test_subnet.id}"] + subnets = [aws_subnet.tf_test_subnet.id] - security_groups = ["${aws_security_group.elb.id}"] + security_groups = [aws_security_group.elb.id] listener { instance_port = 80 @@ -134,62 +134,70 @@ resource "aws_elb" "hapee_elb" { interval = 30 } - instances = ["${aws_instance.hapee_node.*.id}"] + instances = aws_instance.hapee_node.*.id cross_zone_load_balancing = false idle_timeout = 400 connection_draining = true connection_draining_timeout = 400 - tags { + tags = { Name = "hapee_elb" } } resource "aws_proxy_protocol_policy" "proxy_http" { - load_balancer = "${aws_elb.hapee_elb.name}" + load_balancer = aws_elb.hapee_elb.name instance_ports = ["80"] } resource "aws_instance" "web_node" { - count = "${var.web_cluster_size}" + count = var.web_cluster_size - instance_type = "${var.aws_web_instance_type}" + instance_type = var.aws_web_instance_type - ami = "${lookup(var.ubuntu_aws_amis, var.aws_region)}" + ami = var.ubuntu_aws_amis[var.aws_region] - key_name = "${var.key_name}" + key_name = var.key_name - vpc_security_group_ids = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.instance_sg2.id}"] - subnet_id = "${aws_subnet.tf_test_subnet.id}" - user_data = "${file("web-userdata.sh")}" + vpc_security_group_ids = [aws_security_group.instance_sg1.id, aws_security_group.instance_sg2.id] + subnet_id = aws_subnet.tf_test_subnet.id + user_data = file("web-userdata.sh") - tags { + tags = { Name = "web_node_${count.index}" } } data "template_file" "hapee-userdata" { - template = "${file("hapee-userdata.sh.tpl")}" - - vars { - serverlist = "${join("\n", formatlist(" server app-%v %v:80 cookie app-%v check", aws_instance.web_node.*.id, aws_instance.web_node.*.private_ip, aws_instance.web_node.*.id))}" + template = file("hapee-userdata.sh.tpl") + + vars = { + serverlist = join( + "\n", + formatlist( + " server app-%v %v:80 cookie app-%v check", + aws_instance.web_node.*.id, + aws_instance.web_node.*.private_ip, + aws_instance.web_node.*.id, + ), + ) } } resource "aws_instance" "hapee_node" { - count = "${var.hapee_cluster_size}" + count = var.hapee_cluster_size - instance_type = "${var.aws_hapee_instance_type}" + instance_type = var.aws_hapee_instance_type - ami = "${lookup(var.hapee_aws_amis, var.aws_region)}" + ami = var.hapee_aws_amis[var.aws_region] - key_name = "${var.key_name}" + key_name = var.key_name - vpc_security_group_ids = ["${aws_security_group.instance_sg1.id}", "${aws_security_group.instance_sg2.id}"] - subnet_id = "${aws_subnet.tf_test_subnet.id}" - user_data = "${data.template_file.hapee-userdata.rendered}" + vpc_security_group_ids = [aws_security_group.instance_sg1.id, aws_security_group.instance_sg2.id] + subnet_id = aws_subnet.tf_test_subnet.id + user_data = data.template_file.hapee-userdata.rendered - tags { + tags = { Name = "hapee_node_${count.index}" } } diff --git a/aws_elb/outputs.tf b/aws_elb/outputs.tf index 8f5bf25..5c78cda 100644 --- a/aws_elb/outputs.tf +++ b/aws_elb/outputs.tf @@ -1,19 +1,24 @@ -output "HAPEE nodes private IPs" { - value = "${aws_instance.hapee_node.*.private_ip}" +output "hapee_node_private_ips" { + description = "HAPEE nodes private IPs" + value = aws_instance.hapee_node.*.private_ip } -output "HAPEE node public IPs" { - value = "${aws_instance.hapee_node.*.public_ip}" +output "hapee_node_public_ips" { + description = "HAPEE nodes public IPs" + value = aws_instance.hapee_node.*.public_ip } -output "Web node private IPs" { - value = "${aws_instance.web_node.*.private_ip}" +output "web_node_private_ips" { + description = "Web node private IPs" + value = aws_instance.web_node.*.private_ip } -output "Web node public IPs" { - value = "${aws_instance.web_node.*.public_ip}" +output "web_node_public_ips" { + description = "Web node public IPs" + value = aws_instance.web_node.*.public_ip } -output "ELB DNS address" { - value = "${aws_elb.hapee_elb.dns_name}" +output "elb_dns_address" { + description = "ELB DNS address" + value = aws_elb.hapee_elb.dns_name } diff --git a/aws_elb/variables.tf b/aws_elb/variables.tf index abbb1fb..4840c7d 100644 --- a/aws_elb/variables.tf +++ b/aws_elb/variables.tf @@ -1,30 +1,36 @@ variable "aws_region" { description = "Home AWS region" + type = string default = "us-east-1" } variable "aws_hapee_instance_type" { description = "Default AWS instance type for HAPEE nodes" + type = string default = "t3.small" } variable "aws_web_instance_type" { description = "Default AWS instance type for Web nodes" + type = string default = "t3.small" } variable "key_name" { description = "SSH key pair to use in AWS" + type = string default = "hapee-test" } variable "hapee_cluster_size" { description = "Size of HAPEE nodes cluster" + type = number default = 2 } variable "web_cluster_size" { description = "Size of Web nodes cluster" + type = number default = 3 } diff --git a/aws_elb/versions.tf b/aws_elb/versions.tf new file mode 100644 index 0000000..d9b6f79 --- /dev/null +++ b/aws_elb/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/aws_heartbeat/main.tf b/aws_heartbeat/main.tf index 996a580..24a5bea 100644 --- a/aws_heartbeat/main.tf +++ b/aws_heartbeat/main.tf @@ -4,24 +4,25 @@ // file 'LICENSE.txt', which is part of this source code package. // provider "aws" { - region = "${var.aws_region}" + region = var.aws_region } // Lookup latest HAPEE AWS AMI (1.8r1 at this moment) data "aws_ami" "hapee_aws_amis" { most_recent = true - filter { - name = "product-code" - values = ["483gxnuft87jy44d3q8n4kvt1"] - } + // filter { + // name = "product-code" + // values = ["483gxnuft87jy44d3q8n4kvt1"] + // } filter { name = "name" values = ["hapee-ubuntu-xenial-amd64-hvm-1.8*"] } - owners = ["aws-marketplace"] + # Source: 123832860963/hapee-ubuntu-xenial-amd64-hvm-1.8r1-20180516 + owners = ["123832860963"] } // Lookup latest Ubuntu Xenial 16.04 AMI @@ -41,56 +42,56 @@ resource "aws_vpc" "default" { cidr_block = "20.0.0.0/16" enable_dns_hostnames = true - tags { + tags = { Name = "hapee_test_vpc" } } // Default subnet definition; in real world this sould span over at least two AZ resource "aws_subnet" "tf_test_subnet" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id cidr_block = "20.0.0.0/24" map_public_ip_on_launch = true - tags { + tags = { Name = "hapee_test_subnet" } } // Define our IGW resource "aws_internet_gateway" "gw" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id - tags { + tags = { Name = "hapee_test_ig" } } // Define our standard routing table resource "aws_route_table" "r" { - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id route { cidr_block = "0.0.0.0/0" - gateway_id = "${aws_internet_gateway.gw.id}" + gateway_id = aws_internet_gateway.gw.id } - tags { + tags = { Name = "hapee_test_route_table" } } // Routing table association for default subnet resource "aws_route_table_association" "a" { - subnet_id = "${aws_subnet.tf_test_subnet.id}" - route_table_id = "${aws_route_table.r.id}" + subnet_id = aws_subnet.tf_test_subnet.id + route_table_id = aws_route_table.r.id } // Security group for Web backends resource "aws_security_group" "web_node_sg" { name = "web_node_sg" description = "Instance Web SG: pass SSH, permit HTTP only from HAPEE" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 22 @@ -104,7 +105,7 @@ resource "aws_security_group" "web_node_sg" { from_port = 80 to_port = 80 protocol = "tcp" - security_groups = ["${aws_security_group.hapee_node_sg.id}"] + security_groups = [aws_security_group.hapee_node_sg.id] } egress { @@ -115,7 +116,7 @@ resource "aws_security_group" "web_node_sg" { self = true } - tags { + tags = { Name = "hapee_web_node_sg" } } @@ -124,7 +125,7 @@ resource "aws_security_group" "web_node_sg" { resource "aws_security_group" "hapee_node_sg" { name = "hapee_node_sg" description = "Instance HAPEE SG: pass SSH, HTTP, HTTPS and Dashboard traffic by default" - vpc_id = "${aws_vpc.default.id}" + vpc_id = aws_vpc.default.id ingress { from_port = 3 @@ -189,7 +190,7 @@ resource "aws_security_group" "hapee_node_sg" { self = true } - tags { + tags = { Name = "hapee_node_sg" } } @@ -230,33 +231,33 @@ data "aws_iam_policy_document" "eip_policy" { // IAM role - EIP role resource "aws_iam_role" "eip_role" { name = "hapee_eip_role" - assume_role_policy = "${data.aws_iam_policy_document.instance_assume_role_policy.json}" + assume_role_policy = data.aws_iam_policy_document.instance_assume_role_policy.json } // IAM role policy - EIP role policy resource "aws_iam_role_policy" "eip_role_policy" { name = "hapee_eip_role_policy" - role = "${aws_iam_role.eip_role.id}" - policy = "${data.aws_iam_policy_document.eip_policy.json}" + role = aws_iam_role.eip_role.id + policy = data.aws_iam_policy_document.eip_policy.json } // IAM instance profile - EIP instance profile resource "aws_iam_instance_profile" "eip_instance_profile" { name = "hapee_instance_profile" - role = "${aws_iam_role.eip_role.id}" + role = aws_iam_role.eip_role.id } // Instance definition for Web backends // Variable instance count resource "aws_instance" "web_node" { - count = "${var.web_cluster_size}" + count = var.web_cluster_size - instance_type = "${var.aws_web_instance_type}" - ami = "${data.aws_ami.ubuntu_aws_amis.id}" - key_name = "${var.key_name}" + instance_type = var.aws_web_instance_type + ami = data.aws_ami.ubuntu_aws_amis.id + key_name = var.key_name - vpc_security_group_ids = ["${aws_security_group.web_node_sg.id}"] - subnet_id = "${aws_subnet.tf_test_subnet.id}" + vpc_security_group_ids = [aws_security_group.web_node_sg.id] + subnet_id = aws_subnet.tf_test_subnet.id user_data = <