From 46b41bc256eed94d44234d0ad2f905e85063747c Mon Sep 17 00:00:00 2001 From: Jason Paul Deland <9366595+jaydeland@users.noreply.github.com> Date: Tue, 21 Jun 2022 16:09:11 -0400 Subject: [PATCH] update hashistack demo for current versions of Terraform Replace deprecated `template` block with `templatefile` function --- .../aws/modules/hashistack/hashistack.tf | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/terraform/aws/modules/hashistack/hashistack.tf b/terraform/aws/modules/hashistack/hashistack.tf index 476eada50..9def08e75 100644 --- a/terraform/aws/modules/hashistack/hashistack.tf +++ b/terraform/aws/modules/hashistack/hashistack.tf @@ -93,7 +93,7 @@ resource "aws_security_group" "primary" { security_groups = [aws_security_group.server_lb.id] } - # Fabio + # Fabio ingress { from_port = 9998 to_port = 9999 @@ -157,37 +157,6 @@ resource "aws_security_group" "primary" { } } -data "template_file" "user_data_server" { - template = file("${path.root}/user-data-server.sh") - - vars = { - server_count = var.server_count - region = var.region - retry_join = chomp( - join( - " ", - formatlist("%s=%s", keys(var.retry_join), values(var.retry_join)), - ), - ) - nomad_binary = var.nomad_binary - } -} - -data "template_file" "user_data_client" { - template = file("${path.root}/user-data-client.sh") - - vars = { - region = var.region - retry_join = chomp( - join( - " ", - formatlist("%s=%s ", keys(var.retry_join), values(var.retry_join)), - ), - ) - nomad_binary = var.nomad_binary - } -} - resource "aws_instance" "server" { ami = var.ami instance_type = var.server_instance_type @@ -211,7 +180,19 @@ resource "aws_instance" "server" { delete_on_termination = "true" } - user_data = data.template_file.user_data_server.rendered + user_data = templatefile("${path.root}/user-data-server.sh", + { + server_count = var.server_count + region = var.region + retry_join = chomp( + join( + " ", + formatlist("%s=%s", keys(var.retry_join), values(var.retry_join)), + ), + ) + nomad_binary = var.nomad_binary + } + ) iam_instance_profile = aws_iam_instance_profile.instance_profile.name } @@ -246,7 +227,18 @@ resource "aws_instance" "client" { delete_on_termination = "true" } - user_data = data.template_file.user_data_client.rendered + user_data = templatefile("${path.root}/user-data-client.sh", + { + region = var.region + retry_join = chomp( + join( + " ", + formatlist("%s=%s ", keys(var.retry_join), values(var.retry_join)), + ), + ) + nomad_binary = var.nomad_binary + } + ) iam_instance_profile = aws_iam_instance_profile.instance_profile.name }