Added support for comment on a route53 zone.

This commit is contained in:
Stephen Chu 2015-05-21 19:51:53 +00:00
parent e5f5e1a167
commit cfbd546286
2 changed files with 17 additions and 2 deletions

View File

@ -35,6 +35,11 @@ func resourceAwsRoute53Zone() *schema.Resource {
ForceNew: true, ForceNew: true,
}, },
"comment": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"vpc_region": &schema.Schema{ "vpc_region": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Optional: true, Optional: true,
@ -61,10 +66,13 @@ func resourceAwsRoute53Zone() *schema.Resource {
func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsRoute53ZoneCreate(d *schema.ResourceData, meta interface{}) error {
r53 := meta.(*AWSClient).r53conn r53 := meta.(*AWSClient).r53conn
comment := &route53.HostedZoneConfig{Comment: aws.String("Managed by Terraform")} comment := "Managed by Terraform"
if c := d.Get("comment"); c != "" {
comment = c.(string)
}
req := &route53.CreateHostedZoneInput{ req := &route53.CreateHostedZoneInput{
Name: aws.String(d.Get("name").(string)), Name: aws.String(d.Get("name").(string)),
HostedZoneConfig: comment, HostedZoneConfig: &route53.HostedZoneConfig{Comment: aws.String(comment)},
CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)), CallerReference: aws.String(time.Now().Format(time.RFC3339Nano)),
} }
if v := d.Get("vpc_id"); v != "" { if v := d.Get("vpc_id"); v != "" {

View File

@ -203,6 +203,12 @@ func testAccCheckRoute53ZoneExistsWithProvider(s *terraform.State, n string, zon
return fmt.Errorf("Hosted zone err: %v", err) return fmt.Errorf("Hosted zone err: %v", err)
} }
aws_comment := *resp.HostedZone.Config.Comment
rs_comment := rs.Primary.Attributes["comment"]
if rs_comment != "" && rs_comment != aws_comment {
return fmt.Errorf("Hosted zone with comment '%s' found but does not match '%s'", aws_comment, rs_comment)
}
if !*resp.HostedZone.Config.PrivateZone { if !*resp.HostedZone.Config.PrivateZone {
sorted_ns := make([]string, len(resp.DelegationSet.NameServers)) sorted_ns := make([]string, len(resp.DelegationSet.NameServers))
for i, ns := range resp.DelegationSet.NameServers { for i, ns := range resp.DelegationSet.NameServers {
@ -272,6 +278,7 @@ func testAccLoadTagsR53(zone *route53.GetHostedZoneOutput, td *route53.ResourceT
const testAccRoute53ZoneConfig = ` const testAccRoute53ZoneConfig = `
resource "aws_route53_zone" "main" { resource "aws_route53_zone" "main" {
name = "hashicorp.com" name = "hashicorp.com"
comment = "Custom comment"
tags { tags {
foo = "bar" foo = "bar"