

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](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 ]

**适用于 PowerShell V4 的工具**  
**示例 1：创建名为“example.com”的新托管区，并与可重复使用的委托集相关联。请注意，您必须为 CallerReference 参数提供一个值，这样在必要时需要重试的请求就不会有执行两次操作的风险。由于托管区域是在 VPC 中创建的，因此它自动为私有区域，因此您不应设置-HostedZoneConfig \$1 PrivateZone 参数。**  

```
$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 参考 (V* 4) [CreateHostedZone](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：创建名为“example.com”的新托管区，并与可重复使用的委托集相关联。请注意，您必须为 CallerReference 参数提供一个值，这样在必要时需要重试的请求就不会有执行两次操作的风险。由于托管区域是在 VPC 中创建的，因此它自动为私有区域，因此您不应设置-HostedZoneConfig \$1 PrivateZone 参数。**  

```
$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 参考 (V* 5) [CreateHostedZone](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------