搭配使用 CreateHostedZone 與 CLI - AWS SDK 程式碼範例

AWS文件開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例。

搭配使用 CreateHostedZone 與 CLI

下列程式碼範例示範如何使用 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

PowerShell
Tools for PowerShell V4

範例 1:建立名為 'example.com',且與可重複使用的委派集相關聯的新託管區域。請注意,您必須為 CallerReference 參數提供一個值,以便在必要時重試請求,而不會有執行兩次操作的風險。由於託管區域是在 VPC 中建立,因此會自動變成私有,而且您不應該設定 -HostedZoneConfig_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 參考 (V4)》中的 CreateHostedZone

Tools for PowerShell V5

範例 1:建立名為 'example.com',且與可重複使用的委派集相關聯的新託管區域。請注意,您必須為 CallerReference 參數提供一個值,以便在必要時重試請求,而不會有執行兩次操作的風險。由於託管區域是在 VPC 中建立,因此會自動變成私有,而且您不應該設定 -HostedZoneConfig_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 參考 (V5)》中的 CreateHostedZone