mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
perf(cloudformation): probe Lambda S3 code with headObject, not getObject (#2728)
Resolving an AWS::Lambda::Function whose Code points at S3 checked the object by calling getObject and discarding the result. S3Object.getData() is a materialised byte array, so that read the whole package into memory purely to answer whether it was readable, and LambdaService then read the same object again for real during CreateFunction. Every stack create or update paid for two full copies of every Lambda package it provisions. headObject answers the same question without the body: getObject is getObjectMetadata plus readFile, headObject is getObjectMetadata alone. Both resolve the object through that same metadata lookup, so a missing key or bucket still fails the resource exactly as before, and the failure behaviour added for #2648 is unchanged. Closes #2675
This commit is contained in:
1 parent
e2e69f65f5
commit
ff36141c19
2 files changed
+134
-1
No files matched your search
+9
-1
@@ -2502,8 +2502,16 @@ public class CloudFormationResourceProvisioner {
|
||||
// deliberately leaves its Lambda packages unbuilt and only cares about the
|
||||
// other resources. Off by default: silently serving a placeholder is the more
|
||||
// dangerous of the two behaviours.
|
||||
//
|
||||
// headObject, not getObject: this only needs to know whether the code is
|
||||
// readable. getObject additionally reads the whole body, which is then thrown
|
||||
// away, and LambdaService reads it again for real during CreateFunction. That
|
||||
// is a second full copy of the package per Lambda per stack operation, for a
|
||||
// question a metadata lookup answers (issue #2675). Both resolve the object
|
||||
// through the same getObjectMetadata call, so a missing key or bucket still
|
||||
// fails here exactly as before.
|
||||
try {
|
||||
s3Service.getObject(s3Bucket, s3Key);
|
||||
s3Service.headObject(s3Bucket, s3Key);
|
||||
return new LambdaCodeSpec(Map.of("S3Bucket", s3Bucket, "S3Key", s3Key),
|
||||
"s3:" + s3Bucket + "\n" + s3Key);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in new issue
Block a user