Files
hyperframes/examples/aws-lambda/video-function.yaml
T
James RussoandClaude Opus 5.5 81d73d2278 fix(aws-lambda): chrome-headless-shell 158 in the arm64 video image, sparticuz 153 in the x86 ZIP (#8155)
* fix(aws-lambda): run chrome-headless-shell 158 in the arm64 video image

The arm64 video image now installs Chrome for Testing's linux-arm64 chrome-headless-shell
158.0.8127.36, pinned by sha256 and fetched with curl -f, as the whole shell folder. The Lambda
Node 22 base has none of the shared libraries the shell links and no fonts, so the image installs
them from the base's repository at the same pinned release. The image sets
HYPERFRAMES_LAMBDA_CHROME_SOURCE and HYPERFRAMES_LAMBDA_CHROME_PATH itself, and the nested video
function no longer passes ChromeSource, which would override them. stage-arm64-image.ts stops
fetching the sparticuz arm64 pack and drops the ZIP's x86 sparticuz Chrome instead.

The x86 handler ZIP stays on @sparticuz/chromium, bumped from 148.0.0 to 153.0.0. It builds at
258,502,222 bytes unzipped, under Lambda's 262,144,000-byte limit and the 248 MiB in-house gate.

Two fixes for --source=chrome-headless-shell:
- build-zip.ts staged only the executable, which exits at launch without its ICU data and .pak
  files. It now stages the whole shell folder at chrome-headless-shell-linux64/.
- Nothing set HYPERFRAMES_LAMBDA_CHROME_PATH, which src/chromium.ts requires for that source.
  The SAM template and the CDK stack now set it to the bundled shell when ChromeSource asks for it.

Drops the unused @types/aws-lambda devDependency, which the dead-code audit reports whenever this
package's manifest changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(publish): build the Lambda arm64 video image on an ARM runner

The video stage now installs Chrome's system libraries with microdnf, so it runs code for arm64.
The pack job built that image on ubuntu-latest with no emulation, which it could do only while the
stage copied files. A new lambda-video-image job builds it natively on ubuntu-24.04-arm, from the
handler zip whose sha256 the zip job reported, and reports the OCI tarball's sha256. Pack downloads
that tarball, checks the sha256 against the job's, and pins it as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(aws-lambda): fit the comment ratchet and the package size budget

chromium.ts loses the two doc lines on BUNDLED_SHELL_DIR and BUNDLED_SHELL_PATH; the names and the
SAM template's comment already say what they are.

@hyperframes/aws-lambda's unpacked budget goes from 290,508 to 298,000 bytes. The package unpacks to
295,324 bytes, up from the shared chrome-headless-shell staging module the ZIP and image scripts now
import and from the README and docs that describe the two Chrome sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 09:07:46 +00:00

112 lines
3.7 KiB
YAML

AWSTemplateFormatVersion: "2010-09-09"
Description: >-
HyperFrames arm64 video renderer: the render handler as a container image, invoked for plan and
renderChunk. Nested in template.yaml when VideoImageUri is set; plain CloudFormation, because `sam deploy`
demands an image repository for any top-level image function, even one whose Condition is false.
Parameters:
ProjectName:
Type: String
ImageUri:
Type: String
RenderBucket:
Type: String
MemorySize:
Type: Number
Timeout:
Type: Number
ReservedConcurrency:
Type: Number
Conditions:
HasReservedConcurrency: !Not [!Equals [!Ref ReservedConcurrency, -1]]
Resources:
Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
- !Sub "arn:${AWS::Partition}:iam::aws:policy/AWSXRayDaemonWriteAccess"
# The render function's S3CrudPolicy plus AbortMultipartUpload, spelled out.
Policies:
- PolicyName: render-bucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:ListBucket
- s3:GetBucketLocation
- s3:GetObjectVersion
- s3:PutObject
- s3:PutObjectAcl
- s3:GetLifecycleConfiguration
- s3:PutLifecycleConfiguration
- s3:DeleteObject
- s3:AbortMultipartUpload
Resource:
- !Sub "arn:${AWS::Partition}:s3:::${RenderBucket}"
- !Sub "arn:${AWS::Partition}:s3:::${RenderBucket}/*"
# The plan sizes an unreserved render to the account's concurrency.
- Effect: Allow
Action: lambda:GetAccountSettings
Resource: "*"
# Stitch helpers, should this function ever run an assemble.
- Effect: Allow
Action: lambda:InvokeFunction
Resource: !Sub "arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:${ProjectName}-video"
Tags:
- Key: Project
Value: !Ref ProjectName
- Key: HyperFramesComponent
Value: lambda-renderer
Function:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "${ProjectName}-video"
Description: HyperFrames distributed render handler on arm64, invoked for plan and renderChunk.
PackageType: Image
Code:
ImageUri: !Ref ImageUri
Architectures: [arm64]
Role: !GetAtt Role.Arn
MemorySize: !Ref MemorySize
Timeout: !Ref Timeout
ReservedConcurrentExecutions: !If
- HasReservedConcurrency
- !Ref ReservedConcurrency
- !Ref AWS::NoValue
EphemeralStorage:
Size: 10240
TracingConfig:
Mode: Active
Environment:
Variables:
# No HYPERFRAMES_LAMBDA_CHROME_SOURCE or _PATH: the image sets them for the Chrome it installs.
NODE_OPTIONS: "--enable-source-maps"
TMPDIR: /tmp
HYPERFRAMES_RENDER_BUCKET: !Ref RenderBucket
HYPERFRAMES_LAMBDA_RESERVED_CONCURRENCY: !Ref ReservedConcurrency
HYPERFRAMES_STITCH_FUNCTION: !Sub "${ProjectName}-video"
Tags:
- Key: Project
Value: !Ref ProjectName
- Key: HyperFramesComponent
Value: lambda-renderer
Outputs:
FunctionArn:
Value: !GetAtt Function.Arn
FunctionName:
Value: !Ref Function