【发布时间】:2020-03-14 10:47:42
【问题描述】:
在我的模板中,我配置了一个使用 EC2 Launch template 的 ASG
在UserData 部分,我执行cfn-init 来配置实例,效果很好。
但是,当我执行 cfn-signal 命令时,命令成功(退出代码为 0),但 Cloudformation 堆栈从未收到它,并且堆栈创建/更新失败并显示 Failed to receive 1 resource signal(s) for the current batch. Each resource signal timeout is counted as a FAILURE.
当我检查 Cloudtrail 时,我看到 SignalResource API 调用已完成,用 SUCCESS 表示正确的堆栈和资源,(但 responseElements 的 null)
摘自我的 Cloudformation 模板:
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
知道我在这里缺少什么吗?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation