Files
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

29 lines
1.5 KiB
Bash

#!/usr/bin/env bash
# `sam deploy` validates the template before it calls AWS. With fake credentials it must get past that
# validation and fail at the first upload, with and without a video image (an image function at the
# top level of template.yaml, for one, fails validation for every deploy).
set -uo pipefail
cd "$(dirname "$0")/.."
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
mkdir -p "$work/examples/aws-lambda" "$work/packages/aws-lambda/dist"
cp template.yaml video-function.yaml "$work/examples/aws-lambda/"
echo zip > "$work/packages/aws-lambda/dist/handler.zip"
cd "$work/examples/aws-lambda"
sam validate --lint --region us-east-1 -t template.yaml || exit 1
sam validate --lint --region us-east-1 -t video-function.yaml || exit 1
digest=sha256:$(printf '%064d' 0)
for uri in '""' "123456789012.dkr.ecr.us-east-1.amazonaws.com/hf-video@$digest"; do
# The CLI's argv (sam.ts), with --s3-bucket in place of --resolve-s3 so nothing calls AWS before the upload.
out=$(env -u AWS_PROFILE AWS_ACCESS_KEY_ID=AKIAFAKEFAKEFAKEFAKE AWS_SECRET_ACCESS_KEY=fake \
sam deploy --stack-name hf-sam-check --region us-east-1 --s3-bucket hf-sam-check-none \
--capabilities CAPABILITY_IAM --no-confirm-changeset --no-fail-on-empty-changeset \
--parameter-overrides ChromeSource=sparticuz "VideoImageUri=$uri" </dev/null 2>&1)
if ! grep -q "Unable to upload artifact" <<<"$out"; then
echo "sam deploy stopped before reaching AWS (VideoImageUri=$uri):"
echo "$out" | tail -5
exit 1
fi
echo "VideoImageUri=$uri: past validation, stopped at the upload"
done