-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provider/aws: Add ability to update r53 zone comment #5318
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()), | ||
|
@@ -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") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't btw. I think |
||
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) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the third condition is necessary since
d.Set
should be able to handlenil
s, but it does no harm. 😉There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely familiar with what the underlying API does here but it could actually be important as it means that unsetting a comment in the UI will not be reflected in the state if it becomes nil vs empty string? (Also not sure whether removing a comment is even a thing, not overly familiar with R53)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jen20 there is no real risk here. It can be made an empty string but I just wanted to catch any potential panic points :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM then.