expose Route53 zone name servers

This commit is contained in:
Luke Amdor 2015-04-14 14:17:01 -05:00
parent 0bd7856942
commit 8f1acaf026
2 changed files with 18 additions and 1 deletions

View File

@ -31,6 +31,12 @@ func resourceAwsRoute53Zone() *schema.Resource {
Computed: true,
},
"delegation_set_name_servers": &schema.Schema{
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"tags": tagsSchema(),
},
}
@ -80,7 +86,7 @@ func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) erro
func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error {
r53 := meta.(*AWSClient).r53conn
_, err := r53.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(d.Id())})
zone, err := r53.GetHostedZone(&route53.GetHostedZoneRequest{ID: aws.String(d.Id())})
if err != nil {
// Handle a deleted zone
if r53err, ok := err.(aws.APIError); ok && r53err.Code == "NoSuchHostedZone" {
@ -90,6 +96,8 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
return err
}
d.Set("delegation_set_name_servers", zone.DelegationSet.NameServers)
// get tags
req := &route53.ListTagsForResourceRequest{
ResourceID: aws.String(d.Id()),

View File

@ -114,6 +114,15 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource.
if err != nil {
return fmt.Errorf("Hosted zone err: %v", err)
}
for i, ns := range resp.DelegationSet.NameServers {
attribute := fmt.Sprintf("delegation_set_name_servers.%d", i)
dsns := rs.Primary.Attributes[attribute]
if dsns != ns {
return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns)
}
}
*zone = *resp.HostedZone
return nil
}