mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(cloudformation): support UpdateTerminationProtection (#1692)
* feat(cloudformation): support UpdateTerminationProtection CDK bootstrap calls UpdateTerminationProtection on the CDKToolkit stack; Floci returned UnknownAction. Add it: a boolean enableTerminationProtection on Stack, a CloudFormationService.updateTerminationProtection(stackName, enabled, region) that sets and persists it, a handler returning the UpdateTerminationProtectionResult/StackId envelope, and the flag echoed as <EnableTerminationProtection> in DescribeStacks. Register the action in AwsQueryController's CloudFormation action set so the Query-protocol POST routes to CloudFormation instead of falling through. Adds an integration test toggling the flag and asserting it round-trips through DescribeStacks. * docs: regenerate action tables
This commit is contained in:
1 parent
dd566857ef
commit
4a16266f48
6 files changed
+179
-8
No files matched your search
+118
@@ -172,6 +172,124 @@ class CloudFormationIntegrationTest {
|
||||
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTerminationProtection_togglesFlagAndReflectsInDescribeStacks() {
|
||||
String template = """
|
||||
{ "Resources": { "Q": { "Type": "AWS::SQS::Queue",
|
||||
"Properties": { "QueueName": "cf-tp-queue" } } } }
|
||||
""";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "tp-stack")
|
||||
.formParam("TemplateBody", template)
|
||||
.when().post("/")
|
||||
.then().statusCode(200).body(containsString("<StackId>"));
|
||||
|
||||
// DescribeStacks reports protection off by default.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "tp-stack")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<EnableTerminationProtection>false</EnableTerminationProtection>"));
|
||||
|
||||
// Enable termination protection — returns the StackId.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "UpdateTerminationProtection")
|
||||
.formParam("StackName", "tp-stack")
|
||||
.formParam("EnableTerminationProtection", "true")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<StackId>"))
|
||||
.body(containsString("</UpdateTerminationProtectionResult>"));
|
||||
|
||||
// DescribeStacks now reflects it.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "tp-stack")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<EnableTerminationProtection>true</EnableTerminationProtection>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteStack_protectedStackIsRejectedAndStackRemains() {
|
||||
String template = """
|
||||
{ "Resources": { "Q": { "Type": "AWS::SQS::Queue",
|
||||
"Properties": { "QueueName": "cf-tp-del-queue" } } } }
|
||||
""";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "tp-del-stack")
|
||||
.formParam("TemplateBody", template)
|
||||
.when().post("/")
|
||||
.then().statusCode(200).body(containsString("<StackId>"));
|
||||
|
||||
// Enable termination protection.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "UpdateTerminationProtection")
|
||||
.formParam("StackName", "tp-del-stack")
|
||||
.formParam("EnableTerminationProtection", "true")
|
||||
.when().post("/")
|
||||
.then().statusCode(200);
|
||||
|
||||
// DeleteStack is rejected with a 400 ValidationError (XML error body, Query protocol).
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DeleteStack")
|
||||
.formParam("StackName", "tp-del-stack")
|
||||
.when().post("/")
|
||||
.then().statusCode(400)
|
||||
.contentType(containsString("xml"))
|
||||
.body(containsString("<Code>ValidationError</Code>"))
|
||||
.body(containsString("cannot be deleted while TerminationProtection is enabled"));
|
||||
|
||||
// The stack still exists and is not in a DELETE state.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "tp-del-stack")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<StackName>tp-del-stack</StackName>"))
|
||||
.body(not(containsString("DELETE_IN_PROGRESS")))
|
||||
.body(not(containsString("DELETE_COMPLETE")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_withTerminationProtectionEnabled() {
|
||||
String template = """
|
||||
{ "Resources": { "Q": { "Type": "AWS::SQS::Queue",
|
||||
"Properties": { "QueueName": "cf-tp-create-queue" } } } }
|
||||
""";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "tp-create-stack")
|
||||
.formParam("TemplateBody", template)
|
||||
.formParam("EnableTerminationProtection", "true")
|
||||
.when().post("/")
|
||||
.then().statusCode(200).body(containsString("<StackId>"));
|
||||
|
||||
// The CreateStackInput flag is honored — DescribeStacks reports protection on.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "tp-create-stack")
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.body(containsString("<EnableTerminationProtection>true</EnableTerminationProtection>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_s3BucketWithCorsConfiguration() {
|
||||
String template = """
|
||||
|
||||
Reference in new issue
Block a user