JobDefinition
Source:
src/AWS/Batch/JobDefinition.ts
An AWS Batch job definition for Fargate container jobs. Job definitions are immutable revisions — changing the container configuration registers a new revision under the same name (like ECS task definitions); destroying the resource deregisters every active revision.
JobDefinition is a Platform: alongside the low-level container form
(image + executionRoleArn), it supports Effect-native run-to-completion
implementations — an inline Effect program that Alchemy bundles,
containerizes as the job container’s command, pushes to a managed ECR
repository, and registers, provisioning the job and execution roles
automatically. Capability bindings (e.g. S3 GetObject) attach IAM policy
statements to the managed job role and inject their environment variables
into the container.
Creating Job Definitions
Section titled “Creating Job Definitions”Busybox echo job (low-level container form)
const jobDef = yield* Batch.JobDefinition("EchoJob", { image: "public.ecr.aws/docker/library/busybox:latest", command: ["echo", "hello from batch"], executionRoleArn: executionRole.roleArn,});Sized job with environment
const jobDef = yield* Batch.JobDefinition("EtlJob", { image: image.imageUri, vcpus: 1, memory: 2048, environment: { STAGE: "prod" }, jobRoleArn: jobRole.roleArn, executionRoleArn: executionRole.roleArn, retryAttempts: 3, timeout: "15 minutes",});Effect-Native Jobs
Section titled “Effect-Native Jobs”Tagged class with an inline run-to-completion Effect
export default class Nightly extends Batch.JobDefinition<Nightly>()( "Nightly", { main: import.meta.url, vcpus: 1, memory: 2048 }, Effect.gen(function* () { const getObject = yield* AWS.S3.GetObject(bucket); return { run: Effect.gen(function* () { const data = yield* getObject({ key: "input.csv" }); yield* Effect.log("processed nightly batch"); }), }; }),) {}Eager inline job
export default Batch.JobDefinition( "Reindex", { main: import.meta.url }, Effect.succeed({ run: Effect.log("reindex complete"), }),);Plain external script (bundled as-is)
// ./job.ts runs top-level and exits; Alchemy bundles + containerizes it.const jobDef = yield* Batch.JobDefinition("Script", { main: path.join(import.meta.dirname, "job.ts"),});