I am trying to set environment variables with EC2s user data, but nothing i do seems to work
here are the User data scripts i tried
#!/b
The user data script on EC2 executes at after boot in its own process. The environment variables get set in that process and disappear when the process exits. You will not see the environment variables in other processes, i.e., login shell or other programs for that matter.
You will have to devise a way to get these environment variables into whatever program needs to see them.
Where do you need these variables to be available? In /startup.sh staging 2649?
EDIT
Try this:
#!/bin/bash
set -e -x
export HOST_URL="checkEmai-LoadBala-ICHJ82KG5C7P-2141709021.us-east-1.elb.amazonaws.com"
/startup.sh staging 2649
Then edit /startup.sh, and put the following line on the top:
echo $HOST_URL > /tmp/var
Boot the instance, and then paste /tmp/var here.