Add support for CloudFormation's DeleteChangeSet

This commit is contained in:
Benjamin Hintz committed 2026-03-24 17:06:01 +01:00
1 parent 5eeb6828cc
commit 794939c331
3 files changed
+57

No files matched your search

@@ -46,6 +46,7 @@ public class CloudFormationQueryHandler {
case "CreateChangeSet" -> createChangeSet(params, region);
case "DescribeChangeSet" -> describeChangeSet(params, region);
case "ExecuteChangeSet" -> executeChangeSet(params, region);
case "DeleteChangeSet" -> deleteChangeSet(params, region);
case "ListChangeSets" -> listChangeSets(params, region);
case "DescribeStackEvents" -> describeStackEvents(params, region);
case "DescribeStackResources" -> describeStackResources(params, region);
@@ -222,6 +223,25 @@ public class CloudFormationQueryHandler {
return Response.ok(xml).type("text/xml").build();
}
// ── DeleteChangeSet ───────────────────────────────────────────────────────
private Response deleteChangeSet(MultivaluedMap<String, String> params, String region) {
String stackName = params.getFirst("StackName");
String changeSetName = params.getFirst("ChangeSetName");
try {
cfnService.deleteChangeSet(stackName, changeSetName, region);
} catch (AwsException e) {
return xmlError(e.getErrorCode(), e.getMessage(), e.getHttpStatus());
}
String xml = new XmlBuilder()
.start("DeleteChangeSetResponse", CF_NS)
.raw("<DeleteChangeSetResult/>")
.raw(AwsQueryResponse.responseMetadata())
.end("DeleteChangeSetResponse")
.build();
return Response.ok(xml).type("text/xml").build();
}
// ── ListChangeSets ────────────────────────────────────────────────────────
private Response listChangeSets(MultivaluedMap<String, String> params, String region) {
@@ -128,6 +128,18 @@ public class CloudFormationService {
executor.submit(() -> executeTemplate(stack, templateBody, params, isCreate, region));
}
// ── DeleteChangeSet ───────────────────────────────────────────────────────
public void deleteChangeSet(String stackName, String changeSetName, String region) {
Stack stack = getStackOrThrow(stackName, region);
ChangeSet cs = stack.getChangeSets().get(changeSetName);
if (cs == null) {
throw new AwsException("ChangeSetNotFoundException",
"ChangeSet [" + changeSetName + "] does not exist", 400);
}
stack.getChangeSets().remove(changeSetName);
}
// ── DeleteStack ───────────────────────────────────────────────────────────
public void deleteStack(String stackName, String region) {