Reputation: 41
I am trying to run a bash script file in user_data that prompts the user for a domain. Here is the domain part of the commands that are of .sh file itself.
DOMAIN=$1
if [ -z $1 ]
then
echo ""
printf "Enter the domain you want to host BookStack and press [ENTER]\nExamples: my-site.com or docs.my-site.com\n"
read DOMAIN
fi
I would like to pass my EIP, aws_eip.one.public_ip as an input to the script.
Here is the actual commands that are run in the user_data section.
#!/bin/bash
sudo apt install wget
# Ensure you have read the above information about what this script does before executing these commands.
sudo apt install -y 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 $ (this is where I would like to pass my eip variable)
Appreciate the help!
Upvotes: 1
Views: 655
Reputation: 238279
Get the IP from the ec2 metadata in your user data:
curl http://169.254.169.254/latest/meta-data/public-ipv4
Upvotes: 3