fix(cloudfront): retain distribution tags by ARN (#6797)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-28 07:05:00 -04:00
1 parent 9fcf1683ee
commit 582dba6419
4 files changed
+75 -2

No files matched your search

@@ -66,7 +66,7 @@ public class CloudFrontController {
try {
DistributionConfig config = parseDistributionConfig(body);
Map<String, String> tags = new LinkedHashMap<>();
if (withTags != null) {
if (withTags != null || "DistributionConfigWithTags".equals(XmlParser.rootElementName(body))) {
tags = parseTags(body);
}
Distribution dist = new Distribution();
@@ -218,7 +218,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
dist.setEtag(UUID.randomUUID().toString());
if (tags != null && !tags.isEmpty()) {
dist.setTags(tags);
tagStore.put("distribution/" + id, tags);
tagStore.put(dist.getArn(), tags);
}
distStore.put(id, dist);
return dist;
@@ -443,6 +443,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
}
distStore.delete(id);
invalidationStore.delete(id);
tagStore.delete(existing.getArn());
tagStore.delete("distribution/" + id);
}
@@ -452,8 +453,12 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
* which owns the resource lifecycle at the stack level.
*/
public synchronized void removeDistribution(String id) {
Distribution existing = distStore.get(id).orElse(null);
distStore.delete(id);
invalidationStore.delete(id);
if (existing != null) {
tagStore.delete(existing.getArn());
}
tagStore.delete("distribution/" + id);
}