mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(route53): implement UpdateHostedZoneComment (#3906)
* feat(route53): implement UpdateHostedZoneComment The path carried GET and DELETE but no POST, so the action answered 405 and a caller that renames or re-comments a zone could not proceed. Terraform's aws_route53_zone sends it whenever the comment changes, which includes importing an existing zone under a new configuration. A request with no Comment clears the existing one, as AWS documents, rather than leaving the previous value in place. * fix(route53): reject a body that is not an UpdateHostedZoneCommentRequest A missing Comment means "clear the comment", and XmlParser returns the default for a body it cannot parse, so a truncated or wrong-root document cleared the zone's comment and answered 200. Validate the root element first. * fix(route53): resolve the zone through the caller-ownership lookup UpdateHostedZoneComment resolved the zone with getHostedZone, which reads pre-account-isolation data written before the store was account-scoped and migrates it into whichever partition asked for it first. Use the same lookup the VPC association actions use, so only the owning account can rewrite the comment.
This commit is contained in:
1 parent
df9535d7db
commit
037236daf8
4 files changed
+143
No files matched your search
@@ -122,6 +122,28 @@ public class Route53Controller {
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/hostedzone/{Id}")
|
||||
public Response updateHostedZoneComment(@PathParam("Id") String id, String body) {
|
||||
try {
|
||||
if (body != null && !body.isBlank()
|
||||
&& !"UpdateHostedZoneCommentRequest".equals(XmlParser.rootElementName(body))) {
|
||||
throw new AwsException("InvalidInput",
|
||||
"The request body must be an UpdateHostedZoneCommentRequest document.", 400);
|
||||
}
|
||||
String comment = XmlParser.extractFirst(body, "Comment", null);
|
||||
HostedZone zone = service.updateHostedZoneComment(id, comment);
|
||||
String xml = new XmlBuilder()
|
||||
.start("UpdateHostedZoneCommentResponse", NS)
|
||||
.raw(xmlHostedZone(zone))
|
||||
.end("UpdateHostedZoneCommentResponse")
|
||||
.build();
|
||||
return Response.ok(xml, XML).build();
|
||||
} catch (AwsException e) {
|
||||
return xmlErrorResponse(e);
|
||||
}
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/hostedzone/{Id}")
|
||||
public Response deleteHostedZone(@PathParam("Id") String id) {
|
||||
|
||||
@@ -137,6 +137,17 @@ public class Route53Service {
|
||||
return newChange(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The comment is cleared when the request carries none, which is what AWS does rather than
|
||||
* leaving the previous comment in place.
|
||||
*/
|
||||
public synchronized HostedZone updateHostedZoneComment(String id, String comment) {
|
||||
HostedZone zone = getHostedZoneOwnedByCaller(id);
|
||||
zone.setComment(comment);
|
||||
zoneStore.put(id, zone);
|
||||
return zone;
|
||||
}
|
||||
|
||||
public List<HostedZone> listHostedZones(String marker, int maxItems) {
|
||||
List<HostedZone> all = new ArrayList<>(zoneStore.scan(k -> true));
|
||||
all.sort((a, b) -> a.getName().compareTo(b.getName()));
|
||||
|
||||
Reference in new issue
Block a user