fix: Correct AIRFLOW_VERSION in 3.3.1 startup validation and add CI check (#621)
Fix EXPECTED_AIRFLOW_VERSION in post-startup-script-verification for 3.3.1 (was incorrectly set to 3.3.0, causing startup validation failures).
Add quality-checks/version_consistency_check.sh to prevent this class of bug in future — asserts EXPECTED_AIRFLOW_VERSION matches Dockerfile.base for every image directory. Auto-discovered by run_all.py and runs on every push and PR.
Fixes #619
Issue # (if available):
Description of changes:
List any breaking changes for
- The Environment runtime:
- The local development experience:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Co-authored-by: Harsh Bhalani hbhalani@amazon.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
aws-mwaa-docker-images
Overview
This repository contains the Docker Images that Amazon MWAA uses to run Airflow.
You can also use it locally if you want to run a MWAA-like environment for testing, experimentation, and development purposes.
Currently, Airflow v2.9.2 and above are supported. Future versions in parity with Amazon MWAA will be added as well. Notice, however, that we do not plan to support previous Airflow versions supported by MWAA.
Using the Airflow Image
Linux / macOS
To experiment with the image using a vanilla Docker setup, follow these steps:
Build and run a supported Airflow version Docker image:
cd <amazon-mwaa-docker-images path>/images/airflow/2.9.2./run.shBy default this runs fully locally (no AWS account needed): it builds the images, starts the containers, and writes logs inside the container at
/usr/local/airflow/logs/. The web server is athttp://localhost:8080.To publish logs to CloudWatch instead, set
ACCOUNT_ID,ENV_NAME, and real AWS credentials inrun.sh../run.shthen creates and writes to these log groups (your credentials need permission to do so):{ENV_NAME}-DAGProcessing{ENV_NAME}-Scheduler{ENV_NAME}-Worker{ENV_NAME}-Task{ENV_NAME}-WebServerThe credentials you provide are also used by the Airflow components at runtime, so if you hit permission errors, grant the needed permissions to that identity.
Windows (PowerShell 5.1) [Not supported by AWS MWAA Service Team]
Prerequisites
One-time setup
Clone this repository.
Allow PowerShell to run local scripts (run once as your user):
Create the Python virtual environments from the repo root: ```powershell
Create venvs for all Airflow versions
python create_venvs.py –target development
Or for a specific version only
python create_venvs.py –target development –version
This will build the Docker images and start the full Airflow stack. On first run, the image build can take 10–20 minutes.
requirements.txtwithout running Airflow:startup.shwithout running Airflow:AWS Credentials
For local development without a real AWS account,
run.ps1defaults to dummy values — ElasticMQ (the local SQS mock) does not validate credentials. To use real AWS services (e.g. CloudWatch logging), update the$AccountId,$EnvName, and$env:AWS_*values at the top ofrun.ps1.Logging in
Once the stack is up, open
http://localhost:8080. The default credentials are printed in the webserver container logs on startup.Adding DAGs
Drop DAG files into
images\airflow\<version>\dags\. They are live-mounted into the container — no restart needed. The scheduler picks them up within a minute or two.Stopping
Troubleshooting
cannot be loaded because running scripts is disabledSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserDocker is not in Linux containers modepythonnot foundUnable to locate credentialsAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYare non-empty inrun.ps1http://localhost:8080dags\folderAuthentication from version 3.0.1 onward
For environments created using this repository starting with version 3.0.1, we default to using
SimpleAuthManager, which is also the default auth manager in Airflow 3.0.0+. By default,SIMPLE_AUTH_MANAGER_ALL_ADMINSis set to true, which means no username/password is required, and all users will have admin access. You can specify users and roles using the SIMPLE_AUTH_MANAGER_USERS environment variable in the format:To enforce authentication with explicit user passwords and roles, set:
In this mode, a password will be automatically generated for each user and printed in the webserver logs as soon as webserver starts.
Generated Docker Images
When you build the Docker images of a certain Airflow version, using either
build.shorrun.sh(which automatically also callsbuild.shfor you), multiple Docker images will actually be generated. For example, for Airflow 2.9, you will notice the following images:Each of the postfixes added to the image tag represents a certain build type, as explained below:
explorer: The ‘explorer’ build type is almost identical to the default build type except that it doesn’t include an entrypoint, meaning that if you run this image locally, it will not actually start Airflow. This is useful for debugging purposes to run the image and look around its content without starting airflow. For example, you might want to explore the file system and see what is available where.privileged: Privileged images are the same as their non-privileged counterpart except that they run as therootuser instead. This gives the user of this Docker image elevated permissions. This can be useful if the user wants to do some experiments as the root user, e.g. installing DNF packages, creating new folders outside the airflow user folder, among others.dev: These images have extra packages installed for debugging purposes. For example, typically you wouldn’t want to install a text editor in a Docker image that you use for production. However, during debugging, you might want to open some files and inspect their contents, make some changes, etc. Thus, we install an editor in the dev images to aid with such use cases. Similarly, we install tools likewgetto make it possible for the user to fetch web pages. For a complete listing of what is installed indevimages, see thebootstrap-devfolders.Extra commands
Requirements
For details on installing Python depedencies, and optionally bundling wheel files, see the Managing Python dependencies in requirements.txt in the Amazon MWAA user guide.
requirements/requirements.txtrequirements.txtwithout running Apache Airflow, run:Package requirements
requirements.txtas wheel (.whl) and source distribution (.tar.gz) files and bundle them into aplugins.zipfor offline installation on MWAA, run:requirements/directory:plugins.zip— all downloaded packages bundled into a single ZIP.packaged_requirements.txt— your original requirements prefixed with--no-indexand--find-linksflags for offline installation.plugins.zipto your MWAA S3 bucket and usepackaged_requirements.txtas your requirements file. For more details, see Installing Python dependencies using wheel files in the Amazon MWAA user guide.Startup script
startup_script. Add your script there asstartup.shstartup.shscript.startup.shwithout running Apache Airflow, run:Reset database
process fails with "dag_stats_table already exists", you’ll need to reset your database. You just need to restart your container by exiting and rerunning therun.shscriptSecurity
See CONTRIBUTING for more information.
License
This project is licensed under the Apache-2.0 License.