Skip to content

Commit

Permalink
Merge pull request #5318 from stack72/f-aws-route53zone-updateComment
Browse files Browse the repository at this point in the history
provider/aws: Add ability to update r53 zone comment
  • Loading branch information
stack72 committed Feb 26, 2016
2 parents f249a43 + d750d4d commit a372800
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
22 changes: 22 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,12 +201,30 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
func resourceAwsRoute53ZoneUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).r53conn

d.Partial(true)

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
} else {
d.SetPartial("comment")
}
}

if err := setTagsR53(conn, d, "hostedzone"); err != nil {
return err
} else {
d.SetPartial("tags")
}

d.Partial(false)

return resourceAwsRoute53ZoneRead(d, meta)
}

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 a372800

Please sign in to comment.