Following is .tf script
resource "aws_instance" "zk" {
ami = var.ami_id_zk
instance_type = var.instance_type
count = "1"
vpc_security_group_ids=[aws_security_group.allow_ssh.id]
key_name = var.key_name
subnet_id = aws_subnet.public_1.id
tags = {
Name = "Zookeper"
user_data = file("test.sh")
}
}
This is a terraform file and in user_data = file("test.sh") the test sh looks like this
#! /bin/sh
sudo apt-get update -y
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
Expected result : it should launch a instance with docker already installed , but unfortunately every time I run the script docker is not getting installed and I have to do it manually
Can anybody help me where I am lacking ?