From f3600546a1a87f08adc27bd929e174b0cc1faf47 Mon Sep 17 00:00:00 2001 From: Salim Chehab Date: Sat, 2 May 2020 12:08:43 +0200 Subject: [PATCH 1/5] Upgrades to terraform 0.12 --- aws_alb/main.tf | 119 +++++++++++++++++++++---------------- aws_alb/outputs.tf | 50 ++++++++++++---- aws_alb/versions.tf | 3 + aws_elb/main.tf | 92 +++++++++++++++------------- aws_elb/outputs.tf | 25 ++++---- aws_elb/versions.tf | 3 + aws_heartbeat/main.tf | 74 ++++++++++++----------- aws_heartbeat/outputs.tf | 30 ++++++---- aws_heartbeat/versions.tf | 3 + aws_keepalived/main.tf | 81 +++++++++++++------------ aws_keepalived/outputs.tf | 30 ++++++---- aws_keepalived/versions.tf | 3 + 12 files changed, 300 insertions(+), 213 deletions(-) create mode 100644 aws_alb/versions.tf create mode 100644 aws_elb/versions.tf create mode 100644 aws_heartbeat/versions.tf create mode 100644 aws_keepalived/versions.tf 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/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/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..eaed1d3 100644 --- a/aws_heartbeat/main.tf +++ b/aws_heartbeat/main.tf @@ -4,7 +4,7 @@ // 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) @@ -41,56 +41,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 +104,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 +115,7 @@ resource "aws_security_group" "web_node_sg" { self = true } - tags { + tags = { Name = "hapee_web_node_sg" } } @@ -124,7 +124,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 +189,7 @@ resource "aws_security_group" "hapee_node_sg" { self = true } - tags { + tags = { Name = "hapee_node_sg" } } @@ -230,33 +230,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 = < Date: Sat, 2 May 2020 12:08:58 +0200 Subject: [PATCH 2/5] Adds variable types --- aws_alb/variables.tf | 11 +++++++++-- aws_elb/variables.tf | 6 ++++++ aws_heartbeat/variables.tf | 5 +++++ aws_keepalived/variables.tf | 5 +++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/aws_alb/variables.tf b/aws_alb/variables.tf index 6460b34..169b2a0 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" - default = "hapee-test" + type = string + efault = "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/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_heartbeat/variables.tf b/aws_heartbeat/variables.tf index 31ed185..e3d0f98 100644 --- a/aws_heartbeat/variables.tf +++ b/aws_heartbeat/variables.tf @@ -1,29 +1,34 @@ // Set default AWS region. Pay attention to inventory/ec2.ini which should also use the same region. variable "aws_region" { description = "Home AWS region" + type = string default = "us-east-1" } // Default instance type for HAPEE LB instances. Obviously, something along m5.xlarge or c5.xlarge should be a perfect fit. variable "aws_hapee_instance_type" { description = "Default AWS instance type for HAPEE nodes" + type = string default = "t3.small" } // Default instance type for Web backends. Typically m5.4xlarge and similar, depending on use case. variable "aws_web_instance_type" { description = "Default AWS instance type for Web nodes" + type = string default = "t3.small" } // SSH pub key pair located on Amazon. Also set/used in ansible.cfg. variable "key_name" { description = "SSH key pair to use in AWS" + type = string default = "noprod-hapee-test" } // Typical size of Web cluster backends. It's reasonable to have more than 2. variable "web_cluster_size" { description = "Size of Web nodes cluster" + type = number default = 3 } diff --git a/aws_keepalived/variables.tf b/aws_keepalived/variables.tf index 31ed185..e3d0f98 100644 --- a/aws_keepalived/variables.tf +++ b/aws_keepalived/variables.tf @@ -1,29 +1,34 @@ // Set default AWS region. Pay attention to inventory/ec2.ini which should also use the same region. variable "aws_region" { description = "Home AWS region" + type = string default = "us-east-1" } // Default instance type for HAPEE LB instances. Obviously, something along m5.xlarge or c5.xlarge should be a perfect fit. variable "aws_hapee_instance_type" { description = "Default AWS instance type for HAPEE nodes" + type = string default = "t3.small" } // Default instance type for Web backends. Typically m5.4xlarge and similar, depending on use case. variable "aws_web_instance_type" { description = "Default AWS instance type for Web nodes" + type = string default = "t3.small" } // SSH pub key pair located on Amazon. Also set/used in ansible.cfg. variable "key_name" { description = "SSH key pair to use in AWS" + type = string default = "noprod-hapee-test" } // Typical size of Web cluster backends. It's reasonable to have more than 2. variable "web_cluster_size" { description = "Size of Web nodes cluster" + type = number default = 3 } From ac1dcecba63f88aa9e2177493e8d2037a964ce10 Mon Sep 17 00:00:00 2001 From: Salim Chehab Date: Sat, 2 May 2020 12:23:46 +0200 Subject: [PATCH 3/5] Corrects variable syntax typo --- aws_alb/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws_alb/variables.tf b/aws_alb/variables.tf index 169b2a0..cf38e23 100644 --- a/aws_alb/variables.tf +++ b/aws_alb/variables.tf @@ -25,7 +25,7 @@ variable "aws_web_instance_type" { variable "key_name" { description = "SSH key pair to use in AWS" type = string - efault = "hapee-test" + default = "hapee-test" } variable "hapee_cluster_size" { From 3f7caa083bef680604a631553146ae3366ee4931 Mon Sep 17 00:00:00 2001 From: Salim Chehab Date: Sat, 2 May 2020 12:25:12 +0200 Subject: [PATCH 4/5] Adjusts ami search criteria --- aws_heartbeat/main.tf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/aws_heartbeat/main.tf b/aws_heartbeat/main.tf index eaed1d3..5dc62df 100644 --- a/aws_heartbeat/main.tf +++ b/aws_heartbeat/main.tf @@ -11,17 +11,18 @@ provider "aws" { 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 From 96068d2172e635f0f571c4170fb5a761b6e4f2ac Mon Sep 17 00:00:00 2001 From: Salim Chehab Date: Sat, 2 May 2020 12:26:46 +0200 Subject: [PATCH 5/5] Applies terraform fmt --- aws_alb/variables.tf | 2 +- aws_heartbeat/main.tf | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aws_alb/variables.tf b/aws_alb/variables.tf index cf38e23..a44037f 100644 --- a/aws_alb/variables.tf +++ b/aws_alb/variables.tf @@ -25,7 +25,7 @@ variable "aws_web_instance_type" { variable "key_name" { description = "SSH key pair to use in AWS" type = string - default = "hapee-test" + default = "hapee-test" } variable "hapee_cluster_size" { diff --git a/aws_heartbeat/main.tf b/aws_heartbeat/main.tf index 5dc62df..24a5bea 100644 --- a/aws_heartbeat/main.tf +++ b/aws_heartbeat/main.tf @@ -11,10 +11,10 @@ provider "aws" { data "aws_ami" "hapee_aws_amis" { most_recent = true -// filter { -// name = "product-code" -// values = ["483gxnuft87jy44d3q8n4kvt1"] -// } + // filter { + // name = "product-code" + // values = ["483gxnuft87jy44d3q8n4kvt1"] + // } filter { name = "name"