Amazon EMR Serverless Operators

Amazon EMR Serverless is a serverless option in Amazon EMR that makes it easy for data analysts and engineers to run open-source big data analytics frameworks without configuring, managing, and scaling clusters or servers. You get all the features and benefits of Amazon EMR without the need for experts to plan and manage clusters.

Prerequisite Tasks

To use these operators, you must do a few things:

Operators

Create an EMR Serverless Application

You can use EmrServerlessCreateApplicationOperator to create a new EMR Serverless Application.

tests/system/providers/amazon/aws/example_emr_serverless.py[source]

emr_serverless_app = EmrServerlessCreateApplicationOperator(
    task_id='create_emr_serverless_task',
    release_label='emr-6.6.0',
    job_type="SPARK",
    config={'name': 'new_application'},
    wait_for_completion=False,
)

Start an EMR Serverless Job

You can use EmrServerlessStartJobOperator to start an EMR Serverless Job.

tests/system/providers/amazon/aws/example_emr_serverless.py[source]

start_job = EmrServerlessStartJobOperator(
    task_id='start_emr_serverless_job',
    application_id=emr_serverless_app_id,
    execution_role_arn=role_arn,
    job_driver=SPARK_JOB_DRIVER,
    configuration_overrides=SPARK_CONFIGURATION_OVERRIDES,
)

Delete an EMR Serverless Application

You can use EmrServerlessDeleteApplicationOperator to delete an EMR Serverless Application.

tests/system/providers/amazon/aws/example_emr_serverless.py[source]

delete_app = EmrServerlessDeleteApplicationOperator(
    task_id='delete_application',
    application_id=emr_serverless_app_id,
    trigger_rule=TriggerRule.ALL_DONE,
)

Sensors

Wait on an EMR Serverless Job state

To monitor the state of an EMR Serverless Job you can use EmrServerlessJobSensor.

tests/system/providers/amazon/aws/example_emr_serverless.py[source]

wait_for_job = EmrServerlessJobSensor(
    task_id='wait_for_job', application_id=emr_serverless_app_id, job_run_id=start_job.output
)

Wait on an EMR Serverless Application state

To monitor the state of an EMR Serverless Application you can use EmrServerlessApplicationSensor.

tests/system/providers/amazon/aws/example_emr_serverless.py[source]

wait_for_app_creation = EmrServerlessApplicationSensor(
    task_id='wait_for_app_creation',
    application_id=emr_serverless_app_id,
)

Was this entry helpful?