Parcourir la source

setup initial provisioning

Chris Mague il y a 6 ans
Parent
commit
bd6242f588
2 fichiers modifiés avec 25 ajouts et 1 suppressions
  1. 12 1
      instances.tf
  2. 13 0
      provisioning.tf

+ 12 - 1
instances.tf

@@ -7,7 +7,7 @@ resource "aws_instance" "re" {
   vpc_security_group_ids = [aws_security_group.re.id]
   source_dest_check      = false
   key_name               = "${var.vpc-name}"
-  tags                   = merge({ Name = "${var.vpc-name}-private-${element(var.vpc-azs, count.index)}" }, var.common-tags)
+  tags                   = merge({ Name = "RedisEnterprise-${var.vpc-name}-${count.index}" }, var.common-tags)
 
 }
 
@@ -37,3 +37,14 @@ resource "aws_volume_attachment" "re-persistant" {
   instance_id = "${element(aws_instance.re.*.id, count.index)}"
 }
 
+resource "aws_eip" "re-eip" {
+  vpc   = true
+  count = var.data-node-count
+  tags  = merge({ Name = "${var.vpc-name}-node-eip-${count.index}" }, var.common-tags)
+}
+
+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)}"
+}

+ 13 - 0
provisioning.tf

@@ -0,0 +1,13 @@
+resource "null_resource" "remote-config" {
+  count = var.data-node-count
+  provisioner "remote-exec" {
+    connection {
+      user        = "ubuntu"
+      host        = "${element(aws_instance.re.*.public_ip, count.index)}"
+      private_key = "${file("~/.ssh/${var.vpc-name}.pem")}"
+      agent       = true
+    }
+    inline = ["hostname"]
+  }
+  depends_on = ["aws_instance.re", "aws_eip_association.re-eip-assoc"]
+}