mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
CDK passes TemplateURL as https://s3.{region}.amazonaws.com/{bucket}/{key}. The condition host.endsWith(".amazonaws.com") incorrectly matched this as virtual-hosted style, extracting "s3" as the bucket name instead of the real bucket. Fixed by only treating URLs with a bucket label before ".s3." as virtual-hosted. Also changed the failure path from silently returning "{}" (causing CREATE_COMPLETE with zero resources) to rethrowing so the stack correctly reaches CREATE_FAILED.
This commit is contained in:
1 parent
3960b6e20e
commit
78b0d4d3e2
2 files changed
+156
-26
No files matched your search
+122
@@ -2268,4 +2268,126 @@ class CloudFormationIntegrationTest {
|
||||
.then()
|
||||
.statusCode(404);
|
||||
}
|
||||
|
||||
// ── TemplateURL (path-style AWS S3) ──────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void createStack_templateUrlPathStyle_resolvesLocalS3() {
|
||||
String bucket = "cfn-template-url-bucket";
|
||||
String key = "template.json";
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"MyQueue": {
|
||||
"Type": "AWS::SQS::Queue",
|
||||
"Properties": {
|
||||
"QueueName": "cfn-template-url-queue"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
// Create S3 bucket and upload template
|
||||
given().when().put("/" + bucket).then().statusCode(200);
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.body(template)
|
||||
.when()
|
||||
.put("/" + bucket + "/" + key)
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// CreateStack using a CDK-style path-style AWS S3 TemplateURL
|
||||
String templateUrl = "https://s3.us-east-1.amazonaws.com/" + bucket + "/" + key;
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "cfn-template-url-stack")
|
||||
.formParam("TemplateURL", templateUrl)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackId>"));
|
||||
|
||||
// Verify stack and its resource were provisioned from the S3 template
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "cfn-template-url-stack")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CREATE_COMPLETE"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "GetQueueUrl")
|
||||
.formParam("QueueName", "cfn-template-url-queue")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_templateUrlVirtualHosted_resolvesLocalS3() {
|
||||
String bucket = "cfn-vhost-template-bucket";
|
||||
String key = "template.json";
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"MyQueue": {
|
||||
"Type": "AWS::SQS::Queue",
|
||||
"Properties": {
|
||||
"QueueName": "cfn-vhost-template-queue"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
given().when().put("/" + bucket).then().statusCode(200);
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.body(template)
|
||||
.when()
|
||||
.put("/" + bucket + "/" + key)
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Virtual-hosted style: bucket.s3.region.amazonaws.com/key
|
||||
String templateUrl = "https://" + bucket + ".s3.us-east-1.amazonaws.com/" + key;
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "cfn-vhost-template-stack")
|
||||
.formParam("TemplateURL", templateUrl)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackId>"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "cfn-vhost-template-stack")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CREATE_COMPLETE"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "GetQueueUrl")
|
||||
.formParam("QueueName", "cfn-vhost-template-queue")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user