Generated banner for Testing Mwaa Workflow
Generated logo for Testing Mwaa Workflow

Testing Mwaa Workflow

AWSOfficialPublished by AWS

  • Skill
  • Workflow
  • Cloud and DevOps
  • Apache-2.0
  • No issues found

From the author

Tests Amazon MWAA workflow execution end-to-end: trigger a run and monitor it to completion for Provisioned (Python DAG, via Airflow REST API) and Serverless (YAML workflow, via StartWorkflowRun). Verifies the artifact is deployed and parse-ready, triggers with confirmation, polls to terminal state, and on failure delegates diagnosis to debugging-mwaa-workflow and artifact/redeploy fixes to authoring-mwaa-workflow, then retests up to a capped number of attempts. Triggers on: test my DAG, test my workflow, run my DAG, trigger a test run, does my DAG work, smoke-test the pipeline, verify my workflow runs, execute my DAG to check it. Not applicable to writing or deploying a new workflow (handled by authoring-mwaa-workflow), or for diagnosing why a run failed or root-causing an error (handled by debugging-mwaa-workflow).
— the description by AWS

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a robust, end-to-end testing framework for Amazon MWAA workflows, supporting both Provisioned (Python DAGs) and Serverless (YAML) environments. It manages the entire lifecycle of a test run: verifying readiness, triggering execution, polling for completion, and handling failures. When a test fails, the skill integrates with debugging and authoring skills to diagnose issues, apply fixes, and perform retests, ensuring a closed-loop resolution process.

What it does

  • Verifies workflow readiness before triggering to prevent premature execution.
  • Triggers test runs for both Provisioned and Serverless MWAA environments.
  • Polls runs to terminal states using adaptive intervals based on elapsed time.
  • Implements a safety gate requiring user confirmation for production-like environments.
  • Delegates root-cause diagnosis to debugging-mwaa-workflow upon failure.
  • Coordinates with authoring-mwaa-workflow to apply fixes and perform retests.

When to use it

  • When you need to verify that a newly deployed DAG or workflow is functional.
  • To perform smoke tests on a pipeline after deployment.
  • When you want to automate the cycle of testing, diagnosing, and fixing workflow failures.
  • To ensure a workflow is parse-ready and executable before production use.

Advantages

  • Reduces manual effort by automating the test-debug-retest loop.
  • Ensures safety through explicit confirmation gates for production environments.
  • Provides consistent, standardized testing logic across different MWAA flavors.
  • Prevents stale test results by enforcing freshness checks on runs.

Usage examples

“test my DAG”
The agent identifies the environment, verifies the DAG is ready, requests confirmation, and triggers a test run, monitoring it until completion.
“smoke-test the pipeline”
The agent performs an end-to-end test of the workflow, and if it fails, it automatically invokes the debugging skill to identify the issue.
“verify my workflow runs”
The agent checks the status of the specified workflow and executes a test run if the current state allows, reporting the final outcome.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/aws/testing-mwaa-workflow/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip testing-mwaa-workflow.zip -d .agents/skills

Documentation by AWS

Testing MWAA Workflows

AWS MCP server (optional but recommended): running the AWS CLI commands in this skill through the AWS MCP server gives sandboxed execution and audit logging. Every command here also works with the plain AWS CLI, so the skill does not require the MCP server or any MCP-only tools.

Test Amazon MWAA workflow execution end-to-end: trigger a run, poll it to a terminal state, and on failure drive a capped debug -> fix -> retest loop. This skill triggers and reads state only; it delegates every diagnosis to debugging-mwaa-workflow and every mutation (artifact edit, redeploy, environment create/update) to authoring-mwaa-workflow. Routes by flavor, then runs one shared spine.

Execution note — poll in discrete steps: whenever you wait for an AWS operation to reach a terminal or ready state, issue one status check per call and decide in your own loop whether to check again. Never block a single command or script on the wait (no while+sleep until done), regardless of the operation or how long it takes.

Guardrail — where this skill's own files live (MCP vs local install)

This skill can be loaded two ways, and they resolve the skill's own bundled files from different places. Determine how the skill was loaded before reading a reference:

  • Loaded through the AWS MCP retrieve_skill tool: The skill is not installed on the local filesystem. You MUST fetch each reference via retrieve_skill with the file parameter (e.g. file="references/provisioned-testing.md") and read the returned content. Do NOT file_read these paths locally — they do not exist on disk.

  • Installed locally (e.g. .kiro/skills/testing-mwaa-workflow/ or ~/.claude/skills/testing-mwaa-workflow/): Read the files from the local skill directory using relative paths.

This distinction applies only to the skill's own packaged files. User data and session artifacts are always read from and written to the user's working directory. Never fetch or write customer data through retrieve_skill.

Step 0: Detect Flavor, Mode, and Complexity

Flavor (reuse debugging's logic)
  1. An environment name resolvable via aws mwaa get-environment -> Provisioned.

  2. A workflow/... ARN or any aws mwaa-serverless context -> Serverless.

  3. Neither signal -> ask: MWAA Provisioned (Python DAG) or MWAA Serverless (YAML workflow)?

Invocation mode
  • Standalone — the user points at an existing, already-deployed target.

  • Delegated — authoring-mwaa-workflow deployed and handed over the resolved target (env name + dag_id, or workflow ARN). Its "deploy and test now?" approval satisfies the first trigger confirmation only.

Complexity
  • Simple — target already deployed and known-ready -> skip to Step 2.

  • Standard — just deployed, readiness unknown -> full spine.

  • Complex — retest inside an active fix loop.

Step 1: Readiness Check (before the first trigger)

Confirm the artifact is deployed and parse-ready. Do not trigger blind. This step is MANDATORY even when you plan to adopt an existing run — the readiness data (last_parsed_time, is_active, has_import_errors) feeds the freshness gate in Step 2.

  • Provisioned: confirm dag_id present with has_import_errors: false, then apply the version-aware ready check via the /dags collection endpoint. Determine the poll window from the environment's configured scan interval: check get-environment -> AirflowConfigurationOptions for scheduler.dag_dir_list_interval (AF2) or dag_processor.refresh_interval (AF3). If unset, default to 300s. Poll up to that interval + 30s at 15s intervals (the per-DAG endpoint can lag). On AF2 (REST API v1) require is_active: true. On AF3 (REST API v2) the is_active field does not exist — require is_stale: false instead and never wait on is_active (it reads as absent/false forever). A DAG that is parsed but not yet ready will reject trigger attempts with an opaque RestApiClientException. Not ready in time -> hand to debugging-mwaa-workflow.

  • Serverless: confirm WorkflowStatus is READY (via get-workflow --workflow-arn). Not ready -> hand to debugging-mwaa-workflow.

This readiness window is separate from the Step 3 run timeout. See references/provisioned-testing.md and references/serverless-testing.md for exact commands.

Step 2: Confirm, then Trigger (safety gate)

State the resolved target and classify its environment. Unless you are certain it is a development/test environment (name or tags clearly indicate dev/test), treat it as production: emit a prod warning and require explicit user confirmation before triggering. If the target is confirmed production (name or tags contain prod, prd, or production, or the user says so), require explicit approval at every state-changing step — each trigger, re-trigger, and clear/rerun — not just once. For a target you are certain is dev/test, require explicit user confirmation before the first trigger and each re-trigger.

This gate is already satisfied when the user has given explicit approval for the action: in delegated mode the authoring "deploy and test now?" approval covers the first trigger, and an explicit pre-authorization to trigger a specific run counts as that confirmation — do not re-ask when approval has already been given.

Before triggering, check for scheduler-created runs (see provisioned-testing reference). Apply the freshness gate before adopting any prior run:

  • Delegated mode: always trigger fresh. Prior runs predate the deployment by definition — do not adopt regardless of state.

  • Standalone mode: compare run.start_date against dag.last_parsed_time read from the /dags collection response the Step 1 readiness check already fetches (the collection returns last_parsed_time per DAG in both v1 and v2 — no per-DAG call needed). If start_date < last_parsed_time, the run tested a prior artifact version — treat as stale, trigger fresh. Only adopt runs where start_date >= last_parsed_time.

For fresh, non-stale runs that pass the gate: if a run already exists for the target interval, adopt it instead of POSTing. Monitor through Step 3.

On a retest, all run identifiers must be fresh (Provisioned: both dag_run_id and logical_date; Serverless: new start-workflow-run call). Before re-triggering, confirm every prior run is terminal — a still-running prior run can block the new one from starting.

See references for exact trigger commands and retest hygiene.

Step 3: Poll to Terminal

Poll the triggered run until it reaches a terminal state. See references for exact poll commands and error fallbacks.

Timeout handling:

  • Provisioned with dagrun_timeout set: if elapsed time exceeds dagrun_timeout and the run is still not terminal, treat as failure -> Step 4. (dagrun_timeout is a DAG-level Airflow parameter and does not apply to MWAA Serverless.)

  • Serverless: poll until the service returns a terminal state — no caller ceiling is needed, because the MWAA Serverless service enforces its own run cap and surfaces it as the TIMEOUT terminal state.

  • Provisioned without dagrun_timeout: there is no DAG- or service-level deadline, so agree a maximum wait with the user before polling (they know the DAG's expected runtime; default to 1h if they have no preference). Poll until terminal OR the maximum wait elapses. On reaching the cap, stop polling and report — do not silently mark it failed, and do not keep polling unbounded:

    Run <run-id> has not reached a terminal state within the agreed <max-wait>. It may still be running — I have not failed it. Choose: (a) extend the wait, (b) inspect logs / the Airflow UI, or (c) treat this test as inconclusive.

Poll interval scales with elapsed time:

Elapsed timePoll interval
<= 5 min15s
> 5-15 min30s
> 15-30 min60s
> 30-60 min2 min
> 60 min5 min

Pass = terminal SUCCESS only; no output-data inspection. On pass -> Step 6.

Step 4: On Failure, Delegate to Debugging

Hand the run identifiers to debugging-mwaa-workflow. It returns its standard structure (Root Cause / Impact / Immediate Fix / Prevention / Commands). Do not re-diagnose here.

Step 5: Classify Fixes and Loop

5a. Classify each action item debugging returns into one bucket:

BucketExamplesHandling
ARTIFACTwrong operator param, missing import, bad YAML schema/timedelta, wrong task wiring, Serverless code-package fix (missing dep / wrong-platform wheel / bad zip layout)Delegate to authoring-mwaa-workflow: regenerate the compliant artifact (and rebuild/redeploy the --code package for Serverless), then redeploy. Auto-continue.
ENVIRONMENTrequirements.txt dependency, plugins.zip, env config / worker sizingDelegate to authoring's deploy path (owns env mutation + its own approval). Auto-continue after that gate.
HUMAN-GATEDnew IAM permission, VPC/networking, missing data asset, quota increaseCannot be auto-applied. Present exact commands, pause the loop, wait for the user to confirm resolution before any retest.

Testing never mutates directly.

5b. Re-test. After an auto-fixable bucket is applied and redeployed, loop back to Step 1 (redeploy triggers a fresh S3-sync/parse) -> Step 2 (re-confirm) -> Step 3. Apply Step 2's re-trigger hygiene: fresh dag_run_id and logical_date, and confirm the prior run is terminal (not just still retry-backing-off) before the new trigger.

5c. Mixed action items in one cycle (parallel). Kick off the auto-fixable fixes (regenerate + redeploy via authoring) and present the human-gated items at the same time; do not fully serialize. Two guardrails: (1) gate the retest on both completing — do not re-trigger until auto-fixes are redeployed and the user confirms the human-gated items; (2) if an auto-fix depends on a human-gated item (the regenerated artifact references a resource/permission the user must create first), sequence them instead of parallelizing.

5d. Loop cap and stop conditions. The cap counts attempts without progress, not raw attempts — default 3 (override "retry up to N"). Define progress as either: a task that failed before now reaches SUCCESS (the pipeline advanced), or debugging reports a different root cause than the prior attempt. An attempt that makes progress resets the counter — a multi-task pipeline that clears one blocker per run is advancing, and a hard raw-count cap would abandon it mid-repair. Stop and summarize when any of: (1) run reaches SUCCESS -> Step 6 pass; (2) the no-progress counter hits the cap; (3) a HUMAN-GATED item -> pause for the user. Two consecutive runs with the same root cause count as one no-progress increment each — that is the counter advancing, not a separate rule.

Step 6: Report

Test Result: PASS | FAIL | STOPPED (<reason>)
Target: <env-name + dag_id | workflow ARN>  [PROD WARNING if applicable]
Attempts: <n>/<cap>
Run History:
  Attempt 1: <run_id> -> <state> (<duration>) [-> root cause if failed]
Fixes Applied: <artifact/env fixes auto-applied via authoring, per attempt> | none
Outstanding Action Items: <human-gated items, exact commands> | none
Next Step: <re-invoke to retest after resolving | passed, nothing needed>

PASS requires terminal SUCCESS. STOPPED covers cap-reached / no-progress / human-gated-pause, each named explicitly.

Gotchas

  • A freshly deployed artifact is not immediately runnable — it must sync from S3 and parse (Provisioned) or was validated at create/update (Serverless). Step 1 is mandatory before the first trigger unless complexity is Simple.

  • This skill never edits an artifact, changes requirements, or creates/updates an environment. Those are authoring-mwaa-workflow's job and carry its approval gates. Testing only triggers (confirmed) and reads state.

  • Pass is run-state SUCCESS only. Output-data correctness is out of scope.

Troubleshooting

SymptomCauseAction
DAG absent from GET /dagsS3-sync lag or import errorHand to debugging-mwaa-workflow before triggering
--path rejected / truncatedPath over 64 chars (https://docs.aws.amazon.com/cli/latest/reference/mwaa/invoke-rest-api.html)Poll the collection path with --query-parameters
RestApiClientException on pollWeb server unreachableFall back to DAGProcessing/Scheduler log groups
RestApiClientException on dagRuns POST (empty message)DAG not ready — AF2: is_active=false (activation incomplete); AF3: is_stale=true (is_active does not exist in v2)Poll /dags collection until ready (AF2 is_active=true / AF3 is_stale=false); do not retry the trigger blind
Manual run created but stuck in queued, never starts (AF3)DAG is paused — AF3 does not execute manual runs while paused (AF2 does)Unpause (PATCH /dags/<dag_id> {"is_paused": false}) then trigger; common right after an upgrade where DAGs are deployed paused
Serverless get-workflow not READYStill creating/updating or failedWait for READY; if FAILED, hand to debugging
Same failure two attempts runningFix not addressing root causeStop at no-progress; summarize; do not burn the cap

References

Security Considerations

  • Triggers real runs (state-changing): every trigger and re-trigger requires explicit confirmation; prod-named targets get a warning first.

  • No autonomous mutation: the skill never edits artifacts, requirements, or environments and never changes IAM — those are delegated to authoring (with its own gates). Human-gated fixes pause the loop for user action.

  • No secret exposure: run and log inspection must not surface credentials or connection strings into output.

Files

references/provisioned-testing.md

Provisioned MWAA Testing

Trigger and monitor a run on MWAA Provisioned (Python DAG). Every call here is a single, aws-shaped aws mwaa invoke-rest-api invocation that proxies the Airflow REST API through one AWS API call. No create-web-login-token, no curl: invoke-rest-api reaches private (VPC-only) web servers.

invoke-rest-api returns {"RestApiStatusCode": <int>, "RestApiResponse": {...}}. Read the run/DAG state from RestApiResponse.

CLI vs SDK difference for Body: the CLI --body flag accepts a JSON string ('{"key": "value"}'). The boto3 SDK Body parameter accepts a Python dict ({"key": "value"}) — do NOT wrap it in json.dumps(). Passing a string produces the same generic RestApiClientException (empty message) as other failures, with no indication the cause is serialization. All examples below use CLI syntax; when calling via SDK, pass the equivalent dict.

Readiness (before the first trigger)

Confirm the DAG is present and import-error-free:

aws mwaa invoke-rest-api --name <env> --path /dags --method GET \
  --query-parameters '{"dag_id_pattern":"<dag_id>"}'

RestApiResponse.dags[] lists parsed DAGs. dag_id_pattern bounds the response to the target so it is found even on an environment with more than 100 DAGs (an unfiltered /dags returns only the first 100 by default); it is a substring match, so exact-match <dag_id> in dags[] (and if the pattern itself matches more than 100 DAGs, add "limit":"100","offset":"0" and loop offset until total_entries). The target dag_id must be present with has_import_errors: false, plus a version-aware ready check via the /dags collection endpoint (the per-DAG endpoint /dags/<dag_id> can return stale values due to response caching):

  • AF2 (REST API v1): require is_active: true.

  • AF3 (REST API v2): the is_active field does not exist in the v2 /dags[] schema — never wait on it (a naive check reads it as absent/false forever and the readiness gate never passes). Require is_stale: false instead.

A DAG that is parsed but not yet ready (AF2 is_active: false, AF3 is_stale: true) can reject trigger POST requests with an opaque RestApiClientException (empty error message). This readiness lag is typically 1-5 minutes after the file first appears in S3.

Absent after the readiness window, has_import_errors: true, or still not ready after that window (the environment's scan interval + 30s, default 300s when unset, per SKILL.md Step 1; AF2 is_active never true / AF3 is_stale never false) — hand to debugging-mwaa-workflow to split S3-sync lag from an import error (it reads the DAGProcessing log group). Do not trigger a DAG that is absent, has import errors, or is not ready.

Trigger

Airflow 3.x (REST API v2):

aws mwaa invoke-rest-api --name <env> --path /dags/<dag_id>/dagRuns \
  --method POST --body '{"dag_run_id": "<explicit-id>", "logical_date": "<unique-ISO8601-UTC>"}'

<explicit-id> is a unique string you choose (e.g., smoke_test__2026-08-11T01-00-00). Constraints: must not contain /; max 250 chars; must be unique per (dag_id, logical_date) pair.

Airflow 2.x (REST API v1):

aws mwaa invoke-rest-api --name <env> --path /dags/<dag_id>/dagRuns \
  --method POST --body '{"dag_run_id": "<explicit-id>", "conf": {}}'

<explicit-id> follows the same constraints as above. AF2 does not require logical_date and accepts conf directly.

invoke-rest-api auto-routes to v1 or v2 based on the environment's Airflow version — callers do not specify a version prefix in the path. The body format differs: AF3 requires logical_date (ISO 8601 UTC) and does not accept conf at the top level; AF2 does not require logical_date and accepts conf directly. Sending the wrong format produces a generic RestApiClientException with no descriptive message.

Capture the dag_run_id so the poll can find this exact run.

Unpause before triggering (AF3 behavior change). On Airflow 3.x, a manual run POSTed against a paused DAG is accepted (the run is created in queued) but the scheduler does not execute it while the DAG is paused — it sits queued indefinitely and looks like a stuck trigger. Airflow 2.x runs manual triggers regardless of pause state; AF3 does not. Unpause first (PATCH /dags/<dag_id> with {"is_paused": false}), then trigger. This is common right after an upgrade, where DAGs are deployed paused.

Prefer a definitely-past logical_date. Manually triggered runs are processed regardless of logical_date, but using a timestamp in the past (e.g., 5 minutes ago) avoids two practical issues: (1) if prior runs of the same DAG are still retrying, the new run may be blocked by max_active_runs and appear stuck — a past timestamp makes it obvious the issue is concurrency, not scheduling; (2) if the DAG templates on {{ ds }}, a past timestamp on the same calendar day keeps data paths aligned with seeded test data.

On a retest, vary both dag_run_id and logical_date. Airflow enforces a unique (dag_id, logical_date); reusing a prior value makes the POST a silent no-op — a generic RestApiClientException with no run created, indistinguishable at a glance from a transient error. If the DAG templates on {{ ds }} (or other date-derived paths), keep the same calendar date and vary only the time-of-day so those paths still resolve to the staged test data.

Before re-triggering, confirm the prior run is terminal (see the poll below). A task in retry-backoff still occupies a max_active_runs slot, so a new run sits queued behind it rather than starting — a stall that looks like a trigger failure but is the concurrency cap.

Existing runs after unpause

When a paused DAG is unpaused during testing (common in delegated mode — the DAG was just deployed paused), and catchup=False with an eligible interval already past, the scheduler creates a scheduled__ run immediately. This consumes the next eligible logical_date.

Before POSTing a manual trigger:

  1. GET /dags/<dag_id>/dagRuns with {"order_by": "-start_date", "limit": "1"}.

  2. Apply the freshness gate — a prior run may have tested a previous version of the artifact:

    • Delegated mode: the artifact was just rewritten and redeployed. Any prior run by definition tested the previous file. Skip adoption and trigger fresh regardless of state.

    • Standalone mode: compare run.start_date against dag.last_parsed_time read from the /dags collection readiness response (the ready check already fetches it; the collection returns last_parsed_time per DAG, so there is no need to re-query the per-DAG endpoint). If start_date < last_parsed_time, the run predates the current artifact — treat as stale, trigger fresh.

  3. If a fresh run exists (passes the gate):

    • Non-terminal (queued/running) — adopt it: skip the POST, proceed directly to poll (Step 3) using the scheduler's dag_run_id.

    • Terminal success — the DAG already passed; report it (Step 6).

    • Terminal failed — the DAG already failed; proceed to Step 4 (diagnosis).

  4. If no fresh runs exist — POST the manual trigger as normal.

This check is cheap (one GET) and prevents the silent-failure scenario where the POST returns RestApiClientException because the logical_date is already taken — indistinguishable from a transient error without this context.

Poll to terminal

Task instances without a state field (or with state: null) mean the scheduler has not yet processed them. This is normal immediately after triggering — wait for at least one poll cycle (scheduler heartbeat is 5-30 seconds). If they remain stateless after 60 seconds, the likely causes are: the run is behind a max_active_runs concurrency cap (prior runs still retrying), or the scheduler is overloaded. Check for other active runs of the same DAG before concluding the trigger failed.

Mind the 64-character --path limit: a per-run path (/dags/<dag_id>/dagRuns/<url-encoded-run-id>) can exceed it. Poll the short collection path with query parameters instead:

aws mwaa invoke-rest-api --name <env> --path /dags/<dag_id>/dagRuns \
  --method GET --query-parameters '{"order_by": "-start_date", "limit": "5"}'

Scan RestApiResponse.dag_runs[] for the entry whose dag_run_id equals the captured id and read its state — a scheduler-created or concurrent run can otherwise be the newest by start_date and mask the target run. Terminal states: success, failed. queued/running mean keep polling.

Fallback

A RestApiClientException or timeout (rare with invoke-rest-api, possible on a mis-scoped execution role) falls back to the Scheduler and DAGProcessing CloudWatch log groups for run/task state, exactly as debugging-mwaa-workflow documents. Prefer invoke-rest-api; use logs only when it errors.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS
Publisher
AWS (Official)
Source
aws/agent-toolkit-for-aws · plugins/aws-data-analytics/skills/testing-mwaa-workflow · commit 0a218f8
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
aws/agent-toolkit-for-aws

AutoGineer is not affiliated with or endorsed by AWS.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download testing-mwaa-workflow.zip