gpt4 book ai didi

bash - AWS Cloud Formation UserData 停止

转载 作者:行者123 更新时间:2023-12-03 07:27:31 25 4
gpt4 key购买 nike

我正在为自动扩展组创建启动配置。

WebAppLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
UserData: !Base64 |
#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
sudo su
apt-get update -y
apt-get install unzip awscli -y
apt-get install apache2 -y
systemctl start apache2.service
cd /var/www/html
aws s3 cp s3://udacity-demo-1/udacity.zip .
unzip -o udacity.zip
/bin/echo "Hello World" >> /tmp/testfile.txt
IamInstanceProfile:
Ref: "ProfileWithRolesForOurApp"
KeyName: UdacityCFNEC2Key
ImageId: ami-005bdb005fb00e791
SecurityGroups:
- Ref: WebServerSecGroup
InstanceType: t3.medium
BlockDeviceMappings:
- DeviceName: "/dev/sdk"
Ebs:
VolumeSize: '10'

我将服务器放在公共(public)子网中,以便简单地通过 ssh 登录并确认 Apache 是否已启动,但我发现它没有启动。当我尝试运行启动命令时,出现 httpd.conf 文件不存在的错误。

我在这里做错了什么?

我发现的最接近的问题是:Using userdata in Cloudformation他们正在讨论 ami 的类型,我已经能够成功地将用户数据日志导出到控制台,并且我正在使用 ubuntu ami,所以我认为这不是类似的问题。

最佳答案

我相信您的脚本中缺少此命令

-> systemctl 启用 httpd

这是 AWS 文档中的示例:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

关于bash - AWS Cloud Formation UserData 停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61840499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com