I am deploying my code to AWS EC2. The documentation says there's something called "user data" or "user data scripts" that you can enter this info when you're launching an ec2 instance and the script will be executed at instance startup.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-shell-scripts
the following is in my user data script:
#!/bin/bash
echo 1111 >> /home/ubuntu/1111.txt
export MONGODB_HOST=www.mongodb.com
export MONGODB_PORT=12345
export MONGODB_USER=user
export MONGODB_PASS=pass
So when I launch the instance with this user data script I would expect to see the environment variables being set, but it didn't.
So is there something that I did wrong?
/var/lib/cloud/instance/user-data.txt
also I can get$user_data
variable withuser_data=
curl 169.254.169.254/latest/user-data` but I just cannot get them into environment variables.. (my node.js app reads credentials from env variables..)node server.js