

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

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

# 搭配使用 `CreateHostedZone` 與 CLI
<a name="route-53_example_route-53_CreateHostedZone_section"></a>

下列程式碼範例示範如何使用 `CreateHostedZone`。

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

**AWS CLI**  
**若要建立託管區域**  
下列 `create-hosted-zone` 命令會使用呼叫者參考 `2014-04-01-18:47` 新增名為 `example.com` 的託管區域。選用的註解包含空格，因此必須以引號括住：  

```
aws route53 create-hosted-zone --name example.com --caller-reference 2014-04-01-18:47 --hosted-zone-config Comment="command-line version"
```
如需詳細資訊，請參閱《Amazon Route 53 開發人員指南》中的*使用託管區域*。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateHostedZone](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/route53/create-hosted-zone.html)。

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

**Tools for PowerShell V4**  
**範例 1：建立名為 'example.com'，且與可重複使用的委派集相關聯的新託管區域。請注意，您必須為 CallerReference 參數提供一個值，以便在必要時重試請求，而不會有執行兩次操作的風險。由於託管區域是在 VPC 中建立，因此會自動變成私有，而且您不應該設定 -HostedZoneConfig\$1PrivateZone 參數。**  

```
$params = @{
    Name="example.com"
    CallerReference="myUniqueIdentifier"
    HostedZoneConfig_Comment="This is my first hosted zone"
    DelegationSetId="NZ8X2CISAMPLE"
    VPC_VPCId="vpc-1a2b3c4d"
    VPC_VPCRegion="us-east-1"
}

New-R53HostedZone @params
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [CreateHostedZone](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：建立名為 'example.com'，且與可重複使用的委派集相關聯的新託管區域。請注意，您必須為 CallerReference 參數提供一個值，以便在必要時重試請求，而不會有執行兩次操作的風險。由於託管區域是在 VPC 中建立，因此會自動變成私有，而且您不應該設定 -HostedZoneConfig\$1PrivateZone 參數。**  

```
$params = @{
    Name="example.com"
    CallerReference="myUniqueIdentifier"
    HostedZoneConfig_Comment="This is my first hosted zone"
    DelegationSetId="NZ8X2CISAMPLE"
    VPC_VPCId="vpc-1a2b3c4d"
    VPC_VPCRegion="us-east-1"
}

New-R53HostedZone @params
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [CreateHostedZone](https://docs.aws.amazon.com/powershell/v5/reference)。

------