Pass ip adress to user data that contains a bash script

Hey guys! I am trying to run a bash script in user_data that prompts the user for a domain

if [ -z $1 ]
echo ""
printf "Enter the domain you want to host BookStack and press [ENTER]\nExamples: or\n"

I would like to pass my EIP, as an input to the script.

Here is the actual commands that are run in the user_data section.

      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

      # Make it executable
      chmod a+x

      # Run the script with admin permissions
      sudo ./ $ (this is where I would like to pass my eip variable) 

Thanks for your help!

Depending on how user_data is embedded within the terraform code, there a different options. You could utilise templatefile() or in case of an inline definition, just add the variable as an argument:

user_data = <<USERDATA
        .... script ...
       sudo ${aws_eip.myeip.public_ip}