mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cloudformation): carry PackageType through SAM Function expansion (#1772)
* fix(cloudformation): carry PackageType through SAM Function expansion
expandServerlessFunction/createLambdaFunction copied FunctionName, Handler,
and Runtime from AWS::Serverless::Function onto the expanded
AWS::Lambda::Function, but never PackageType. CloudFormationResourceProvisioner's
buildLambdaDesiredState defaults a missing PackageType to "Zip"
(resolveOrDefault(props, "PackageType", engine, "Zip")), which then also
forces Runtime/Handler defaults (nodejs18.x / index.handler) onto a
function that declared neither. Net effect: a SAM function declared with
PackageType: Image and an ImageUri silently deployed as a broken Zip
function running the wrong runtime instead of the real container image —
Code.ImageUri was preserved by buildLambdaCode, but nothing on the
resource said to actually use it as an image.
Found by deploying a real container-image SAM template end-to-end against
a build with #1758+#1759 applied: the function created successfully and
the stack reported CREATE_COMPLETE, but invoking it pulled
public.ecr.aws/lambda/nodejs:18 and failed with
Runtime.ImportModuleError ("Cannot find module 'index'") instead of
running the pushed image.
Adds a one-line copyIfPresent(properties, "PackageType", lambdaProps) fix,
a SamTransformProcessorTest unit test asserting the transform output
carries PackageType/ImageUri through with no synthesized Handler/Runtime,
and a CloudFormationIntegrationTest asserting the full create-stack ->
GetFunction round trip reports PackageType: Image.
* fix(cloudformation): carry ImageConfig through SAM Function expansion
Same class of omission as PackageType: CloudFormationResourceProvisioner
already reads ImageConfig off AWS::Lambda::Function (provisionLambda's
putResolvedMapIfPresent(configRequest, props, "ImageConfig", ...)), but
SamTransformProcessor.createLambdaFunction never copied it from the SAM
resource's Properties. A PackageType: Image SAM function combined with an
ImageConfig block (EntryPoint/Command/WorkingDirectory container overrides)
silently lost that configuration on the deployed function.
ImageConfig's SAM shape is identical to raw CFN's, so a plain
copyIfPresent is sufficient (no case conversion needed, unlike some other
SAM->CFN property mappings in this file).
Adds a unit test asserting the expanded resource carries ImageConfig
through, and an integration test asserting the full CreateStack ->
GetFunction round trip reports it under Configuration.ImageConfigResponse.
Addresses review feedback on #1772.
This commit is contained in:
3 files changed
+188
No files matched your search
+2
@@ -417,8 +417,10 @@ class SamTransformProcessor {
|
||||
ObjectNode lambdaProps = objectMapper.createObjectNode();
|
||||
|
||||
copyIfPresent(properties, "FunctionName", lambdaProps);
|
||||
copyIfPresent(properties, "PackageType", lambdaProps);
|
||||
copyIfPresent(properties, "Handler", lambdaProps);
|
||||
copyIfPresent(properties, "Runtime", lambdaProps);
|
||||
copyIfPresent(properties, "ImageConfig", lambdaProps);
|
||||
|
||||
lambdaProps.set("Code", buildLambdaCode(properties));
|
||||
|
||||
|
||||
Reference in new issue
Block a user