[英]AWS Cloudformation cfn-init not installing packages
I'm trying to get a simple AWS Cloudformation cfn-init script working but not having any success.我正在尝试让一个简单的 AWS Cloudformation cfn-init脚本正常工作,但没有任何成功。 The script is shown below.脚本如下所示。 When I log in to the instance created, httpd isn't even installed.当我登录到创建的实例时,甚至没有安装 httpd。 I'm creating an AWS Linux2 instance in us-east-1.我正在 us-east-1 中创建一个 AWS Linux2 实例。
Resources:
...
Ec2Instance:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
config:
packages:
yum:
httpd: []
files:
/var/www/html/index.html:
content: !Sub |
<html><body>Hello, World</body></html>
services:
sysvinit:
httpd:
enabled: true
ensureRunning: true
Properties:
InstanceType: t2.micro
ImageId: ami-0323c3dd2da7fb37d
KeyName: KeyPair
SecurityGroupIds:
- !Ref InstanceSecurityGroup
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource Ec2Instance --region ${AWS::Region}
I deployed your template, and can confirm it is correct .我部署了您的模板,并且可以确认它是正确的。 httpd
and index.html
are installed and deployed as expected. httpd
和index.html
已按预期安装和部署。
There must be something else happening.一定有别的事情发生。 For example, deploying to a private subnet without internet.例如,部署到没有 Internet 的私有子网。 In that case httpd want be installed.在这种情况下,需要安装 httpd。 Or like @Christian mentioned, amending existing instance.或者像@Christian 提到的那样,修改现有实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.