Using Apache Airflow configuration options on Amazon MWAA
Apache Airflow configuration options can be attached to your Amazon Managed Workflows for Apache Airflow environment as environment variables. You can choose from the suggested dropdown list, or specify custom configuration options for your Apache Airflow version on the Amazon MWAA console. This topic describes the Apache Airflow configuration options available, and how to use these options to override Apache Airflow configuration settings on your environment.
Contents
Prerequisites
You'll need the following before you can complete the steps on this page.
-
Permissions — Your Amazon account must have been granted access by your administrator to the AmazonMWAAFullConsoleAccess access control policy for your environment. In addition, your Amazon MWAA environment must be permitted by your execution role to access the Amazon resources used by your environment.
-
Access — If you require access to public repositories to install dependencies directly on the web server, your environment must be configured with public network web server access. For more information, see Apache Airflow access modes.
-
Amazon S3 configuration — The Amazon S3 bucket used to store your DAGs, custom plugins in
plugins.zip
, and Python dependencies inrequirements.txt
must be configured with Public Access Blocked and Versioning Enabled.
How it works
When you create an environment, Amazon MWAA attaches the configuration settings you specify on the Amazon MWAA console in Airflow configuration options as environment variables to the Amazon Fargate container for your environment. If you're using a setting of the same name in airflow.cfg
, the options you specify on the Amazon MWAA console override the values in airflow.cfg
.
While we don't expose the airflow.cfg
in the Apache Airflow UI of an Amazon MWAA
environment by default, you can change the Apache Airflow configuration options directly on
the Amazon MWAA console, including setting webserver.expose_config
to expose the
configurations.
Using configuration options to load plugins in Apache Airflow v2
By default in Apache Airflow v2, plugins are configured to be "lazily" loaded using the core.lazy_load_plugins : True
setting.
If you're using custom plugins in Apache Airflow v2, you must add core.lazy_load_plugins : False
as an Apache Airflow configuration option to load
plugins at the start of each Airflow process to override the default setting.
Configuration options overview
When you add a configuration on the Amazon MWAA console, Amazon MWAA writes the configuration as an environment variable.
-
Listed options. You can choose from one of the configuration settings available for your Apache Airflow version in the dropdown list. For example,
dag_concurrency
:16
. The configuration setting is translated to your environment's Fargate container asAIRFLOW__CORE__DAG_CONCURRENCY : 16
-
Custom options. You can also specify Airflow configuration options that are not listed for your Apache Airflow version in the dropdown list. For example,
foo.user
:YOUR_USER_NAME
. The configuration setting is translated to your environment's Fargate container asAIRFLOW__FOO__USER : YOUR_USER_NAME
Apache Airflow configuration options
The following image shows where you can customize the Apache Airflow configuration options on the Amazon MWAA console.
Apache Airflow reference
For a list of configuration options supported by Apache Airflow, see Configuration Reference
Using the Amazon MWAA console
The following procedure walks you through the steps of adding an Airflow configuration option to your environment.
-
Open the Environments page
on the Amazon MWAA console. -
Choose an environment.
-
Choose Edit.
-
Choose Next.
-
Choose Add custom configuration in the Airflow configuration options pane.
-
Choose a configuration from the dropdown list and enter a value, or type a custom configuration and enter a value.
-
Choose Add custom configuration for each configuration you want to add.
-
Choose Save.
Configuration reference
The following section contains the list of available Apache Airflow configurations in the dropdown list on the Amazon MWAA console.
Email configurations
The following list shows the Airflow email notification configuration options available on Amazon MWAA.
We recommend using port 587 for SMTP traffic. By default, Amazon blocks outbound SMTP traffic on port 25 of all Amazon EC2 instances. If you want to send outbound traffic on port 25, you can request for this restriction to be removed
Task configurations
The following list shows the configurations available in the dropdown list for Airflow tasks on Amazon MWAA.
Scheduler configurations
The following list shows the Apache Airflow scheduler configurations available in the dropdown list on Amazon MWAA.
Worker configurations
The following list shows the Airflow worker configurations available in the dropdown list on Amazon MWAA.
Web server configurations
The following list shows the Airflow web server configurations available in the dropdown list on Amazon MWAA.
Triggerer configurations
The following list shows the Apache Airflow triggerer
Examples and sample code
Example DAG
You can use the following DAG to print your email_backend
Apache Airflow configuration options. To run in response to Amazon MWAA events, copy the code to your environment's DAGs folder on your Amazon S3 storage bucket.
from airflow.decorators import dag from datetime import datetime def print_var(**kwargs): email_backend = kwargs['conf'].get(section='email', key='email_backend') print("email_backend") return email_backend @dag( dag_id="print_env_variable_example", schedule_interval=None, start_date=datetime(
yyyy
,m
,d
), catchup=False, ) def print_variable_dag(): email_backend_test = PythonOperator( task_id="email_backend_test", python_callable=print_var, provide_context=True ) print_variable_test = print_variable_dag()
Example email notification settings
The following Apache Airflow configuration options can be used for a Gmail.com email account using an app password. For more information, see Sign in using app passwords
What's next?
-
Learn how to upload your DAG folder to your Amazon S3 bucket in Adding or updating DAGs.