View a markdown version of this page

搭配使用 CreateHostedZone 與 CLI - Amazon Route 53

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

搭配使用 CreateHostedZone 與 CLI

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

CLI
AWS CLI

若要建立託管區域

下列create-hosted-zone範例example.com會使用呼叫者參考 新增名為 的託管區域2014-04-01-18:47。選用的註解包含空格,因此必須以引號括住。

aws route53 create-hosted-zone \ --name example.com \ --caller-reference 2014-04-01-18:47 \ --hosted-zone-config Comment="command-line version"

輸出:

{ "Location": "https://route53.amazonaws.com/2013-04-01/hostedzone/Z1D633PJEXAMPLE", "HostedZone": { "Id": "/hostedzone/Z1D633PJEXAMPLE", "Name": "example.com.", "CallerReference": "2014-04-01-18:47", "Config": { "Comment": "command-line version", "PrivateZone": false }, "ResourceRecordSetCount": 2 }, "ChangeInfo": { "Id": "/change/C1PA6795EXAMPLE", "Status": "PENDING", "SubmittedAt": "2014-04-01T18:47:10.123Z" }, "DelegationSet": { "NameServers": [ "ns-2048.awsdns-64.com", "ns-2049.awsdns-65.net", "ns-2050.awsdns-66.org", "ns-2051.awsdns-67.co.uk" ] } }

如需詳細資訊,請參閱《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。

如需 AWS SDK 開發人員指南和程式碼範例的完整清單,請參閱 搭配 AWS SDK 使用 Route 53。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。