I am trying to use template file on remote-exec provisioner. But the problem is, it only execute the first command of the script. Can anyone help me on this?
resource "template_file" "user_data" {
template = "${file("${path.module}/userdata.sh.tpl")}"
vars {
foo = "${var.bar}"
}
}
resource "aws_instance" "test"{
ami = "${var.ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
subnet_id = "${var.subnet_id}"
provisioner "remote-exec" {
inline = ["${template_file.user_data.rendered}"]
connection {
user = "${var.user}"
type = "ssh"
private_key = "${file(var.private_key)}"
timeout = "2m"
}
}
}