最后再看看如何用PowerShell 管理AWS的DNS服务。
Route 53的启用很简单,可以在AWS上注册新的域名 也可以在其他网站注册新的域名再迁徙过来。豆子在GoDaddy上已经有一个域名 beanxyz.com了,管理界面挪到Route 53 很简单,在Route 53新建一个HostedZone beanxyz.com, 他会自动生成对应的NS 记录,在我的GoDaddy里面把NS记录指向AWS的NS就行了。
手动配置很简单,如下所示,我创建了一个blog.beanxyz.com 的记录
下面简单的演示用PowerShell来修改这个记录,修改的操作其实是删除和创建两个步骤
$domain=Get-R53HostedZonesByName -DNSName beanxyz.com $hostid=$domain.id.Split("/")[2] Get-R53ResourceRecordSet -HostedZoneId $domain.id.Split("/")[2] | select -ExpandProperty ResourceRecordSets $change1 = New-Object Amazon.Route53.Model.Change $change1.Action = "DELETE" $change1.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "blog.beanxyz.com" $change1.ResourceRecordSet.Type = "A" $change1.ResourceRecordSet.TTL = 300 $change1.ResourceRecordSet.ResourceRecords.Add(@{Value="52.63.115.148"}) $change3 = New-Object Amazon.Route53.Model.Change $change3.Action = "CREATE" $change3.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change3.ResourceRecordSet.Name = "blog.beanxyz.com" $change3.ResourceRecordSet.Type = "A" $change3.ResourceRecordSet.TTL = 300 $change3.ResourceRecordSet.ResourceRecords.Add(@{Value="52.63.241.219"}) $params = @{ HostedZoneId=$hostid ChangeBatch_Comment="Changes the A record for blog.beanxyz.com from 52.63.115.148 to 52.63.241.219" ChangeBatch_Change=$change1,$change3 } Edit-R53ResourceRecordSet @params
执行成功
稍等片刻之后 DNS就可以成功解析了
本文出自 “麻婆豆腐” 博客,请务必保留此出处http://beanxyz.blog.51cto.com/5570417/1827402
Powershell AWS 自动化管理 (9) - Route 53
原文地址:http://beanxyz.blog.51cto.com/5570417/1827402