This topic provides setup steps for configuring AWS Secrets Manager as a secrets backend on Astro.
For more information about Airflow and AWS connections, see Amazon Web Services Connection.
If you use a different secrets backend tool or want to learn the general approach on how to integrate one, see Configure a Secrets Backend.
apache-airflow-providers-amazon version 5.1.0 or later. See Add Python and OS-level packages.SecretsManagerReadWrite policy that your Astro cluster can assume. See AWS IAM roles.values.yaml file from the Register Agents modal in your Deployments>Agents page.Create directories for Airflow variables and connections in AWS Secrets Manager that you want to store as secrets. You can use real or test values.
Other type of secret and select the Plaintext option.Next.Secret names must correspond with the connections_prefix and variables_prefix set below in step 2. Specifically:
If you use "variables_prefix": "airflow/variables", you must set Airflow variable names as:
The <variable-key> is how you will retrieve that variable’s value in a dag. For example:
If you use "connections_prefix": "airflow/connections", you must set Airflow connections as:
The <connection-id> is how you will retrieve that connection’s URI in a dag. For example:
Be sure to not include a leading / at the beginning of your variable or connection name
For more information on adding secrets to Secrets Manager, see AWS documentation.
Add the following environment variables to your Astro project’s .env file:
After you configure an Airflow connection to AWS, can run a dag locally to check that your variables are accessible using Variable.get("<your-variable-key>").
Run the following commands to export your secrets backend configurations as environment variables to Astro.
(Optional) Remove the environment variables from your .env file or store your .env file in a safe location to protect your credentials.
.env file, the Secrets Manager backend won’t work locally. To further customize the Airflow and AWS SSM Parameter Store integration, see the full list of available kwargs.