CloudForformationStack未收到来自EC2启动模板中的用户数据的信号 [英] Cloudformation Stack not receiving signal from userdata in EC2 Launch Template
本文介绍了CloudForformationStack未收到来自EC2启动模板中的用户数据的信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的模板中,我设置了一个使用EC2 Launch template
的ASG在UserData
部分中,我执行了cfn-init
设置实例,操作正常。
但是,当我执行cfn-signal
命令时,命令成功(退出代码为0),但是CloudForformation栈从未收到它,并且栈创建/更新失败,错误为Failed to receive 1 resource signal(s) for the current batch. Each resource signal timeout is counted as a FAILURE.
当我检查Cloudtraach时,我看到SignalResource
API调用已完成,并用SUCCESS
(但null
的responseElements
)表示正确的堆栈和资源)
摘录自我的云表单模板:
Resources:
MyLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Metadata:
'AWS::CloudFormation::Init':
configSets:
# lots-o-stuff to be done by cfn-init
Properties:
LaunchTemplateData:
# Remove other attributes for brevity
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -x
yum update -y
# gather ENI
/opt/aws/bin/cfn-init -c install
--stack ${AWS::StackName}
--resource MyLaunchTemplate
--region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $?
--stack ${AWS::StackName}
--resource MyAsg
--region ${AWS::Region}
echo $?
LaunchTemplateName: my-launch-template
MyAsg:
Type: AWS::AutoScaling::AutoScalingGroup
CreationPolicy:
AutoScalingCreationPolicy:
MinSuccessfulInstancesPercent: 100
ResourceSignal:
Count: 1
Timeout: PT10M
UpdatePolicy:
AutoScalingReplacingUpdate:
WillReplace: true
Properties:
# Remove other attributes for brevity
LaunchTemplate:
LaunchTemplateId: !Ref MyLaunchTemplate
Version: !GetAtt MyLaunchTemplate.LatestVersionNumber
知道我这里错过了什么吗?
推荐答案
我最近也遇到过类似的问题。由于某些原因,CFN-Signals似乎不适用于启动模板。出于测试目的,我将启动模板更改为启动配置,CFN信号工作正常。AWS为什么不支持启动模板,这很奇怪。
这篇关于CloudForformationStack未收到来自EC2启动模板中的用户数据的信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文