Skip to content

InvokeRestApi

Source: src/AWS/MWAA/InvokeRestApi.ts

Runtime binding for airflow:InvokeRestApi (Airflow 2.4.3+).

Bind an Environment inside a function runtime to call the Apache Airflow REST API on the environment’s webserver — trigger DAG runs, list DAGs, inspect task instances, manage variables and connections — without minting tokens yourself. The IAM grant is scoped to the Airflow RBAC role the call is mapped to (Admin by default — pass { airflowRole } to scope it down). Provide the implementation with Effect.provide(AWS.MWAA.InvokeRestApiHttp).

List DAGs

// init — bind the operation to the environment
const invokeRestApi = yield* AWS.MWAA.InvokeRestApi(environment);
// runtime — GET /dags through the Airflow REST API
const result = yield* invokeRestApi({
Method: "GET",
Path: "/dags",
QueryParameters: { paused: false },
});
const dags = result.RestApiResponse as { dags: { dag_id: string }[] };

Trigger a DAG Run

const run = yield* invokeRestApi({
Method: "POST",
Path: "/dags/my_dag/dagRuns",
Body: { conf: { source: "lambda" } },
});