mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): implement nested stack deployment via AWS::CloudFormation::Stack (#1052)
Previously AWS::CloudFormation::Stack was stubbed — it returned a synthetic stack ID but never fetched or deployed the child template, so all resources defined in nested stacks were silently skipped. Intercept AWS::CloudFormation::Stack in CloudFormationService.executeTemplate() before delegating to the provisioner. Resolve TemplateURL via the template engine, fetch the child template from the bootstrap S3 bucket, create a child Stack, and execute it recursively on the same thread. Child outputs are surfaced as Outputs.X attributes on the parent resource so Fn::GetAtt cross-stack references resolve correctly. Removes the provisionNestedStack stub from CloudFormationResourceProvisioner. Closes #1051
This commit is contained in:
1 parent
b07c9ef28b
commit
ec948fe3a8
3 files changed
+141
-15
No files matched your search
+89
@@ -4426,4 +4426,93 @@ class CloudFormationIntegrationTest {
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_withNestedStack_resourcesAreProvisioned() {
|
||||
String childTemplate = """
|
||||
{
|
||||
"Resources": {
|
||||
"ChildQueue": {
|
||||
"Type": "AWS::SQS::Queue",
|
||||
"Properties": {
|
||||
"QueueName": "nested-stack-child-queue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Outputs": {
|
||||
"QueueUrl": {
|
||||
"Value": {"Ref": "ChildQueue"}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
// Upload child template to S3
|
||||
given().when().put("/nested-stack-templates").then().statusCode(200);
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.body(childTemplate)
|
||||
.when()
|
||||
.put("/nested-stack-templates/child.json")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
String parentTemplate = """
|
||||
{
|
||||
"Resources": {
|
||||
"ChildStack": {
|
||||
"Type": "AWS::CloudFormation::Stack",
|
||||
"Properties": {
|
||||
"TemplateURL": "http://localhost/nested-stack-templates/child.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "parent-nested-stack")
|
||||
.formParam("TemplateBody", parentTemplate)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackId>"));
|
||||
|
||||
// Parent stack reaches CREATE_COMPLETE
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "parent-nested-stack")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));
|
||||
|
||||
// Nested stack resource itself is CREATE_COMPLETE
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStackResources")
|
||||
.formParam("StackName", "parent-nested-stack")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<ResourceType>AWS::CloudFormation::Stack</ResourceType>"))
|
||||
.body(containsString("<ResourceStatus>CREATE_COMPLETE</ResourceStatus>"));
|
||||
|
||||
// SQS queue defined in the nested template actually exists
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "GetQueueUrl")
|
||||
.formParam("QueueName", "nested-stack-child-queue")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("nested-stack-child-queue"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user