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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ