本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
檢視變更集
建立變更集之後,即可先檢視請求的變更,再加以執行。您可以使用 CloudFormation 主控台 AWS CLI或 CloudFormation API 來檢視變更集。 CloudFormation 主控台提供變更的摘要,以及JSON格式變更的詳細清單。 AWS CLI 和 AWS CloudFormation API 會傳回JSON格式變更的詳細清單。
檢視變更集 (AWS CLI)
-
若要取得變更集的 ID,請執行 change-sets 命令。
指定堆疊 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" } ] }
-
執行 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-1abc23d4
EC2執行個體的標籤。如需每個欄位的說明,請參閱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",