This is a stable example. It should successfully build out of the box
This sample demonstrates how to deploy AWS Managed Workflows for Apache Airflow (MWAA) using AWS CDK with example DAGs for basic workflows, Lambda integration, and human approval processes.
This CDK project creates:
- VPC with public/private subnets and NAT Gateway
- S3 bucket for DAG storage with automatic deployment
- MWAA environment with proper IAM roles and security groups
- DynamoDB table for human approval workflows
- Lambda function for integration testing
- Three example DAGs demonstrating different patterns
graph TD
subgraph "example_dag"
A1[Start] --> A2[Print Hello]
A2 --> A3[Print Goodbye]
A3 --> A4[End]
end
subgraph "lambda_invoke_dag"
B1[List Lambda Functions] --> B2[Invoke Demo Lambda]
B2 --> B3[Process Response]
end
subgraph "ddb_approval_dag"
C1[Create Approval Request] --> C5[(DynamoDB Table)]
C1 --> C2[Wait for Human Approval]
C5 --> C2
C2 --> C3[Process Transaction]
C3 --> C4[Complete]
C6[Manual Approval via AWS Console] --> C5
end
Example DAGs included:
example_dag.py- Basic Airflow workflow with simple taskslambda_invoke_dag.py- Demonstrates Lambda function invocation from Airflowddb_approval_dag.py- Human approval workflow using DynamoDB sensors
npm install
npm run buildcdk deployNote the outputs after deployment:
- MwaaWebServerUrl - Access the Airflow web interface
- S3BucketName - Where your DAGs are stored
- ApprovalTableName - DynamoDB table for approval workflows
- Login to AWS Console first - Ensure you're logged into the AWS Console in your browser
- Use the deployment output URL - Copy the
MwaaWebServerUrlfrom the deployment outputs - Access Airflow - Open the URL in the same browser where you're logged into AWS Console
Note: MWAA requires AWS authentication even with PUBLIC_ONLY access mode. You must be logged into the AWS Console to access the Airflow web interface.
- Trigger the
example_dagDAG from the Airflow UI - Watch it execute the simple "Hello" and "Goodbye" tasks
- Verify successful completion in the DAG run logs
- Trigger the
lambda_invoke_exampleDAG from the Airflow UI - View logs to see Lambda function listing and invocation results
- Trigger the
dynamodb_human_approval_pipelineDAG from the Airflow UI - Go to AWS Console → DynamoDB → Tables →
mwaa-approval-table-{region} - Find your process record and change
approval_statusfromPENDINGtoAPPROVED - Watch the workflow complete automatically
cdk destroyAll resources are configured with RemovalPolicy.DESTROY for easy cleanup.
- Environment Class:
mw1.small(1-2 workers) - Airflow Version: 2.7.2
- Web Access: Public (configure private access for production)
- Logging: All log types enabled at INFO level
This sample uses demo-friendly settings. For production:
- Web Access: Change from
PUBLIC_ONLYtoPRIVATE_ONLYfor MWAA environment - IAM Permissions: Replace wildcard (
'*') permissions with specific resource ARNs - S3 Encryption: Enable server-side encryption for the DAGs bucket
- VPC Endpoints: Add endpoints for S3, DynamoDB, and Lambda to avoid internet traffic
- Resource Policies: Use
RETAINinstead ofDESTROYfor production resources - DynamoDB: Enable point-in-time recovery (currently disabled)
- Monitoring: Enable CloudTrail and CloudWatch alarms for security monitoring