Skip to content

Results of running terraform 0.12upgrade #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ before_script:
- export TF_VAR_region=${AWS_REGION}
- echo "using AWS_REGION=${AWS_REGION}"
- export TF_WARN_OUTPUT_ERRORS=1
- curl --silent --output terraform.zip https://releases.hashicorp.com/terraform/0.11.8/terraform_0.11.8_linux_amd64.zip
- sha256sum terraform.zip | grep "84ccfb8e13b5fce63051294f787885b76a1fedef6bdbecf51c5e586c9e20c9b7"
- curl --silent --output terraform.zip https://releases.hashicorp.com/terraform/0.12.6/terraform_0.12.6_linux_amd64.zip
- sha256sum terraform.zip | grep "6544eb55b3e916affeea0a46fe785329c36de1ba1bdb51ca5239d3567101876f"
- unzip terraform.zip ; rm -f terraform.zip; chmod +x terraform
- mkdir -p ${HOME}/bin ; export PATH=${PATH}:${HOME}/bin; mv terraform ${HOME}/bin/
- terraform -v
Expand Down
87 changes: 44 additions & 43 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "aws_vpc" "vpc" {
id = "${var.vpc_id}"
id = var.vpc_id
}

data "aws_region" "current" {}
Expand Down Expand Up @@ -44,27 +44,27 @@ data "aws_iam_policy_document" "policy_doc" {
}

data "template_file" "cloud-init" {
template = "${file("${path.module}/cloud-init.yaml")}"
template = file("${path.module}/cloud-init.yaml")

vars {
vars = {
sync_node_count = 3
asg_name = "${local.cluster_name}"
region = "${data.aws_region.current.name}"
admin_password = "${random_string.admin_password.result}"
rabbit_password = "${random_string.rabbit_password.result}"
secret_cookie = "${random_string.secret_cookie.result}"
message_timeout = "${3 * 24 * 60 * 60 * 1000}" # 3 days
asg_name = local.cluster_name
region = data.aws_region.current.name
admin_password = random_string.admin_password.result
rabbit_password = random_string.rabbit_password.result
secret_cookie = random_string.secret_cookie.result
message_timeout = 3 * 24 * 60 * 60 * 1000 # 3 days
}
}

resource "aws_iam_role" "role" {
name = "${local.cluster_name}"
assume_role_policy = "${data.aws_iam_policy_document.policy_doc.json}"
name = local.cluster_name
assume_role_policy = data.aws_iam_policy_document.policy_doc.json
}

resource "aws_iam_role_policy" "policy" {
name = "${local.cluster_name}"
role = "${aws_iam_role.role.id}"
name = local.cluster_name
role = aws_iam_role.role.id

policy = <<EOF
{
Expand All @@ -83,16 +83,17 @@ resource "aws_iam_role_policy" "policy" {
]
}
EOF

}

resource "aws_iam_instance_profile" "profile" {
name_prefix = "${local.cluster_name}"
role = "${aws_iam_role.role.name}"
name_prefix = local.cluster_name
role = aws_iam_role.role.name
}

resource "aws_security_group" "rabbitmq_elb" {
name = "rabbitmq_elb-${var.name}"
vpc_id = "${var.vpc_id}"
vpc_id = var.vpc_id
description = "Security Group for the rabbitmq elb"

egress {
Expand All @@ -102,14 +103,14 @@ resource "aws_security_group" "rabbitmq_elb" {
cidr_blocks = ["0.0.0.0/0"]
}

tags {
tags = {
Name = "rabbitmq ${var.name} ELB"
}
}

resource "aws_security_group" "rabbitmq_nodes" {
name = "${local.cluster_name}-nodes"
vpc_id = "${var.vpc_id}"
vpc_id = var.vpc_id
description = "Security Group for the rabbitmq nodes"

ingress {
Expand All @@ -123,14 +124,14 @@ resource "aws_security_group" "rabbitmq_nodes" {
protocol = "tcp"
from_port = 5672
to_port = 5672
security_groups = ["${aws_security_group.rabbitmq_elb.id}"]
security_groups = [aws_security_group.rabbitmq_elb.id]
}

ingress {
protocol = "tcp"
from_port = 15672
to_port = 15672
security_groups = ["${aws_security_group.rabbitmq_elb.id}"]
security_groups = [aws_security_group.rabbitmq_elb.id]
}

egress {
Expand All @@ -143,24 +144,24 @@ resource "aws_security_group" "rabbitmq_nodes" {
]
}

tags {
tags = {
Name = "rabbitmq ${var.name} nodes"
}
}

resource "aws_launch_configuration" "rabbitmq" {
name = "${local.cluster_name}"
image_id = "${data.aws_ami_ids.ami.ids[0]}"
instance_type = "${var.instance_type}"
key_name = "${var.ssh_key_name}"
security_groups = ["${aws_security_group.rabbitmq_nodes.id}", "${var.nodes_additional_security_group_ids}"]
iam_instance_profile = "${aws_iam_instance_profile.profile.id}"
user_data = "${data.template_file.cloud-init.rendered}"
name = local.cluster_name
image_id = data.aws_ami_ids.ami.ids[0]
instance_type = var.instance_type
key_name = var.ssh_key_name
security_groups = flatten([aws_security_group.rabbitmq_nodes.id, var.nodes_additional_security_group_ids])
iam_instance_profile = aws_iam_instance_profile.profile.id
user_data = data.template_file.cloud-init.rendered

root_block_device {
volume_type = "${var.instance_volume_type}"
volume_size = "${var.instance_volume_size}"
iops = "${var.instance_volume_iops}"
volume_type = var.instance_volume_type
volume_size = var.instance_volume_size
iops = var.instance_volume_iops
delete_on_termination = true
}

Expand All @@ -170,20 +171,20 @@ resource "aws_launch_configuration" "rabbitmq" {
}

resource "aws_autoscaling_group" "rabbitmq" {
name = "${local.cluster_name}"
min_size = "${var.min_size}"
desired_capacity = "${var.desired_size}"
max_size = "${var.max_size}"
name = local.cluster_name
min_size = var.min_size
desired_capacity = var.desired_size
max_size = var.max_size
health_check_grace_period = 300
health_check_type = "ELB"
force_delete = true
launch_configuration = "${aws_launch_configuration.rabbitmq.name}"
load_balancers = ["${aws_elb.elb.name}"]
vpc_zone_identifier = ["${var.subnet_ids}"]
launch_configuration = aws_launch_configuration.rabbitmq.name
load_balancers = [aws_elb.elb.name]
vpc_zone_identifier = var.subnet_ids

tag {
key = "Name"
value = "${local.cluster_name}"
value = local.cluster_name
propagate_at_launch = true
}
}
Expand Down Expand Up @@ -213,12 +214,12 @@ resource "aws_elb" "elb" {
target = "TCP:5672"
}

subnets = ["${var.subnet_ids}"]
subnets = var.subnet_ids
idle_timeout = 3600
internal = true
security_groups = ["${aws_security_group.rabbitmq_elb.id}", "${var.elb_additional_security_group_ids}"]
security_groups = flatten([aws_security_group.rabbitmq_elb.id, var.elb_additional_security_group_ids])

tags {
Name = "${local.cluster_name}"
tags = {
Name = local.cluster_name
}
}
9 changes: 5 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
output "rabbitmq_elb_dns" {
value = "${aws_elb.elb.dns_name}"
value = aws_elb.elb.dns_name
}

output "admin_password" {
value = "${random_string.admin_password.result}"
value = random_string.admin_password.result
sensitive = true
}

output "rabbit_password" {
value = "${random_string.rabbit_password.result}"
value = random_string.rabbit_password.result
sensitive = true
}

output "secret_cookie" {
value = "${random_string.secret_cookie.result}"
value = random_string.secret_cookie.result
sensitive = true
}

8 changes: 5 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variable "vpc_id" {}

variable "ssh_key_name" {}

variable "name" {
Expand All @@ -22,16 +23,16 @@ variable "max_size" {

variable "subnet_ids" {
description = "Subnets for RabbitMQ nodes"
type = "list"
type = list(string)
}

variable "nodes_additional_security_group_ids" {
type = "list"
type = list(string)
default = []
}

variable "elb_additional_security_group_ids" {
type = "list"
type = list(string)
default = []
}

Expand All @@ -50,3 +51,4 @@ variable "instance_volume_size" {
variable "instance_volume_iops" {
default = "0"
}

4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}