@@ -85,9 +85,8 @@ Globals:
8585 # terminate at the Step Functions → Lambda boundary instead of
8686 # following into per-function spans.
8787 Tracing : Active
88- # Cost-allocation tags for every AWS::Serverless::Function (the render
89- # function and the optional video function). Bucket + state-machine carry
90- # the same tags resource-locally because Globals only covers functions.
88+ # Cost-allocation tags for the render function. Bucket, state machine and
89+ # video-function.yaml carry the same tags themselves; Globals covers only SAM functions.
9190 Tags :
9291 Project : !Ref ProjectName
9392 HyperFramesComponent : lambda-renderer
@@ -151,7 +150,7 @@ Resources:
151150 HyperFrames distributed render handler. Dispatches on event.Action.
152151 Handler : handler.handler
153152 Runtime : nodejs22.x
154- # The ZIP's @sparticuz/chromium ships x86_64 Chrome only; arm64 runs as VideoFunction's image .
153+ # The ZIP's @sparticuz/chromium ships x86_64 Chrome only; video-function.yaml runs chunks on arm64 .
155154 Architectures : [x86_64]
156155 # Local path is resolved by `sam build` + `sam deploy --resolve-s3`
157156 # (or `--s3-bucket`); the resulting CodeUri rewrites to s3://.
@@ -190,34 +189,25 @@ Resources:
190189 # IAM into adopters' accounts.
191190
192191 # ── Optional arm64 chunk renderer: the same handler as a container image ──
193- VideoFunction :
194- Type : AWS::Serverless::Function
192+ # Nested: `sam deploy` demands an image repository for any image function in this template.
193+ VideoFunctionStack :
194+ Type : AWS::CloudFormation::Stack
195195 Condition : HasVideoFunction
196196 Properties :
197- FunctionName : !Sub "${ProjectName}-video"
198- Description : >-
199- HyperFrames distributed render handler on arm64, invoked for renderChunk only.
200- PackageType : Image
201- ImageUri : !Ref VideoImageUri
202- Architectures : [arm64]
203- ReservedConcurrentExecutions : !If
204- - HasReservedConcurrency
205- - !Ref ReservedConcurrency
206- - !Ref AWS::NoValue
207- EphemeralStorage :
208- Size : 10240
209- Environment :
210- Variables :
211- TMPDIR : /tmp
212- HYPERFRAMES_RENDER_BUCKET : !Ref RenderBucket
213- HYPERFRAMES_LAMBDA_RESERVED_CONCURRENCY : !Ref ReservedConcurrency
214- Policies :
215- - S3CrudPolicy :
216- BucketName : !Ref RenderBucket
217- - Statement :
218- - Effect : Allow
219- Action : s3:AbortMultipartUpload
220- Resource : !Sub "arn:${AWS::Partition}:s3:::${RenderBucket}/*"
197+ TemplateURL : video-function.yaml
198+ Parameters :
199+ ProjectName : !Ref ProjectName
200+ ImageUri : !Ref VideoImageUri
201+ RenderBucket : !Ref RenderBucket
202+ MemorySize : !Ref LambdaMemoryMb
203+ Timeout : !Ref LambdaTimeoutSec
204+ ReservedConcurrency : !Ref ReservedConcurrency
205+ ChromeSource : !Ref ChromeSource
206+ Tags :
207+ - Key : Project
208+ Value : !Ref ProjectName
209+ - Key : HyperFramesComponent
210+ Value : lambda-renderer
221211
222212 # ── CloudWatch log group for the state machine ──────────────────────────
223213 # SAM doesn't auto-create one when `LoggingConfiguration` is set, so we
@@ -460,7 +450,11 @@ Resources:
460450 Resource : arn:aws:states:::lambda:invoke
461451 Parameters :
462452 FunctionName :
463- !If [HasVideoFunction, !GetAtt VideoFunction.Arn, !GetAtt RenderFunction.Arn]
453+ !If [
454+ HasVideoFunction,
455+ !GetAtt VideoFunctionStack.Outputs.FunctionArn,
456+ !GetAtt RenderFunction.Arn,
457+ ]
464458 Payload :
465459 Action : renderChunk
466460 PlanProtocol : v1
@@ -581,7 +575,7 @@ Resources:
581575 FunctionName :
582576 !If [
583577 HasVideoFunction,
584- !GetAtt VideoFunction.Arn ,
578+ !GetAtt VideoFunctionStack.Outputs.FunctionArn ,
585579 !GetAtt RenderFunction.Arn,
586580 ]
587581 Payload :
@@ -768,7 +762,11 @@ Resources:
768762 Action : lambda:InvokeFunction
769763 Resource :
770764 - !GetAtt RenderFunction.Arn
771- - !If [HasVideoFunction, !GetAtt VideoFunction.Arn, !Ref AWS::NoValue]
765+ - !If [
766+ HasVideoFunction,
767+ !GetAtt VideoFunctionStack.Outputs.FunctionArn,
768+ !Ref AWS::NoValue,
769+ ]
772770 # A Distributed Map runs each chunk as a child execution of this state machine.
773771 # ARNs built by name: !Ref RenderStateMachine here would be a dependency cycle.
774772 - PolicyName : RunDistributedMapChildren
@@ -823,7 +821,12 @@ Resources:
823821 MetricName : Invocations
824822 Dimensions :
825823 - Name : FunctionName
826- Value : !If [HasVideoFunction, !Ref VideoFunction, !Ref RenderFunction]
824+ Value :
825+ !If [
826+ HasVideoFunction,
827+ !GetAtt VideoFunctionStack.Outputs.FunctionName,
828+ !Ref RenderFunction,
829+ ]
827830 Statistic : Sum
828831 Period : 3600
829832 EvaluationPeriods : 1
@@ -867,7 +870,7 @@ Resources:
867870 MetricName : Errors
868871 Dimensions :
869872 - Name : FunctionName
870- Value : !Ref VideoFunction
873+ Value : !GetAtt VideoFunctionStack.Outputs.FunctionName
871874 Statistic : Sum
872875 Period : 300
873876 EvaluationPeriods : 1
@@ -918,7 +921,7 @@ Outputs:
918921 VideoFunctionArn :
919922 Condition : HasVideoFunction
920923 Description : ARN of the arm64 chunk-rendering function.
921- Value : !GetAtt VideoFunction.Arn
924+ Value : !GetAtt VideoFunctionStack.Outputs.FunctionArn
922925
923926 RenderStateMachineArn :
924927 Description : ARN of the Step Functions state machine. Pass to `aws stepfunctions start-execution`.
0 commit comments