Run shell script as EC2 user on Cloud formation User data

0

Hi, I want to run the Shell script n cloudformation userdata section as EC2 user, Could you please guide me how to execute this and whether it is possible or not.

Thanks, Sreenivas.

질문됨 2년 전1179회 조회
1개 답변
0

There's a couple different ways you can do it, but this was the one that worked best for me. Add this to your user-data script, minus the nvm stuff of course:

# Install nvm
sudo -u ec2-user  -i <<'EOF'

cd /home/ec2-user
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source /home/ec2-user/.bashrc
nvm install 10.19.0
nvm use 10.19.0

EOF
profile picture
kyager
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠