

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

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

# CloudFormation 使用 的範例 AWS CLI
<a name="cli_2_cloudformation_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 來執行動作和實作常見案例 CloudFormation。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `activate-type`
<a name="cloudformation_ActivateType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `activate-type`。

**AWS CLI**  
**啟用類型**  
下列 `activate-type` 範例啟用公有第三方擴充功能，使其可用在堆疊範本中使用。  

```
aws cloudformation activate-type \
    --region us-west-2 \
    --type RESOURCE \
    --type-name Example::Test::1234567890abcdef0 \
    --type-name-alias Example::Test::Alias
```
輸出：  

```
{
    "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Alias"
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ActivateType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/activate-type.html)。

### `batch-describe-type-configurations`
<a name="cloudformation_BatchDescribeTypeConfigurations_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `batch-describe-type-configurations`。

**AWS CLI**  
**批次描述類型組態**  
下列 `batch-describe-type-configurations` 範例會設定類型的資料。  

```
aws cloudformation batch-describe-type-configurations \
    --region us-west-2 \
    --type-configuration-identifiers TypeArn="arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Type,TypeConfigurationAlias=MyConfiguration"
```
輸出：  

```
{
    "Errors": [],
    "UnprocessedTypeConfigurations": [],
    "TypeConfigurations": [
        {
            "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Type",
            "Alias": "MyConfiguration",
            "Configuration": "{\n        \"Example\": {\n            \"ApiKey\": \"examplekey\",\n            \"ApplicationKey\": \"examplekey1\",\n            \"ApiURL\": \"exampleurl\"\n            }\n}",
            "LastUpdated": "2021-10-01T15:25:46.210000+00:00",
            "TypeArn": "arn:aws:cloudformation:us-east-1:123456789012:type/resource/Example-Test-Type"
        }
    ]
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [BatchDescribeTypeConfigurations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/batch-describe-type-configurations.html)。

### `cancel-update-stack`
<a name="cloudformation_CancelUpdateStack_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `cancel-update-stack`。

**AWS CLI**  
**取消進行中的堆疊更新**  
下列 `cancel-update-stack` 命令會取消 `myteststack` 堆疊上的堆疊更新：  

```
aws cloudformation cancel-update-stack --stack-name myteststack
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CancelUpdateStack](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/cancel-update-stack.html)。

### `continue-update-rollback`
<a name="cloudformation_ContinueUpdateRollback_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `continue-update-rollback`。

**AWS CLI**  
**重試更新還原**  
下列 `continue-update-rollback` 範例從先前失敗的堆疊更新處繼續還原操作。  

```
aws cloudformation continue-update-rollback \
    --stack-name my-stack
```
此命令不會產生輸出。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ContinueUpdateRollback](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/continue-update-rollback.html)。

### `create-change-set`
<a name="cloudformation_CreateChangeSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-change-set`。

**AWS CLI**  
**建立變更集**  
下列 `create-change-set` 範例會使用 `CAPABILITY_IAM` 功能建立變更集。檔案`template.yaml`是目前資料夾中的 AWS CloudFormation 範本，可定義包含 IAM 資源的堆疊。  

```
aws cloudformation create-change-set \
    --stack-name my-application \
    --change-set-name my-change-set \
    --template-body file://template.yaml \
    --capabilities CAPABILITY_IAM
```
輸出：  

```
{
    "Id": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784",
    "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-application/d0a825a0-e4cd-xmpl-b9fb-061c69e99204"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateChangeSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/create-change-set.html)。

### `create-generated-template`
<a name="cloudformation_CreateGeneratedTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-generated-template`。

**AWS CLI**  
**從掃描的資源建立產生的範本**  
下列`create-generated-template`範例`MyTemplate`會從掃描的資源建立名為 的產生範本。  

```
aws cloudformation create-generated-template \
    --generated-template-name MyTemplate \
    --resources file://resources.json
```
`resources.json` 的內容：  

```
[
    {
        "ResourceType": "AWS::EKS::Cluster",
        "LogicalResourceId":"MyCluster",
        "ResourceIdentifier": {
            "ClusterName": "MyAppClusterName"
        }
    },
    {
        "ResourceType": "AWS::AutoScaling::AutoScalingGroup",
        "LogicalResourceId":"MyASG",
        "ResourceIdentifier": {
            "AutoScalingGroupName": "MyAppASGName"
        }
    },
    {
        "ResourceType": "AWS::EKS::Nodegroup",
        "LogicalResourceId":"MyNodegroup",
        "ResourceIdentifier": {
            "NodegroupName": "MyAppNodegroupName"
        }
    },
    {
        "ResourceType": "AWS::IAM::Role",
        "LogicalResourceId":"MyRole",
        "ResourceIdentifier": {
            "RoleId": "arn:aws::iam::123456789012:role/MyAppIAMRole"
        }
    }
]
```
輸出：  

```
{
  "Arn":
    "arn:aws:cloudformation:us-east-1:123456789012:generatedtemplate/7fc8512c-d8cb-4e02-b266-d39c48344e48",
  "Name": "MyTemplate"
}
```
如需詳細資訊，請參閱[CloudFormation 使用者指南》中的從使用 IaC 產生器掃描的資源建立](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-create-template-from-scanned-resources.html) CloudFormation 範本。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [CreateGeneratedTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/create-generated-template.html)。

### `create-stack-instances`
<a name="cloudformation_CreateStackInstances_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-stack-instances`。

**AWS CLI**  
**建立堆疊執行個體**  
下列 `create-stack-instances` 範例會在兩個帳戶和四個區域中建立堆疊集的執行個體。容錯設定可以確保能在所有帳戶和區域中進行更新，即使無法建立某些堆疊。  

```
aws cloudformation create-stack-instances \
    --stack-set-name my-stack-set \
    --accounts 123456789012 223456789012 \
    --regions us-east-1 us-east-2 us-west-1 us-west-2 \
    --operation-preferences FailureToleranceCount=7
```
輸出：  

```
{
    "OperationId": "d7995c31-83c2-xmpl-a3d4-e9ca2811563f"
}
```
使用 `create-stack-set` 命令建立堆疊集。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateStackInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/create-stack-instances.html)。

### `create-stack-refactor`
<a name="cloudformation_CreateStackRefactor_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-stack-refactor`。

**AWS CLI**  
**建立堆疊重構操作的堆疊定義**  
下列`create-stack-refactor`範例會建立堆疊重構的堆疊定義。  

```
aws cloudformation create-stack-refactor \
    --stack-definitions \
      StackName=Stack1,TemplateBody@=file://template1-updated.yaml \
      StackName=Stack2,TemplateBody@=file://template2-updated.yaml
```
輸出：  

```
{
    "StackRefactorId": "9c384f70-4e07-4ed7-a65d-fee5eb430841"
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[堆疊重構](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [CreateStackRefactor](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/create-stack-refactor.html)。

### `create-stack-set`
<a name="cloudformation_CreateStackSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-stack-set`。

**AWS CLI**  
**建立堆疊集**  
下列`create-stack-set`範例使用指定的 YAML 檔案樣板建立堆疊集。 `template.yaml`是定義堆疊之目前資料夾中的 AWS CloudFormation 範本。  

```
aws cloudformation create-stack-set \
    --stack-set-name my-stack-set \
    --template-body file://template.yaml \
    --description "SNS topic"
```
輸出：  

```
{
    "StackSetId": "my-stack-set:8d0f160b-d157-xmpl-a8e6-c0ce8e5d8cc1"
}
```
使用 `create-stack-instances` 命令，將堆疊執行個體新增至堆疊集。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateStackSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/create-stack-set.html)。

### `create-stack`
<a name="cloudformation_CreateStack_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-stack`。

**AWS CLI**  
**建立 an AWS CloudFormation 堆疊**  
以下 `create-stacks` 命令使用 `sampletemplate.json` 範本建立名為 `myteststack` 的堆疊：  

```
aws cloudformation create-stack --stack-name myteststack --template-body file://sampletemplate.json --parameters ParameterKey=KeyPairName,ParameterValue=TestKey ParameterKey=SubnetIDs,ParameterValue=SubnetID1\\,SubnetID2
```
輸出：  

```
{
    "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896"
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的堆疊。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateStack](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/create-stack.html)。

### `deactivate-type`
<a name="cloudformation_DeactivateType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `deactivate-type`。

**AWS CLI**  
**停用類型**  
下列 `deactivate-type` 範例會停用先前在此帳戶和區域中啟用的公有延伸。  

```
aws cloudformation deactivate-type \
    --region us-west-2 \
    --type MODULE \
    --type-name Example::Test::Type::MODULE
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [DeactivateType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deactivate-type.html)。

### `delete-change-set`
<a name="cloudformation_DeleteChangeSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-change-set`。

**AWS CLI**  
**刪除變更集**  
下列 `delete-change-set` 範例會透過指定變更集名稱和堆疊名稱來刪除變更集。  

```
aws cloudformation delete-change-set \
    --stack-name my-stack \
    --change-set-name my-change-set
```
此命令不會產生輸出。  
下列 `delete-change-set` 範例會透過指定變更集的完整 ARN 來刪除變更集。  

```
aws cloudformation delete-change-set \
    --change-set-name arn:aws:cloudformation:us-east-2:123456789012:changeSet/my-change-set/4eca1a01-e285-xmpl-8026-9a1967bfb4b0
```
此命令不會產生輸出。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteChangeSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/delete-change-set.html)。

### `delete-generated-template`
<a name="cloudformation_DeleteGeneratedTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-generated-template`。

**AWS CLI**  
**刪除產生的範本**  
下列`delete-generated-template`範例會刪除指定的範本。  

```
aws cloudformation delete-generated-template \
    --generated-template-name MyTemplate
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[從現有資源產生範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [DeleteGeneratedTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/delete-generated-template.html)。

### `delete-stack-instances`
<a name="cloudformation_DeleteStackInstances_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-stack-instances`。

**AWS CLI**  
**刪除堆疊執行個體**  
下列 `delete-stack-instances` 範例會刪除兩個區域中的兩個帳戶中堆疊集的執行個體，並終止堆疊。  

```
aws cloudformation delete-stack-instances \
    --stack-set-name my-stack-set \
    --accounts 123456789012 567890123456 \
    --regions us-east-1 us-west-1 \
    --no-retain-stacks
```
輸出：  

```
{
    "OperationId": "ad49f10c-fd1d-413f-a20a-8de6e2fa8f27"
}
```
若要刪除空堆疊集，請使用 `delete-stack-set` 命令。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteStackInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/delete-stack-instances.html)。

### `delete-stack-set`
<a name="cloudformation_DeleteStackSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-stack-set`。

**AWS CLI**  
**刪除堆疊集**  
以下命令會刪除指定的空堆疊集。堆疊集必須是空的。  

```
aws cloudformation delete-stack-set \
    --stack-set-name my-stack-set
```
此命令不會產生輸出。  
若要從堆疊集刪除執行個體，請使用 `delete-stack-instances` 命令。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteStackSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/delete-stack-set.html)。

### `delete-stack`
<a name="cloudformation_DeleteStack_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-stack`。

**AWS CLI**  
**刪除堆疊**  
以下 `delete-stack` 範例會刪除指定的堆疊。  

```
aws cloudformation delete-stack \
    --stack-name my-stack
```
此命令不會產生輸出。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteStack](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/delete-stack.html)。

### `deploy`
<a name="cloudformation_Deploy_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `deploy`。

**AWS CLI**  
下列命令會將名為 `template.json` 的範本，部署至名為 `my-new-stack` 的堆疊：  

```
aws cloudformation deploy --template-file /path_to_template/template.json --stack-name my-new-stack --parameter-overrides Key1=Value1 Key2=Value2 --tags Key1=Value1 Key2=Value2
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [Deploy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy.html)。

### `deregister-type`
<a name="cloudformation_DeregisterType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `deregister-type`。

**AWS CLI**  
**取消註冊類型版本**  
下列 `deregister-type` 範例會從 CloudFormation 登錄檔中移除指定類型版本的作用中狀態，使其無法再用於 CloudFormation 操作。  

```
aws cloudformation deregister-type \
    --type RESOURCE \
    --type-name My::Logs::LogGroup \
    --version-id 00000002
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[使用 the CloudFormation 登錄檔](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [DeregisterType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deregister-type.html)。

### `describe-account-limits`
<a name="cloudformation_DescribeAccountLimits_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-account-limits`。

**AWS CLI**  
**取得帳戶限制的相關資訊**  
下列命令會擷取目前帳戶的區域限制清單。  

```
aws cloudformation describe-account-limits
```
輸出：  

```
{
    "AccountLimits": [
        {
            "Name": "StackLimit",
            "Value": 200
        },
        {
            "Name": "StackOutputsLimit",
            "Value": 60
        },
        {
            "Name": "ConcurrentResourcesLimit",
            "Value": 2500
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeAccountLimits](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-account-limits.html)。

### `describe-change-set`
<a name="cloudformation_DescribeChangeSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-change-set`。

**AWS CLI**  
**取得變更集的相關資訊**  
下列 `describe-change-set` 範例顯示的是，變更集名稱和堆疊名稱所指定的變更集詳細資訊。  

```
aws cloudformation describe-change-set \
    --change-set-name my-change-set \
    --stack-name my-stack
```
下列 `describe-change-set` 範例顯示的是，變更集的完整 ARN 所指定的變更集詳細資訊：  

```
aws cloudformation describe-change-set \
    --change-set-name arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784
```
輸出：  

```
{
    "Changes": [
        {
            "Type": "Resource",
            "ResourceChange": {
                "Action": "Modify",
                "LogicalResourceId": "function",
                "PhysicalResourceId": "my-function-SEZV4XMPL4S5",
                "ResourceType": "AWS::Lambda::Function",
                "Replacement": "False",
                "Scope": [
                    "Properties"
                ],
                "Details": [
                    {
                        "Target": {
                            "Attribute": "Properties",
                            "Name": "Timeout",
                            "RequiresRecreation": "Never"
                        },
                        "Evaluation": "Static",
                        "ChangeSource": "DirectModification"
                    }
                ]
            }
        }
    ],
    "ChangeSetName": "my-change-set",
    "ChangeSetId": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/4eca1a01-e285-xmpl-8026-9a1967bfb4b0",
    "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
    "StackName": "my-stack",
    "Description": null,
    "Parameters": null,
    "CreationTime": "2019-10-02T05:20:56.651Z",
    "ExecutionStatus": "AVAILABLE",
    "Status": "CREATE_COMPLETE",
    "StatusReason": null,
    "NotificationARNs": [],
    "RollbackConfiguration": {},
    "Capabilities": [
        "CAPABILITY_IAM"
    ],
    "Tags": null
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeChangeSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-change-set.html)。

### `describe-generated-template`
<a name="cloudformation_DescribeGeneratedTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-generated-template`。

**AWS CLI**  
**描述產生的範本**  
下列`describe-generated-template`範例說明指定的範本。  

```
aws cloudformation describe-generated-template \
    --generated-template-name MyTemplate
```
輸出：  

```
{
    "GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedTemplate/7d881acf-f307-4ded-910e-f8fb49b96894",
    "GeneratedTemplateName": "MyTemplate",
    "Resources": [
        {
            "ResourceType": "AWS::EC2::SecurityGroup",
            "LogicalResourceId": "EC2SecurityGroup",
            "ResourceIdentifier": {
                "Id": "sg-1234567890abcdef0"
            },
            "ResourceStatus": "COMPLETE",
            "ResourceStatusReason": "Resource Template complete",
            "Warnings": []
        },
        {
            "ResourceType": "AWS::EC2::Instance",
            "LogicalResourceId": "EC2Instance",
            "ResourceIdentifier": {
                "InstanceId": "i-1234567890abcdef0"
            },
            "ResourceStatus": "COMPLETE",
            "ResourceStatusReason": "Resource Template complete",
            "Warnings": []
        },
        {
            "ResourceType": "AWS::EC2::KeyPair",
            "LogicalResourceId": "EC2KeyPairSshkeypair",
            "ResourceIdentifier": {
                "KeyName": "sshkeypair"
            },
            "ResourceStatus": "COMPLETE",
            "ResourceStatusReason": "Resource Template complete",
            "Warnings": []
        }
    ],
    "Status": "COMPLETE",
    "StatusReason": "All resources complete",
    "CreationTime": "2025-09-23T19:38:06.435000+00:00",
    "LastUpdatedTime": "2025-09-23T19:38:10.798000+00:00",
    "Progress": {
        "ResourcesSucceeded": 3,
        "ResourcesFailed": 0,
        "ResourcesProcessing": 0,
        "ResourcesPending": 0
    },
    "TemplateConfiguration": {
        "DeletionPolicy": "RETAIN",
        "UpdateReplacePolicy": "RETAIN"
    },
    "TotalWarnings": 0
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[從現有資源產生範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [DescribeGeneratedTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-generated-template.html)。

### `describe-publisher`
<a name="cloudformation_DescribePublisher_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-publisher`。

**AWS CLI**  
**描述發布者**  
下列 `describe-publisher` 範例會設定發布者的資訊。  

```
aws cloudformation describe-publisher \
    --region us-west-2 \
    --publisher-id 000q6TfUovXsEMmgKowxDZLlwqr2QUsh
```
輸出：  

```
{
    "PublisherId": "000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c",
    "PublisherStatus": "VERIFIED",
    "IdentityProvider": "AWS_Marketplace",
    "PublisherProfile": "https://aws.amazon.com/marketplace/seller-profile?id=2c5dc1f0-17cd-4259-8e46-822a83gdtegd"
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribePublisher](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-publisher.html)。

### `describe-resource-scan`
<a name="cloudformation_DescribeResourceScan_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-resource-scan`。

**AWS CLI**  
**描述資源掃描**  
下列`describe-resource-scan`範例說明具有指定掃描 ID 的資源掃描。  

```
aws cloudformation describe-resource-scan --region \
    --resource-scan-id arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60
```
輸出：  

```
{
    "ResourceScanId": "arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60",
    "Status": "COMPLETE",
    "StartTime": "2025-08-21T03:10:38.485000+00:00",
    "EndTime": "2025-08-21T03:20:28.485000+00:00",
    "PercentageCompleted": 100.0,
    "ResourceTypes": [
        "AWS::CloudFront::CachePolicy",
        "AWS::CloudFront::OriginRequestPolicy",
        "AWS::EC2::DHCPOptions",
        "AWS::EC2::InternetGateway",
        "AWS::EC2::KeyPair",
        "AWS::EC2::NetworkAcl",
        "AWS::EC2::NetworkInsightsPath",
        "AWS::EC2::NetworkInterface",
        "AWS::EC2::PlacementGroup",
        "AWS::EC2::Route",
        "AWS::EC2::RouteTable",
        "AWS::EC2::SecurityGroup",
        "AWS::EC2::Subnet",
        "AWS::EC2::SubnetCidrBlock",
        "AWS::EC2::SubnetNetworkAclAssociation",
        "AWS::EC2::SubnetRouteTableAssociation",
        ...
    ],
    "ResourcesRead": 676
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[從現有資源產生範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [DescribeResourceScan](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-resource-scan.html)。

### `describe-stack-drift-detection-status`
<a name="cloudformation_DescribeStackDriftDetectionStatus_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-drift-detection-status`。

**AWS CLI**  
**檢查偏離偵測操作的狀態**  
下列 `describe-stack-drift-detection-status` 範例顯示偏離偵測操作的狀態。若要取得 ID，請執行 `detect-stack-drift` 命令。  

```
aws cloudformation describe-stack-drift-detection-status \
    --stack-drift-detection-id 1a229160-e4d9-xmpl-ab67-0a4f93df83d4
```
輸出：  

```
{
    "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
    "StackDriftDetectionId": "1a229160-e4d9-xmpl-ab67-0a4f93df83d4",
    "StackDriftStatus": "DRIFTED",
    "DetectionStatus": "DETECTION_COMPLETE",
    "DriftedStackResourceCount": 1,
    "Timestamp": "2019-10-02T05:54:30.902Z"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackDriftDetectionStatus](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-drift-detection-status.html)。

### `describe-stack-events`
<a name="cloudformation_DescribeStackEvents_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-events`。

**AWS CLI**  
**描述堆疊事件**  
下列 `describe-stack-events` 範例顯示指定堆疊的 2 個最近事件。  

```
aws cloudformation describe-stack-events \
    --stack-name my-stack \
    --max-items 2

{
    "StackEvents": [
        {
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "EventId": "4e1516d0-e4d6-xmpl-b94f-0a51958a168c",
            "StackName": "my-stack",
            "LogicalResourceId": "my-stack",
            "PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2019-10-02T05:34:29.556Z",
            "ResourceStatus": "UPDATE_COMPLETE"
        },
        {
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "EventId": "4dd3c810-e4d6-xmpl-bade-0aaf8b31ab7a",
            "StackName": "my-stack",
            "LogicalResourceId": "my-stack",
            "PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "ResourceType": "AWS::CloudFormation::Stack",
            "Timestamp": "2019-10-02T05:34:29.127Z",
            "ResourceStatus": "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS"
        }
    ],
    "NextToken": "eyJOZXh0VG9XMPLiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ=="
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackEvents](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-events.html)。

### `describe-stack-instance`
<a name="cloudformation_DescribeStackInstance_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-instance`。

**AWS CLI**  
**描述堆疊執行個體**  
下列命令描述指定帳戶和區域中指定堆疊集的執行個體。堆疊集位於目前區域和帳戶中，而執行個體位於帳戶 `123456789012` 中的 `us-west-2` 區域：  

```
aws cloudformation describe-stack-instance \
    --stack-set-name my-stack-set \
    --stack-instance-account 123456789012 \
    --stack-instance-region us-west-2
```
輸出：  

```
{
    "StackInstance": {
        "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743",
        "Region": "us-west-2",
        "Account": "123456789012",
        "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532/4287f9a0-e615-xmpl-894a-12b31d3117be",
        "ParameterOverrides": [],
        "Status": "OUTDATED",
        "StatusReason": "ResourceLogicalId:ConfigBucket, ResourceType:AWS::S3::Bucket, ResourceStatusReason:You have attempted to create more buckets than allowed (Service: Amazon S3; Status Code: 400; Error Code: TooManyBuckets; Request ID: F7F21CXMPL580224; S3 Extended Request ID: egd/Fdt89BXMPLyiqbMNljVk55Yqqvi3NYW2nKLUVWhUGEhNfCmZdyj967lhriaG/dWMobSO40o=)."
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackInstance](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-instance.html)。

### `describe-stack-refactor`
<a name="cloudformation_DescribeStackRefactor_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-refactor`。

**AWS CLI**  
**描述堆疊重構操作**  
下列`describe-stack-refactor`範例說明具有指定堆疊重構 ID 的堆疊重構操作。  

```
aws cloudformation describe-stack-refactor \
    --stack-refactor-id 9c384f70-4e07-4ed7-a65d-fee5eb430841
```
輸出：  

```
{
    "StackRefactorId": "9c384f70-4e07-4ed7-a65d-fee5eb430841",
    "StackIds": [
        "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack1/3e6a1ff0-94b1-11f0-aa6f-0a88d2e03acf",
        "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b"
    ],
    "ExecutionStatus": "AVAILABLE",
    "Status": "CREATE_COMPLETE"
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[堆疊重構](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [DescribeStackRefactor](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-refactor.html)。

### `describe-stack-resource-drifts`
<a name="cloudformation_DescribeStackResourceDrifts_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-resource-drifts`。

**AWS CLI**  
**取得漂移堆疊定義之資源的相關資訊**  
下列命令顯示指定堆疊之漂移資源的相關資訊。若要啟動漂移偵測，請使用 `detect-stack-drift` 命令：  

```
aws cloudformation describe-stack-resource-drifts \
    --stack-name my-stack
```
輸出顯示已修改out-of-band的 AWS Lambda 函數：  

```
{
    "StackResourceDrifts": [
        {
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "LogicalResourceId": "function",
            "PhysicalResourceId": "my-function-SEZV4XMPL4S5",
            "ResourceType": "AWS::Lambda::Function",
            "ExpectedProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":128,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":900,\"TracingConfig\":{\"Mode\":\"Active\"}}",
            "ActualProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":256,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":22,\"TracingConfig\":{\"Mode\":\"Active\"}}",
            "PropertyDifferences": [
                {
                    "PropertyPath": "/MemorySize",
                    "ExpectedValue": "128",
                    "ActualValue": "256",
                    "DifferenceType": "NOT_EQUAL"
                },
                {
                    "PropertyPath": "/Timeout",
                    "ExpectedValue": "900",
                    "ActualValue": "22",
                    "DifferenceType": "NOT_EQUAL"
                }
            ],
            "StackResourceDriftStatus": "MODIFIED",
            "Timestamp": "2019-10-02T05:54:44.064Z"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackResourceDrifts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-resource-drifts.html)。

### `describe-stack-resource`
<a name="cloudformation_DescribeStackResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-resource`。

**AWS CLI**  
**取得堆疊資源的相關資訊**  
下列 `describe-stack-resource` 範例顯示指定的堆疊中名為 `MyFunction` 的資源詳細資訊。  

```
aws cloudformation describe-stack-resource \
    --stack-name MyStack \
    --logical-resource-id MyFunction
```
輸出：  

```
{
    "StackResourceDetail": {
        "StackName": "MyStack",
        "StackId": "arn:aws:cloudformation:us-east-2:123456789012:stack/MyStack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
        "LogicalResourceId": "MyFunction",
        "PhysicalResourceId": "my-function-SEZV4XMPL4S5",
        "ResourceType": "AWS::Lambda::Function",
        "LastUpdatedTimestamp": "2019-10-02T05:34:27.989Z",
        "ResourceStatus": "UPDATE_COMPLETE",
        "Metadata": "{}",
        "DriftInformation": {
            "StackResourceDriftStatus": "IN_SYNC"
        }
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-resource.html)。

### `describe-stack-resources`
<a name="cloudformation_DescribeStackResources_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-resources`。

**AWS CLI**  
**取得堆疊資源的相關資訊**  
下列 `describe-stack-resources` 範例顯示指定之堆疊中的資源詳細資訊。  

```
aws cloudformation describe-stack-resources \
    --stack-name my-stack
```
輸出：  

```
{
    "StackResources": [
        {
            "StackName": "my-stack",
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "LogicalResourceId": "bucket",
            "PhysicalResourceId": "my-stack-bucket-1vc62xmplgguf",
            "ResourceType": "AWS::S3::Bucket",
            "Timestamp": "2019-10-02T04:34:11.345Z",
            "ResourceStatus": "CREATE_COMPLETE",
            "DriftInformation": {
                "StackResourceDriftStatus": "IN_SYNC"
            }
        },
        {
            "StackName": "my-stack",
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "LogicalResourceId": "function",
            "PhysicalResourceId": "my-function-SEZV4XMPL4S5",
            "ResourceType": "AWS::Lambda::Function",
            "Timestamp": "2019-10-02T05:34:27.989Z",
            "ResourceStatus": "UPDATE_COMPLETE",
            "DriftInformation": {
                "StackResourceDriftStatus": "IN_SYNC"
            }
        },
        {
            "StackName": "my-stack",
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "LogicalResourceId": "functionRole",
            "PhysicalResourceId": "my-functionRole-HIZXMPLEOM9E",
            "ResourceType": "AWS::IAM::Role",
            "Timestamp": "2019-10-02T04:34:06.350Z",
            "ResourceStatus": "CREATE_COMPLETE",
            "DriftInformation": {
                "StackResourceDriftStatus": "IN_SYNC"
            }
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-resources.html)。

### `describe-stack-set-operation`
<a name="cloudformation_DescribeStackSetOperation_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-set-operation`。

**AWS CLI**  
**取得堆疊集操作的相關資訊**  
下列 describe-stack-set-operation` 範例顯示的是，指定堆疊集上更新操作的詳細資訊。  

```
aws cloudformation describe-stack-set-operation \
    --stack-set-name enable-config \
    --operation-id 35d45ebc-ed88-xmpl-ab59-0197a1fc83a0
```
輸出：  

```
{
    "StackSetOperation": {
        "OperationId": "35d45ebc-ed88-xmpl-ab59-0197a1fc83a0",
        "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743",
        "Action": "UPDATE",
        "Status": "SUCCEEDED",
        "OperationPreferences": {
            "RegionOrder": [
                "us-east-1",
                "us-west-2",
                "eu-west-1",
                "us-west-1"
            ],
            "FailureToleranceCount": 7,
            "MaxConcurrentCount": 2
        },
        "AdministrationRoleARN": "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole",
        "ExecutionRoleName": "AWSCloudFormationStackSetExecutionRole",
        "CreationTimestamp": "2019-10-03T16:28:44.377Z",
        "EndTimestamp": "2019-10-03T16:42:08.607Z"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackSetOperation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-set-operation.html)。

### `describe-stack-set`
<a name="cloudformation_DescribeStackSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stack-set`。

**AWS CLI**  
**取得堆疊集的相關資訊**  
下列 describe-stack-set` 範例顯示指定堆疊集的詳細資訊。  

```
aws cloudformation describe-stack-set \
    --stack-set-name my-stack-set
```
輸出：  

```
{
    "StackSet": {
        "StackSetName": "my-stack-set",
        "StackSetId": "my-stack-set:296a3360-xmpl-40af-be78-9341e95bf743",
        "Description": "Create an Amazon SNS topic",
        "Status": "ACTIVE",
        "TemplateBody": "AWSTemplateFormatVersion: '2010-09-09'\nDescription: An AWS SNS topic\nResources:\n  topic:\n    Type: AWS::SNS::Topic",
        "Parameters": [],
        "Capabilities": [],
        "Tags": [],
        "StackSetARN": "arn:aws:cloudformation:us-west-2:123456789012:stackset/enable-config:296a3360-xmpl-40af-be78-9341e95bf743",
        "AdministrationRoleARN": "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole",
        "ExecutionRoleName": "AWSCloudFormationStackSetExecutionRole"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeStackSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stack-set.html)。

### `describe-stacks`
<a name="cloudformation_DescribeStacks_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-stacks`。

**AWS CLI**  
**描述 AWS CloudFormation 堆疊**  
以下 `describe-stacks` 範例顯示 `myteststack` 堆疊的摘要資訊：  

```
aws cloudformation describe-stacks --stack-name myteststack
```
輸出：  

```
{
    "Stacks":  [
        {
            "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896",
            "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
            "Tags": [],
            "Outputs": [
                {
                    "Description": "Name of S3 bucket to hold website content",
                    "OutputKey": "BucketName",
                    "OutputValue": "myteststack-s3bucket-jssofi1zie2w"
                }
            ],
            "StackStatusReason": null,
            "CreationTime": "2013-08-23T01:02:15.422Z",
            "Capabilities": [],
            "StackName": "myteststack",
            "StackStatus": "CREATE_COMPLETE",
            "DisableRollback": false
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的堆疊。  
+  如需 API 詳細資訊，請參閱*《AWS CLI 命令參考》*中的 [DescribeStacks](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-stacks.html)。

### `describe-type-registration`
<a name="cloudformation_DescribeTypeRegistration_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-type-registration`。

**AWS CLI**  
**顯示類型註冊資訊**  
下列 `describe-type-registration` 範例顯示指定類型註冊的相關資訊，包括該類型的目前狀態、類型和版本。  

```
aws cloudformation describe-type-registration \
    --registration-token a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
```
輸出：  

```
{
    "ProgressStatus": "COMPLETE",
    "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup",
    "Description": "Deployment is currently in DEPLOY_STAGE of status COMPLETED; ",
    "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup/00000001"
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[使用 the CloudFormation 登錄檔](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeTypeRegistration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-type-registration.html)。

### `describe-type`
<a name="cloudformation_DescribeType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-type`。

**AWS CLI**  
**顯示類型資訊**  
下列 `describe-type` 範例顯示指定類型的資訊。  

```
aws cloudformation describe-type \
    --type-name My::Logs::LogGroup \
    --type RESOURCE
```
輸出：  

```
{
    "SourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs.git",
    "Description": "Customized resource derived from AWS::Logs::LogGroup",
    "TimeCreated": "2019-12-03T23:29:33.321Z",
    "Visibility": "PRIVATE",
    "TypeName": "My::Logs::LogGroup",
    "LastUpdated": "2019-12-03T23:29:33.321Z",
    "DeprecatedStatus": "LIVE",
    "ProvisioningType": "FULLY_MUTABLE",
    "Type": "RESOURCE",
    "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup/00000001",
    "Schema": "[details omitted]"
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[使用 the CloudFormation 登錄檔](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/describe-type.html)。

### `detect-stack-drift`
<a name="cloudformation_DetectStackDrift_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `detect-stack-drift`。

**AWS CLI**  
**偵測漂移的資源**  
以下 `detect-stack-drift` 範例為指定之堆疊啟動漂移偵測。  

```
aws cloudformation detect-stack-drift \
    --stack-name my-stack
```
輸出：  

```
{
    "StackDriftDetectionId": "1a229160-e4d9-xmpl-ab67-0a4f93df83d4"
}
```
然後就可以搭配使用此 ID和 `describe-stack-resource-drifts` 命令來描述漂移的資源。  
+  如需 API 詳細資訊，請參閱 *AWS CLI Command Reference* 中的 [DetectStackDrift](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/detect-stack-drift.html)。

### `detect-stack-resource-drift`
<a name="cloudformation_DetectStackResourceDrift_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `detect-stack-resource-drift`。

**AWS CLI**  
**偵測資源的漂移**  
下列 `detect-stack-resource-drift` 範例會檢查名為 `MyStack` 的堆疊中的名為 `MyFunction` 的資源漂移情況：  

```
aws cloudformation detect-stack-resource-drift \
   --stack-name MyStack \
   --logical-resource-id MyFunction
```
輸出顯示已修改out-of-band的 AWS Lambda 函數：  

```
{
    "StackResourceDrift": {
        "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/MyStack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
        "LogicalResourceId": "MyFunction",
        "PhysicalResourceId": "my-function-SEZV4XMPL4S5",
        "ResourceType": "AWS::Lambda::Function",
        "ExpectedProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":128,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":900,\"TracingConfig\":{\"Mode\":\"Active\"}}",
        "ActualProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":256,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":22,\"TracingConfig\":{\"Mode\":\"Active\"}}",
        "PropertyDifferences": [
            {
                "PropertyPath": "/MemorySize",
                "ExpectedValue": "128",
                "ActualValue": "256",
                "DifferenceType": "NOT_EQUAL"
            },
            {
                "PropertyPath": "/Timeout",
                "ExpectedValue": "900",
                "ActualValue": "22",
                "DifferenceType": "NOT_EQUAL"
            }
        ],
        "StackResourceDriftStatus": "MODIFIED",
        "Timestamp": "2019-10-02T05:58:47.433Z"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DetectStackResourceDrift](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/detect-stack-resource-drift.html)。

### `detect-stack-set-drift`
<a name="cloudformation_DetectStackSetDrift_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `detect-stack-set-drift`。

**AWS CLI**  
**偵測堆疊集上和整個關聯之堆疊執行個體的上漂移。**  
下列 `detect-stack-set-drift` 範例在指定的堆疊集上啟動漂移偵測操作，包括與該堆疊集相關聯的所有堆疊執行個體，並傳回可用於追蹤漂移操作狀態的操作 ID。  

```
aws cloudformation detect-stack-set-drift \
    --stack-set-name stack-set-drift-example
```
輸出：  

```
{
    "OperationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[偵測堆疊集中的未受管組態變更](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-drift.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DetectStackSetDrift](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/detect-stack-set-drift.html)。

### `estimate-template-cost`
<a name="cloudformation_EstimateTemplateCost_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `estimate-template-cost`。

**AWS CLI**  
**估算範本成本**  
下列 `estimate-template-cost` 範例會為目前資料夾中名為 `template.yaml` 的範本產生估算成本。  

```
aws cloudformation estimate-template-cost \
    --template-body file://template.yaml
```
輸出：  

```
{
    "Url": "http://calculator.s3.amazonaws.com/calc5.html?key=cloudformation/7870825a-xmpl-4def-92e7-c4f8dd360cca"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [EstimateTemplateCost](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/estimate-template-cost.html)。

### `execute-change-set`
<a name="cloudformation_ExecuteChangeSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `execute-change-set`。

**AWS CLI**  
**執行變更集**  
下列 `execute-change-set` 範例會執行由變更集名稱和堆疊名稱指定的變更集。  

```
aws cloudformation execute-change-set \
    --change-set-name my-change-set \
    --stack-name my-stack
```
下列 `execute-change-set` 範例會執行變更集的完整 ARN 所指定的變更集。  

```
aws cloudformation execute-change-set \
    --change-set-name arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ExecuteChangeSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/execute-change-set.html)。

### `execute-stack-refactor`
<a name="cloudformation_ExecuteStackRefactor_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `execute-stack-refactor`。

**AWS CLI**  
**完成堆疊重構操作**  
下列`execute-stack-refactor`範例會使用指定的堆疊重構 ID 完成堆疊重構操作。  

```
aws cloudformation execute-stack-refactor \
    --stack-refactor-id 9c384f70-4e07-4ed7-a65d-fee5eb430841
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[堆疊重構](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [ExecuteStackRefactor](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/execute-stack-refactor.html)。

### `get-stack-policy`
<a name="cloudformation_GetStackPolicy_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-stack-policy`。

**AWS CLI**  
**檢視堆疊政策**  
下列 `get-stack-policy` 範例顯示指定堆疊的堆疊政策。若要將政策連接至堆疊，請使用 `set-stack-policy` 命令。  

```
aws cloudformation get-stack-policy \
    --stack-name my-stack
```
輸出：  

```
{
    "StackPolicyBody": "{\n  \"Statement\" : [\n    {\n      \"Effect\" : \"Allow\",\n      \"Action\" : \"Update:*\",\n      \"Principal\": \"*\",\n      \"Resource\" : \"*\"\n    },\n    {\n      \"Effect\" : \"Deny\",\n      \"Action\" : \"Update:*\",\n      \"Principal\": \"*\",\n      \"Resource\" : \"LogicalResourceId/bucket\"\n    }\n  ]\n}\n"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetStackPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/get-stack-policy.html)。

### `get-template-summary`
<a name="cloudformation_GetTemplateSummary_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-template-summary`。

**AWS CLI**  
**顯示範本摘要**  
下列命令會顯示與指定範本檔案的資源和中繼資料相關的摘要資訊。  

```
aws cloudformation get-template-summary \
   --template-body file://template.yaml
```
輸出：  

```
{
    "Parameters": [],
    "Description": "A VPC and subnets.",
    "ResourceTypes": [
        "AWS::EC2::VPC",
        "AWS::EC2::Subnet",
        "AWS::EC2::Subnet",
        "AWS::EC2::RouteTable",
        "AWS::EC2::VPCEndpoint",
        "AWS::EC2::SubnetRouteTableAssociation",
        "AWS::EC2::SubnetRouteTableAssociation",
        "AWS::EC2::VPCEndpoint"
    ],
    "Version": "2010-09-09"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetTemplateSummary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/get-template-summary.html)。

### `get-template`
<a name="cloudformation_GetTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `get-template`。

**AWS CLI**  
**檢視 an AWS CloudFormation 堆疊的範本內文**  
下列 `get-template` 命令示範 `myteststack` 堆疊的範本：  

```
aws cloudformation get-template --stack-name myteststack
```
輸出：  

```
{
    "TemplateBody": {
        "AWSTemplateFormatVersion": "2010-09-09",
        "Outputs": {
            "BucketName": {
                "Description": "Name of S3 bucket to hold website content",
                "Value": {
                    "Ref": "S3Bucket"
                }
            }
        },
        "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
        "Resources": {
            "S3Bucket": {
                "Type": "AWS::S3::Bucket",
                "Properties": {
                    "AccessControl": "PublicRead"
                }
            }
        }
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/get-template.html)。

### `list-change-sets`
<a name="cloudformation_ListChangeSets_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-change-sets`。

**AWS CLI**  
**列出變更集**  
下列 `list-change-sets` 範例顯示指定堆疊的待處理變更集清單。  

```
aws cloudformation list-change-sets \
   --stack-name my-stack
```
輸出：  

```
{
    "Summaries": [
        {
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204",
            "StackName": "my-stack",
            "ChangeSetId": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/70160340-7914-xmpl-bcbf-128a1fa78b5d",
            "ChangeSetName": "my-change-set",
            "ExecutionStatus": "AVAILABLE",
            "Status": "CREATE_COMPLETE",
            "CreationTime": "2019-10-02T05:38:54.297Z"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListChangeSets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-change-sets.html)。

### `list-exports`
<a name="cloudformation_ListExports_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-exports`。

**AWS CLI**  
**列出匯出項目**  
下列 `list-exports` 範例顯示目前區域中堆疊的匯出清單。  

```
aws cloudformation list-exports
```
輸出：  

```
{
    "Exports": [
        {
            "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800",
            "Name": "private-vpc-subnet-a",
            "Value": "subnet-07b410xmplddcfa03"
        },
        {
            "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800",
            "Name": "private-vpc-subnet-b",
            "Value": "subnet-075ed3xmplebd2fb1"
        },
        {
            "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800",
            "Name": "private-vpc-vpcid",
            "Value": "vpc-011d7xmpl100e9841"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListExports](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-exports.html)。

### `list-generated-templates`
<a name="cloudformation_ListGeneratedTemplates_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-generated-templates`。

**AWS CLI**  
**列出產生的範本**  
下列`list-generated-templates`範例列出所有產生的範本。  

```
aws cloudformation list-generated-templates
```
輸出：  

```
{
    "Summaries": [
        {
            "GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedtemplate/7fc8512c-d8cb-4e02-b266-d39c48344e48",
            "GeneratedTemplateName": "MyTemplate",
            "Status": "COMPLETE",
            "StatusReason": "All resources complete",
            "CreationTime": "2025-09-23T20:13:24.283000+00:00",
            "LastUpdatedTime": "2025-09-23T20:13:28.610000+00:00",
            "NumberOfResources": 4
        },
        {
            "GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedTemplate/f10dd1c4-edc6-4823-8153-ab6112b8d051",
            "GeneratedTemplateName": "MyEC2InstanceTemplate",
            "Status": "COMPLETE",
            "StatusReason": "All resources complete",
            "CreationTime": "2024-08-08T19:35:49.790000+00:00",
            "LastUpdatedTime": "2024-08-08T19:35:52.207000+00:00",
            "NumberOfResources": 3
        },
        {
            "GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedTemplate/e5a1c89f-7ce2-41bd-9bdf-75b7c852e3ca",
            "GeneratedTemplateName": "MyEKSNodeGroupTemplate",
            "Status": "COMPLETE",
            "StatusReason": "All resources complete",
            "CreationTime": "2024-07-16T20:39:27.883000+00:00",
            "LastUpdatedTime": "2024-07-16T20:39:35.766000+00:00",
            "NumberOfResources": 4
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[從現有資源產生範本](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [ListGeneratedTemplates](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-generated-templates.html)。

### `list-imports`
<a name="cloudformation_ListImports_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-imports`。

**AWS CLI**  
**列出匯入項目**  
下列 `list-imports` 範例列出匯入指定匯出項目的堆疊。若要取得可用匯出的清單，請使用 `list-exports` 命令。  

```
aws cloudformation list-imports \
    --export-name private-vpc-vpcid
```
輸出：  

```
{
    "Imports": [
        "my-database-stack"
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListImports](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-imports.html)。

### `list-resource-scan-related-resources`
<a name="cloudformation_ListResourceScanRelatedResources_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-resource-scan-related-resources`。

**AWS CLI**  
**從資源掃描列出相關資源**  
下列`list-resource-scan-related-resources`範例列出來自指定資源掃描的資源，這些資源掃描與 中的資源相關`resources.json`。  

```
aws cloudformation list-resource-scan-related-resources \
    --resource-scan-id arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60 \
    --resources file://resources.json
```
`resources.json` 的內容：  

```
[
    {
        "ResourceType": "AWS::EKS::Cluster",
        "ResourceIdentifier": {
            "ClusterName": "MyAppClusterName"
        }
    },
    {
        "ResourceType": "AWS::AutoScaling::AutoScalingGroup",
        "ResourceIdentifier": {
            "AutoScalingGroupName": "MyAppASGName"
        }
    }
]
```
輸出：  

```
{
    "RelatedResources": [
        {
            "ResourceType": "AWS::EKS::Nodegroup",
            "ResourceIdentifier": {
                "NodegroupName": "MyAppNodegroupName"
            },
            "ManagedByStack": false
        },
        {
            "ResourceType": "AWS::IAM::Role",
            "ResourceIdentifier": {
                "RoleId": "arn:aws::iam::123456789012:role/MyAppIAMRole"
            },
            "ManagedByStack": false
        }
    ]
}
```
如需詳細資訊，請參閱[CloudFormation 使用者指南》中的從使用 IaC 產生器掃描的資源建立](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-create-template-from-scanned-resources.html) CloudFormation 範本。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [ListResourceScanRelatedResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-resource-scan-related-resources.html)。

### `list-resource-scan-resources`
<a name="cloudformation_ListResourceScanResources_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-resource-scan-resources`。

**AWS CLI**  
**從資源掃描列出資源**  
下列`list-resource-scan-resources`範例列出來自指定資源掃描的資源，依資源識別符篩選。  

```
aws cloudformation list-resource-scan-resources \
    --resource-scan-id arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60 \
    --resource-identifier MyApp
```
輸出：  

```
{
    "Resources": [
        {
            "ResourceType": "AWS::EKS::Cluster",
            "ResourceIdentifier": {
                "ClusterName": "MyAppClusterName"
            },
            "ManagedByStack": false
        },
        {
            "ResourceType": "AWS::AutoScaling::AutoScalingGroup",
            "ResourceIdentifier": {
                "AutoScalingGroupName": "MyAppASGName"
            },
            "ManagedByStack": false
        }
    ]
}
```
如需詳細資訊，請參閱[CloudFormation 使用者指南》中的從使用 IaC 產生器掃描的資源建立](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-create-template-from-scanned-resources.html) CloudFormation 範本。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [ListResourceScanResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-resource-scan-resources.html)。

### `list-stack-instances`
<a name="cloudformation_ListStackInstances_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stack-instances`。

**AWS CLI**  
**列出堆疊的執行個體**  
下列 `list-stack-instances` 範例列出從指定堆疊集建立的執行個體。  

```
aws cloudformation list-stack-instances \
    --stack-set-name enable-config
```
範例輸出包含因錯誤而無法更新之堆疊的詳細資訊：  

```
{
    "Summaries": [
        {
            "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743",
            "Region": "us-west-2",
            "Account": "123456789012",
            "StackId": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/StackSet-enable-config-35a6ac50-d9f8-4084-86e4-7da34d5de4c4/a1631cd0-e5fb-xmpl-b474-0aa20f14f06e",
            "Status": "CURRENT"
        },
        {
            "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743",
            "Region": "us-west-2",
            "Account": "123456789012",
            "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532/eab53680-e5fa-xmpl-ba14-0a522351f81e",
            "Status": "OUTDATED",
            "StatusReason": "ResourceLogicalId:ConfigDeliveryChannel, ResourceType:AWS::Config::DeliveryChannel, ResourceStatusReason:Failed to put delivery channel 'StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532-ConfigDeliveryChannel-1OJWJ7XD59WR0' because the maximum number of delivery channels: 1 is reached. (Service: AmazonConfig; Status Code: 400; Error Code: MaxNumberOfDeliveryChannelsExceededException; Request ID: d14b34a0-ef7c-xmpl-acf8-8a864370ae56)."
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListStackInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stack-instances.html)。

### `list-stack-refactor-actions`
<a name="cloudformation_ListStackRefactorActions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stack-refactor-actions`。

**AWS CLI**  
**列出堆疊重構操作的動作**  
下列`list-stack-refactor-actions`範例列出具有指定堆疊重構 ID 之堆疊重構操作的動作。  

```
aws cloudformation list-stack-refactor-actions \
    --stack-refactor-id 9c384f70-4e07-4ed7-a65d-fee5eb430841
```
輸出：  

```
{
    "StackRefactorActions": [
        {
            "Action": "MOVE",
            "Entity": "RESOURCE",
            "PhysicalResourceId": "MyTestLambdaRole",
            "Description": "No configuration changes detected.",
            "Detection": "AUTO",
            "TagResources": [],
            "UntagResources": [],
            "ResourceMapping": {
                "Source": {
                    "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack1/3e6a1ff0-94b1-11f0-aa6f-0a88d2e03acf",
                    "LogicalResourceId": "MyLambdaRole"
                },
                "Destination": {
                    "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b",
                    "LogicalResourceId": "MyLambdaRole"
                }
            }
        },
        {
            "Action": "MOVE",
            "Entity": "RESOURCE",
            "PhysicalResourceId": "MyTestFunction",
            "Description": "Resource configuration changes will be validated during refactor execution.",
            "Detection": "AUTO",
            "TagResources": [
                {
                    "Key": "aws:cloudformation:stack-name",
                    "Value": "Stack2"
                },
                {
                    "Key": "aws:cloudformation:logical-id",
                    "Value": "MyFunction"
                },
                {
                    "Key": "aws:cloudformation:stack-id",
                    "Value": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b"
                }
            ],
            "UntagResources": [
                "aws:cloudformation:stack-name",
                "aws:cloudformation:logical-id",
                "aws:cloudformation:stack-id"
            ],
            "ResourceMapping": {
                "Source": {
                    "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack1/3e6a1ff0-94b1-11f0-aa6f-0a88d2e03acf",
                    "LogicalResourceId": "MyFunction"
                },
                "Destination": {
                    "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b",
                    "LogicalResourceId": "MyFunction"
                }
            }
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[堆疊重構](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html)。  
+  如需 API 詳細資訊，請參閱《 *AWS CLI 命令參考*》中的 [ListStackRefactorActions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stack-refactor-actions.html)。

### `list-stack-resources`
<a name="cloudformation_ListStackResources_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stack-resources`。

**AWS CLI**  
**列出堆疊中的資源**  
下列命令顯示指定堆疊中的資源清單。  

```
aws cloudformation list-stack-resources \
    --stack-name my-stack
```
輸出：  

```
{
    "StackResourceSummaries": [
        {
            "LogicalResourceId": "bucket",
            "PhysicalResourceId": "my-stack-bucket-1vc62xmplgguf",
            "ResourceType": "AWS::S3::Bucket",
            "LastUpdatedTimestamp": "2019-10-02T04:34:11.345Z",
            "ResourceStatus": "CREATE_COMPLETE",
            "DriftInformation": {
                "StackResourceDriftStatus": "IN_SYNC"
            }
        },
        {
            "LogicalResourceId": "function",
            "PhysicalResourceId": "my-function-SEZV4XMPL4S5",
            "ResourceType": "AWS::Lambda::Function",
            "LastUpdatedTimestamp": "2019-10-02T05:34:27.989Z",
            "ResourceStatus": "UPDATE_COMPLETE",
            "DriftInformation": {
                "StackResourceDriftStatus": "IN_SYNC"
            }
        },
        {
            "LogicalResourceId": "functionRole",
            "PhysicalResourceId": "my-functionRole-HIZXMPLEOM9E",
            "ResourceType": "AWS::IAM::Role",
            "LastUpdatedTimestamp": "2019-10-02T04:34:06.350Z",
            "ResourceStatus": "CREATE_COMPLETE",
            "DriftInformation": {
                "StackResourceDriftStatus": "IN_SYNC"
            }
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListStackResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stack-resources.html)。

### `list-stack-set-operation-results`
<a name="cloudformation_ListStackSetOperationResults_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stack-set-operation-results`。

**AWS CLI**  
**列出堆疊集操作結果**  
下列命令顯示指定堆疊集中執行個體的更新操作結果。  

```
aws cloudformation list-stack-set-operation-results \
    --stack-set-name enable-config \
    --operation-id 35d45ebc-ed88-xmpl-ab59-0197a1fc83a0
```
輸出：  

```
{
    "Summaries": [
        {
            "Account": "223456789012",
            "Region": "us-west-2",
            "Status": "SUCCEEDED",
            "AccountGateResult": {
                "Status": "SKIPPED",
                "StatusReason": "Function not found: arn:aws:lambda:eu-west-1:223456789012:function:AWSCloudFormationStackSetAccountGate"
            }
        },
        {
            "Account": "223456789012",
            "Region": "ap-south-1",
            "Status": "CANCELLED",
            "StatusReason": "Cancelled since failure tolerance has exceeded"
        }
    ]
}
```
**注意：**除非建立帳戶閘道函數，否則 `AccountGateResult` 的 `SKIPPED` 狀態預計會操作成功。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListStackSetOperationResults](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stack-set-operation-results.html)。

### `list-stack-set-operations`
<a name="cloudformation_ListStackSetOperations_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stack-set-operations`。

**AWS CLI**  
**列出堆疊集操作**  
下列 `list-stack-set-operations` 範例顯示指定之堆疊集上的最近操作清單。  

```
aws cloudformation list-stack-set-operations \
    --stack-set-name my-stack-set
```
輸出：  

```
{
    "Summaries": [
        {
            "OperationId": "35d45ebc-ed88-xmpl-ab59-0197a1fc83a0",
            "Action": "UPDATE",
            "Status": "SUCCEEDED",
            "CreationTimestamp": "2019-10-03T16:28:44.377Z",
            "EndTimestamp": "2019-10-03T16:42:08.607Z"
        },
        {
            "OperationId": "891aa98f-7118-xmpl-00b2-00954d1dd0d6",
            "Action": "UPDATE",
            "Status": "FAILED",
            "CreationTimestamp": "2019-10-03T15:43:53.916Z",
            "EndTimestamp": "2019-10-03T15:45:58.925Z"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListStackSetOperations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stack-set-operations.html)。

### `list-stack-sets`
<a name="cloudformation_ListStackSets_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stack-sets`。

**AWS CLI**  
**列出堆疊集**  
下列 `list-stack-sets` 範例顯示目前區域和帳戶中的堆疊集清單。  

```
aws cloudformation list-stack-sets
```
輸出：  

```
{
    "Summaries": [
        {
            "StackSetName": "enable-config",
            "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743",
            "Description": "Enable AWS Config",
            "Status": "ACTIVE"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListStackSets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stack-sets.html)。

### `list-stacks`
<a name="cloudformation_ListStacks_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-stacks`。

**AWS CLI**  
**列出 AWS CloudFormation 堆疊**  
以下 `list-stacks` 命令示範狀態為 `CREATE_COMPLETE` 之所有堆疊的摘要：  

```
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE
```
輸出：  

```
[
    {
        "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896",
        "TemplateDescription": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
        "StackStatusReason": null,
        "CreationTime": "2013-08-26T03:27:10.190Z",
        "StackName": "myteststack",
        "StackStatus": "CREATE_COMPLETE"
    }
]
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListStacks](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-stacks.html)。

### `list-type-registrations`
<a name="cloudformation_ListTypeRegistrations_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-type-registrations`。

**AWS CLI**  
**列出已完成類型的註冊**  
下列 `list-type-registrations` 範例顯示指定類型的已完成類型的註冊清單。  

```
aws cloudformation list-type-registrations \
    --type RESOURCE \
    --type-name My::Logs::LogGroup \
    --registration-status-filter COMPLETE
```
輸出：  

```
{
    "RegistrationTokenList": [
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333"
    ]
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[使用 the CloudFormation 登錄檔](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTypeRegistrations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-type-registrations.html)。

### `list-type-versions`
<a name="cloudformation_ListTypeVersions_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-type-versions`。

**AWS CLI**  
**列出延伸模組的版本**  
下列 `list-type-versions` 範例傳回延伸模組版本的摘要資訊。  

```
aws cloudformation list-type-versions \
  --endpoint https://example.com \
  --region us-west-2 \
  --type RESOURCE \
  --type-name My::Resource::Example \
  --publisher-id 123456789012
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTypeVersions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-type-versions.html)。

### `list-types`
<a name="cloudformation_ListTypes_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `list-types`。

**AWS CLI**  
**列出帳戶中的私有資源類型**  
下列`list-types`範例顯示目前在目前 AWS 帳戶中註冊的私有資源類型清單。  

```
aws cloudformation list-types
```
輸出：  

```
{
    "TypeSummaries": [
        {
            "Description": "WordPress blog resource for internal use",
            "LastUpdated": "2019-12-04T18:28:15.059Z",
            "TypeName": "My::WordPress::BlogExample",
            "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-WordPress-BlogExample",
            "DefaultVersionId": "00000005",
            "Type": "RESOURCE"
        },
        {
            "Description": "Customized resource derived from AWS::Logs::LogGroup",
            "LastUpdated": "2019-12-04T18:28:15.059Z",
            "TypeName": "My::Logs::LogGroup",
            "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup",
            "DefaultVersionId": "00000003",
            "Type": "RESOURCE"
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[使用 the CloudFormation 登錄檔](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListTypes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/list-types.html)。

### `package`
<a name="cloudformation_Package_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `package`。

**AWS CLI**  
下列命令透過將本機成品上傳至 S3 儲存貯體 `bucket-name` 以匯出名為 `template.json` 的範本，並將匯出的範本寫入 `packaged-template.json`：  

```
aws cloudformation package --template-file /path_to_template/template.json --s3-bucket bucket-name --output-template-file packaged-template.json --use-json
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [Package](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/package.html)。

### `publish-type`
<a name="cloudformation_PublishType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `publish-type`。

**AWS CLI**  
**發佈延伸模組**  
下列 `publish-type` 範例將指定的延伸模組發佈至 CloudFormation 登錄檔，做為此區域中的公有延伸模組。  

```
aws cloudformation publish-type \
  --region us-west-2 \
  --type RESOURCE \
  --type-name Example::Test::1234567890abcdef0
```
輸出：  

```
{
    "PublicTypeArn":"arn:aws:cloudformation:us-west-2::type/resource/000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c/Example-Test-1234567890abcdef0/1.0.0"
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [PublishType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/publish-type.html)。

### `register-publisher`
<a name="cloudformation_RegisterPublisher_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `register-publisher`。

**AWS CLI**  
**註冊發布者**  
下列 `register-publisher` 範例會註冊發布者，並接受條款與條件參數。  

```
aws cloudformation register-publisher \
  --region us-west-2 \
  --accept-terms-and-conditions
```
輸出：  

```
{
    "PublisherId": "000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c"
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [RegisterPublisher](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/register-publisher.html)。

### `register-type`
<a name="cloudformation_RegisterType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `register-type`。

**AWS CLI**  
**註冊資源類型**  
下列 `register-type` 範例將指定的資源類型註冊為使用者帳戶中的私有資源類型。  

```
aws cloudformation register-type \
    --type-name My::Organization::ResourceName \
    --schema-handler-package s3://bucket_name/my-organization-resource_name.zip \
    --type RESOURCE
```
輸出：  

```
{
    "RegistrationToken": "f5525280-104e-4d35-bef5-8f1f1example"
}
```
如需詳細資訊，請參閱《*CloudFormation 命令列介面使用者指南*》中的[註冊資源提供者](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-register.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [RegisterType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/register-type.html)。

### `set-stack-policy`
<a name="cloudformation_SetStackPolicy_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `set-stack-policy`。

**AWS CLI**  
**套用堆疊政策**  
下列 `set-stack-policy` 範例停用對於指定堆疊中指定資源的更新。`stack-policy.json` 是 JSON 文件，此文件定義堆疊中資源上所允許的操作。  

```
aws cloudformation set-stack-policy \
    --stack-name my-stack \
    --stack-policy-body file://stack-policy.json
```
輸出：  

```
{
  "Statement" : [
    {
      "Effect" : "Allow",
      "Action" : "Update:*",
      "Principal": "*",
      "Resource" : "*"
    },
    {
      "Effect" : "Deny",
      "Action" : "Update:*",
      "Principal": "*",
      "Resource" : "LogicalResourceId/bucket"
    }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [SetStackPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/set-stack-policy.html)。

### `set-type-configuration`
<a name="cloudformation_SetTypeConfiguration_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `set-type-configuration`。

**AWS CLI**  
**設定資料**  
下列 `set-type-configuration` 範例在給定帳戶和區域中，指定註冊的 CloudFormation 延伸模組的組態資料。  

```
aws cloudformation set-type-configuration \
    --region us-west-2 \
    --type RESOURCE \
    --type-name Example::Test::Type \
    --configuration-alias default \
    --configuration "{\"CredentialKey\": \"testUserCredential\"}"
```
輸出：  

```
{
    "ConfigurationArn": "arn:aws:cloudformation:us-west-2:123456789012:type-configuration/resource/Example-Test-Type/default"
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [SetTypeConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/set-type-configuration.html)。

### `set-type-default-version`
<a name="cloudformation_SetTypeDefaultVersion_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `set-type-default-version`。

**AWS CLI**  
**設定類型的預設版本**  
下列 `set-type-default-version` 範例將指定的類型版本設定為此類型的預設值。  

```
aws cloudformation set-type-default-version \
    --type RESOURCE \
    --type-name My::Logs::LogGroup \
    --version-id 00000003
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的[使用 the CloudFormation 登錄檔](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [SetTypeDefaultVersion](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/set-type-default-version.html)。

### `signal-resource`
<a name="cloudformation_SignalResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `signal-resource`。

**AWS CLI**  
**向資源發出訊號**  
下列 `signal-resource` 範例會發出訊號 `success`，以滿足堆疊 `MyWaitCondition` 的等待條件 `my-stack`。  

```
aws cloudformation signal-resource \
    --stack-name my-stack \
    --logical-resource-id MyWaitCondition \
    --unique-id 1234 \
    --status SUCCESS
```
此命令不會產生輸出。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [SignalResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/signal-resource.html)。

### `start-resource-scan`
<a name="cloudformation_StartResourceScan_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `start-resource-scan`。

**AWS CLI**  
**啟動資源掃描**  
下列`start-resource-scan`範例會啟動資源掃描，以掃描目前帳戶和區域中所有現有的資源。  

```
aws cloudformation start-resource-scan
```
輸出：  

```
{
    "ResourceScanId":
      "arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60"
}
```
如需詳細資訊，請參閱《[CloudFormation 使用者指南》中的使用 CloudFormation IaC 產生器啟動資源掃描](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-start-resource-scan.html)。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StartResourceScan](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/start-resource-scan.html)。

### `stop-stack-set-operation`
<a name="cloudformation_StopStackSetOperation_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `stop-stack-set-operation`。

**AWS CLI**  
**停止堆疊集操作**  
下列 `stop-stack-set-operation` 範例將指定认堆疊集上進行中的更新操作停止。  

```
aws cloudformation stop-stack-set-operation \
    --stack-set-name my-stack-set \
    --operation-id 1261cd27-490b-xmpl-ab42-793a896c69e6
```
此命令不會產生輸出。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StopStackSetOperation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/stop-stack-set-operation.html)。

### `test-type`
<a name="cloudformation_TestType_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `test-type`。

**AWS CLI**  
**測試延伸模組**  
下列 `test-type` 範例測試已註冊延伸模組，確保其符合在 CloudFormation 登錄檔中發佈的所有必要需求。  

```
aws cloudformation test-type \
    --arn arn:aws:cloudformation:us-west-2:123456789012:type/resource/Sample-Test-Resource123/00000001
```
輸出：  

```
{
    "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Sample-Test-Resource123/00000001"
}
```
如需詳細資訊，請參閱《[AWS CloudFormation 使用者指南》中的使用 CloudFormation 登錄](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html)檔。 *AWS CloudFormation *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TestType](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/test-type.html)。

### `update-stack-instances`
<a name="cloudformation_UpdateStackInstances_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-stack-instances`。

**AWS CLI**  
**更新堆疊執行個體**  
下列 `update-stack-instances` 範例使用最新的設定，在兩個區域的兩個帳戶中，重試堆疊執行個體的更新。指定的容錯設定可以確保能在所有帳戶和區域中進行更新，即使無法更新某些堆疊。  

```
aws cloudformation update-stack-instances \
    --stack-set-name my-stack-set \
    --accounts 123456789012 567890123456 \
    --regions us-east-1 us-west-2 \
    --operation-preferences FailureToleranceCount=3
```
輸出：  

```
{
    "OperationId": "103ebdf2-21ea-xmpl-8892-de5e30733132"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateStackInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/update-stack-instances.html)。

### `update-stack-set`
<a name="cloudformation_UpdateStackSet_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-stack-set`。

**AWS CLI**  
**更新堆疊集**  
下列 `update-stack-set` 範例將索引鍵名稱為 `Owner` 且值為 `IT` 的標籤，新增至指定的堆疊集中的堆疊執行個體。  

```
aws cloudformation update-stack-set \
    --stack-set-name my-stack-set \
    --use-previous-template \
    --tags Key=Owner,Value=IT
```
輸出：  

```
{
    "OperationId": "e2b60321-6cab-xmpl-bde7-530c6f47950e"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateStackSet](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/update-stack-set.html)。

### `update-stack`
<a name="cloudformation_UpdateStack_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-stack`。

**AWS CLI**  
**更新 AWS CloudFormation 堆疊**  
以下 `update-stack` 命令更新 `mystack` 堆疊的範本和輸入參數：  

```
aws cloudformation update-stack --stack-name mystack --template-url https://s3.amazonaws.com/sample/updated.template --parameters ParameterKey=KeyPairName,ParameterValue=SampleKeyPair ParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1\\,SampleSubnetID2
```
以下 `update-stack` 命令僅更新 `mystack` 堆疊的 `SubnetIDs` 參數值。如果您未指定參數值，則會使用範本中所指定的預設值：  

```
aws cloudformation update-stack --stack-name mystack --template-url https://s3.amazonaws.com/sample/updated.template --parameters ParameterKey=KeyPairName,UsePreviousValue=true ParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1\\,UpdatedSampleSubnetID2
```
以下 `update-stack` 命令會將兩個堆疊通知主題新增至 `mystack` 堆疊：  

```
aws cloudformation update-stack --stack-name mystack --use-previous-template --notification-arns "arn:aws:sns:use-east-1:123456789012:mytopic1" "arn:aws:sns:us-east-1:123456789012:mytopic2"
```
如需詳細資訊，請參閱《*AWS CloudFormation 使用者指南*》中的 [AWS CloudFormation 堆疊更新](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateStack](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/update-stack.html)。

### `update-termination-protection`
<a name="cloudformation_UpdateTerminationProtection_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-termination-protection`。

**AWS CLI**  
**啟用終止保護**  
下列 `update-termination-protection` 範例會在指定的堆疊上啟用終止保護。  

```
aws cloudformation update-termination-protection \
    --stack-name my-stack \
    --enable-termination-protection
```
輸出：  

```
{
    "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateTerminationProtection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/update-termination-protection.html)。

### `validate-template`
<a name="cloudformation_ValidateTemplate_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `validate-template`。

**AWS CLI**  
**驗證 an AWS CloudFormation 範本**  
下列 `validate-template` 命令可驗證 `sampletemplate.json` 範本：  

```
aws cloudformation validate-template --template-body file://sampletemplate.json
```
輸出：  

```
{
    "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
    "Parameters": [],
    "Capabilities": []
}
```
如需詳細資訊，請參閱《 AWS CloudFormation *AWS 使用者指南》中的使用 CloudFormation *範本。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [ValidateTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/validate-template.html)。