diff --git a/examples/aws-lambda/template.yaml b/examples/aws-lambda/template.yaml index 4a03fe96f5..18a5ca3570 100644 --- a/examples/aws-lambda/template.yaml +++ b/examples/aws-lambda/template.yaml @@ -3,7 +3,7 @@ Transform: AWS::Serverless-2016-10-31 Description: >- HyperFrames distributed rendering — Step Functions standard workflow with one Lambda function handling Plan, RenderChunk (fan-out via Map state), - and Assemble, or RenderChunk on an optional arm64 image. One S3 bucket, alarms for runaway concurrency, Lambda + and Assemble, or Plan and RenderChunk on an optional arm64 image. One S3 bucket, alarms for runaway concurrency, Lambda errors, and Step Functions execution failures. Built from the handler ZIP at packages/aws-lambda/dist/handler.zip. @@ -274,7 +274,13 @@ Resources: Type: Task Resource: arn:aws:states:::lambda:invoke Parameters: - FunctionName: !GetAtt RenderFunction.Arn + # Chunks must run the ffmpeg build the plan records, so the plan runs where they do. + FunctionName: + !If [ + HasVideoFunction, + !GetAtt VideoFunctionStack.Outputs.FunctionArn, + !GetAtt RenderFunction.Arn, + ] Payload: Action: plan PlanProtocol: v1 @@ -333,7 +339,12 @@ Resources: Type: Task Resource: arn:aws:states:::lambda:invoke Parameters: - FunctionName: !GetAtt RenderFunction.Arn + FunctionName: + !If [ + HasVideoFunction, + !GetAtt VideoFunctionStack.Outputs.FunctionArn, + !GetAtt RenderFunction.Arn, + ] Payload: Action: plan PlanProtocol: v2 diff --git a/examples/aws-lambda/video-function.yaml b/examples/aws-lambda/video-function.yaml index 98fd7198e5..de8046432b 100644 --- a/examples/aws-lambda/video-function.yaml +++ b/examples/aws-lambda/video-function.yaml @@ -1,7 +1,7 @@ AWSTemplateFormatVersion: "2010-09-09" Description: >- - HyperFrames arm64 chunk renderer: the render handler as a container image, invoked for renderChunk - only. Nested in template.yaml when VideoImageUri is set; plain CloudFormation, because `sam deploy` + 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: @@ -58,6 +58,10 @@ Resources: 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 @@ -68,7 +72,7 @@ Resources: Type: AWS::Lambda::Function Properties: FunctionName: !Sub "${ProjectName}-video" - Description: HyperFrames distributed render handler on arm64, invoked for renderChunk only. + Description: HyperFrames distributed render handler on arm64, invoked for plan and renderChunk. PackageType: Image Code: ImageUri: !Ref ImageUri diff --git a/packages/aws-lambda/src/cdk/HyperframesRenderStack.snapshot.test.ts b/packages/aws-lambda/src/cdk/HyperframesRenderStack.snapshot.test.ts index 0b33748b9d..2977fa98e3 100644 --- a/packages/aws-lambda/src/cdk/HyperframesRenderStack.snapshot.test.ts +++ b/packages/aws-lambda/src/cdk/HyperframesRenderStack.snapshot.test.ts @@ -345,8 +345,8 @@ describe("HyperframesRenderStack — snapshot", () => { } }); - it("sends only renderChunk to the SAM template's optional arm64 video function", () => { - // Plan, audio and assemble encode audio; on the x86 function that audio stays byte-identical. + it("runs plan and renderChunk on the SAM template's optional arm64 video function", () => { + // A chunk refuses a plan made with another ffmpeg build; audio and assemble stay on x86. const targets = Object.values(lambdaTasks(readSamDefinition().States)).map((task) => ({ action: sentPayload(task).Action, functionName: requireRecordProperty(requireRecord(task, "task"), "Parameters", "task params") @@ -359,7 +359,7 @@ describe("HyperframesRenderStack — snapshot", () => { expect({ action, functionName }).toEqual({ action, functionName: - action === "renderChunk" + action === "plan" || action === "renderChunk" ? ["HasVideoFunction", "VideoFunctionStack.Outputs.FunctionArn", "RenderFunction.Arn"] : "RenderFunction.Arn", });