Merge pull request #5318 from stack72/f-aws-route53zone-updateComment
provider/aws: Add ability to update r53 zone comment
This commit is contained in:
commit
a372800cd0
|
@ -171,6 +171,10 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
|
||||||
d.Set("delegation_set_id", cleanDelegationSetId(*zone.DelegationSet.Id))
|
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
|
// get tags
|
||||||
req := &route53.ListTagsForResourceInput{
|
req := &route53.ListTagsForResourceInput{
|
||||||
ResourceId: aws.String(d.Id()),
|
ResourceId: aws.String(d.Id()),
|
||||||
|
@ -197,12 +201,30 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
|
||||||
func resourceAwsRoute53ZoneUpdate(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsRoute53ZoneUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AWSClient).r53conn
|
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 {
|
if err := setTagsR53(conn, d, "hostedzone"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
d.SetPartial("tags")
|
d.SetPartial("tags")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.Partial(false)
|
||||||
|
|
||||||
return resourceAwsRoute53ZoneRead(d, meta)
|
return resourceAwsRoute53ZoneRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
func TestAccAWSRoute53Zone_private_basic(t *testing.T) {
|
||||||
var zone route53.GetHostedZoneOutput
|
var zone route53.GetHostedZoneOutput
|
||||||
|
|
||||||
|
@ -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 = `
|
const testAccRoute53PrivateZoneConfig = `
|
||||||
resource "aws_vpc" "main" {
|
resource "aws_vpc" "main" {
|
||||||
cidr_block = "172.29.0.0/24"
|
cidr_block = "172.29.0.0/24"
|
||||||
|
|
Loading…
Reference in New Issue