

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

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

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

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

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

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

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

**Tools for PowerShell V4**  
**例 1: 指定されたテンプレートコンテンツを検証します。出力は、テンプレートの機能、説明、パラメータを詳しく説明します。**  

```
Test-CFNTemplate -TemplateBody "{TEMPLATE CONTENT HERE}"
```
**例 2: Amazon S3 URL 経由でアクセスされる、指定されたテンプレートを検証します。出力は、テンプレートの機能、説明、パラメータを詳しく説明します。**  

```
Test-CFNTemplate -TemplateURL https://s3.amazonaws.com/amzn-s3-demo-bucket/templatefile.template
```
+  API の詳細については、「*AWS Tools for PowerShell Cmdlet Reference (V4)*」の「[ValidateTemplate](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**Tools for PowerShell V5**  
**例 1: 指定されたテンプレートコンテンツを検証します。出力は、テンプレートの機能、説明、パラメータを詳しく説明します。**  

```
Test-CFNTemplate -TemplateBody "{TEMPLATE CONTENT HERE}"
```
**例 2: Amazon S3 URL 経由でアクセスされる、指定されたテンプレートを検証します。出力は、テンプレートの機能、説明、パラメータを詳しく説明します。**  

```
Test-CFNTemplate -TemplateURL https://s3.amazonaws.com/amzn-s3-demo-bucket/templatefile.template
```
+  API の詳細については、「*AWS Tools for PowerShell Cmdlet Reference (V5)*」の「[ValidateTemplate](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

------