Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Running a Bash Script in terraform user_data

I am using Terraform to deploy EC2 instance and install boostacks wiki on it. Bookstack offers a bash script that automatically installs the files on the ubuntu server however, when i run the script in the user_data nothing happens. I am not sure why? Here is the user_Data code

user_data= <<-EOF
      # 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"
}

When the script has run successfully, the user should be prompted to enter the domain. However, nothing happens and I dont know how to test it.

like image 820
Karthik Thovinakere Avatar asked Jun 27 '26 07:06

Karthik Thovinakere


1 Answers

Your apt will hang for your confirmation. You forgot about -y:

sudo apt install -y wget
like image 55
Marcin Avatar answered Jun 30 '26 06:06

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!