檢視變更集 - AWS CloudFormation

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

檢視變更集

建立變更集之後,即可先檢視請求的變更,再加以執行。您可以使用 CloudFormation 控制台 AWS CLI、或 CloudFormation API來檢視變更集。主 CloudFormation 控台會提供變更摘要,以及JSON格式變更的詳細清單。 AWS CLI 並 AWS CloudFormation API返回格式更改的詳細列JSON表。

View a change set for nested stack (console)
檢視巢狀堆疊的變更集 (主控台)
  1. CloudFormation 主控台的「堆」中,選擇包含您要檢視之變更集的堆疊名稱。

  2. 在導覽窗格中,選擇 [變更集] 以檢視堆疊的變更集清單。

  3. 選擇要檢視的變更集名稱。

    主 CloudFormation 控台會將您引導至變更集的詳細資訊頁面,您可以在此查看建立變更集的時間、其狀態、用於產生變更集的輸入,以及變更摘要。

    在「變更」區段中,每一列代表 CloudFormation 將新增、修改、移除或顯示動態狀態的資源。

    • 新增 — 將資源新增至堆疊範本時 CloudFormation 建立資源。

    • CloudFormation 修改 — 當您變更堆疊範本中資源的屬性時修改資源。

    • 移 CloudFormation 除 — 當您從堆疊的範本中刪除資源時刪除資源。

    • 動態 — CloudFormation 無法從巢狀堆疊的範本判斷確切的資源變更動作。

    注意

    修改作業可能會造成系統終止或替換 (重新建立) 資源。如需資源更新行為的詳細資訊,請參閱 瞭解堆疊資源的更新行為

    您可以使用篩選條件檢視,以便著重特定的變更。舉例來說,篩選特定的資料類型,例如 AWS::CloudFormation::Stack。若要篩選特定資源,請指定該資源的邏輯或實體 ID,例如:DeadLetterQueueNestedStack

  4. Changes (變更) 區段中,選擇您要檢視之巢狀變更集的 View nested change set (檢視巢狀變更集)

    主 CloudFormation 控台會將您導向至巢狀變更集的詳細資訊頁面。您可以選擇 Go to root change set (跳至根變更集) 來檢視根變更集,或者選擇 View parent change set (檢視父項變更集) 來檢視父項變更集。若要取得更多資訊,請參閱變更巢狀堆疊集

  5. 在「變更」段落中,選擇屬性層次變更料欄中的檢視詳細資料,以檢視資源特性值的詳細變更。

  6. CloudFormation 主控台會將您導向至資源的屬性層級變更頁面,您可以在其中查看資源的範本組態,然後再執行變更集,以及執行變更集後範本組態的外觀。

    「性質層級變更」區段表會顯示受影響屬性的「路徑」、「變更類型」、「之前值和「之後」值。在表格中,選擇您要在範本的「編輯」和「編輯」檢視中反白顯示的每個變更的核取方塊,以查看將在屬性層級進行哪些變更。

    • 新增 — 新增的屬性會反白顯示為綠色。

    • 修改 — 修改過的屬性以藍色反白顯示。

    • 移除 — 已移除的屬性以紅色反白顯示。

View a change set (console)
檢視變更集 (主控台)
  1. CloudFormation 主控台的「堆」中,選擇包含您要檢視之變更集的堆疊名稱。

  2. 在導覽窗格中,選擇 Change Sets (變更集) 以檢視堆疊的變更集清單。

  3. 選擇要檢視的變更集名稱。

    主 CloudFormation 控台會將您引導至變更集的詳細資訊頁面,您可以在此查看建立變更集的時間、其狀態、用於產生變更集的輸入,以及變更摘要。

    在「變更」區段中,每一列代表 CloudFormation 將新增、修改或移除的資源。

    • 新增 — 將資源新增至堆疊範本時 CloudFormation 建立資源。

    • CloudFormation 修改 — 當您變更堆疊範本中資源的屬性時修改資源。

    • 移 CloudFormation 除 — 當您從堆疊的範本中刪除資源時刪除資源。

    注意

    修改作業可能會造成系統終止或替換 (重新建立) 資源。如需資源更新行為的詳細資訊,請參閱 瞭解堆疊資源的更新行為

    您可以使用篩選條件檢視,以便著重特定的變更。舉例來說,篩選特定的資料類型,例如 AWS::EC2::Instance。若要篩選特定資源,請指定該資源的邏輯或實體 ID,例如:myWebServeri-123abcd4

  4. 在「變更」段落中,選擇「屬性層級變更」欄中的「檢視詳細資料」,以檢視對資源所做的屬性值變更。

  5. CloudFormation 主控台會將您導向至資源的屬性層級變更頁面,您可以在其中查看資源的範本組態,然後再執行變更集,以及執行變更集後範本組態的外觀。

    「性質層級變更」區段表會顯示受影響屬性的「路徑」、「變更類型」、「之前值和「之後」值。在表格中,選擇您要在範本的「編輯」和「編輯」檢視中反白顯示的每個變更的核取方塊,以查看將在屬性層級進行哪些變更。

    • 新增 — 新增的屬性會反白顯示為綠色。

    • 修改 — 修改過的屬性以藍色反白顯示。

    • 移除 — 已移除的屬性以紅色反白顯示。

檢視變更集 (AWS CLI)
  1. 執行 aws cloudformation list-change-sets 命令,即可取得變更集的 ID。

    指定堆疊 ID,該堆疊內含您要檢視的變更集;如以下範例所示:

    $ aws cloudformation list-change-sets \ --stack-name arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000

    CloudFormation 會傳回變更集清單,類似下列內容:

    { "Summaries": [ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000", "Status": "CREATE_COMPLETE", "ChangeSetName": "SampleChangeSet", "CreationTime": "2020-11-18T20:44:05.889Z", "StackName": "SampleStack", "ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/SampleChangeSet/1a2345b6-0000-00a0-a123-00abc0abc000" }, { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000", "Status": "CREATE_COMPLETE", "ChangeSetName": "SampleChangeSet-conditional", "CreationTime": "2020-11-18T21:15:56.398Z", "StackName": "SampleStack", "ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/SampleChangeSet-conditional/1a2345b6-0000-00a0-a123-00abc0abc000" }, { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000", "Status": "CREATE_COMPLETE", "ChangeSetName": "SampleChangeSet-replacement", "CreationTime": "2020-11-18T21:03:37.706Z", "StackName": "SampleStack", "ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/SampleChangeSet-replacement/1a2345b6-0000-00a0-a123-00abc0abc000" } ] }
  2. 執行 aws cloudformation describe-change-set 命令,藉此指定要檢視的變更集 ID。例如:

    $ aws cloudformation describe-change-set --change-set-name arn:aws:cloudformation:us-east-1:123456789012:changeSet/SampleChangeSet/1a2345b6-0000-00a0-a123-00abc0abc000

    CloudFormation 返回有關指定變更集的信息:

    { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000", "Status": "CREATE_COMPLETE", "ChangeSetName": "SampleChangeSet-direct", "Parameters": [ { "ParameterValue": "testing", "ParameterKey": "Purpose" }, { "ParameterValue": "ellioty-useast1", "ParameterKey": "KeyPairName" }, { "ParameterValue": "t2.micro", "ParameterKey": "InstanceType" } ], "Changes": [ { "ResourceChange": { "ResourceType": "AWS::EC2::Instance", "PhysicalResourceId": "i-1abc23d4", "Details": [ { "ChangeSource": "DirectModification", "Evaluation": "Static", "Target": { "Attribute": "Tags", "RequiresRecreation": "Never" } } ], "Action": "Modify", "Scope": [ "Tags" ], "LogicalResourceId": "MyEC2Instance", "Replacement": "False" }, "Type": "Resource" } ], "CreationTime": "2020-11-18T23:35:25.813Z", "Capabilities": [], "StackName": "SampleStack", "NotificationARNs": [], "ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/SampleChangeSet-direct/9edde307-960d-4e6e-ad66-b09ea2f20255" }

    --include-property-values搭配使用describe-change-set可列出屬性層級的變更。

    Changes 金鑰會列出系統對資源進行的變更。如果您要執行此變更集,則 CloudFormation 會更新執行個i-1abc23d4EC2體的標籤。如需每個欄位的說明,請參閱「AWS CloudFormation API參考」中的Change資料類型。

    如需變更集的其他範例,請參閱變更集範例

檢視變更集中性質層級變更的步驟 ()AWS CLI
  • 下列命令會列出與AWS::EC2::NetworkInterface資源變更集相關的屬性層級變更,這些變更將會移除Ipv4Prefixes屬性、修改資源Description的內容,並新增:Tag

    $ aws cloudformation describe-change-set --include-property-values --change-set-name arn:aws:cloudformation:us-east-1:123456789012:changeSet/ExampleChangeSet/9f7b541b-126b-44f7-998e-932174557841
    "ChangeSetName": "ExampleChangeSet", "ChangeSetId": "arn:aws:cloudformation:us-east-1:803642222207:changeSet/ExampleChangeSet/9f7b541b-126b-44f7-998e-932174557841", "StackId": "arn:aws:cloudformation:us-east-1:803642222207:stack/ExampleStack/ab664180-f686-11ee-9e29-12cd92393671", "StackName": "ExampleStack", "Description": null, "Parameters": null, "CreationTime": "2024-04-09T18:04:59.935000+00:00", "ExecutionStatus": "AVAILABLE", "Status": "CREATE_COMPLETE", "StatusReason": null, "NotificationARNs": [], "RollbackConfiguration": { "RollbackTriggers": [] }, "Capabilities": [], "Tags": null, "ParentChangeSetId": null, "IncludeNestedStacks": true, "RootChangeSetId": null, "OnStackFailure": null, { "Changes": [ { "Type": "Resource", "ResourceChange": { "Action": "Modify", "LogicalResourceId": "EC2NetworkInterface00eni067fd35b649a05b7100Tpyls", "PhysicalResourceId": "eni-067fd35b649a05b71", "ResourceType": "AWS::EC2::NetworkInterface", "Replacement": "False", "Scope": [ "Properties", "Tags" ], "Details": [ { "Target": { "Attribute": "Properties", "Name": "Ipv4Prefixes", "RequiresRecreation": "Never", "Path": "/Properties/Ipv4Prefixes", "BeforeValue": "[]", "AttributeChangeType": "Remove" }, "Evaluation": "Static", "ChangeSource": "DirectModification" }, { "Target": { "Attribute": "Properties", "Name": "Description", "RequiresRecreation": "Never", "Path": "/Properties/Description", "BeforeValue": "", "AfterValue": "Description", "AttributeChangeType": "Modify" }, "Evaluation": "Static", "ChangeSource": "DirectModification" }, { "Target": { "Attribute": "Tags", "RequiresRecreation": "Never", "Path": "/Properties/Tags/0", "AfterValue": "{\"Key\":\"Test\",\"Value\":\"Test\"}", "AttributeChangeType": "Add" }, "Evaluation": "Static", "ChangeSource": "DirectModification" } ], "BeforeContext": "{\"Properties\":{\"Description\":\"\",\"PrivateIpAddress\":\"172.31.76.2\",\"PrivateIpAddresses\":[{\"PrivateIpAddress\":\"172.31.76.2\",\"Primary\":\"true\"}],\"SecondaryPrivateIpAddressCount\":\"0\",\"Ipv6PrefixCount\":\"0\",\"Ipv4Prefixes\":[],\"Ipv4PrefixCount\":\"0\",\"GroupSet\":[\"sg-05a45689b1059e82d\"],\"Ipv6Prefixes\":[],\"SubnetId\":\"subnet-455e8969\",\"SourceDestCheck\":\"true\",\"InterfaceType\":\"interface\",\"Tags\":[]},\"UpdateReplacePolicy\":\"Retain\",\"DeletionPolicy\":\"Retain\"}", "AfterContext": "{\"Properties\":{\"Description\":\"Description\",\"PrivateIpAddress\":\"172.31.76.2\",\"PrivateIpAddresses\":[{\"PrivateIpAddress\":\"172.31.76.2\",\"Primary\":\"true\"}],\"SecondaryPrivateIpAddressCount\":\"0\",\"Ipv6PrefixCount\":\"0\",\"Ipv4PrefixCount\":\"0\",\"GroupSet\":[\"sg-05a45689b1059e82d\"],\"Ipv6Prefixes\":[],\"SubnetId\":\"subnet-455e8969\",\"SourceDestCheck\":\"true\",\"InterfaceType\":\"interface\",\"Tags\":[{\"Value\":\"Test\",\"Key\":\"Test\"}]},\"UpdateReplacePolicy\":\"Retain\",\"DeletionPolicy\":\"Retain\"}" } } ], "ChangeSetName": "ExampleChangeSet", "ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/ExampleChangeSet/9f7b541b-126b-44f7-998e-932174557841", "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/ExampleStack/ab664180-f686-11ee-9e29-12cd92393671",