Skip to content

Commit

Permalink
provider/aws: Add ability to update r53 zone comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stack72 committed Feb 25, 2016
1 parent dd4f696 commit 52f4cac
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
17 changes: 17 additions & 0 deletions builtin/providers/aws/resource_aws_route53_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
d.Set("delegation_set_id", cleanDelegationSetId(*zone.DelegationSet.Id))
}

if zone.HostedZone != nil && zone.HostedZone.Config != nil && zone.HostedZone.Config.Comment != nil {
d.Set("comment", zone.HostedZone.Config.Comment)
}

// get tags
req := &route53.ListTagsForResourceInput{
ResourceId: aws.String(d.Id()),
Expand All @@ -197,6 +201,19 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
func resourceAwsRoute53ZoneUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).r53conn

if d.HasChange("comment") {
zoneInput := route53.UpdateHostedZoneCommentInput{
Id: aws.String(d.Id()),
Comment: aws.String(d.Get("comment").(string)),
}

_, err := conn.UpdateHostedZoneComment(&zoneInput)
if err != nil {
return err
}

}

if err := setTagsR53(conn, d, "hostedzone"); err != nil {
return err
} else {
Expand Down
45 changes: 45 additions & 0 deletions builtin/providers/aws/resource_aws_route53_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,39 @@ func TestAccAWSRoute53Zone_basic(t *testing.T) {
})
}

func TestAccAWSRoute53Zone_updateComment(t *testing.T) {
var zone route53.GetHostedZoneOutput
var td route53.ResourceTagSet

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRoute53ZoneDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRoute53ZoneConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53ZoneExists("aws_route53_zone.main", &zone),
testAccLoadTagsR53(&zone, &td),
testAccCheckTagsR53(&td.Tags, "foo", "bar"),
resource.TestCheckResourceAttr(
"aws_route53_zone.main", "comment", "Custom comment"),
),
},

resource.TestStep{
Config: testAccRoute53ZoneConfigUpdateComment,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53ZoneExists("aws_route53_zone.main", &zone),
testAccLoadTagsR53(&zone, &td),
resource.TestCheckResourceAttr(
"aws_route53_zone.main", "comment", "Change Custom Comment"),
),
},
},
})
}

func TestAccAWSRoute53Zone_private_basic(t *testing.T) {
var zone route53.GetHostedZoneOutput

Expand Down Expand Up @@ -287,6 +320,18 @@ resource "aws_route53_zone" "main" {
}
`

const testAccRoute53ZoneConfigUpdateComment = `
resource "aws_route53_zone" "main" {
name = "hashicorp.com"
comment = "Change Custom Comment"
tags {
foo = "bar"
Name = "tf-route53-tag-test"
}
}
`

const testAccRoute53PrivateZoneConfig = `
resource "aws_vpc" "main" {
cidr_block = "172.29.0.0/24"
Expand Down

0 comments on commit 52f4cac

Please sign in to comment.