Run Libretto workflows as ECS Fargate tasks, triggered from your API or EventBridge.ECS on Fargate is the closest AWS analog to Cloud Run Jobs: you register a task definition, then invoke it on demand and Fargate starts a fresh container, runs the task, and exits. Libretto workflows map cleanly to this model.
Prerequisites
- An AWS account with a VPC (default VPC is fine to start).
- ECR, ECS, CodeBuild, and Secrets Manager available in your target region.
- A task execution role and a task role scoped to the secrets your workflows need.
- AWS CLI installed and authenticated locally.
Write the dispatcher and Dockerfile
Use the same env-var dispatcher pattern as the GCP guide; the image is portable across clouds:
Push the image to ECR
buildspec.yml that tags both :latest and :$CODEBUILD_RESOLVED_SOURCE_VERSION.Inject credentials at runtime
Pull secrets from Secrets Manager inside your dispatcher, not the container environment, so they never appear in the task definition:Attach an IAM policy to
browserAgentTaskRole that allows secretsmanager:GetSecretValue on the specific ARNs the workflows use.Trigger the task
From your API, using the AWS SDK:For scheduled runs, point an EventBridge rule at the task definition on a cron schedule.
Observability
- Logs: Container stdout/stderr streams to CloudWatch Logs under the group declared in the task definition (
/ecs/browser-agent). - Task history:
aws ecs list-tasks —cluster browser-agent-cluster —desired-status STOPPED. - Session artifacts: upload
.libretto/sessions/<name>/to S3 at the end of each run for post-hoc debugging.