【发布时间】:2017-04-22 00:05:06
【问题描述】:
我在 cloudFormation 模板中使用了两个自定义资源。基本上这些自定义资源是具有自定义代码的 lambda 函数。我想在恒定 3 分钟之后开始创建第二个 lambda。
我想使用带有 timeout 属性 的 cloudFormation 的 WaitCondition 来解决这个问题。但它需要一个 WaitHandle,它必须在超时之前接收成功信号。收到信号后,WaitCondition 将变为 Create-Complete。 但在我的情况下,我无法使用自定义函数将信号发送到等待句柄。 第一个自定义资源完成后,我需要有一个恒定的 3 分钟等待时间。 然后,在 创建完成 之后开始创建 第二个自定义资源 WaitCondition。 这是我的代码:
"SecondCustomResource": {
"Type": "Custom::SecondCustomResource",
"DependsOn" : "WaitCondition",
"Properties": {
"ServiceToken": { "Fn::GetAtt" : ["SecondCustomResourceFunction", "Arn"] }
}
},
"SecondCustomResourceFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": { "Ref": "S3Bucket" },
"S3Key": { "Ref": "S3Key" }
},
"Handler": { "Fn::Join" : [ "", [{ "Ref": "ModuleName" },".handler"] ] },
"Runtime": "nodejs4.3",
"Timeout": "30"
}
},
"WaitCondition": {
"Type" : "AWS::CloudFormation::WaitCondition",
"DependsOn" : "FirstCustomResource",
"Properties": {
"Timeout": "180"
}
},
"FirstCustomResource": {
"Type": "Custom::FirstCustomResource",
"Properties": {
"ServiceToken": { "Fn::GetAtt" : ["FirstCustomResourceFunction", "Arn"] }
}
},
"FirstCustomResourceFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": { "Ref": "S3Bucket" },
"S3Key": { "Ref": "S3Key" }
},
"Handler": { "Fn::Join" : [ "", [{ "Ref": "ModuleName" },".handler"] ] },
"Runtime": "nodejs4.3",
"Timeout": "30"
}
}
这似乎不起作用。有什么 hack 或变通方法可以让 WaitCondition 保持不变?
【问题讨论】:
-
堆栈中是否有一个实例可以提供“睡眠”然后向句柄发出信号?
-
没有。我正在自定义函数中部署一个 kubernetes 集群。从 Google 云发送成功信号会很困难。
标签: amazon-web-services amazon-cloudformation