[英]How to run custom setup for AWS EC2 instance?
I have seen this is possible in GCP and other clouds, but the "Advanced details" section in AWS EC2 doesn't seem to do anything to me.我已经看到这在 GCP 和其他云中是可能的,但是 AWS EC2 中的“高级详细信息”部分似乎对我没有任何作用。
I want to ensure I have the latest security dependencies and install custom monitoring agents.我想确保我拥有最新的安全依赖项并安装自定义监控代理。
I have tried pasting my scripts or pre-setup commands in the "User data" section.我尝试在“用户数据”部分粘贴我的脚本或预设置命令。 I don't see any sign of this being executed in the background.我没有看到在后台执行此操作的任何迹象。 I check the history, running processes, and monitoring section.我检查历史记录、运行进程和监控部分。
My question is, how to do it for AWS EC2?我的问题是,如何为 AWS EC2 做到这一点? Is the approach different compared to other clouds?与其他云相比,该方法是否不同?
NOTE: In GCP, there is both pre-config and post-config script.注意:在 GCP 中,有 pre-config 和 post-config 脚本。
UPDATE 1:更新 1:
export ENV=test
sudo yum update -y
sudo yum install docker -y
aws s3 cp s3://app-deployment-my-app/ec2-runner-$ENV.sh ec2-runner.sh
sudo systemctl start docker
sudo sh ec2-runner.sh
sudo chmod +x ec2-runner.sh
sudo /bin/bash -c 'echo "*/5 * * * * ec2-user sh /home/ec2-user/ec2-runner.sh" >> /etc/crontab'
sudo systemctl restart crond.service
Cloud-init takes multiple user-data formats . Cloud-init 采用 多种用户数据格式。 If you want your user-data to be interpreted as a Unix script then it must begin with #!
如果您希望您的用户数据被解释为 Unix 脚本,那么它必须以#!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.