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
You can add another shell script in /etc/profile.d/yourscript.sh which will contain the set of environment variables you want to add.
This script will run at every bootup and your variable will be available to all users.
#!/bin/sh
echo 'export AWS_DEFAULT_REGION=ap-southeast-2' > ~/myconfiguration.sh
chmod +x ~/myconfiguration.sh
sudo cp ~/myconfiguration.sh /etc/profile.d/myconfiguration.sh
The above code creates a shell script to set environment variable for aws default region and copies it to profile.d .