剛剛更新了我們的一些CF模板,並且正在更新它引用的堆棧。我添加了一些默認值並添加了一個CloudWatch警報,我也將該實例從m4.xlarge降級到m4.large。更新堆棧w。 「替代:有條件」;它會取代嗎?
我已經降級EC2-GUI中的實例,它很好。然後,我根據原始模板(即m4.xlarge)將其恢復爲默認狀態。 但是,當我修改模板中的實例類型的默認值時,它並不反映何時將修改後的模板上傳到CloudFormation。 含義默認值仍然是m4.xlarge,我必須使用下拉菜單來選擇模板中指定的m4.large。
如果我不更改實例類型,我會得到: 「Replacement:False」,但如果我更新實例類型,則會得到「Replacement:Conditional」。
如果我仔細閱讀「變更集詳細信息」,然後更多的「詳細信息」我看到:
[
{
"resourceChange": {
"logicalResourceId": "CPUAlarm",
"action": "Add",
"physicalResourceId": null,
"resourceType": "AWS::CloudWatch::Alarm",
"replacement": null,
"details": [],
"scope": []
},
"type": "Resource"
},
{
"resourceChange": {
"logicalResourceId": "myInstanceName",
"action": "Modify",
"physicalResourceId": "<masked>",
"resourceType": "AWS::EC2::Instance",
"replacement": "Conditional",
"details": [
{
"target": {
"name": null,
"requiresRecreation": "Never",
"attribute": "Tags"
},
"causingEntity": null,
"evaluation": "Dynamic",
"changeSource": "DirectModification"
},
{
"target": {
"name": null,
"requiresRecreation": "Never",
"attribute": "Tags"
},
"causingEntity": "Project",
"evaluation": "Static",
"changeSource": "ParameterReference"
},
{
"target": {
"name": null,
"requiresRecreation": "Never",
"attribute": "Tags"
},
"causingEntity": null,
"evaluation": "Static",
"changeSource": null
},
{
"target": {
"name": "InstanceType",
"requiresRecreation": "Conditionally",
"attribute": "Properties"
},
"causingEntity": "InstanceType",
"evaluation": "Static",
"changeSource": "ParameterReference"
},
{
"target": {
"name": "InstanceType",
"requiresRecreation": "Conditionally",
"attribute": "Properties"
},
"causingEntity": null,
"evaluation": "Dynamic",
"changeSource": "DirectModification"
}
],
"scope": [
"Properties",
"Tags"
]
},
"type": "Resource"
},
{
所以,我可以看到的是: 「名」:「InstanceType」,「requiresRecreation」:「有條件地「,是唯一具有更多限制性價值的價值,因此整個堆棧得到」替代:有條件「。
根據AWS: 「在某些情況下,AWS CloudFormation只能在您執行更改集後才能確定值,AWS CloudFormation會將這些更改標記爲動態評估,例如,如果引用了有條件替換的更新資源,AWS CloudFormation無法確定對已更新資源的引用是否會發生更改。「
AFAIK「替換:條件」「可能」代替資源即創建一個新的physicalResourceID反過來強迫我改變相關的SG等,但也可能不這樣做,對嗎?
感謝您的協助!