EMR Serverless Deployer
An AWS CloudOps agent skill that deploys Amazon EMR Serverless
applications with correct production defaults. Emits a
READY_TO_DEPLOY checklist verifying every configuration item.
Quick navigation
| Need |
Section |
| What MUST be in the response |
"STRICT output contract" |
| Why application-before-job order matters |
"Reasoning framework" |
| What to verify before deploying |
"Prerequisites" |
| The ordered deployment steps |
"Deployment procedure" |
| Common silent-failure pitfalls |
"NEVER" |
| Application-type decision matrix |
"Workload matrix" |
| 2024-2026 feature changes |
"Recent AWS features" |
| Deep CLI sequences |
references/cli-commands-and-iac.md |
| Execution roles, VPC, capacity, full NEVER |
references/execution-and-capacity-guide.md |
STRICT output contract
When this skill is invoked with an EMR Serverless deployment request,
the agent MUST respond with the READY_TO_DEPLOY checklist defined in
"Output format" using the literal all-caps labels APPLICATION:,
VERDICT:, CHECKLIST:, and VERIFICATION_COMMANDS:. Do NOT preface
the checklist with prose, headings, or disclaimers — emit the block
as the first lines.
Required output structure
APPLICATION: <application-name> — the EMR Serverless application
being deployed.
VERDICT: READY_TO_DEPLOY OR VERDICT: PREREQUISITES_MISSING.
CHECKLIST: followed by indented lines with status markers
([✓], [✗], [OPTIONAL], [INPUT NEEDED]).
VERIFICATION_COMMANDS: followed by indented
aws emr-serverless ... commands.
FORBIDDEN output patterns
- No prose preamble before
APPLICATION: — first non-empty line
MUST be APPLICATION:.
- No markdown variants of labels — write
VERDICT:, not
**VERDICT:**, ### Verdict, or `VERDICT`.
- No swapping verdict tokens — exactly
READY_TO_DEPLOY or
PREREQUISITES_MISSING.
- No omitting
VERIFICATION_COMMANDS: — include even when
PREREQUISITES_MISSING.
- No extra sections after
VERIFICATION_COMMANDS: — the
checklist block is the entire response.
- No status marker drift — use only
[✓], [✗], [OPTIONAL],
[INPUT NEEDED].
Perfect example (copy the shape exactly)
APPLICATION: etl-spark-prod
VERDICT: READY_TO_DEPLOY
CHECKLIST:
[✓] Application type — Spark, release label emr-7.2.0
[✓] Execution role — arn:aws:iam::123456789012:role/EMRServerlessExecRole (S3, Glue, CloudWatch, Secrets Manager scoped)
[✓] Pre-initialized capacity — 50 workers, 4 vCPU / 16 GB each, Spark driver 2 vCPU / 8 GB
[✓] Maximum capacity — 200 workers (burst ceiling)
[✓] VPC access — subnets subnet-aaa, subnet-bbb, security groups sg-emr-prod
[✓] S3 log bucket — s3://emr-logs-123456789012/etl-spark-prod/
[✓] CloudWatch logging — enabled, log group /aws/emr-serverless/etl-spark-prod
[✓] Job submission — entry point s3://etl-scripts/daily_transform.py, args --source s3://raw-data/ --target s3://curated/
[✓] Configuration overrides — spark.sql.shuffle.partitions=200, spark.executor.memoryOverhead=2g
[✓] Tags — Environment=production, Application=etl-spark
[OPTIONAL] Interactive endpoint — Spark Connect for notebooks (not configured)
VERIFICATION_COMMANDS:
aws emr-serverless get-application --application-id <app-id>
aws iam get-role --role-name EMRServerlessExecRole
aws s3 ls s3://emr-logs-123456789012/etl-spark-prod/
aws logs describe-log-groups --log-group-name-prefix /aws/emr-serverless/etl-spark-prod
Reasoning framework (why the application-before-job order matters)
- Application FIRST — an EMR Serverless application is the
container for all Spark/Hive jobs. It defines the release label,
type, execution role, capacity, and VPC access. Without an
application you cannot submit a job.
- Execution role — the IAM role the application assumes at
runtime for S3 reads/writes, Glue catalog access, CloudWatch
logging, and Secrets Manager. Without it, the job fails with
AccessDeniedException on the first S3 operation.
- Capacity configuration — pre-initialized capacity keeps workers
warm for immediate job start (no cold start). Maximum capacity is
the burst ceiling — jobs that exceed it are queued or fail.
- VPC access (if private resources) — if the job reads from RDS,
Redshift (private), or internal APIs, VPC subnets and security
groups are REQUIRED. Without them, the job cannot reach private
resources.
- S3 log bucket — EMR Serverless streams stdout/stderr and Spark
event logs to S3. Without a log bucket, job failures are invisible.
- Job submission LAST — the entry point (S3 path to the
PySpark/Scala/Hive script), arguments, and configuration overrides
are submitted AFTER the application is CREATED and STARTED.
Prerequisites (verify before deployment)
| Prerequisite |
Why it matters |
How to verify |
| IAM execution role |
Trust emr-serverless.amazonaws.com. Scope for S3/Glue/CloudWatch/Secrets Manager. NEVER AdministratorAccess. |
aws iam get-role --role-name <role> |
| S3 log bucket |
Stores stdout/stderr and Spark event logs. MUST exist before job submission. |
aws s3 ls s3://<bucket>/ |
| S3 script bucket |
Stores the entry-point PySpark/Scala/Hive script. MUST exist with the script. |
aws s3 ls s3://<scripts>/<script> |
| VPC subnets (if private resources) |
At least 2 private subnets across AZs for HA. Required if job accesses RDS/Redshift/internal APIs. |
aws ec2 describe-subnets --subnet-ids <ids> |
| Security groups (if VPC access) |
Inbound from EMR Serverless ENIs. Outbound to S3/Glue VPC endpoints. |
aws ec2 describe-security-groups --group-ids <sg-ids> |
| Release label |
EMR release version (e.g., emr-7.2.0). Determines Spark/Hive versions. Use the latest stable. |
aws emr-serverless list-release-labels |
| Service quota |
Default capacity (RPUs) per Region per account. Request increase BEFORE production. |
aws service-quotas get-service-quota --service-code emr-serverless --quota-code L-XXXXXXXX |
| Glue database (if catalog integration) |
Source/target Glue database and tables MUST exist for catalog-mode jobs. |
aws glue get-database --name <db> |
| Application release label compatibility |
Spark/Hive version in the release label MUST match the job's compiled dependencies. |
Check EMR release notes for the release label. |
Deployment procedure (apply in order)
Step 1: IAM execution role
The execution role is assumed by the EMR Serverless application for
all runtime AWS API calls (S3 reads/writes, Glue catalog access,
CloudWatch logging, Secrets Manager). Without it, the job fails on
the first S3 operation.
Execution-role CLI (create-role with emr-serverless trust policy, put-role-policy scoping S3/Glue/CloudWatch/Secrets Manager) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when creating the execution role.
Rules:
- Trust
emr-serverless.amazonaws.com — NOT elasticmapreduce.amazonaws.com
(that is the provisioned EMR principal).
- NEVER use
AdministratorAccess — scope the role to the specific
S3 buckets, Glue databases, and Secrets Manager secrets the job needs.
- CloudWatch Logs permissions — required for structured logging.
Step 2: S3 log bucket
S3 log bucket CLI (create-bucket, put-public-access-block, Glacier lifecycle rule) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when setting up the log bucket.
Step 3: Create the application
create-application CLI (release label, type, initial/maximum capacity, network config, auto-start/stop, custom image, tags) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when creating the application.
Parameters:
- release-label — the EMR release version (e.g.,
emr-7.2.0).
Determines the Spark and Hive versions. Use the latest stable unless
compatibility requires otherwise.
- type —
SPARK or HIVE. Spark for ETL/ML; Hive for
schema-on-read and legacy HiveQL pipelines.
- initial-capacity — pre-initialized workers kept warm for
immediate job start. Eliminates cold-start latency (60-90s).
- maximum-capacity — the burst ceiling. Jobs that need more
workers are queued (if auto-scaling) or fail.
- network-configuration — VPC subnets and security groups. Required
if the job accesses private resources (RDS, Redshift private,
internal APIs).
- auto-start — application starts automatically when a job is
submitted. Recommended for production.
- auto-stop — application stops after
idleTimeoutMinutes of no
activity. Saves cost. Default 15 minutes.
- image-configuration — custom Docker image from ECR for
additional libraries (pandas, scikit-learn, custom JARs). Optional.
Step 4: Start the application
start-application CLI and STARTED-state check moved verbatim to references/cli-commands-and-iac.md.
Load on demand when starting the application.
Step 5: Configure pre-initialized capacity (warm workers)
Pre-initialized capacity keeps workers warm so the first job starts
immediately (no 60-90s cold start). This is the ONLY way to get
sub-minute job start latency.
Pre-initialized capacity CLI (update-application --initial-capacity) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when configuring warm workers.
Rules:
- Pre-initialized capacity is billed even when idle. Set
initialCount based on the minimum sustained workload.
- Pair with auto-stop — if auto-stop triggers (idle for 15 min),
pre-initialized capacity is released. When a new job starts, the
application re-starts and re-initializes workers (cold start).
- NEVER set
initialCount higher than needed. Each warm worker
is billed at the hourly rate whether or not it runs a job.
Step 6: Job submission (Spark)
Spark start-job-run CLI (sparkSubmit job driver, monitoring and application configuration overrides) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when submitting a Spark job.
Step 7: Job submission (Hive)
Hive start-job-run CLI (hive job driver, monitoring configuration) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when submitting a Hive job.
Step 8: Configuration overrides (Spark tuning)
Configuration overrides are applied at the application level and can
be overridden per-job via sparkSubmitParameters.
| Override |
Default |
Production |
Why |
spark.sql.shuffle.partitions |
200 |
200-400 |
Tune to data volume. Too low = OOM; too high = scheduling overhead. |
spark.sql.adaptive.enabled |
false |
true |
AQE coalesces shuffle partitions dynamically. Always enable. |
spark.executor.memoryOverhead |
10% of executor memory |
2g |
Off-heap memory for Python UDFs, broadcasts. |
spark.sql.adaptive.skewJoin.enabled |
false |
true |
Handles skewed join keys without manual salting. |
spark.serializer |
JavaSerializer |
KryoSerializer |
10x faster serialization for complex objects. |
spark.sql.parquet.compression.codec |
snappy |
snappy |
Snappy for speed, gzip for size. |
Step 9: VPC access (private resources)
If the job reads from RDS, Redshift (private), or internal APIs, VPC
access is REQUIRED.
VPC access CLI (update-application --network-configuration) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when attaching subnets and security groups.
Rules:
- Use PRIVATE subnets. EMR Serverless workers do not need public IPs.
- Span at least 2 AZs (3 for production HA).
- Security group outbound must allow the database port (e.g., 5432
for Postgres, 3306 for MySQL) and 443 for S3/Glue VPC endpoints.
- NAT Gateway is NOT required for S3/Glue access — use VPC gateway
endpoints. NAT is only needed for external API calls.
- NEVER deploy without VPC access if the job reads from private RDS.
The job will fail with
ConnectionTimeoutException.
Step 10: Interactive endpoints (Spark Connect, notebooks)
Spark Connect allows remote Spark sessions from notebooks (Jupyter,
Zeppelin), IDEs (Databricks Connect, IntelliJ), and applications
without running a full Spark driver locally.
Interactive endpoint CLI (create-interactive-endpoint for Spark Connect) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when creating interactive endpoints.
Rules:
- Interactive endpoints are billed per-second while active. Set
auto-stop to 15 minutes idle.
- Spark Connect uses a thin client protocol — the driver runs on
the EMR Serverless cluster, not locally. Ideal for laptop-based
exploration.
- Jupyter Enterprise Gateway is the backend for notebook-style
interactive sessions. Configured via the
managedEndpoints option.
Step 11: Verification
Verification CLI (get-application, list-job-runs, get-job-run, role/bucket/log-group checks) moved verbatim to references/cli-commands-and-iac.md.
Load on demand when verifying the deployment.
Latest EMR Serverless features (2024-2026)
Feature deep dive (Spark Connect, interactive endpoints, automated start/stop, Lake Formation integration, gang scheduling, custom images, blueprints, application snapshots) moved verbatim to references/advanced-patterns.md.
Load on demand when deciding which 2024-2026 features to enable.
Workload matrix
| Workload |
Type |
Pre-init capacity |
Max capacity |
VPC access |
Interactive |
| Nightly ETL (Spark) |
Spark |
50 workers |
200 workers |
Yes (S3 via VPC endpoint) |
No |
| Ad-hoc analytics (Spark Connect) |
Spark |
10 workers |
100 workers |
Yes |
Yes (Spark Connect) |
| Hive batch (legacy) |
Hive |
0 (cold start OK) |
50 workers |
No |
No |
| Streaming (Structured Streaming) |
Spark |
20 workers |
50 workers |
Yes |
No |
| ML training |
Spark |
100 workers |
300 workers |
Yes (S3 models) |
No |
| Notebook exploration |
Spark |
5 workers |
30 workers |
Yes |
Yes (Jupyter) |
| Dev/test |
Spark |
0 (cold start OK) |
10 workers |
No |
No |
NEVER (top 5 — full list of 12 in references)
- NEVER submit a job to an application that has no execution role
configured. The job fails immediately with
AccessDeniedException
on the first S3 operation. The execution role is the #1
prerequisite for EMR Serverless.
- NEVER use
AdministratorAccess on the execution role. Scope to the
specific S3 buckets, Glue databases, and Secrets Manager secrets the
job needs. EMR Serverless jobs run arbitrary code — a broad role is
a privilege escalation vector.
- NEVER deploy a Spark application that reads from private RDS without
VPC access configured. The job fails with
ConnectionTimeoutException
after the configured socket timeout (default 60s). This is the #1
silent-failure pitfall for database-connected Spark jobs.
- NEVER set pre-initialized capacity higher than needed. Each warm
worker is billed at the hourly rate whether or not it runs a job.
Start at the minimum sustained workload and scale up based on
observed cold-start frequency.
- NEVER use
:latest on the custom image tag. EMR Serverless pulls
the image at application start — a new push silently changes what
runs. Pin to a version tag or SHA digest. #1 reproducibility breaker.
Expert heuristic — sizing, capacity, and interactive strategy
- Pre-initialized capacity decision: set
initialCount to the
number of workers needed for the minimum sustained workload. For
nightly ETL that runs for 2 hours, pre-initialized capacity is a
waste — use cold start (60-90s is acceptable). For ad-hoc analytics
with frequent queries, pre-initialized capacity eliminates cold-start
latency.
- The 3x burst rule: set maximum capacity to 3x the pre-initialized
capacity. This gives headroom for bursty workloads without
unbounded cost.
- Spark Connect vs JDBC: use Spark Connect for interactive
exploration from notebooks/IDEs (thin client, driver on cluster).
Use JDBC for BI tools that need a persistent connection (Tableau,
Looker via Spark Thrift Server).
- Auto-stop tuning: 15 minutes is the default. For interactive
workloads, set to 60 minutes (users take breaks). For batch, set to
5 minutes (job finishes, application should stop immediately).
- Hive vs Spark SQL: use Spark SQL for all new workloads — it is
3-10x faster than Hive on Tez for the same query. Use Hive only for
legacy HiveQL pipelines that are too complex to migrate.
- AQE (Adaptive Query Execution): ALWAYS enable
spark.sql.adaptive.enabled=true. It dynamically coalesces shuffle
partitions, converts sort-merge joins to broadcast joins, and
handles skew. There is no reason to disable it in production.
- Log lifecycle: S3 logs transition to Glacier after 30 days and
expire after 365 days. CloudWatch Logs set to 30-day retention.
NEVER leave logs at default (Never Expire) — costs balloon.
Pre-flight safety checks (run before any deployment CLI)
- Confirm execution role exists and trusts
emr-serverless.amazonaws.com.
- Confirm S3 log bucket exists and is not public.
- Confirm S3 script bucket has the entry-point script.
- Confirm VPC subnets exist (if VPC access needed).
- Confirm security group outbound allows S3/Glue VPC endpoints.
- Confirm release label is the latest stable.
- Confirm service quota for capacity is sufficient.
- Confirm Glue database and tables exist (if catalog integration).
- For custom images, confirm ECR image exists and is pinned to a tag.
- For existing applications, capture current config for rollback.
Full CLI sequences for all checks in references/execution-and-capacity-guide.md.
Output format — MANDATORY literal labels
When invoked with an EMR Serverless deployment request, your ENTIRE
response MUST be the checklist block below. The labels are
case-sensitive all-caps keywords. Do NOT write a preamble. Start
with APPLICATION: and stop after the VERIFICATION_COMMANDS: block.
APPLICATION: <name>
VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING
CHECKLIST:
[✓] Application type — Spark | Hive, release label <release>
[✓] Execution role — <role-arn> (<scoped-permissions>)
[✓] Pre-initialized capacity — <count> workers, <cpu> / <memory> each
[✓] Maximum capacity — <max-workers> workers (burst ceiling)
[✓] VPC access — subnets <subnet-ids>, security groups <sg-ids>
[✓] S3 log bucket — s3://<bucket>/<prefix>/
[✓] CloudWatch logging — enabled, log group <log-group>
[✓] Job submission — entry point <s3-path>, args <args>
[✓] Configuration overrides — <spark-conf-overrides>
[✓] Tags — <tags>
[OPTIONAL] Interactive endpoint — Spark Connect | Jupyter (configured | not configured)
VERIFICATION_COMMANDS:
aws emr-serverless get-application --application-id <app-id>
aws iam get-role --role-name <exec-role>
aws s3 ls s3://<log-bucket>/<prefix>/
aws logs describe-log-groups --log-group-name-prefix /aws/emr-serverless/<name>
Status marker semantics:
[✓] — applied and verified.
[✗] — NOT applied or misconfigured. Cite the gap.
[OPTIONAL] — recommended but not required.
[INPUT NEEDED] — prerequisite value missing; operator must provide.
PREREQUISITES_MISSING verdict: if any REQUIRED prerequisite is
missing (execution role, S3 log bucket, S3 entry-point script, VPC
subnets for private-resource workloads), the verdict is
PREREQUISITES_MISSING.
References (load on demand)
- references/cli-commands-and-iac.md — full CLI sequence for all 11 deployment steps plus Terraform/CloudFormation; extended with the CLI blocks moved verbatim from the Deployment procedure.
- references/execution-and-capacity-guide.md — execution roles, VPC, capacity tuning, full NEVER list, pre-flight safety CLI.
- references/advanced-patterns.md — 2024-2026 feature deep dive and the edge-case handling catalog.
Domain
AWS CloudOps / EMR Serverless Analytics Compute Provisioning.
Edge-case handling
Edge-case catalog (cross-account S3, custom image updates, pre-init capacity with auto-stop, Lake Formation column-level access, gang scheduling, Spark Connect session isolation, Hive-to-Spark migration) moved verbatim to references/advanced-patterns.md.
Load on demand when a deployment hits a non-obvious edge case.
AWS documentation
References
references/cli-commands-and-iac.md — full copy-pasteable CLI command
sequence for all 11 deployment steps, including execution role
creation, S3 log bucket setup, application creation with capacity
and VPC config, application start, pre-initialized capacity, Spark
and Hive job submission, configuration overrides, interactive
endpoints, and Terraform / CloudFormation equivalents.
references/execution-and-capacity-guide.md — deep reference on
execution role scoping, VPC networking, pre-initialized capacity
tuning, maximum capacity burst strategy, Spark Connect interactive
endpoints, Spark/Hive configuration overrides, full NEVER list,
edge-case handling, and pre-flight safety CLI.
1---2name: emr-serverless-deployer3description: 'Deploys Amazon EMR Serverless applications with production-grade configuration: application creation (release label, type: Spark or Hive), capacity configuration (pre-initialized capacity for warm starts, maximum capacity for burst limits), VPC access (subnets, security groups for private resources), IAM execution role (S3, Glue, CloudWatch scoped), job submission (entry point, arguments, configuration overrides), interactive endpoints (Spark Connect, Jupyter), and latest features (Spark Connect remote sessions, interactive endpoints for notebooks, automated start/stop, Lake Formation integration, gang scheduling). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when creating an EMR Serverless application, deploying a Spark or Hive job, validating a configuration, or generating deployment CLI and IaC templates. Triggers: EMR Serverless, serverless Spark, serverless Hive, pre-initialized capacity, Spark Connect, interactive endpoints, job submission.'4license: Apache-2.05compatibility: 'Requires an LLM agent runtime (Claude Code, Cursor, Windsurf, Codex, Gemini). For live deployment: AWS CLI v2 with emr-serverless, s3, iam, ec2, logs, and glue access. Works with Terraform aws_emrserverless_* resources, CloudFormation AWS::EMRServerless::* resources, and the AWS Console EMR Serverless wizard.'6metadata:7 source: https://skillmd.com/skills/jhkchan/emr-serverless-deployer8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '1'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Analytics15 task_type: deploy16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY_TO_DEPLOY | PREREQUISITES_MISSING19 version: 0.1.020 author: Jacky Chan — AWS Community Builder21 tags: aws, emr, emr-serverless, cloudops, deploy, analytics, spark, hive22 dependencies: aws-orchestrator23 keywords: aws, emr, emr-serverless, cloudops, deploy, provisioning, analytics, spark, hive, pre-initialized-capacity, spark-connect, interactive-endpoints, job-submission, execution-role, vpc-access24 when_to_use: Invoke when the user wants to create a new EMR Serverless application, deploy a serverless Spark or Hive workload, validate an existing EMR Serverless configuration against best practices, generate deployment CLI commands or IaC templates, or troubleshoot an EMR Serverless deployment failure caused by missing prerequisites (execution role, VPC subnets, S3 log bucket). Do NOT invoke for provisioned EMR clusters (use emr-cluster-deployer), Glue jobs (use glue-job-troubleshooter), or Athena (use athena-query-optimizer).25---2627# EMR Serverless Deployer2829An AWS CloudOps agent skill that deploys Amazon EMR Serverless30applications with correct production defaults. Emits a31READY_TO_DEPLOY checklist verifying every configuration item.3233## Quick navigation3435| Need | Section |36|---|---|37| What MUST be in the response | "STRICT output contract" |38| Why application-before-job order matters | "Reasoning framework" |39| What to verify before deploying | "Prerequisites" |40| The ordered deployment steps | "Deployment procedure" |41| Common silent-failure pitfalls | "NEVER" |42| Application-type decision matrix | "Workload matrix" |43| 2024-2026 feature changes | "Recent AWS features" |44| Deep CLI sequences | `references/cli-commands-and-iac.md` |45| Execution roles, VPC, capacity, full NEVER | `references/execution-and-capacity-guide.md` |4647## STRICT output contract4849When this skill is invoked with an EMR Serverless deployment request,50the agent MUST respond with the READY_TO_DEPLOY checklist defined in51"Output format" using the literal all-caps labels `APPLICATION:`,52`VERDICT:`, `CHECKLIST:`, and `VERIFICATION_COMMANDS:`. Do NOT preface53the checklist with prose, headings, or disclaimers — emit the block54as the first lines.5556### Required output structure57581. `APPLICATION: <application-name>` — the EMR Serverless application59 being deployed.602. `VERDICT: READY_TO_DEPLOY` OR `VERDICT: PREREQUISITES_MISSING`.613. `CHECKLIST:` followed by indented lines with status markers62 (`[✓]`, `[✗]`, `[OPTIONAL]`, `[INPUT NEEDED]`).634. `VERIFICATION_COMMANDS:` followed by indented64 `aws emr-serverless ...` commands.6566### FORBIDDEN output patterns6768- **No prose preamble before `APPLICATION:`** — first non-empty line69 MUST be `APPLICATION:`.70- **No markdown variants of labels** — write `VERDICT:`, not71 `**VERDICT:**`, `### Verdict`, or `` `VERDICT` ``.72- **No swapping verdict tokens** — exactly `READY_TO_DEPLOY` or73 `PREREQUISITES_MISSING`.74- **No omitting `VERIFICATION_COMMANDS:`** — include even when75 PREREQUISITES_MISSING.76- **No extra sections after `VERIFICATION_COMMANDS:`** — the77 checklist block is the entire response.78- **No status marker drift** — use only `[✓]`, `[✗]`, `[OPTIONAL]`,79 `[INPUT NEEDED]`.8081### Perfect example (copy the shape exactly)8283```text84APPLICATION: etl-spark-prod85VERDICT: READY_TO_DEPLOY86CHECKLIST:87 [✓] Application type — Spark, release label emr-7.2.088 [✓] Execution role — arn:aws:iam::123456789012:role/EMRServerlessExecRole (S3, Glue, CloudWatch, Secrets Manager scoped)89 [✓] Pre-initialized capacity — 50 workers, 4 vCPU / 16 GB each, Spark driver 2 vCPU / 8 GB90 [✓] Maximum capacity — 200 workers (burst ceiling)91 [✓] VPC access — subnets subnet-aaa, subnet-bbb, security groups sg-emr-prod92 [✓] S3 log bucket — s3://emr-logs-123456789012/etl-spark-prod/93 [✓] CloudWatch logging — enabled, log group /aws/emr-serverless/etl-spark-prod94 [✓] Job submission — entry point s3://etl-scripts/daily_transform.py, args --source s3://raw-data/ --target s3://curated/95 [✓] Configuration overrides — spark.sql.shuffle.partitions=200, spark.executor.memoryOverhead=2g96 [✓] Tags — Environment=production, Application=etl-spark97 [OPTIONAL] Interactive endpoint — Spark Connect for notebooks (not configured)98VERIFICATION_COMMANDS:99 aws emr-serverless get-application --application-id <app-id>100 aws iam get-role --role-name EMRServerlessExecRole101 aws s3 ls s3://emr-logs-123456789012/etl-spark-prod/102 aws logs describe-log-groups --log-group-name-prefix /aws/emr-serverless/etl-spark-prod103```104105## Reasoning framework (why the application-before-job order matters)1061071. **Application FIRST** — an EMR Serverless application is the108 container for all Spark/Hive jobs. It defines the release label,109 type, execution role, capacity, and VPC access. Without an110 application you cannot submit a job.1112. **Execution role** — the IAM role the application assumes at112 runtime for S3 reads/writes, Glue catalog access, CloudWatch113 logging, and Secrets Manager. Without it, the job fails with114 `AccessDeniedException` on the first S3 operation.1153. **Capacity configuration** — pre-initialized capacity keeps workers116 warm for immediate job start (no cold start). Maximum capacity is117 the burst ceiling — jobs that exceed it are queued or fail.1184. **VPC access (if private resources)** — if the job reads from RDS,119 Redshift (private), or internal APIs, VPC subnets and security120 groups are REQUIRED. Without them, the job cannot reach private121 resources.1225. **S3 log bucket** — EMR Serverless streams stdout/stderr and Spark123 event logs to S3. Without a log bucket, job failures are invisible.1246. **Job submission LAST** — the entry point (S3 path to the125 PySpark/Scala/Hive script), arguments, and configuration overrides126 are submitted AFTER the application is CREATED and STARTED.127128## Prerequisites (verify before deployment)129130| Prerequisite | Why it matters | How to verify |131|---|---|---|132| **IAM execution role** | Trust `emr-serverless.amazonaws.com`. Scope for S3/Glue/CloudWatch/Secrets Manager. NEVER `AdministratorAccess`. | `aws iam get-role --role-name <role>` |133| **S3 log bucket** | Stores stdout/stderr and Spark event logs. MUST exist before job submission. | `aws s3 ls s3://<bucket>/` |134| **S3 script bucket** | Stores the entry-point PySpark/Scala/Hive script. MUST exist with the script. | `aws s3 ls s3://<scripts>/<script>` |135| **VPC subnets (if private resources)** | At least 2 private subnets across AZs for HA. Required if job accesses RDS/Redshift/internal APIs. | `aws ec2 describe-subnets --subnet-ids <ids>` |136| **Security groups (if VPC access)** | Inbound from EMR Serverless ENIs. Outbound to S3/Glue VPC endpoints. | `aws ec2 describe-security-groups --group-ids <sg-ids>` |137| **Release label** | EMR release version (e.g., `emr-7.2.0`). Determines Spark/Hive versions. Use the latest stable. | `aws emr-serverless list-release-labels` |138| **Service quota** | Default capacity (RPUs) per Region per account. Request increase BEFORE production. | `aws service-quotas get-service-quota --service-code emr-serverless --quota-code L-XXXXXXXX` |139| **Glue database (if catalog integration)** | Source/target Glue database and tables MUST exist for catalog-mode jobs. | `aws glue get-database --name <db>` |140| **Application release label compatibility** | Spark/Hive version in the release label MUST match the job's compiled dependencies. | Check EMR release notes for the release label. |141142## Deployment procedure (apply in order)143144### Step 1: IAM execution role145146The execution role is assumed by the EMR Serverless application for147all runtime AWS API calls (S3 reads/writes, Glue catalog access,148CloudWatch logging, Secrets Manager). Without it, the job fails on149the first S3 operation.150Execution-role CLI (create-role with emr-serverless trust policy, put-role-policy scoping S3/Glue/CloudWatch/Secrets Manager) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).151Load on demand when creating the execution role.152153Rules:154- **Trust `emr-serverless.amazonaws.com`** — NOT `elasticmapreduce.amazonaws.com`155 (that is the provisioned EMR principal).156- **NEVER use `AdministratorAccess`** — scope the role to the specific157 S3 buckets, Glue databases, and Secrets Manager secrets the job needs.158- **CloudWatch Logs permissions** — required for structured logging.159160### Step 2: S3 log bucket161S3 log bucket CLI (create-bucket, put-public-access-block, Glacier lifecycle rule) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).162Load on demand when setting up the log bucket.163164### Step 3: Create the application165create-application CLI (release label, type, initial/maximum capacity, network config, auto-start/stop, custom image, tags) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).166Load on demand when creating the application.167168Parameters:169- **release-label** — the EMR release version (e.g., `emr-7.2.0`).170 Determines the Spark and Hive versions. Use the latest stable unless171 compatibility requires otherwise.172- **type** — `SPARK` or `HIVE`. Spark for ETL/ML; Hive for173 schema-on-read and legacy HiveQL pipelines.174- **initial-capacity** — pre-initialized workers kept warm for175 immediate job start. Eliminates cold-start latency (60-90s).176- **maximum-capacity** — the burst ceiling. Jobs that need more177 workers are queued (if auto-scaling) or fail.178- **network-configuration** — VPC subnets and security groups. Required179 if the job accesses private resources (RDS, Redshift private,180 internal APIs).181- **auto-start** — application starts automatically when a job is182 submitted. Recommended for production.183- **auto-stop** — application stops after `idleTimeoutMinutes` of no184 activity. Saves cost. Default 15 minutes.185- **image-configuration** — custom Docker image from ECR for186 additional libraries (pandas, scikit-learn, custom JARs). Optional.187188### Step 4: Start the application189start-application CLI and STARTED-state check moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).190Load on demand when starting the application.191192### Step 5: Configure pre-initialized capacity (warm workers)193194Pre-initialized capacity keeps workers warm so the first job starts195immediately (no 60-90s cold start). This is the ONLY way to get196sub-minute job start latency.197Pre-initialized capacity CLI (update-application --initial-capacity) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).198Load on demand when configuring warm workers.199200Rules:201- **Pre-initialized capacity is billed even when idle.** Set202 `initialCount` based on the minimum sustained workload.203- **Pair with auto-stop** — if auto-stop triggers (idle for 15 min),204 pre-initialized capacity is released. When a new job starts, the205 application re-starts and re-initializes workers (cold start).206- **NEVER set `initialCount` higher than needed.** Each warm worker207 is billed at the hourly rate whether or not it runs a job.208209### Step 6: Job submission (Spark)210Spark start-job-run CLI (sparkSubmit job driver, monitoring and application configuration overrides) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).211Load on demand when submitting a Spark job.212213### Step 7: Job submission (Hive)214Hive start-job-run CLI (hive job driver, monitoring configuration) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).215Load on demand when submitting a Hive job.216217### Step 8: Configuration overrides (Spark tuning)218219Configuration overrides are applied at the application level and can220be overridden per-job via `sparkSubmitParameters`.221222| Override | Default | Production | Why |223|---|---|---|---|224| `spark.sql.shuffle.partitions` | 200 | 200-400 | Tune to data volume. Too low = OOM; too high = scheduling overhead. |225| `spark.sql.adaptive.enabled` | false | true | AQE coalesces shuffle partitions dynamically. Always enable. |226| `spark.executor.memoryOverhead` | 10% of executor memory | 2g | Off-heap memory for Python UDFs, broadcasts. |227| `spark.sql.adaptive.skewJoin.enabled` | false | true | Handles skewed join keys without manual salting. |228| `spark.serializer` | JavaSerializer | KryoSerializer | 10x faster serialization for complex objects. |229| `spark.sql.parquet.compression.codec` | snappy | snappy | Snappy for speed, gzip for size. |230231### Step 9: VPC access (private resources)232233If the job reads from RDS, Redshift (private), or internal APIs, VPC234access is REQUIRED.235VPC access CLI (update-application --network-configuration) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).236Load on demand when attaching subnets and security groups.237238Rules:239- **Use PRIVATE subnets.** EMR Serverless workers do not need public IPs.240- **Span at least 2 AZs** (3 for production HA).241- **Security group outbound** must allow the database port (e.g., 5432242 for Postgres, 3306 for MySQL) and 443 for S3/Glue VPC endpoints.243- **NAT Gateway is NOT required** for S3/Glue access — use VPC gateway244 endpoints. NAT is only needed for external API calls.245- **NEVER deploy without VPC access if the job reads from private RDS.**246 The job will fail with `ConnectionTimeoutException`.247248### Step 10: Interactive endpoints (Spark Connect, notebooks)249250Spark Connect allows remote Spark sessions from notebooks (Jupyter,251Zeppelin), IDEs (Databricks Connect, IntelliJ), and applications252without running a full Spark driver locally.253Interactive endpoint CLI (create-interactive-endpoint for Spark Connect) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).254Load on demand when creating interactive endpoints.255256Rules:257- **Interactive endpoints are billed per-second** while active. Set258 auto-stop to 15 minutes idle.259- **Spark Connect uses a thin client protocol** — the driver runs on260 the EMR Serverless cluster, not locally. Ideal for laptop-based261 exploration.262- **Jupyter Enterprise Gateway** is the backend for notebook-style263 interactive sessions. Configured via the `managedEndpoints` option.264265### Step 11: Verification266Verification CLI (get-application, list-job-runs, get-job-run, role/bucket/log-group checks) moved verbatim to [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md).267Load on demand when verifying the deployment.268269## Latest EMR Serverless features (2024-2026)270Feature deep dive (Spark Connect, interactive endpoints, automated start/stop, Lake Formation integration, gang scheduling, custom images, blueprints, application snapshots) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).271Load on demand when deciding which 2024-2026 features to enable.272273## Workload matrix274275| Workload | Type | Pre-init capacity | Max capacity | VPC access | Interactive |276|---|---|---|---|---|---|277| **Nightly ETL (Spark)** | Spark | 50 workers | 200 workers | Yes (S3 via VPC endpoint) | No |278| **Ad-hoc analytics (Spark Connect)** | Spark | 10 workers | 100 workers | Yes | Yes (Spark Connect) |279| **Hive batch (legacy)** | Hive | 0 (cold start OK) | 50 workers | No | No |280| **Streaming (Structured Streaming)** | Spark | 20 workers | 50 workers | Yes | No |281| **ML training** | Spark | 100 workers | 300 workers | Yes (S3 models) | No |282| **Notebook exploration** | Spark | 5 workers | 30 workers | Yes | Yes (Jupyter) |283| **Dev/test** | Spark | 0 (cold start OK) | 10 workers | No | No |284285## NEVER (top 5 — full list of 12 in references)286287- NEVER submit a job to an application that has no execution role288 configured. The job fails immediately with `AccessDeniedException`289 on the first S3 operation. The execution role is the #1290 prerequisite for EMR Serverless.291- NEVER use `AdministratorAccess` on the execution role. Scope to the292 specific S3 buckets, Glue databases, and Secrets Manager secrets the293 job needs. EMR Serverless jobs run arbitrary code — a broad role is294 a privilege escalation vector.295- NEVER deploy a Spark application that reads from private RDS without296 VPC access configured. The job fails with `ConnectionTimeoutException`297 after the configured socket timeout (default 60s). This is the #1298 silent-failure pitfall for database-connected Spark jobs.299- NEVER set pre-initialized capacity higher than needed. Each warm300 worker is billed at the hourly rate whether or not it runs a job.301 Start at the minimum sustained workload and scale up based on302 observed cold-start frequency.303- NEVER use `:latest` on the custom image tag. EMR Serverless pulls304 the image at application start — a new push silently changes what305 runs. Pin to a version tag or SHA digest. #1 reproducibility breaker.306307## Expert heuristic — sizing, capacity, and interactive strategy308309- **Pre-initialized capacity decision:** set `initialCount` to the310 number of workers needed for the minimum sustained workload. For311 nightly ETL that runs for 2 hours, pre-initialized capacity is a312 waste — use cold start (60-90s is acceptable). For ad-hoc analytics313 with frequent queries, pre-initialized capacity eliminates cold-start314 latency.315- **The 3x burst rule:** set maximum capacity to 3x the pre-initialized316 capacity. This gives headroom for bursty workloads without317 unbounded cost.318- **Spark Connect vs JDBC:** use Spark Connect for interactive319 exploration from notebooks/IDEs (thin client, driver on cluster).320 Use JDBC for BI tools that need a persistent connection (Tableau,321 Looker via Spark Thrift Server).322- **Auto-stop tuning:** 15 minutes is the default. For interactive323 workloads, set to 60 minutes (users take breaks). For batch, set to324 5 minutes (job finishes, application should stop immediately).325- **Hive vs Spark SQL:** use Spark SQL for all new workloads — it is326 3-10x faster than Hive on Tez for the same query. Use Hive only for327 legacy HiveQL pipelines that are too complex to migrate.328- **AQE (Adaptive Query Execution):** ALWAYS enable329 `spark.sql.adaptive.enabled=true`. It dynamically coalesces shuffle330 partitions, converts sort-merge joins to broadcast joins, and331 handles skew. There is no reason to disable it in production.332- **Log lifecycle:** S3 logs transition to Glacier after 30 days and333 expire after 365 days. CloudWatch Logs set to 30-day retention.334 NEVER leave logs at default (Never Expire) — costs balloon.335336## Pre-flight safety checks (run before any deployment CLI)337338- **Confirm execution role exists and trusts `emr-serverless.amazonaws.com`.**339- **Confirm S3 log bucket exists and is not public.**340- **Confirm S3 script bucket has the entry-point script.**341- **Confirm VPC subnets exist (if VPC access needed).**342- **Confirm security group outbound allows S3/Glue VPC endpoints.**343- **Confirm release label is the latest stable.**344- **Confirm service quota for capacity is sufficient.**345- **Confirm Glue database and tables exist (if catalog integration).**346- **For custom images, confirm ECR image exists and is pinned to a tag.**347- **For existing applications, capture current config for rollback.**348349Full CLI sequences for all checks in `references/execution-and-capacity-guide.md`.350351## Output format — MANDATORY literal labels352353When invoked with an EMR Serverless deployment request, your ENTIRE354response MUST be the checklist block below. The labels are355**case-sensitive all-caps keywords**. Do NOT write a preamble. Start356with `APPLICATION:` and stop after the `VERIFICATION_COMMANDS:` block.357358```text359APPLICATION: <name>360VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING361CHECKLIST:362 [✓] Application type — Spark | Hive, release label <release>363 [✓] Execution role — <role-arn> (<scoped-permissions>)364 [✓] Pre-initialized capacity — <count> workers, <cpu> / <memory> each365 [✓] Maximum capacity — <max-workers> workers (burst ceiling)366 [✓] VPC access — subnets <subnet-ids>, security groups <sg-ids>367 [✓] S3 log bucket — s3://<bucket>/<prefix>/368 [✓] CloudWatch logging — enabled, log group <log-group>369 [✓] Job submission — entry point <s3-path>, args <args>370 [✓] Configuration overrides — <spark-conf-overrides>371 [✓] Tags — <tags>372 [OPTIONAL] Interactive endpoint — Spark Connect | Jupyter (configured | not configured)373VERIFICATION_COMMANDS:374 aws emr-serverless get-application --application-id <app-id>375 aws iam get-role --role-name <exec-role>376 aws s3 ls s3://<log-bucket>/<prefix>/377 aws logs describe-log-groups --log-group-name-prefix /aws/emr-serverless/<name>378```379380**Status marker semantics:**381- `[✓]` — applied and verified.382- `[✗]` — NOT applied or misconfigured. Cite the gap.383- `[OPTIONAL]` — recommended but not required.384- `[INPUT NEEDED]` — prerequisite value missing; operator must provide.385386**PREREQUISITES_MISSING verdict:** if any REQUIRED prerequisite is387missing (execution role, S3 log bucket, S3 entry-point script, VPC388subnets for private-resource workloads), the verdict is389`PREREQUISITES_MISSING`.390391## References (load on demand)392393- [references/cli-commands-and-iac.md](references/cli-commands-and-iac.md) — full CLI sequence for all 11 deployment steps plus Terraform/CloudFormation; extended with the CLI blocks moved verbatim from the Deployment procedure.394- [references/execution-and-capacity-guide.md](references/execution-and-capacity-guide.md) — execution roles, VPC, capacity tuning, full NEVER list, pre-flight safety CLI.395- [references/advanced-patterns.md](references/advanced-patterns.md) — 2024-2026 feature deep dive and the edge-case handling catalog.396397## Domain398399AWS CloudOps / EMR Serverless Analytics Compute Provisioning.400401## Edge-case handling402Edge-case catalog (cross-account S3, custom image updates, pre-init capacity with auto-stop, Lake Formation column-level access, gang scheduling, Spark Connect session isolation, Hive-to-Spark migration) moved verbatim to [references/advanced-patterns.md](references/advanced-patterns.md).403Load on demand when a deployment hits a non-obvious edge case.404405## AWS documentation406407- **EMR Serverless Developer Guide** — https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/emr-serverless.html408- **CreateApplication API** — https://docs.aws.amazon.com/emr-serverless/latest/APIReference/API_CreateApplication.html409- **StartJobRun API** — https://docs.aws.amazon.com/emr-serverless/latest/APIReference/API_StartJobRun.html410- **EMR Serverless Execution Role** — https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/getting-started.html411- **Spark Connect on EMR Serverless** — https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/interactive-endpoints-spark-connect.html412- **Interactive Endpoints** — https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/interactive-endpoints.html413- **Pre-initialized Capacity** — https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/using-preinitialized-capacity.html414- **VPC Access** — https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/vpc-access.html415- **EMR Serverless CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/emr-serverless/416417## References418419- `references/cli-commands-and-iac.md` — full copy-pasteable CLI command420 sequence for all 11 deployment steps, including execution role421 creation, S3 log bucket setup, application creation with capacity422 and VPC config, application start, pre-initialized capacity, Spark423 and Hive job submission, configuration overrides, interactive424 endpoints, and Terraform / CloudFormation equivalents.425426- `references/execution-and-capacity-guide.md` — deep reference on427 execution role scoping, VPC networking, pre-initialized capacity428 tuning, maximum capacity burst strategy, Spark Connect interactive429 endpoints, Spark/Hive configuration overrides, full NEVER list,430 edge-case handling, and pre-flight safety CLI.