- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个模板,在其中创建了 EC2 实例,并使用 cfn-init 来处理配置集,在实例的 Userdata 部分中,我编写了一些由 cloud-init 执行的命令和一些要执行的命令没有云初始化。
我不确定哪些命令按哪个顺序运行?我的意思是,命令执行的顺序是什么?例如:
我的部分代码如下:
UserData:
Fn::If:
- DatadogAgentEnabled
-
Fn::Base64: !Sub |
#!/bin/bash -xe
yum update -y
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init --stack ${AWS::StackName} --resource GhostServer --configsets prepare_instance_with_datadog --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource GhostServer --region ${AWS::Region}
#cloud-config <----cloud-init section inside the Userdata
runcmd:
- [ sh, -c, "sed 's/api_key:.*/api_key: {DatadogAPIKey}/' /etc/datadog-agent/datadog.yaml.example > /etc/datadog-agent/datadog.yaml" ]
- systemctl restart datadog-agent
最佳答案
来自 AWS 文档
UserData :The user data to make available to the instance. For moreinformation, see Running commands on your Linux instance at launch(Linux) and Adding User Data (Windows). If you are using a commandline tool, base64-encoding is performed for you, and you can load thetext from a file. Otherwise, you must provide base64-encoded text.User data is limited to 16 KB.
因此,基本上我们定义 UserData
来在启动 EC2 实例时执行一些命令。
引用:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html
要回答您的问题,首先将执行所有 UserData
命令,并且本节中指定的所有命令将按顺序执行,因此在您的示例中,您首先调用 cfn 帮助程序脚本,然后调用 cloud init,因此 configsets 将首先应用,然后调用云初始化命令。
在 UserData
部分中,我们调用 cfn 帮助程序脚本,该脚本读取 cloudformation 模板元数据并执行 AWS::CloudFormation::Init 下定义的所有
configsets
:
来自 AWS 文档:
The cfn-init helper script reads template metadata from theAWS::CloudFormation::Init key and acts accordingly to:
Fetch and parse metadata from AWS CloudFormation
Install packages
Write files to disk
Enable/disable and start/stop services
引用:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-init.html
关于amazon-web-services - AWS Cloudformation : Order of Execution among ConfigSets, 用户数据,云初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65842527/
在我迁移到 Angular 13 和 Jest 28 之后,我的测试停止了。我收到这种错误: Test suite failed to run TypeError: configSet.pro
这是 cloudformationinit 的元数据 { "Metadata": { "AWS::CloudFormation::Init": { "configSets":
情况 首先,我必须提到我正在使用 Solr 8.1.1 并运行默认的“solr -e cloud”来进行一些测试。这是在 Windows Azure VM 上运行的。我正在尝试创建一个 PowerSh
拥有一个像这样的配置集 example : "AWS::CloudFormation::Init" : { "configSets" : { "ascending" : [ "
我似乎无法使用 AWS Cloud Formation 堆栈创建新的 AWS SES 配置集。错误显示“YAML 格式不正确” 下面是我的 CF 堆栈的 json 模板: "Resources" :
我创建了一个模板,在其中创建了 EC2 实例,并使用 cfn-init 来处理配置集,在实例的 Userdata 部分中,我编写了一些由 cloud-init 执行的命令和一些要执行的命令没有云初始化
我是一名优秀的程序员,十分优秀!