Hey guys! I have successfully deployed an EC2 instance using terraform and now working on installing a Bookstacks wiki onto the server. The purpose is to have bookstacks automatically installed when the instance has been deployed. I am using the script that was provided by Bookstacks and have manually tested the script, it works.
Here is the script in the user_data section that i want to run automatically.
resource "aws_instance" "web-server-instance" {
ami = "ami-0e472ba40eb589f49"
instance_type ="t2.micro"
availability_zone = "us-east-1a"
key_name = "Main-key"
network_interface {
device_index = 0
network_interface_id = aws_network_interface.web-server-nic.id
}
user_data= <<-EOF
#!/bin/bash
# Ensure you have read the above information about what this script does before executing these commands.
sudo apt install wget
# Download the script
wget https://raw.githubusercontent.com/BookStackApp/devops/main/scripts/installation-ubuntu-18.04.sh
# Make it executable
chmod a+x installation-ubuntu-18.04.sh
# Run the script with admin permissions
sudo ./installation-ubuntu-18.04.sh
EOF
tags ={
Name ="bookstacks_terraform"
}
}
Unfortunately, This is not working and I am not sure how to fix this. Any help would be appreciate. Thanks:)