Ver Fonte

remove all interpolation where not required

Chris Mague há 4 anos atrás
pai
commit
d60669eb35
5 ficheiros alterados com 47 adições e 50 exclusões
  1. 17 17
      instances.tf
  2. 2 2
      main.tf
  3. 12 15
      provisioning.tf
  4. 15 15
      security.tf
  5. 1 1
      variables.tf

+ 17 - 17
instances.tf

@@ -2,8 +2,8 @@ resource "aws_instance" "re" {
   count                  = var.data-node-count
   ami                    = data.aws_ami.re-ami.id
   instance_type          = var.re-instance-type
-  availability_zone      = "${element(var.vpc-azs, count.index)}"
-  subnet_id              = "${element(var.vpc-subnets, count.index)}"
+  availability_zone      = element(var.vpc-azs, count.index)
+  subnet_id              = element(var.vpc-subnets, count.index)
   vpc_security_group_ids = [aws_security_group.re.id]
   source_dest_check      = false
   key_name               = local.ssh_key
@@ -19,47 +19,47 @@ resource "aws_eip" "re-eip" {
 
 resource "aws_eip_association" "re-eip-assoc" {
   count         = var.data-node-count
-  instance_id   = "${element(aws_instance.re.*.id, count.index)}"
-  allocation_id = "${element(aws_eip.re-eip.*.id, count.index)}"
-  depends_on    = ["aws_instance.re", "aws_eip.re-eip"]
+  instance_id   = element(aws_instance.re.*.id, count.index)
+  allocation_id = element(aws_eip.re-eip.*.id, count.index)
+  depends_on    = [aws_instance.re, aws_eip.re-eip]
 }
 
 # Handle attaching volumes if enable-volumes is set (true by default)
 
 resource "aws_ebs_volume" "re-ephemeral" {
   count             = local.count_volumes
-  availability_zone = "${element(var.vpc-azs, count.index)}"
-  size              = "${var.re-volume-size}"
+  availability_zone = element(var.vpc-azs, count.index)
+  size              = var.re-volume-size
   tags              = merge({ Name = "ephemeral-${var.vpc-name}-${count.index}" }, var.common-tags)
 }
 
 resource "aws_volume_attachment" "re-ephemeral" {
   count       = local.count_volumes
   device_name = "/dev/sdh"
-  volume_id   = "${element(aws_ebs_volume.re-ephemeral.*.id, count.index)}"
-  instance_id = "${element(aws_instance.re.*.id, count.index)}"
+  volume_id   = element(aws_ebs_volume.re-ephemeral.*.id, count.index)
+  instance_id = element(aws_instance.re.*.id, count.index)
 }
 
 resource "aws_ebs_volume" "re-persistant" {
   count             = local.count_volumes
-  availability_zone = "${element(var.vpc-azs, count.index)}"
-  size              = "${var.re-volume-size}"
+  availability_zone = element(var.vpc-azs, count.index)
+  size              = var.re-volume-size
   tags              = merge({ Name = "persistant-${var.vpc-name}-${count.index}" }, var.common-tags)
 }
 
 resource "aws_volume_attachment" "re-persistant" {
   count       = local.count_volumes
   device_name = "/dev/sdj"
-  volume_id   = "${element(aws_ebs_volume.re-persistant.*.id, count.index)}"
-  instance_id = "${element(aws_instance.re.*.id, count.index)}"
+  volume_id   = element(aws_ebs_volume.re-persistant.*.id, count.index)
+  instance_id = element(aws_instance.re.*.id, count.index)
 }
 
 # Handle attaching volumes if enable-flash is set (false by default)
 
 resource "aws_ebs_volume" "re-flash" {
   count = local.count_flash
-  availability_zone = "${element(var.vpc-azs, count.index)}"
-  size              = "${var.re-volume-size}"
+  availability_zone = element(var.vpc-azs, count.index)
+  size              = var.re-volume-size
   type              = "gp2"
   tags              = merge({ Name = "flash-${var.vpc-name}-${count.index}" }, var.common-tags)
 }
@@ -67,6 +67,6 @@ resource "aws_ebs_volume" "re-flash" {
 resource "aws_volume_attachment" "re-flash" {
   count       = local.count_flash
   device_name = "/dev/sdi"
-  volume_id   = "${element(aws_ebs_volume.re-flash.*.id, count.index)}"
-  instance_id = "${element(aws_instance.re.*.id, count.index)}"
+  volume_id   = element(aws_ebs_volume.re-flash.*.id, count.index)
+  instance_id = element(aws_instance.re.*.id, count.index)
 }

+ 2 - 2
main.tf

@@ -1,6 +1,6 @@
 provider "aws" {
-  region  = "${var.region}"
-  profile = "${var.profile}"
+  region  = var.region
+  profile = var.profile
 }
 
 # Allow us to configure volumes

+ 12 - 15
provisioning.tf

@@ -5,13 +5,13 @@ resource "null_resource" "remote-config" {
   provisioner "remote-exec" {
     connection {
       user        = "ubuntu"
-      host        = "${element(aws_eip.re-eip.*.public_ip, count.index)}"
-      private_key = "${file(local.ssh_key_path)}"
+      host        = element(aws_eip.re-eip.*.public_ip, count.index)
+      private_key = file(local.ssh_key_path)
       agent       = true
     }
     inline = ["sudo apt update > /dev/null  && sudo apt install -y python python-pip > /dev/null"]
   }
-  depends_on = ["aws_instance.re", "aws_eip_association.re-eip-assoc", "null_resource.inventory-setup", "null_resource.ssh-setup"]
+  depends_on = [aws_instance.re, aws_eip_association.re-eip-assoc, null_resource.inventory-setup, null_resource.ssh-setup]
 }
 
 ###############################################################################
@@ -20,19 +20,19 @@ data "template_file" "ansible_inventory" {
   count    = var.data-node-count
   template = "${file("${path.module}/inventory.tpl")}"
   vars = {
-    host_ip  = "${element(aws_eip.re-eip.*.public_ip, count.index)}"
-    vpc_name = "${var.vpc-name}"
-    ncount   = "${count.index}"
+    host_ip  = element(aws_eip.re-eip.*.public_ip, count.index)
+    vpc_name = var.vpc-name
+    ncount   = count.index
   }
-  depends_on = ["aws_instance.re", "aws_eip_association.re-eip-assoc", "aws_volume_attachment.re-ephemeral"]
+  depends_on = [aws_instance.re, aws_eip_association.re-eip-assoc, aws_volume_attachment.re-ephemeral]
 }
 
 data "template_file" "ssh_config" {
   template = "${file("${path.module}/ssh.tpl")}"
   vars = {
-    vpc_name = "${var.vpc-name}"
+    vpc_name = var.vpc-name
   }
-  depends_on = ["aws_instance.re", "aws_eip_association.re-eip-assoc", "aws_volume_attachment.re-ephemeral"]
+  depends_on = [aws_instance.re, aws_eip_association.re-eip-assoc, aws_volume_attachment.re-ephemeral]
 }
 
 ###############################################################################
@@ -42,14 +42,14 @@ resource "null_resource" "inventory-setup" {
   provisioner "local-exec" {
     command = "echo \"${element(data.template_file.ansible_inventory.*.rendered, count.index)}\" > /tmp/${var.vpc-name}_node_${count.index}.ini"
   }
-  depends_on = ["data.template_file.ansible_inventory"]
+  depends_on = [data.template_file.ansible_inventory]
 }
 
 resource "null_resource" "ssh-setup" {
   provisioner "local-exec" {
     command = "echo \"${data.template_file.ssh_config.rendered}\" > /tmp/${var.vpc-name}_node.cfg"
   }
-  depends_on = ["data.template_file.ssh_config"]
+  depends_on = [data.template_file.ssh_config]
 }
 
 ###############################################################################
@@ -59,8 +59,5 @@ resource "null_resource" "ansible-run" {
   provisioner "local-exec" {
     command = "ansible-playbook ${path.module}/ansible/playbook.yml --private-key ${local.ssh_key_path} -i /tmp/${var.vpc-name}_node_${count.index}.ini --become -e 'ENABLE_VOLUMES=${var.enable-volumes}'"
   }
-  depends_on = ["null_resource.remote-config"]
+  depends_on = [null_resource.remote-config]
 }
-
-
-

+ 15 - 15
security.tf

@@ -1,28 +1,28 @@
 resource "aws_security_group" "re" {
   name        = "RedisEnterprise"
   description = "Redis Enterprise Security Group"
-  vpc_id      = "${var.vpc-id}"
+  vpc_id      = var.vpc-id
   tags        = merge({ Name = "RedisEnterprise-${var.vpc-name}" }, var.common-tags)
 }
 
 resource "aws_security_group_rule" "internal_rules" {
   count             = length(var.internal-rules)
-  type              = "${lookup(var.internal-rules[count.index], "type")}"
-  from_port         = "${lookup(var.internal-rules[count.index], "from_port")}"
-  to_port           = "${lookup(var.internal-rules[count.index], "to_port")}"
-  protocol          = "${lookup(var.internal-rules[count.index], "protocol")}"
+  type              = lookup(var.internal-rules[count.index], "type")
+  from_port         = lookup(var.internal-rules[count.index], "from_port")
+  to_port           = lookup(var.internal-rules[count.index], "to_port")
+  protocol          = lookup(var.internal-rules[count.index], "protocol")
   cidr_blocks       = [var.vpc-cidr]
-  security_group_id = "${aws_security_group.re.id}"
+  security_group_id = aws_security_group.re.id
 }
 
 resource "aws_security_group_rule" "external_rules" {
   count             = length(var.external-rules)
-  type              = "${lookup(var.external-rules[count.index], "type")}"
-  from_port         = "${lookup(var.external-rules[count.index], "from_port")}"
-  to_port           = "${lookup(var.external-rules[count.index], "to_port")}"
-  protocol          = "${lookup(var.external-rules[count.index], "protocol")}"
-  cidr_blocks       = "${lookup(var.external-rules[count.index], "cidr")}"
-  security_group_id = "${aws_security_group.re.id}"
+  type              = lookup(var.external-rules[count.index], "type")
+  from_port         = lookup(var.external-rules[count.index], "from_port")
+  to_port           = lookup(var.external-rules[count.index], "to_port")
+  protocol          = lookup(var.external-rules[count.index], "protocol")
+  cidr_blocks       = lookup(var.external-rules[count.index], "cidr")
+  security_group_id = aws_security_group.re.id
 }
 
 resource "aws_security_group_rule" "open_nets" {
@@ -31,7 +31,7 @@ resource "aws_security_group_rule" "open_nets" {
   to_port           = "65535"
   protocol          = "all"
   cidr_blocks       = var.open-nets
-  security_group_id = "${aws_security_group.re.id}"
+  security_group_id = aws_security_group.re.id
 }
 
 resource "aws_security_group_rule" "allow_public_ssh" {
@@ -41,5 +41,5 @@ resource "aws_security_group_rule" "allow_public_ssh" {
   to_port           = "22"
   protocol          = "all"
   cidr_blocks       = ["0.0.0.0/0"]
-  security_group_id = "${aws_security_group.re.id}"
-}
+  security_group_id = aws_security_group.re.id
+}

+ 1 - 1
variables.tf

@@ -68,7 +68,7 @@ variable "enable-flash" {
 
 variable "enable-volumes" {
   description = "Enable EBS Devices for Ephemeral and Persistent storage"
-  default     = false
+  default     = true
 }
 
 variable "flash-iops" {