

Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 [AWS](https://github.com/awsdocs/aws-doc-sdk-examples)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# CLI で `GetTemplate` を使用する
<a name="cloudformation_example_cloudformation_GetTemplate_section"></a>

次のサンプルコードは、`GetTemplate` を使用する方法を説明しています。

------
#### [ CLI ]

**AWS CLI**  
** 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)」を参照してください。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**例 1: 指定されたスタックに関連付けられているテンプレートを返します。**  

```
Get-CFNTemplate -StackName "myStack"
```
+  API の詳細については、「*AWS Tools for PowerShell Cmdlet Reference (V4)*」の「[GetTemplate](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**Tools for PowerShell V5**  
**例 1: 指定されたスタックに関連付けられているテンプレートを返します。**  

```
Get-CFNTemplate -StackName "myStack"
```
+  API の詳細については、「*AWS Tools for PowerShell Cmdlet Reference (V5)*」の「[GetTemplate](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

------