Skip to content

AWS.EMRServerless reference

Source: src/AWS/EMRServerless/Application.ts

An Amazon EMR Serverless application — a serverless Spark or Hive environment that automatically provisions and scales workers per job, with no cluster to manage. An application in the CREATED or STOPPED state costs nothing; billing only occurs for workers while the application is started (including any pre-initialized initialCapacity).

Spark Application

import * as AWS from "alchemy/AWS";
const app = yield* AWS.EMRServerless.Application("Spark", {
releaseLabel: "emr-7.9.0",
});
// app.applicationId is passed to StartJobRun

Hive Application with Auto-Stop Tuning

const app = yield* AWS.EMRServerless.Application("Hive", {
type: "HIVE",
releaseLabel: "emr-7.9.0",
autoStartConfiguration: { enabled: true },
autoStopConfiguration: { enabled: true, idleTimeout: "5 minutes" },
});
const app = yield* AWS.EMRServerless.Application("Warm", {
releaseLabel: "emr-7.9.0",
initialCapacity: {
Driver: {
workerCount: 1,
workerConfiguration: { cpu: "2 vCPU", memory: "4 GB" },
},
Executor: {
workerCount: 2,
workerConfiguration: { cpu: "2 vCPU", memory: "4 GB" },
},
},
maximumCapacity: { cpu: "16 vCPU", memory: "64 GB" },
});
const app = yield* AWS.EMRServerless.Application("InVpc", {
releaseLabel: "emr-7.9.0",
networkConfiguration: {
subnetIds: [subnet.subnetId],
securityGroupIds: [securityGroup.securityGroupId],
},
});

Source: src/AWS/EMRServerless/CancelJobRun.ts

Runtime binding for emr-serverless:CancelJobRun.

Cancels a running or queued job run on the bound Application — the kill switch for a runaway or superseded job. Provide the implementation with Effect.provide(AWS.EMRServerless.CancelJobRunHttp).

// init
const cancelJobRun = yield* AWS.EMRServerless.CancelJobRun(app);
// runtime
yield* cancelJobRun({ jobRunId });

Source: src/AWS/EMRServerless/GetDashboardForJobRun.ts

Runtime binding for emr-serverless:GetDashboardForJobRun.

Creates a pre-signed URL to the live Spark/Tez UI (or Spark History Server) for a job run on the bound Application — hand it to an on-call engineer to debug a slow or failed job without console access. Provide the implementation with Effect.provide(AWS.EMRServerless.GetDashboardForJobRunHttp).

// init
const getDashboardForJobRun =
yield* AWS.EMRServerless.GetDashboardForJobRun(app);
// runtime
const { url } = yield* getDashboardForJobRun({ jobRunId });

Source: src/AWS/EMRServerless/GetJobRun.ts

Runtime binding for emr-serverless:GetJobRun.

Reads a job run’s full detail on the bound Application — state, driver, resource utilization, timeout — so a function can poll a submitted job to completion or inspect why it failed. Provide the implementation with Effect.provide(AWS.EMRServerless.GetJobRunHttp).

// init
const getJobRun = yield* AWS.EMRServerless.GetJobRun(app);
// runtime
const { jobRun } = yield* getJobRun({ jobRunId });
yield* Effect.log(`${jobRun.jobRunId} is ${jobRun.state}`);

Source: src/AWS/EMRServerless/GetResourceDashboard.ts

Runtime binding for emr-serverless:GetResourceDashboard.

Creates a pre-signed dashboard URL for a specific resource (e.g. a worker) of the bound Application. Provide the implementation with Effect.provide(AWS.EMRServerless.GetResourceDashboardHttp).

// init
const getResourceDashboard =
yield* AWS.EMRServerless.GetResourceDashboard(app);
// runtime
const { url } = yield* getResourceDashboard({ resourceId, resourceType });

Source: src/AWS/EMRServerless/GetSession.ts

Runtime binding for emr-serverless:GetSession.

Reads an interactive session’s detail on the bound Application — state, execution role, idle time, resource utilization. Provide the implementation with Effect.provide(AWS.EMRServerless.GetSessionHttp).

// init
const getSession = yield* AWS.EMRServerless.GetSession(app);
// runtime
const { session } = yield* getSession({ sessionId });
yield* Effect.log(`${session.sessionId} is ${session.state}`);

Source: src/AWS/EMRServerless/GetSessionEndpoint.ts

Runtime binding for emr-serverless:GetSessionEndpoint.

Resolves the connection endpoint and short-lived auth token for an interactive session on the bound Application. The authToken in the response is Redacted — unwrap it with Redacted.value only at the point of use. Provide the implementation with Effect.provide(AWS.EMRServerless.GetSessionEndpointHttp).

// init
const getSessionEndpoint = yield* AWS.EMRServerless.GetSessionEndpoint(app);
// runtime
const { endpoint, authToken } = yield* getSessionEndpoint({ sessionId });

Source: src/AWS/EMRServerless/ListJobRunAttempts.ts

Runtime binding for emr-serverless:ListJobRunAttempts.

Enumerates the attempts of a retried job run on the bound Application — how many times the retry policy re-ran the job and how each attempt ended. Provide the implementation with Effect.provide(AWS.EMRServerless.ListJobRunAttemptsHttp).

// init
const listJobRunAttempts = yield* AWS.EMRServerless.ListJobRunAttempts(app);
// runtime
const { jobRunAttempts } = yield* listJobRunAttempts({ jobRunId });

Source: src/AWS/EMRServerless/ListJobRuns.ts

Runtime binding for emr-serverless:ListJobRuns.

Enumerates job runs on the bound Application, optionally filtered by state, creation window, or mode — so a function can report on running or recently failed jobs. Provide the implementation with Effect.provide(AWS.EMRServerless.ListJobRunsHttp).

// init
const listJobRuns = yield* AWS.EMRServerless.ListJobRuns(app);
// runtime
const { jobRuns } = yield* listJobRuns({ states: ["RUNNING"] });

Source: src/AWS/EMRServerless/ListSessions.ts

Runtime binding for emr-serverless:ListSessions.

Enumerates interactive sessions on the bound Application, optionally filtered by state or creation window. Provide the implementation with Effect.provide(AWS.EMRServerless.ListSessionsHttp).

// init
const listSessions = yield* AWS.EMRServerless.ListSessions(app);
// runtime
const { sessions } = yield* listSessions({ states: ["IDLE"] });

Source: src/AWS/EMRServerless/StartApplication.ts

Runtime binding for emr-serverless:StartApplication.

Starts the bound Application — pre-warming its pre-initialized capacity ahead of a burst of job submissions so the first job skips the application cold start. Provide the implementation with Effect.provide(AWS.EMRServerless.StartApplicationHttp).

// init
const startApplication = yield* AWS.EMRServerless.StartApplication(app);
// runtime
yield* startApplication();

Source: src/AWS/EMRServerless/StartJobRun.ts

Runtime binding for emr-serverless:StartJobRun.

Submits a Spark or Hive job to the bound Application — the serverless equivalent of spark-submit. The application id is injected from the binding; the caller supplies the job driver, the execution role the job assumes, and optional configuration overrides. Grants iam:PassRole (conditioned to emr-serverless.amazonaws.com) so the function can hand the service the execution role. Provide the implementation with Effect.provide(AWS.EMRServerless.StartJobRunHttp).

// init — bind the operation to the application
const startJobRun = yield* AWS.EMRServerless.StartJobRun(app);
// runtime
const run = yield* startJobRun({
executionRoleArn: jobRoleArn,
jobDriver: {
sparkSubmit: {
entryPoint: "s3://my-scripts/etl.py",
entryPointArguments: ["--date", "2026-07-14"],
},
},
executionTimeoutMinutes: 60,
});
yield* Effect.log(`started ${run.jobRunId}`);

Source: src/AWS/EMRServerless/StartSession.ts

Runtime binding for emr-serverless:StartSession.

Starts an interactive session on the bound Application (the application must enable interactiveConfiguration). The session assumes the given execution role; grants iam:PassRole (conditioned to emr-serverless.amazonaws.com) accordingly. Provide the implementation with Effect.provide(AWS.EMRServerless.StartSessionHttp).

// init
const startSession = yield* AWS.EMRServerless.StartSession(app);
// runtime
const session = yield* startSession({ executionRoleArn: sessionRoleArn });
yield* Effect.log(`started ${session.sessionId}`);

Source: src/AWS/EMRServerless/StopApplication.ts

Runtime binding for emr-serverless:StopApplication.

Stops the bound Application, releasing its pre-initialized capacity so it stops billing — e.g. a scheduled cost-control function that shuts the application down outside business hours. Provide the implementation with Effect.provide(AWS.EMRServerless.StopApplicationHttp).

// init
const stopApplication = yield* AWS.EMRServerless.StopApplication(app);
// runtime
yield* stopApplication();

Source: src/AWS/EMRServerless/TerminateSession.ts

Runtime binding for emr-serverless:TerminateSession.

Terminates an interactive session on the bound Application, releasing its workers — e.g. a cost-control function reaping sessions left idle past a policy window. Provide the implementation with Effect.provide(AWS.EMRServerless.TerminateSessionHttp).

// init
const terminateSession = yield* AWS.EMRServerless.TerminateSession(app);
// runtime
yield* terminateSession({ sessionId });