How to set Environment Variables on EC2 instance via User Data

前端 未结 9 743
北荒
北荒 2020-12-14 07:34

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         


        
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 08:20

    After doing the stuffs in the user data script, the process exits. So, whatever environment variable you export will not be there in the next process. One way is to to put exports in the .bashrc file so that it gets available in the next session also.

        echo "export HOST_URL=checkEmai-LoadBala-ICHJ82KG5C7P-23235232.us-east-1.elb.amazonaws.com" >> ~/.bashrc
    

提交回复
热议问题