What is the way of execute a sh script into ec2 instance when terraform is building resources? I created an ami with some files in directory for execute, if i enter via ssh i can execute file as follow:
sh /home/resources/wso/bin/wso.sh
I have a start.tpl file with follow content:
#!/bin/bash
# update ubuntu
sudo apt-get update
# install nginx
sudo apt-get install nginx -y
sudo service nginx start
#start wso2
sh /home/resources/wso/bin/wso.sh
In my main.tf i have this:
data "template_file" "start" {
template = "${file("start.tpl")}"
}
resource "aws_instance" "wnginx" {
ami = "${var.instance_ami}"
instance_type = "${var.instance_type}"
user_data = "${data.template_file.start.rendered}"
}
Nginx start good, but my start script wso.sh can't start.
Exist some configuration of terraform for debug my start.tpl?