CloudFormation 更新支持 "Refer to Resources in Another Stack"
CloudFormation Update support for "Refer to Resources in Another Stack"
我正在使用 Walkthrough: Refer to Resources in Another Stack 中的示例来引用另一个堆栈中的资源(我认为这非常有用并且应该是一个开箱即用的功能)。但是,该示例似乎不适用于更新,即如果将新输出添加到引用的堆栈。
有趣的是,甚至没有根据日志和指标调用 lambda 函数,因此这似乎不是可以在代码中修复的问题。我确实认为代码应该根据 Replacing a Custom Resource During an Update.
在更新时使用不同的 PhysicalResourceId
的交叉 post
事实证明,CloudFormation 仅在其属性之一发生更改时才更新自定义资源。一旦发生这种情况,自定义资源应该发出它已更改的信号。所以
替换:
response.send(event, context, response.SUCCESS, responseData);
和
var crypto = require('crypto');
var hash = crypto.createHash('md5').update(JSON.stringify(responseData)).digest('hex');
response.send(event, context, response.SUCCESS, responseData, hash);
这将导致更新期间发生以下事件:
15:08:16 UTC+0200 UPDATE_COMPLETE Custom::NetworkInfo NetworkInfo
15:08:15 UTC+0200 UPDATE_IN_PROGRESS Custom::NetworkInfo NetworkInfo Requested update required the provider to create a new physical resource
15:08:08 UTC+0200 UPDATE_IN_PROGRESS Custom::NetworkInfo NetworkInfo
这仍然需要 属性 才能更改。我想出的最好办法是将伪随机参数传递给自定义资源:
{
"Parameters": {
"Random": {
"Description": "Random value to force stack-outputs update",
"Type": "String"
}
},
"Resources": {
"NetworkInfo": {
"Type": "Custom::NetworkInfo",
"Properties": {
"ServiceToken": { "Fn::GetAtt" : ["LookupStackOutputs", "Arn"] },
"Random": { "Ref": "Random" },
"StackName": { "Ref": "NetworkStackName" }
}
}
}
}
lambda 函数会简单地忽略未知参数(即 Random
)。
我正在使用 Walkthrough: Refer to Resources in Another Stack 中的示例来引用另一个堆栈中的资源(我认为这非常有用并且应该是一个开箱即用的功能)。但是,该示例似乎不适用于更新,即如果将新输出添加到引用的堆栈。
有趣的是,甚至没有根据日志和指标调用 lambda 函数,因此这似乎不是可以在代码中修复的问题。我确实认为代码应该根据 Replacing a Custom Resource During an Update.
在更新时使用不同的PhysicalResourceId
的交叉 post
事实证明,CloudFormation 仅在其属性之一发生更改时才更新自定义资源。一旦发生这种情况,自定义资源应该发出它已更改的信号。所以
替换:
response.send(event, context, response.SUCCESS, responseData);
和
var crypto = require('crypto');
var hash = crypto.createHash('md5').update(JSON.stringify(responseData)).digest('hex');
response.send(event, context, response.SUCCESS, responseData, hash);
这将导致更新期间发生以下事件:
15:08:16 UTC+0200 UPDATE_COMPLETE Custom::NetworkInfo NetworkInfo
15:08:15 UTC+0200 UPDATE_IN_PROGRESS Custom::NetworkInfo NetworkInfo Requested update required the provider to create a new physical resource
15:08:08 UTC+0200 UPDATE_IN_PROGRESS Custom::NetworkInfo NetworkInfo
这仍然需要 属性 才能更改。我想出的最好办法是将伪随机参数传递给自定义资源:
{
"Parameters": {
"Random": {
"Description": "Random value to force stack-outputs update",
"Type": "String"
}
},
"Resources": {
"NetworkInfo": {
"Type": "Custom::NetworkInfo",
"Properties": {
"ServiceToken": { "Fn::GetAtt" : ["LookupStackOutputs", "Arn"] },
"Random": { "Ref": "Random" },
"StackName": { "Ref": "NetworkStackName" }
}
}
}
}
lambda 函数会简单地忽略未知参数(即 Random
)。