update hashistack demo for current versions of Terraform

Replace deprecated `template` block with `templatefile` function
This commit is contained in:
Jason Paul Deland
2022-06-21 16:09:11 -04:00
committed by GitHub
parent 009a4d9a85
commit 46b41bc256

View File

@@ -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
}