Files
hyperframes/examples/aws-lambda/video-function.yaml
T
Miguel Ángel 03ed14615a feat(aws-lambda): run chunks on an optional arm64 image function (#6065)
* feat(aws-lambda): run chunks on an optional arm64 image function

A new VideoImageUri parameter adds an arm64 container-image function that only
renders chunks. Plan, audio and assemble stay on the x86 ZIP function, so audio
encodes are unchanged. Empty (the default) deploys exactly as before. The
reserved concurrency moves to whichever function renders the chunks.

* docs(aws-lambda): the template tags both render functions

* fix(aws-lambda): nest the arm64 video function so sam deploy needs no image repository

sam deploy refuses a template with any top-level image function unless it is given an image
repository, even when that function's Condition is false, so every deploy of the template failed.
The video function now lives in video-function.yaml, a nested stack created only when
VideoImageUri is set. The release ships it beside template.yaml and the CLI stages both.

A new workflow runs the CLI's sam deploy argv against the template with fake credentials and
requires it to reach the first upload.

* fix(aws-lambda): run the plan on the arm64 video function with the chunks it plans

* refactor(cli): name the staged template directory instead of commenting it

* docs(aws-lambda): say the arm64 image runs the plan as well as the chunks
2026-10-23 00:40:55 +00:00

109 lines
3.4 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
ChromeSource:
Type: String
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: "*"
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:
NODE_OPTIONS: "--enable-source-maps"
HYPERFRAMES_LAMBDA_CHROME_SOURCE: !Ref ChromeSource
TMPDIR: /tmp
HYPERFRAMES_RENDER_BUCKET: !Ref RenderBucket
HYPERFRAMES_LAMBDA_RESERVED_CONCURRENCY: !Ref ReservedConcurrency
Tags:
- Key: Project
Value: !Ref ProjectName
- Key: HyperFramesComponent
Value: lambda-renderer
Outputs:
FunctionArn:
Value: !GetAtt Function.Arn
FunctionName:
Value: !Ref Function