mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): wrap ZipFile inline source in zip archive before passing to Lambda (#639)
CloudFormation's ZipFile property contains raw source code (JS, Python, etc.), but LambdaService expects Code.ZipFile to be a base64-encoded zip archive per the Lambda REST API contract. Passing raw source directly caused every inline Lambda to land in CREATE_FAILED with "Illegal base64 character". Fix: added sourceToZipBase64() that wraps the raw source in a ZipEntry (filename derived from the Handler property and runtime extension — .js for Node, .py for Python) and base64-encodes the archive before forwarding to LambdaService. Closes #607
This commit is contained in:
1 parent
77db7d24ef
commit
87eda4bcfc
3 files changed
+240
-1
No files matched your search
+50
@@ -452,6 +452,56 @@ class CloudFormationIntegrationTest {
|
||||
.body("Configuration.FunctionName", equalTo("cfn-zipfile-func"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_lambdaWithInlineZipFile() {
|
||||
String template = """
|
||||
{
|
||||
"Resources": {
|
||||
"MyFunction": {
|
||||
"Type": "AWS::Lambda::Function",
|
||||
"Properties": {
|
||||
"FunctionName": "cfn-inline-zipfile-func",
|
||||
"Runtime": "nodejs20.x",
|
||||
"Handler": "index.handler",
|
||||
"Code": {
|
||||
"ZipFile": "exports.handler = async (e) => ({ statusCode: 200 });"
|
||||
},
|
||||
"Role": "arn:aws:iam::000000000000:role/cfn-test-lambda-role"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateStack")
|
||||
.formParam("StackName", "cfn-inline-zipfile-stack")
|
||||
.formParam("TemplateBody", template)
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackId>"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "DescribeStacks")
|
||||
.formParam("StackName", "cfn-inline-zipfile-stack")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));
|
||||
|
||||
given()
|
||||
.when()
|
||||
.get("/2015-03-31/functions/cfn-inline-zipfile-func")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Configuration.FunctionName", equalTo("cfn-inline-zipfile-func"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStack_withDynamoDbGsiAndLsi() {
|
||||
String template = """
|
||||
|
||||
Reference in new issue
Block a user