# Using the Airflow REST API with Astro
Source: https://astronomer.io/docs/astro/airflow-api
Use the Airflow REST API in Astro to trigger Dag runs, list Dags, manage task instances, and automate workflows programmatically. Includes authentication setup and code examples.
For Deployments on Astro, you can use the Airflow [REST API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html) to automate Airflow workflows. For example, you can externally trigger a dag run without accessing your Deployment directly by making an HTTP request in Python or cURL to the [dagRuns endpoint](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_dag_run) in the Airflow REST API.
To test Airflow API calls in a local Airflow environment running with the Astro CLI, see [Troubleshoot your local Airflow environment](/docs/cli/v1.43/run-airflow-locally).
Updates to the Airflow REST API are released in new Airflow versions and new releases don’t have a separate release cycle or versioning scheme. To take advantage of specific Airflow REST API functionality, you might need to upgrade Astro Runtime. See [Upgrade Runtime](/docs/runtime/upgrade-astro-runtime) and the [Airflow release notes](https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html).
**Airflow REST API v2 (Airflow 3.0+)**
The Airflow REST API is available at `/api/v2` for Airflow 3.0 and above. Some endpoints and parameters have changed. See the [Airflow API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html) documentation for more information.
## Prerequisites
* A Deployment on Astro.
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or an [Organization API token](/docs/astro/organization-api-tokens).
* [cURL](https://curl.se/) or, if using Python, the [Requests library](https://docs.python-requests.org/en/latest/index.html).
* The [Astro CLI](/docs/cli/v1.43/overview).
## Step 1: Retrieve your access token
Follow the steps in [Create a Workspace API token](/docs/astro/workspace-api-tokens#create-a-workspace-api-token) to create your token. Make sure to save the token on creation in order to use it later in this setup.
Follow the steps in [Create a Organization API token](/docs/astro/organization-api-tokens#create-an-organization-api-token) to create your token. Make sure to save the token on creation in order to use it later in this setup.
Follow the steps in [Create a Deployment API token](/docs/astro/deployment-api-tokens#create-a-deployment-api-token) to create your token. Make sure to save the token on creation in order to use it later in this setup.
## Step 2: Retrieve the Deployment URL
Your Deployment URL is the [host](https://swagger.io/docs/specification/2-0/api-host-and-base-path/) you use to call the Airflow API.
1. Run the following command to retrieve the URL for your Deployment Airflow UI:
```sh wrap theme={null}
astro deployment inspect -n --key metadata.airflow_api_url
```
Alternatively, you can retrieve your Deployment URL by opening the Airflow UI for your Deployment on Astro and copying the URL of the page up to `/home`. For example, if the home page of your Deployment Airflow UI is hosted at `clq52c95r000208i8c7wahwxt.astronomer.run/dz3uu847/home`, your Deployment URL is `clq52c95r000208i8c7wahwxt.astronomer.run/dz3uu847`.
## Step 3: Make an Airflow API request
You can execute requests against any endpoint that is listed in the [Airflow REST API reference](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html).
To make a request based on Airflow documentation, make sure to:
* Use the Astro access token from Step 1 for authentication.
* Replace `airflow.apache.org` with your Deployment URL from Step 1.
The Airflow REST API doesn't have rate-limiting.
## Example API Requests
The following are common examples of Airflow REST API requests that you can run against a Deployment on Astro.
### List Dags
To retrieve a list of all Dags in a Deployment, you can run a `GET` request to the [`dags` endpoint](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_dags)
#### cURL
```sh wrap theme={null}
curl -X GET https:///api/v2/dags \
-H 'Authorization: Bearer '
```
#### Python
```python wrap theme={null}
import requests
token = ""
deployment_url = ""
response = requests.get(
url=f"https://{deployment_url}/api/v2/dags",
headers={"Authorization": f"Bearer {token}"}
)
print(response.json())
# Prints data about all dags in your Deployment
```
### Trigger a Dag run
You can trigger a Dag run by executing a `POST` request to Airflow's [`dagRuns` endpoint](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_dag_run).
This will trigger a Dag run for the Dag you specify, which is equivalent to clicking the **Play** button in the main **Dags** view of the Airflow UI. The request body must include the `logical_date` key — it can be `null`, which runs the Dag immediately, but it can't be omitted. An empty body `{}` returns a `422 Unprocessable Entity` error.
#### cURL
```sh wrap theme={null}
curl -X POST https:///api/v2/dags//dagRuns \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ' \
-d '{"logical_date": null}'
```
#### Python
```python wrap theme={null}
import requests
token = ""
deployment_url = ""
dag_id = ""
response = requests.post(
url=f"https://{deployment_url}/api/v2/dags/{dag_id}/dagRuns",
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
},
data='{"logical_date": null}'
)
print(response.json())
# Prints metadata of the dag run that was just triggered
```
### Trigger a Dag run by date
You can also specify a `logical_date` at the time in which you wish to trigger the Dag run by passing the `logical_date` with the desired timestamp with the request's `data` field. The timestamp string is expressed in UTC and must be specified in the format `"YYYY-MM-DDTHH:MM:SSZ"`, where:
* `YYYY` represents the year.
* `MM` represents the month.
* `DD` represents the day.
* `HH` represents the hour.
* `MM` represents the minute.
* `SS` represents the second.
* `Z` stands for "Zulu" time, which represents UTC.
#### cURL
```sh wrap theme={null}
curl -v -X POST https:///api/v2/dags//dagRuns \
-H 'Authorization: Bearer ' \
-H 'content-type: application/json' \
-d '{"logical_date":"2022-11-16T11:34:00Z"}'
```
#### Python
Using Python:
```python wrap theme={null}
import requests
token = ""
deployment_url = ""
dag_id = ""
response = requests.post(
url=f"https://{deployment_url}/api/v2/dags/{dag_id}/dagRuns",
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
},
data='{"logical_date": "2021-11-16T11:34:01Z"}'
)
print(response.json())
# Prints metadata of the dag run that was just triggered
```
### Pause a Dag
You can pause a Dag by executing a `PATCH` command against the [`dag` endpoint](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/patch_dag).
Replace `` with your own value.
#### cURL
```sh wrap theme={null}
curl -X PATCH https:///api/v2/dags/ \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ' \
-d '{"is_paused": true}'
```
#### Python
```python wrap theme={null}
import requests
token = ""
deployment_url = ""
dag_id = ""
response = requests.patch(
url=f"https://{deployment_url}/api/v2/dags/{dag_id}",
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
},
data='{"is_paused": true}'
)
print(response.json())
# Prints data about the dag with id
```
### Trigger Dag runs across Deployments
You can use the Airflow REST API to make a request in one Deployment that triggers a Dag run in a different Deployment. This is sometimes necessary when you have interdependent workflows across multiple Deployments. On Astro, you can do this for any Deployment in any Workspace or cluster.
This topic has guidelines on how to trigger a Dag run, but you can modify the example Dag provided to trigger any request that's supported in the Airflow REST API.
1. Create a [Deployment API token](/docs/astro/deployment-api-tokens) for the Deployment that contains the Dag you want to trigger.
2. In the Deployment that contains the triggering Dag, create an [Airflow HTTP connection](https://airflow.apache.org/docs/apache-airflow-providers-http/stable/connections/http.html) with the following values:
* **Connection Id**: `http_conn`
* **Connection Type**: HTTP
* **Host**: ``
* **Schema**: `https`
* **Extra**:
```json wrap theme={null}
{
"Content-Type": "application/json",
"Authorization": "Bearer "
}
```
See [Manage connections in Apache Airflow](/docs/learn/connections).
If the `HTTP` connection type is not available, double check that the [HTTP provider](https://airflow.apache.org/registry/providers/http/) is installed in your Airflow environment. If it's not, add `apache-airflow-providers-http` to the `requirements.txt` file of our Astro project and redeploy it to Astro.
3. In your triggering Dag, add the following task. It uses the [`HttpOperator`](https://airflow.apache.org/registry/providers/http#http-http-HttpOperator) to make a request to the `dagRuns` endpoint of the Deployment that contains the Dag to trigger.
```python wrap theme={null}
from datetime import datetime
from airflow.models.dag import DAG
from airflow.providers.http.operators.http import HttpOperator
with DAG(
dag_id="triggering_dag",
start_date=datetime(2024, 1, 1),
schedule=None,
):
HttpOperator(
task_id="trigger_external_dag",
log_response=True,
method="POST",
endpoint="api/v2/dags//dagRuns",
http_conn_id="http_conn",
data={
"logical_date": "{{ logical_date }}",
# To pass parameters, add: "params": {"foo": "bar"}
},
)
```
# Configure API server autoscaling
Source: https://astronomer.io/docs/astro/api-server-autoscaling
Enable horizontal autoscaling for the Airflow API server to handle high task concurrency and bursty UI or REST API traffic.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
The Airflow API server serves the Airflow UI, the Airflow REST API, and the task execution API that Astro and Celery workers use to fetch and report on tasks. By default, every Airflow 3 Deployment runs with two API server replicas. For workloads with high task concurrency, large Dags, or spikes in UI and REST API traffic, you can enable horizontal autoscaling so that Astro adds API server replicas when load is high and removes them when load decreases.
Use API server autoscaling to:
* Sustain workloads with thousands of concurrent tasks without saturating a fixed pair of API server replicas.
* Support smooth Airflow 2 to Airflow 3 upgrades for environments that pushed the previous webserver to its limits.
* Cap your spend by setting an explicit maximum replica count.
## How autoscaling works
When you enable autoscaling, Astro provisions a [Kubernetes Horizontal Pod Autoscaler (HPA)](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) that tracks CPU utilization across the running API server replicas. The HPA adds or removes replicas to keep the average CPU utilization at 80 percent of the per-replica CPU request.
* When average CPU utilization is consistently above the 80 percent target, Astro adds replicas, up to your configured **API Server Max Replicas** value.
* When average CPU utilization is below the target, Astro removes replicas, down to the minimum of two.
* The minimum replica count is fixed at two. This preserves API availability during a Pod restart and is the same as the default replica count when autoscaling is disabled.
* The maximum replica count is configurable from `2` to `10` in the Astro UI. Setting **API Server Max Replicas** to `2` runs a fixed two-replica configuration and effectively prevents scaling.
The HPA evaluates utilization continuously, and replica changes typically take effect within one to two minutes. The same high-availability and anti-affinity rules that apply to other Deployment components apply to API server replicas. See [Enable high availability](/docs/astro/deployment-resources#enable-high-availability).
## Expected replica counts
The following table shows the approximate API server replica counts you can expect at different levels of task concurrency. Actual counts can vary based on Airflow UI and REST API traffic, Dag complexity, and other workload characteristics.
| Concurrent tasks | API server replicas |
| ---------------- | ------------------- |
| \~500 | 3 |
| \~1,000 | 4 |
| \~2,000 | 6 |
| \~3,000 | 7 |
## Prerequisites
API server autoscaling is supported on Airflow 3 Deployments running on Astro:
* Standard or dedicated clusters.
* Remote Execution Deployments.
API server autoscaling works with all executors: Astro, Celery, and Kubernetes.
API server autoscaling is not available for Airflow 2 Deployments. Airflow 2 uses the Airflow webserver, which doesn't support horizontal autoscaling on Astro.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Enable or disable API server autoscaling
In the Astro UI, click **Deployments**, then select a Deployment.
Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
In the **Advanced** section, set the **API Server Autoscaling** toggle to on or off.
When enabling autoscaling, the **API Server Max Replicas** list becomes editable. Select a value from `2` to `10`. The default is `10`, which gives Astro the largest possible scaling headroom. Choose a lower value to cap your replica count at a known maximum.
When disabling autoscaling, Astro preserves the previous **API Server Max Replicas** value, so you can re-enable autoscaling later with the same configuration.
Click **Update Deployment**. When you enable autoscaling, Astro applies the new HPA without restarting the running API server replicas. When you disable autoscaling, Astro removes the HPA and the Deployment runs with two API server replicas.
In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
Click the **Options** menu of the Deployment, and then select **Edit Deployment**.
In the **Advanced** section, set the **API Server Autoscaling** toggle to on or off.
When enabling autoscaling, the **API Server Max Replicas** list becomes editable. Select a value from `2` to `10`. The default is `10`, which gives Astro the largest possible scaling headroom. Choose a lower value to cap your replica count at a known maximum.
When disabling autoscaling, Astro preserves the previous **API Server Max Replicas** value, so you can re-enable autoscaling later with the same configuration.
Click **Update Deployment**. When you enable autoscaling, Astro applies the new HPA without restarting the running API server replicas. When you disable autoscaling, Astro removes the HPA and the Deployment runs with two API server replicas.
After you enable autoscaling, the Deployment **Details** page shows the configured range under **API Server Autoscaling**, for example `Enabled (2-10 replicas)`.
## Billing
API server replicas are sized the same as an A5 worker. Each Deployment includes two API server replicas at no additional cost. When autoscaling adds replicas above the included two, Astro charges for the additional replicas based on their uptime duration at the A5 unit rate, similar to [KE/KPO chargeback](https://www.astronomer.io/pricing/#:~:text=How%20will%20I%20be%20charged%20for%20the%20Kubernetes%20Executor%20and%20Kubernetes%20Pod%20Operator%3F). The charges appear on your invoice under **Runtime Compute** as **API Server**.
If autoscaling is enabled but the Deployment never exceeds two replicas, no additional API server charges apply.
## Limitations
* The minimum replica count is fixed at two. You can't scale the API server below two replicas.
* The maximum replica count is capped at ten in the Astro UI. If your workload requires more than ten replicas, Astronomer recommends moving some workloads to another Deployment.
# About Astro
Source: https://astronomer.io/docs/astro/astro-architecture
Learn about how Astro is structured to maximize the power of Apache Airflow.
Astro is a fully-managed SaaS application for data orchestration that helps teams write and run data pipelines with Apache Airflow at any level of scale. The infrastructure to run Airflow is managed entirely by Astronomer, enabling you to shift your focus from infrastructure to using data to grow your business.
This document provides an overview of the architecture and key concepts in Astro that enable your team to make the most of your data pipelines. See [Astro Features](/docs/astro/features) to learn more about Astro functionality. To get started with Astro, see [Start a trial](/docs/astro/trial).
## Architecture
Astro, also known as Astro Hosted, both simplifies and optimizes Airflow so you can customize the parts of your environment that matter most to you, with Astro taking care of the rest. Whether you use Astro to power internal analytics or to train machine learning models, learning how Astro works can help you decide which deployment and connectivity model works best for you and enables your team to start running Dags.
You can work with Astro using the [Astro UI](#astro-ui) in your web browser, the [Astro CLI](#astro-cli), or the Astro API. Astro makes it easy for Airflow environments, called [Deployments](#deployment), to securely connect to external data services.
The *Astro Hypervisor* is an Astronomer-managed component of the Astro platform that scales and optimizes your Deployments and the [clusters](#cluster) they're hosted on.
The following diagram shows how these components work together to help you manage Airflow on Astro.
## Key concepts
The following sections give a detailed explanation of key concepts that you need to understand in order to work with Astro. You can find definitions for additional Astro-specific terminology in the [Astro glossary](/docs/astro/astro-glossary).
### Astro CLI
The [Astro CLI](/docs/cli/v1.43/overview) is an open source interface you can use to test Airflow Dags locally, deploy code to Astro, and automate key Astro actions as part of a CI/CD process. Using the Astro CLI to run Airflow locally requires Docker or an alternative container management tool, like Podman.
An Airflow project created with the Astro CLI is also known as an *Astro project*. It contains the set of files necessary to run Airflow, including dedicated folders for your Dag files, Python packages, utility files, and more. Astronomer recommends that you create a dedicated Git repository for each Astro project. To run a Dag, you add the Dag to your Astro project and deploy your Astro project to Astro.
See [Run your first Dag with the Astro CLI](/docs/astro/first-dag-cli) to create your first Astro project.
### Astro UI
The Astro UI, hosted at `https://cloud.astronomer.io`, is the primary interface for accessing and managing Astro from your web browser. You can use the Astro UI to:
* Manage users, teams, and permissions.
* Create and configure Deployments, including infrastructure resources and compute.
* View all of your organization's Deployments, Dags, and tasks in a single place.
* Monitor the health of your Airflow environments with a variety of alerts, logs, and analytics interfaces.
* Stay up to date with the latest Astro features.
When you open the Astro UI, you land on the **Recently Failed Dags** homepage, which lists Dags with failed runs in the selected time window. Use the **1D**, **1W**, and **1M** filters to set the time window, and the Workspace filter to scope the list to a specific Workspace. The list includes any Dag that started up to seven days before the start of the selected time window, not only Dags that started within the window. For example, with the **1M** filter, the list includes Dags that started as early as one month and seven days ago.
For each Dag, the table shows its run history, failure rate, and last run time. Click **Investigate** to start an [Otto investigation](/docs/astro/otto-investigate) of the most recent failed run, or click a Dag row to open its [Asset Catalog](/docs/astro/assets-overview) details page.
### Deployment
An Astro *Deployment* is an Airflow environment hosted on Astro. It encompasses all core Airflow components, including the Airflow webserver, scheduler, and workers, along with additional tools for reliability and observability. It runs in an isolated Kubernetes namespace in an [Astro cluster](#cluster) and has a set of attached resources to run your Airflow tasks.
Compared to an open source Airflow environment, an Astro Deployment is easy to create, delete, and modify through either the Astro UI or with the Astro CLI. You can [fine-tune resources and settings](/docs/astro/deployment-settings) directly from the Astro UI, see metrics and analytics for your Dags, review your deploy history, and more. The infrastructure required to run a Deployment is managed by Astronomer.
To run Dags in a Deployment, you must either deploy an Astro project manually from your local machine or configure an automated deploy process using a third-party CI/CD tool with the Astro CLI. Then, you can open the Airflow UI from the Astro UI and view your Dags. See [Run your first Dag](/docs/astro/run-first-dag) to get started with examples of either workflow.
### Astro Runtime
*Astro Runtime* is a [debian-based Docker image](https://quay.io/repository/astronomer/astro-runtime) that bundles Apache Airflow with optimized configurations and add-ons that make your Airflow experience reliable, fast, and scalable. Astronomer releases an Astro Runtime distribution for each version of Apache airflow.
Every Deployment and Astro project uses Astro Runtime at its core. Astronomer provides [extended support and bug fixes](/docs/runtime/runtime-version-lifecycle-policy) to Astro Runtime versions, so that you can keep your Dags running for longer without disruption.
See [Astro Runtime Architecture and features](/docs/runtime/runtime-image-architecture) for a complete feature list.
### Workspace
A *Workspace* is a collection of Deployments that can be accessed by a specific group of users. You can use a Workspace to group Deployments that share a business use case or environment trait. For example, your data science team might have a dedicated Workspace with two Deployments within it. Workspaces don't require any resources to run and are only an abstraction for grouping Deployments and configuring user access to them. All Deployments must belong to a Workspace.
You can assign new users [Workspace roles](/docs/astro/user-permissions#workspace-roles) that include varying levels of access to your Deployments.
### Cluster
A *cluster* in Astro is a Kubernetes cluster that hosts the infrastructure required to run your Airflow environments, also known as [Deployments](#deployment) in Astro. There are two types of clusters in Astro:
* A *standard cluster* is a multi-tenant cluster that's pre-configured by Astronomer. It's the default cluster type and the quickest way to get an Airflow environment up and running on Astro. Each Deployment in a standard cluster exists in its own isolated Kubernetes namespace. To run a Deployment in a standard cluster, you select a cloud provider and region when you create the Deployment. Then, Astro automatically creates your Deployment in an existing standard cluster based on your configuration. See [Standard cluster configurations](/docs/astro/resource-reference-hosted#standard-cluster-regions) for a list of all cloud providers and regions where you can use standard clusters.
* A *dedicated cluster* is a single-tenant cluster that's used exclusively by Organizations with additional security and networking requirements. Compared to standard clusters, dedicated clusters provide more configuration options for [cloud providers and regions](/docs/astro/resource-reference-hosted#dedicated-cluster-regions), as well as private network connectivity and [security](/docs/astro/authorize-workspaces-to-a-cluster). Note that due to expanded resource usage, dedicated clusters cost more than standard clusters. See [Create a Dedicated cluster](/docs/astro/create-dedicated-cluster) to get started with dedicated clusters.
For both cluster types, Astro manages all underlying infrastructure and provides secure connectivity options to all data services in your ecosystem.
### Organization
An Astro *Organization* is the highest level entity in Astro and represents a shared space for your company on Astro. An Organization is automatically created when you first sign up for Astronomer. At the Organization level, you can manage all of your users, Deployments, Workspaces, and clusters from a single place in the Astro UI.
To securely manage user access, you can [integrate your Organization with an identity provider (IdP)](/docs/astro/configure-idp) and [set up SCIM provisioning](/docs/astro/set-up-scim-provisioning) to have new users automatically join Astro with the correct permissions.
### Execution mode
Astro supports two [execution modes](/docs/astro/execution-mode) that give you flexibility in how and where your Airflow tasks run: **Hosted** and **Remote** execution. Both modes use the same orchestration layer, so you can choose the right execution model based on your infrastructure, security requirements, and performance needs.
* *Hosted execution* is the default mode for Deployments on Astro. In this mode, Astronomer manages all infrastructure for task execution, including worker autoscaling, Dag versioning, and compute provisioning. Hosted execution is well suited for getting started quickly without managing your own execution environment.
* *Remote execution* mode separates orchestration from execution, allowing Airflow tasks to run entirely in your own infrastructure whether it's on-premises or in the cloud, while keeping data, code, and secrets local. The Astro Orchestration Plane handles scheduling, coordination, and observability, while Remote Execution Agents in your environment poll for tasks through a secure Remote Execution API and run them locally.
Each Remote Execution Agent includes a Dag processor, Triggerer, and Worker, which enables Dag parsing, task execution, secret management, and logging within your environment. This model supports custom infrastructure and security requirements while maintaining centralized control and visibility through Astro.
### Astro Observe
Astro Observe provides a fully integrated observability layer in Astro that gives you complete visibility into the health, performance, and reliability of your data pipelines and the data products they power. Unlike standalone tools, Astro Observe is purpose-built for Apache Airflow and deeply connected to the orchestration layer, making it easy to monitor your pipelines with full execution context and minimal setup.
With Astro Observe, you can:
* Monitor Dag execution with real-time task-level insights and pipeline metadata.
* Visualize upstream and downstream dependencies using automatic lineage powered by OpenLineage.
* Set SLAs and alerts on key data products to catch issues before they cause downstream failures.
* Investigate and debug problems quickly with AI-generated log summaries and consolidated pipeline views.
* Track pipeline and asset-level cost metrics (coming soon) to optimize your data operations.
Astro Observe is natively integrated into the Astro platform and can be enabled to provide immediate visibility. As soon as your Dags run, you get access to task logs, lineage graphs, and pipeline health insights with no extra configuration or infrastructure required. This helps your team move quickly, resolve issues efficiently, and deliver trusted data products with confidence.
## Access control architecture
Astro uses role-based access control (RBAC) to define which users are permitted to take certain actions or access certain resources. For example, you can assign a user or automation tool permission to deploy Dags, but not to delete a Deployment. Roles in Astro are defined at the Workspace and Organization levels.
Each Astro user has a Workspace role in every Workspace they belong to, plus a single Organization role. Users can also belong to [Teams](/docs/astro/manage-teams), which apply the same role across a group of users. To automate managing user roles or deploying code, you can create API tokens with specific roles to automate most actions on Astro.
Use the following diagram as a reference for how these components interact with each other in Astro.
# MCP servers
Source: https://astronomer.io/docs/astro/astro-mcp-server
Connect AI tools to Astro and Airflow using Model Context Protocol (MCP) servers
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Astro provides experimental Model Context Protocol (MCP) servers that allow AI models and agents to securely access your Astro and Airflow resources. Connect to MCP servers natively or by using the `mcp-remote` module in compatible AI clients.
For enhanced agent capabilities such as Dag authoring, testing, and debugging, see the [Astronomer AI Agent tooling repository](https://github.com/astronomer/agents).
## MCP servers
Astro provides the following experimental MCP servers:
* **Astro Registry MCP server** (`astro-registry`) is a remote MCP server for accessing the Astro Registry.
* **Astro Cloud MCP server** (`astro-cloud`) is an authenticated remote MCP server for discovering and managing your Astro resources, including Deployments, Workspaces, and environment variables.
**Astro Cloud MCP server deprecation**
The current Astro Cloud MCP server (`astro-cloud`) is deprecated and shouldn't be used. An updated Astro MCP server is in progress and is slated for early access in July 2026. For more information, contact your Astronomer account executive.
## Set up the Astro Registry MCP server
If you experience any issues, try restarting your client or disabling and re-enabling the Astro MCP server connection.
1. Open Windsurf settings with `CTRL/CMD + ,`.
2. Navigate to `Cascade` > `Manage plugins`.
3. Select `View raw config`.
4. Add the following configuration. Only include the `astro-cloud` section if you're using the authenticated Astro Cloud MCP server.
```json wrap theme={null}
{
"mcpServers": {
"astro-registry": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://api.astronomer.io/registryV2/v1alpha1/mcp"
]
},
"astro-cloud": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://api.astronomer.io/v1alpha1/mcp?organizationId=",
"--header",
"Authorization: Bearer ${AUTH_TOKEN}"
],
"env": {
"AUTH_TOKEN": ""
}
}
}
}
```
5. Click `Save` to save your configuration and check the `Plugins` section to verify that your server is connected.
1. Open Cursor.
2. Navigate to `Tools & Integrations` > `Add Custom MCP`.
3. Add the following configuration. Only include the `astro-cloud` section if you're using the authenticated Astro Cloud MCP server.
```json wrap theme={null}
{
"mcpServers": {
"astro-registry": {
"url": "https://api.astronomer.io/registryV2/v1alpha1/mcp"
},
"astro-cloud": {
"url": "https://api.astronomer.io/v1alpha1/mcp?organizationId=",
"headers": {
"Authorization":"Bearer "
}
}
}
}
```
4. Save the configuration and check the `Tools & Integrations` > `MCP Servers` section to verify that your server is connected.
Claude Code connects to remote MCP servers natively without the `mcp-remote` module. You can configure the server at the project level (`.mcp.json`) or at the user level (`~/.claude.json`).
The Astro Registry MCP server is public and requires no authentication. Run the following command to add it to your project:
```sh wrap theme={null}
claude mcp add --transport http --scope project astro-registry \
https://api.astronomer.io/registryV2/v1alpha1/mcp
```
#### Add the Astro Cloud MCP server
The Astro Cloud MCP server requires your Organization ID and an API token.
If you have the Astro CLI installed and authenticated, run `astro organization list` to find your Organization ID. Otherwise, open the [Astro UI](https://cloud.astronomer.io/settings/general) and copy your Organization ID from **Settings** > **General**.
Create a [Workspace or Organization API token](/docs/astro/workspace-api-tokens) in the Astro UI.
Add the following to your shell profile (`.zshrc`, `.bashrc`, or equivalent) so it persists across sessions:
```bash wrap theme={null}
export ASTRO_AUTH_TOKEN=
```
Run the following command, replacing `` with the Organization ID you retrieved earlier:
```bash wrap theme={null}
claude mcp add --transport http --scope project astro-cloud \
"https://api.astronomer.io/v1alpha1/mcp?organizationId=" \
--header "Authorization: Bearer ${ASTRO_AUTH_TOKEN}"
```
Run `claude mcp list` and confirm both `astro-registry` and `astro-cloud` appear.
The resulting `.mcp.json` file should look similar to the following:
```json wrap theme={null}
{
"mcpServers": {
"astro-registry": {
"type": "http",
"url": "https://api.astronomer.io/registryV2/v1alpha1/mcp"
}
}
}
```
## Airflow MCP Plugin
The **Airflow MCP Plugin** ([`astro-airflow-mcp`](https://github.com/astronomer/agents/tree/main/astro-airflow-mcp)) is an open-source package that installs directly into an Airflow Deployment and exposes an MCP endpoint on the webserver. This gives AI tools direct access to Airflow's REST API — Dags, task logs, connections, variables, and more — without running a separate server.
Unlike the Astro Cloud MCP server (which manages Astro-level resources like Deployments and Workspaces), the Airflow MCP Plugin provides Airflow-level access for a single Deployment: listing Dags, viewing task logs, inspecting connections, diagnosing failures, and more.
The plugin auto-detects the installed Airflow version and registers the appropriate integration:
* **Airflow 3.x**: Mounts as a FastAPI app on the API server.
* **Airflow 2.x** (2.4 or later): Registers as a Flask blueprint on the webserver.
### Prerequisites
* An Airflow Deployment on Astro. The plugin supports Airflow 3.x (Runtime 3.1 or later) and Airflow 2.x (2.4 or later).
* A [Deployment API token](/docs/astro/deployment-api-tokens) with a role that allows POST requests (required by the MCP protocol). See [Configure authentication](#configure-authentication) for role options.
### Install the plugin
Add `astro-airflow-mcp` to your Astro project's `requirements.txt`:
```text wrap theme={null}
astro-airflow-mcp
```
Deploy the change. The package auto-registers as an Airflow plugin — no Dockerfile changes or additional configuration needed.
### Set environment variables
After deploying, set the following environment variable on your Deployment to block write operations:
```sh wrap theme={null}
astro deployment variable create \
--deployment-id \
AF_READ_ONLY=true
```
| Variable | Required | Description |
| -------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AF_READ_ONLY` | Recommended | Blocks all write operations (trigger, pause, clear, delete) at the MCP server level, regardless of the token's permissions. Set to `true` for safe read-only access. |
In plugin mode, the MCP server always runs in stateless HTTP mode, so Claude Code and other MCP clients work without additional configuration. The `FASTMCP_STATELESS_HTTP` environment variable applies only when running the MCP server as a standalone process.
### Configure authentication
The MCP protocol uses POST requests for all operations, including read-only ones. Your Deployment API token does **not** need write permissions for read-only MCP access: authorization is still based on the underlying Airflow permissions, so a custom role with read permissions such as `*.get` is sufficient. The important exception is `WORKSPACE_MEMBER`, which Astro's auth proxy blocks from making the POST requests the MCP protocol requires.
#### Option A: Use a built-in role
Create a [Deployment API token](/docs/astro/deployment-api-tokens) with one of the following roles:
* **DEPLOYMENT\_ADMIN** — Full access (works but overprivileged)
* **WORKSPACE\_OPERATOR** or **WORKSPACE\_AUTHOR** — Moderate privilege
**WORKSPACE\_MEMBER** does not work with the MCP plugin. Astro's auth proxy blocks POST requests for this role, which prevents the MCP protocol handshake from completing.
#### Option B: Create a custom `MCP_VIEWER` role (recommended)
For least-privilege access, create a [custom Deployment role](/docs/astro/customize-deployment-roles) that includes only read permissions. This ensures the token can use all MCP read tools but cannot modify any Airflow resources.
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Roles & Permissions**, click **Custom**, then click **+ New Custom Role** (in the legacy UI, go to **Organization Settings** > **Access Management** > **Roles**, then click **+ Add Role**).
2. Set the **Scope** to **Deployment**.
3. Name the role `MCP_VIEWER` with a description like "Read-only access for Airflow MCP plugin."
4. Select all `deployment.airflow.*.get` permissions. See [Custom role permissions reference](/docs/astro/deployment-role-reference) for the full list. The role should include these 28 permissions:
| Permission | Purpose |
| ---------------------------------------- | ------------------------------------------ |
| `deployment.get` | Get Deployment information |
| `deployment.airflow.adminMenu.get` | View Admin menu (gates Airflow config API) |
| `deployment.airflow.astronomer.get` | View Astronomer menu |
| `deployment.airflow.auditLog.get` | View audit logs |
| `deployment.airflow.browseMenu.get` | View Browse menu |
| `deployment.airflow.clusterActivity.get` | View cluster activity and DAG stats |
| `deployment.airflow.config.get` | View Config menu |
| `deployment.airflow.connection.get` | View connections |
| `deployment.airflow.customMenu.get` | View custom plugin menus |
| `deployment.airflow.dag.get` | View Dags |
| `deployment.airflow.dagCode.get` | View DAG source code |
| `deployment.airflow.dagDependencies.get` | View DAG dependencies |
| `deployment.airflow.dagRun.get` | View DAG runs |
| `deployment.airflow.datasets.get` | View assets and datasets |
| `deployment.airflow.docs.get` | View documentation links |
| `deployment.airflow.importError.get` | View import errors |
| `deployment.airflow.job.get` | View scheduler jobs |
| `deployment.airflow.plugin.get` | View plugins |
| `deployment.airflow.pool.get` | View pools |
| `deployment.airflow.provider.get` | View providers |
| `deployment.airflow.slaMiss.get` | View SLA misses |
| `deployment.airflow.taskInstance.get` | View task instances |
| `deployment.airflow.taskLog.get` | View task logs |
| `deployment.airflow.taskReschedule.get` | View task reschedules |
| `deployment.airflow.trigger.get` | View triggers |
| `deployment.airflow.variable.get` | View variables |
| `deployment.airflow.website.get` | Access the Airflow UI |
| `deployment.airflow.xcom.get` | View XCom data |
5. Click **Create role**.
Then create a Deployment API token with the new role:
```sh wrap theme={null}
astro deployment token create \
--deployment-id \
--name "mcp-viewer" \
--role MCP_VIEWER
```
### Connect your MCP client
After the plugin is deployed and a token is created, the MCP endpoint is available at:
```text wrap theme={null}
https:///mcp/v1/
```
You can find your Deployment's webserver URL in the Astro UI on the Deployment's overview page.
```sh wrap theme={null}
claude mcp add -t http -s user \
-H "Authorization: Bearer " \
-- airflow \
"https:///mcp/v1/"
```
Use `-t http`, not `-t sse`. The MCP endpoint returns SSE-formatted responses, but the correct Claude Code transport type is `http`. Using `-t sse` causes the connection to fail.
Add the following to your MCP configuration in Cursor (**Tools & Integrations** > **Add Custom MCP**):
```json wrap theme={null}
{
"mcpServers": {
"airflow": {
"url": "https:///mcp/v1/",
"headers": {
"Authorization": "Bearer "
}
}
}
}
```
Add the following to your MCP client configuration file:
```json wrap theme={null}
{
"mcpServers": {
"airflow": {
"url": "https:///mcp/v1/",
"headers": {
"Authorization": "Bearer "
}
}
}
}
```
### Troubleshooting
| Symptom | Cause | Fix |
| -------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Failed to connect` with `-t sse` | Wrong transport type | Use `-t http` instead of `-t sse` in Claude Code |
| 401 Unauthorized on MCP endpoint | Missing or expired token | Regenerate the Deployment API token |
| 403 Forbidden on some read tools | Incomplete role permissions | Ensure the role includes all `deployment.airflow.*.get` permissions listed above |
| 403 on `get_airflow_config` or `list_dag_warnings` | Airflow Admin RBAC required | A small number of Airflow API endpoints require the Admin role regardless of Astro permissions. Most MCP tools work without Admin access. |
| `WORKSPACE_MEMBER` token fails | POST blocked by Astro auth proxy | Use a higher-privilege role or create a custom `MCP_VIEWER` role |
| 404 on MCP endpoint right after a deploy | Plugin loads per-worker, rolling restart in progress | Wait for the rollout to settle, then retry. The first MCP call per worker also adds a small one-time latency while the FastMCP lifespan warms up. |
# Create Airflow connections in the Astro UI
Source: https://astronomer.io/docs/astro/create-and-link-connections
Create Airflow connections and link them to multiple Deployments in the Astro Environment Manager.
You can create and manage Airflow connections for Deployments with the Astro Environment Manager in the Astro UI. The Environment Manager uses an Astro-managed secrets backend to store connection configurations as Kubernetes Secrets.
Using the Environment Manager, you can quickly and securely create connections once and share them to multiple Deployments without having to set up your own secrets backend. For example, you can configure a connection with the credentials for a sandbox or development environment. Then, you can later configure your connection to be applied to all Deployments in the workspace by default. This means that when you create new Deployments, they automatically have access to your development environment. Later, you can edit the connection to point to your production resources by using [field overrides](#override-connection-fields).
Compared to creating a connection in the Airflow UI, when you create a connection in the Astro UI, you can:
* Share the connection with multiple Deployments within the Workspace.
* Share the connection with [Astro IDE](/docs/astro/ide-overview) projects so that their ephemeral test Deployments can use it.
* Override fields in the connection for individual Deployments or Astro IDE projects.
* Use configured connections in local Airflow environments. See [Import and export connections and variables](/docs/cli/v1.43/local-connections).
* Use connections in branch-based deploys and PR previews.
Workspace Owners and Operators can create and assign connections, while Workspace Authors can view configured connections and use them in Deployments. If your Organization has [**Environment Secrets Fetching**](/docs/astro/organization-settings#configure-environment-secrets-fetching-for-the-astro-environment-manager) enabled, you can additionally use configured connections, including ones that contain secrets, in local development environments. See [Import and export connections and variables](/docs/cli/v1.43/local-connections).
## How connections are stored
When you create an Airflow connection in the Environment Manager, Astro stores Airflow connection details in an Astronomer-hosted secrets manager, and then applies connections to Deployments as Kubernetes Secrets. Specifically the following steps occur:
* Astro stores the connection details in a secure secrets manager hosted by Astronomer.
* When a connection is assigned to a Deployment, Astro uses Airflow's provided [local filesystem secrets backend](https://airflow.apache.org/docs/apache-airflow/stable/security/secrets/secrets-backend/local-filesystem-secrets-backend.html) to mount your connections as Kubernetes Secrets.
* When your Dags use your connections, Airflow reads the connection details from the filesystem using the Airflow local filesystem secrets backend.
This process occurs every time you create or update a connection.
When you use connections for local development, the Astro CLI reads the connections from the Astro API and injects them into the local Airflow instance's metadata database.
### Fetch environment secrets
The Astro CLI can automatically retrieve connections from the Astro UI when you start your local airflow instance with `astro dev start --deployment-id=`, which means you can use your connection details without needing to manage credentials between local and deployed environments. Local environments fetch connection information the same way as for Deployments, so they require an active internet connection and for you to be logged in with the Astro CLI. You can only fetch environment secrets from Deployments that belong to Workspaces where you are at least a Workspace Member.
By default, connections can't be exported locally. However, if you want to work with connections locally, the Organization Owner can enable [**Environment Secrets Fetching**](/docs/astro/organization-settings#configure-environment-secrets-fetching-for-the-astro-environment-manager) in the Astro UI.
## Prerequisites
* Workspace Operator or Workspace Owner [user permissions](/docs/astro/user-permissions)
* A Deployment on Astro. See [Create a Deployment](/docs/astro/create-deployment)
* Astro Runtime 9.3.0 or greater
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a connection
You can create connections both at the Deployment and Workspace level. When you create a connection at the Deployment level, the connection details are available only to that specific Deployment. When you create a connection at the Workspace level, you can apply the connection to several Deployments and override specific fields as needed for each Deployment.
To create a connection at the Workspace level:
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click **+ New Connection** to add a new connection.
3. Find the service you want to connect from the list of available options.
If you don't see your service in the list, or you don't see fields that you need in a service that is in the list, you can select the **Generic** option to specify a connection using [Airflow's standard connection fields](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html).
4. Enter the information for your connection in the listed fields.
5. Click **Create Connection**.
6. Make your connection accessible to Deployments. See [Link connections to Deployments](#link-connections-to-deployments).
1. In the Astro UI, click **Environment** in the left menu to open the **Connections** page.
2. Click **+ Connection** to add a new connection.
3. Find the service you want to connect from the list of available options.
If you don't see your service in the list, or you don't see fields that you need in a service that is in the list, you can select the **Generic** option to specify a connection using [Airflow's standard connection fields](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html).
4. Enter the information for your connection in the listed fields.
5. Click **Create Connection**.
6. Make your connection accessible to Deployments. See [Link connections to Deployments](#link-connections-to-deployments).
To create a connection at the Deployment level:
1. In the Astro UI, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **Connections**, then click **+ New Connection**.
3. Find the service you want to connect from the list of available options.
If you don't see your service in the list, or you don't see fields that you need in a service that is in the list, you can select the **Generic** option to specify a connection using [Airflow's standard connection fields](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html).
4. Enter your information in the required fields.
5. Click **Create Connection** to make your new connection.
1. In the Astro UI, select a Workspace, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **+ Connection** to add a new connection.
3. Find the service you want to connect from the list of available options.
If you don't see your service in the list, or you don't see fields that you need in a service that is in the list, you can select the **Generic** option to specify a connection using [Airflow's standard connection fields](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html).
4. Enter your information in the required fields.
5. Click **Create Connection** to make your new connection.
After you create a connection, you can reference its **Connection ID** from Dag code like you would with any Airflow connection created through the Airflow UI.
## Link connections to Deployments
After you create a connection at the Workspace level, you can link it to multiple Deployments. Linking connections is useful for standardizing external resource usage across your entire team.
For the most flexibility, you can set default connections and override the connection details per-Deployment based on details like the Deployment's usage and environment type (production or development).
### Step 1: Link the connection
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click the connection you want to link to a Deployment.
3. Click **+ Link Deployment**.
4. Choose a Deployment from the list that appears.
5. (Optional) Click **More options** and then add any field overrides for this Deployment. For example, if your connection requests access to a development database by default, you can override its details to instead request access to a production database.
6. Click **Link connection**.
### Step 2: (Optional) Add provider packages to your Deployment
Some connection types require installing dependencies on your Deployment through provider packages. If your connection type requires a provider package and the provider package is neither [included in Astro Runtime](/docs/runtime/runtime-image-architecture#provider-packages) nor included in the `requirements.txt` file of your Astro project, Airflow won't be able to use your connection.
If you are uncertain what provider package the connection needs, you can check in the [Airflow Registry](https://airflow.apache.org/registry/).
1. Open the local Astro project for your Deployment.
2. Add the required provider package name to your project's `requirements.txt` and save your changes.
3. Deploy your project with the new provider to your Deployment.
## Configure connection sharing for a Workspace
You can configure Astro to link Workspace-level connections to all Deployments in the Workspace by default.
This is useful, for example, when you need to configure a connection for development environments that all Deployments in a Workspace should start with. Then, when you create new Deployments, they automatically have a default connection to your development resources.
When you're ready to connect your Deployments to production resources, you can either replace the connection or [override the connection field](#override-connection-fields) values with your production resource information.
If you change the setting from **Restricted** to **Linked to all Deployments**, Astro respects any connection field overrides that you might have configured for existing linked Deployments.
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click the connection that you want to add per-Deployment field overrides to.
3. Click **Deployment Sharing** and toggle the setting to choose either:
* **Restricted**: Only share the connection individually to Deployments.
* **Linked to all Deployments**: Link to all current and future Deployments in this Workspace.
4. (Optional) Change the default connection field values.
5. Click **Update connection** to save.
## Override connection fields
If you create a connection at the Workspace level and link it to a Deployment, you can later edit the connection within the Deployment to specify field overrides. When you override a field, you specify values that you want to use for a one Deployment, but not for others. This way, you can configure the connection and authentication a single time, but still have the flexibility to customize connection at the Deployment level.
For example, you might have created a connection to a Snowflake account, and then add field overrides to specify the default schemas or databases you want each Deployment to use.
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click the connection that you want to add per-Deployment field overrides to.
3. (Optional) Click **Deployment Sharing** and choose if you want to **Restrict** or **Link to all Deployments**. You can also change the default connection field values. Click **Update connection** to save.
4. Click **Edit** to open the connection configurations for a specific linked Deployment.
5. Add the override values to the fields you want to edit. You might need to open **More options** to find the full list of available fields.
6. Click **Update connection link**.
## Link connections to Astro IDE projects
In addition to Deployments, you can link Workspace-level connections to [Astro IDE](/docs/astro/ide-overview) projects. When you link a connection to an Astro IDE project, the project's ephemeral test Deployments start with that connection available, without affecting Deployments that aren't started from the IDE.
For the most flexibility, you can set a default connection at the Workspace level and override its fields per project, similar to how you override fields per Deployment.
### Link a connection to an Astro IDE project
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click the connection you want to link to an Astro IDE project.
3. Click the **Linked Projects** tab.
4. Click **Link Project**.
5. Choose an Astro IDE project from the list. Optionally, add field overrides for this project. For example, point the connection to a dedicated test database for the project.
6. Confirm the link.
### Configure project sharing for a Workspace
You can configure Astro to link a Workspace-level connection to all Astro IDE projects in the Workspace by default. This is useful when you want every project's test Deployments to start with the same set of development credentials.
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click the connection that you want to share with all Astro IDE projects.
3. Click the **Edit** icon next to **Auto-linking** in the connection details.
4. In the **Edit Connection** dialog, under **Auto-linking**, toggle **ALL ASTRO IDE PROJECTS** to **On**.
5. Click **Update Connection**.
### Connection precedence in Astro IDE test Deployments
When an Astro IDE project starts a test Deployment, the Deployment receives the union of:
* Connections linked to the project, including Workspace-level connections linked to the project and connections scoped directly to the project.
* Workspace-level connections linked to that Deployment.
If both the project and a linked Deployment define a connection with the same connection ID, the project-level value takes precedence in the test Deployment.
## Migrate existing connections to the Environment Manager
If you have connections defined in a Deployment's Airflow metadata database, you can move them into the Environment Manager so that they can be reused across Deployments and Astro IDE projects. See [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager).
## Promote a Deployment-scoped connection to the Workspace
If you created a connection on a single Deployment and later want to reuse it across other Deployments or Astro IDE projects, you can promote it to the Workspace level from the Deployment's Environment tab. See [Promote a Deployment environment object to the Workspace](/docs/astro/migrate-metadata-db-to-environment-manager#promote-a-deployment-environment-object-to-the-workspace).
# Create environment variables in the Astro UI
Source: https://astronomer.io/docs/astro/create-and-link-environment-variables
Create environment variables and link them to multiple Deployments in the Astro Environment Manager.
You can create and manage environment variables for Deployments with the Astro Environment Manager in the Astro UI. The Environment Manager uses an Astro-managed secrets backend to store environment variable key-value pairs as Kubernetes Secrets.
Using the Environment Manager, you can quickly and securely create environment variables once and share them to multiple Deployments without having to set up your own secrets backend.
For example, you can configure an environment variable with credentials for a sandbox or development environment. Then, you can later configure your environment variable to be applied to all Deployments in the workspace by default. This means that when you create new Deployments, they automatically have access to your development environment. Later, you can edit the environment variable to point to your production resources by using [value overrides](#override-environment-variable-values).
When you create an environment variable in the Environment Manager instead of the Deployment UI, you can:
* Share the environment variable with multiple Deployments within the Workspace.
* Share the environment variable with [Astro IDE](/docs/astro/ide-overview) projects so that their ephemeral test Deployments can use it.
* Override the environment variable value for individual Deployments or Astro IDE projects.
* Use environment variables in branch-based deploys and PR previews.
Workspace Owners and Operators can create and assign environment variables, while Workspace Authors can view configured environment variables and use them in Deployments. Learn more about [user permissions](/docs/astro/user-permissions).
## How environment variables are stored
When you create an environment variable in the Environment Manager, Astro stores environment variable details in an Astronomer-hosted secrets manager, and then applies environment variables to Deployments as Kubernetes Secrets. Specifically the following steps occur:
* Astro stores the environment variable value in a secure secrets manager hosted by Astronomer.
* When an environment variable is assigned to a Deployment, Astro applies your environment variable as a Kubernetes Secret to your Deployment's namespace.
* When your Deployment starts, the environment variable is loaded into the Airflow environment.
This process occurs every time you create or update an environment variable.
Environment variables marked as secret are stored securely by Astronomer and are not shown in the Astro UI. However, it's possible for a user in your organization to create or configure a dag that exposes secret values in Airflow task logs. Airflow task logs are visible to all Workspace members in the Airflow UI and accessible in your Astro cluster's storage.
To avoid exposing secret values in task logs, instruct users to not log environment variables in Dag code.
## Prerequisites
* Workspace Operator or Workspace Owner [user permissions](/docs/astro/user-permissions)
* An [Astro Deployment](/docs/astro/create-deployment)
* Astro Runtime 9.3.0 or greater
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create an environment variable
You can create environment variables both at the Deployment and Workspace level. When you create an environment variable at the Deployment level, the environment variable is available only to that specific Deployment. When you create an environment variable at the Workspace level, you can apply the environment variable to several Deployments and override its value as needed for each Deployment.
### Create an environment variable at the Workspace level:
1. In the Astro UI, go to **Environment** > **Environment Variables**.
2. Click **+ New Environment Variable** to add a new environment variable.
3. Choose whether you want your environment variable to be **Automatically link to all deployments** by setting the toggle to **On**. See [Link environment variables to Deployments](#link-environment-variables-to-deployments) for more information.
4. Enter your information in the required fields.
5. Choose whether you want your environment variable to be **Not Secret** or **Secret**. This allows you to store API keys, tokens, or other secrets in an environment variable without those credentials being available to future editors.
6. Click **Create environment variable**.
7. If you haven't linked your environment variable to all deployments, make it accessible to individual Deployments. See [Link environment variables to Deployments](#link-environment-variables-to-deployments).
1. In the Astro UI, click **Environment** in the left menu to open the **Environment Variables** page.
2. Click **+ Environment Variable** to add a new environment variable.
3. Choose whether you want your environment variable to be **Automatically link to all deployments** by setting the toggle to **On**. See [Link environment variables to Deployments](#link-environment-variables-to-deployments) for more information.
4. Enter your information in the required fields.
5. Choose whether you want your environment variable to be **Not Secret** or **Secret**. This allows you to store API keys, tokens, or other secrets in an environment variable without those credentials being available to future editors.
6. Click **Create environment variable**.
7. If you haven't linked your environment variable to all deployments, make it accessible to individual Deployments. See [Link environment variables to Deployments](#link-environment-variables-to-deployments).
### Create an environment variable at the Deployment level:
1. In the Astro UI, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **Environment variables**.
3. Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet).
4. Enter an environment variable key and value. For sensitive credentials that should be treated with an additional layer of security, select the **Secret** checkbox. This permanently hides the variable's value from all users in your Workspace.
5. Click **Update Environment Variables** to save your changes. Your Airflow scheduler, webserver, and workers restart. After saving, it can take up to two minutes for new variables to be applied to your Deployment.
1. In the Astro UI, select a Workspace, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **Environment variables**.
3. Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet).
4. Enter an environment variable key and value. For sensitive credentials that should be treated with an additional layer of security, select the **Secret** checkbox. This permanently hides the variable's value from all users in your Workspace.
5. Click **Update Environment Variables** to save your changes. Your Airflow scheduler, webserver, and workers restart. After saving, it can take up to two minutes for new variables to be applied to your Deployment.
After you create an environment variable, you can reference it from Dag code using standard Python methods like `os.getenv()`. For more information and examples of using environment variables in your Dag code, see [Using environment variable](/docs/learn/airflow-variables#using-environment-variables).
## Link environment variables to Deployments
After you create an environment variable at the Workspace level, you can link it to multiple Deployments. Linking environment variables is useful for standardizing configuration across your entire team.
For the most flexibility, you can set default environment variables and override the environment variable values per-Deployment based on details like the Deployment's usage and environment type (production or development).
1. In the Astro UI, go to **Environment** > **Environment Variables**.
2. Click the environment variable you want to link to a Deployment.
3. Click **+ Link Deployment**.
4. Choose a Deployment from the list that appears.
5. (Optional) Click **More options** and then add any value overrides for this Deployment. For example, if your environment variable provides a development API key by default, you can override its value to instead provide a production API key.
6. Click **Link environment variable**.
## Configure environment variable sharing for a Workspace
You can configure Astro to link Workspace-level environment variables to all Deployments in the Workspace by default.
This is useful, for example, when you need to configure an environment variable for development environments that all Deployments in a Workspace should start with. Then, when you create new Deployments, they automatically have a default environment variable to your development resources.
When you're ready to connect your Deployments to production resources, you can either replace the environment variable or [override the environment variable values](#override-environment-variable-values) with your production resource information.
If you toggle the **Automatically link to all deployments** setting from **Off** to **On**, Astro respects any environment variable value overrides that you might have configured for existing linked Deployments.
1. In the Astro UI, go to **Environment** > **Environment Variables**.
2. Click the environment variable that you want to add per-Deployment overrides to.
3. Toggle the **Automatically link to all deployments** setting to choose either:
* **Off**: Only share the environment variable individually to Deployments.
* **On**: Link to all current and future Deployments in this Workspace.
4. (Optional) Change the default environment variable value.
5. Click **Update environment variable** to save.
## Override environment variable values
If you create an environment variable at the Workspace level and link it to a Deployment, you can later edit the environment variable within the Deployment to specify a value override. When you override the value, you specify the value that you want to use for one Deployment, but not for others. This way, you can configure the environment variable a single time, but still have the flexibility to customize environment variables at the Deployment level.
For example, you might have created an environment variable that points to a development API endpoint, and then add a value override to specify a staging or production API endpoint for your staging and production Deployments to use.
### Environment variable precedence
When an environment variable is defined at both the Workspace and Deployment levels with the same key, the Deployment-level value always takes precedence. The Deployment environment variables page shows a unified view of both workspace and deployment environment variables, with clear indicators showing:
* The source of each environment variable (Workspace or Deployment)
* Override badges when a deployment environment variable overrides a workspace one
* Tooltips explaining the relationship between environment variables
To override a workspace environment variable value for a specific Deployment:
1. In the Astro UI, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **Environment variables**.
3. Click **Edit Deployment Variables**.
4. To override a workspace environment variable, add a new environment variable with the same key as the workspace environment variable but with a different value. The deployment value will take precedence.
5. Click **Update Environment Variables** to save your changes.
1. In the Astro UI, select a Workspace, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **Environment variables**.
3. Click **Edit Deployment Variables**.
4. To override a workspace environment variable, add a new environment variable with the same key as the workspace environment variable but with a different value. The deployment value will take precedence.
5. Click **Update Environment Variables** to save your changes.
Alternatively, you can override from the Workspace level:
1. In the Astro UI, go to **Environment** > **Environment Variables**.
2. Click the environment variable that you want to add per-Deployment overrides to.
3. Click **Edit** to open the environment variable configurations for a specific linked Deployment.
4. Switch the **Override value** toggle from **No Override** to **Override**.
5. Add the override value.
6. Click **Update environment variable link**.
## Link environment variables to Astro IDE projects
In addition to Deployments, you can link Workspace-level environment variables to [Astro IDE](/docs/astro/ide-overview) projects. When you link an environment variable to an Astro IDE project, the project's ephemeral test Deployments start with that variable available, without affecting Deployments that aren't started from the IDE.
For the most flexibility, you can set a default value at the Workspace level and override it per project, similar to how you override values per Deployment.
### Link an environment variable to an Astro IDE project
1. In the Astro UI, go to **Environment** > **Environment Variables**.
2. Click the environment variable you want to link to an Astro IDE project.
3. Click the **Linked Projects** tab.
4. Click **Link Project**.
5. Choose an Astro IDE project from the list. Optionally, add a value override for this project.
6. Confirm the link.
### Configure project sharing for a Workspace
You can configure Astro to link a Workspace-level environment variable to all Astro IDE projects in the Workspace by default. This is useful when you want every project's test Deployments to start with the same configuration values.
1. In the Astro UI, go to **Environment** > **Environment Variables**.
2. Click the environment variable that you want to share with all Astro IDE projects.
3. Click the **Edit** icon next to **Auto-linking** in the variable details.
4. In the **Edit Environment Variable** dialog, under **Auto-linking**, toggle **ALL ASTRO IDE PROJECTS** to **On**.
5. Click **Update Environment Variable**.
### Environment variable precedence in Astro IDE test Deployments
When an Astro IDE project starts a test Deployment, the Deployment receives the union of:
* Environment variables linked to the project, including Workspace-level variables linked to the project and variables scoped directly to the project.
* Workspace-level environment variables linked to that Deployment.
If both the project and a linked Deployment define an environment variable with the same key, the project-level value takes precedence in the test Deployment.
## Migrate existing environment variables to the Environment Manager
If you have environment variables set directly on a Deployment, you can move them into the Environment Manager so that they can be reused across Deployments and Astro IDE projects. See [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager).
## Promote a Deployment-scoped environment variable to the Workspace
If you created an environment variable on a single Deployment and later want to reuse it across other Deployments or Astro IDE projects, you can promote it to the Workspace level from the Deployment's Environment tab. See [Promote a Deployment environment object to the Workspace](/docs/astro/migrate-metadata-db-to-environment-manager#promote-a-deployment-environment-object-to-the-workspace).
## See also
* [Manage environment variables on Astro](/docs/astro/manage-env-vars)
* [Environment variables overview](/docs/astro/environment-variables)
* [Manage connections and variables](/docs/astro/manage-connections-variables)
# Create Airflow variables in the Astro UI
Source: https://astronomer.io/docs/astro/create-and-link-variables
Create Airflow variables and link them to multiple Deployments in the Astro Environment Manager.
You can create and manage Airflow variables for Deployments with the Astro Environment Manager in the Astro UI. The Environment Manager uses an Astro-managed secrets backend to store Airflow variable key-value pairs as Kubernetes Secrets.
Using the Environment Manager, you can quickly and securely create Airflow variables once and share them to multiple Deployments without having to set up your own secrets backend. You can also create a variable once and use it across multiple Airflow Deployments.
For example, you can configure a variable with the access token credentials for a sandbox or development environment. Then, you can later configure your variable to be applied to all Deployments in the workspace by default. This means that when you create new Deployments, they automatically have access to your development environment. Later, you can override the variable to use your production credentials in production Deployments by using a [field override or edit](#override-variable-values).
Compared to creating a variable in the Airflow UI, when you create a variable in the Astro UI, you can:
* Share the variable with multiple Deployments within the Workspace.
* Share the variable with [Astro IDE](/docs/astro/ide-overview) projects so that their ephemeral test Deployments can use it.
* Override the variable value for individual Deployments or Astro IDE projects.
* Use variables in branch-based deploys and PR previews.
Workspace Owners and Operators can create and assign variables, while Workspace Authors can view configured variables and use them in Deployments.
## How variables are stored
When you create an Airflow variable in the Environment Manager, Astro stores Airflow variable details in an Astronomer-hosted secrets manager, and then applies variables to Deployments as Kubernetes Secrets. Specifically the following steps occur:
* Astro stores the variable value in a secure secrets manager hosted by Astronomer.
* When a variable is assigned to a Deployment, Astro uses Airflow's provided [local filesystem secrets backend](https://airflow.apache.org/docs/apache-airflow/stable/security/secrets/secrets-backend/local-filesystem-secrets-backend.html) to mount your Airflow variables as Kubernetes Secrets.
* When your Dags use your variables, Airflow reads the details from the filesystem using the Airflow local filesystem secrets backend.
This process occurs every time you create or update a variable.
## Prerequisites
* Workspace Operator or Workspace Owner [user permissions](/docs/astro/user-permissions)
* A Deployment on Astro. See [Create a Deployment](/docs/astro/create-deployment)
* Astro Runtime 9.3.0 or greater
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create an Airflow Variable
You can create Airflow variables both at the Deployment and Workspace level. When you create a variable at the Deployment level, the variable details are available only to that specific Deployment. When you create a variable at the Workspace level, you can apply the variable to several Deployments and override its value as needed for each Deployment.
To create a variable at the Workspace level:
1. In the Astro UI, go to **Environment** > **Airflow Variables**.
2. Click **+ New Airflow Variable** to add a new variable.
3. Choose whether you want your variable to be **Automatically link to all deployments** by setting the toggle to **On**. See [Link variables to Deployments](#link-variables-to-deployments) for more information.
4. Enter your information in the required fields.
5. Choose whether you want your variable to be **Not Secret** or **Secret**, when working with it in the future. This allows you to store API keys, tokens, or other secrets in an Airflow Variable without those credentials being available to future editors.
6. Click **Create Airflow Variable**.
7. If you haven't linked your variable to all deployments, make it accessible to individual Deployments. See [Link variables to Deployments](#link-variables-to-deployments).
1. In the Astro UI, click **Environment** in the left menu to open the **Airflow Variables** page.
2. Click **+ Airflow Variable** to add a new variable.
3. Choose whether you want your variable to be **Automatically link to all deployments** by setting the toggle to **On**. See [Link variables to Deployments](#link-variables-to-deployments) for more information.
4. Enter your information in the required fields.
5. Choose whether you want your variable to be **Not Secret** or **Secret**, when working with it in the future. This allows you to store API keys, tokens, or other secrets in an Airflow Variable without those credentials being available to future editors.
6. Click **Create Airflow Variable**.
7. If you haven't linked your variable to all deployments, make it accessible to individual Deployments. See [Link variables to Deployments](#link-variables-to-deployments).
To create a variable at the Deployment level:
1. In the Astro UI, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **Airflow Variables**, then click **+ New Airflow Variable**.
3. Enter your information in the required fields.
4. Choose whether you want your variable to be **Not Secret** or **Secret**, when working with it in the future. This allows you to store API keys, tokens, or other secrets in an Airflow Variable without those credentials being available to future editors.
5. Click **Create Airflow Variable** to make your new variable.
1. In the Astro UI, select a Workspace, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Click **+ Airflow Variable** to add a new variable.
3. Enter your information in the required fields.
4. Choose whether you want your variable to be **Not Secret** or **Secret**, when working with it in the future. This allows you to store API keys, tokens, or other secrets in an Airflow Variable without those credentials being available to future editors.
5. Click **Create Airflow Variable** to make your new variable.
After you create a variable, you can reference its **Airflow Variable Key** from Dag code like you would with any Airflow variable created through the Airflow UI.
## Link variables to Deployments
After you create a variable at the Workspace level, you can link it to multiple Deployments. Linking variables is useful for standardizing external resource usage across your entire team.
For the most flexibility, you can set default variables and override the variable details per-Deployment based on details like the Deployment's usage and environment type (production or development).
1. In the Astro UI, go to **Environment** > **Airflow Variables**.
2. Click the variable you want to link to a Deployment.
3. Click **+ Link Deployment**.
4. Choose a Deployment from the list that appears.
5. (Optional) Click **More options** and then add any value overrides for this Deployment. For example, if your variable provides a development token by default, you can override its details to instead provide a production token.
6. Click **Link Airflow Variable**.
## Configure variable sharing for a Workspace
You can configure Astro to link Workspace-level variables to all Deployments in the Workspace by default.
This is useful, for example, when you need to configure a variable for development environments that all Deployments in a Workspace should start with. Then, when you create new Deployments, they automatically have a default variable to your development resources.
When you're ready to connect your Deployments to production resources, you can either replace the variable or [override the variable field](#override-variable-values) values with your production resource information.
If you toggle the **Automatically link to all deployments** setting from **Off** to **On**, Astro respects any variable value overrides that you might have configured for existing linked Deployments.
1. In the Astro UI, go to **Environment** > **Airflow Variables**.
2. Click the variable that you want to add per-Deployment field overrides to.
3. Toggle the **Automatically link to all deployments** setting to choose either:
* **Off**: Only share the variable individually to Deployments.
* **On**: Link to all current and future Deployments in this Workspace.
4. (Optional) Change the default variable value.
5. Click **Update Airflow Variable** to save.
## Override variable values
If you create a variable at the Workspace level and link it to a Deployment, you can later edit the variable within the Deployment to specify a value override. When you override the variable's value, you specify the value that you want to use for one Deployment, but not for others. This way, you can configure the variable a single time, but still have the flexibility to customize variables at the Deployment level.
For example, you might have created a variable that points to a dev token, and then add a value override to specify a staging or production token for your staging and production Deployments to use.
1. In the Astro UI, go to **Environment** > **Airflow Variables**.
2. Click the variable that you want to add per-Deployment field overrides to.
3. Click **Edit** to open the variable configurations for a specific linked Deployment.
4. Switch the **Override value** toggle from **No Override** to **Override**.
5. Add the override value.
6. Click **Update Airflow Variable link**.
## Link Airflow variables to Astro IDE projects
In addition to Deployments, you can link Workspace-level Airflow variables to [Astro IDE](/docs/astro/ide-overview) projects. When you link a variable to an Astro IDE project, the project's ephemeral test Deployments start with that variable available, without affecting Deployments that aren't started from the IDE.
For the most flexibility, you can set a default value at the Workspace level and override it per project, similar to how you override values per Deployment.
### Link a variable to an Astro IDE project
1. In the Astro UI, go to **Environment** > **Airflow Variables**.
2. Click the variable you want to link to an Astro IDE project.
3. Open the **Linked Projects** tab.
4. Click **Link Project**.
5. Choose an Astro IDE project from the list.
6. (Optional) Toggle **Override Value** and add a value override for this project.
7. Click **Link Airflow Variable**.
### Configure project sharing for a Workspace
You can configure Astro to link a Workspace-level variable to all Astro IDE projects in the Workspace by default. This is useful when you want every project's test Deployments to start with the same set of development values.
1. In the Astro UI, go to **Environment** > **Airflow Variables**.
2. Click the variable that you want to share with all Astro IDE projects.
3. Click the **Edit** icon next to **Auto-linking** in the variable details.
4. In the **Edit Airflow Variable** dialog, under **Auto-linking**, toggle **ALL ASTRO IDE PROJECTS** to **On**.
5. Click **Update Airflow Variable**.
### Variable precedence in Astro IDE test Deployments
When an Astro IDE project starts a test Deployment, the Deployment receives the union of:
* Variables linked to the project, including Workspace-level variables linked to the project and variables scoped directly to the project.
* Workspace-level variables linked to that Deployment.
If both the project and a linked Deployment define an Airflow variable with the same key, the project-level value takes precedence in the test Deployment.
## Migrate existing Airflow variables to the Environment Manager
If you have Airflow variables defined in a Deployment's Airflow metadata database, you can move them into the Environment Manager so that they can be reused across Deployments and Astro IDE projects. See [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager).
## Promote a Deployment-scoped Airflow variable to the Workspace
If you created an Airflow variable on a single Deployment and later want to reuse it across other Deployments or Astro IDE projects, you can promote it to the Workspace level from the Deployment's Environment tab. See [Promote a Deployment environment object to the Workspace](/docs/astro/migrate-metadata-db-to-environment-manager#promote-a-deployment-environment-object-to-the-workspace).
# Create a Deployment
Source: https://astronomer.io/docs/astro/create-deployment
Learn how to create an Astro Deployment. After you’ve created a Deployment, you can deploy Dags to it from the Astro command-line interface (CLI), or from a continuous integration and continuous delivery (CI/CD) pipeline.
An Astro Deployment is an Airflow environment that is powered by [Astro Runtime](/docs/runtime/runtime-image-architecture). It runs all core Airflow components, including the Airflow webserver, scheduler, and workers, plus additional tooling for reliability and observability.
There are multiple ways to create an Astro Deployment:
* Manually, using the Astro UI. This is the most basic way to create a Deployment and is the focus of this document. You can create a Deployment in the UI using either:
* Quick Start: (Default) Rapid creation with predefined templates for the most common Deployment types.
* Advanced configuration: Full control over Deployment details.
* Programmatically, using [`astro deployment create`](/docs/cli/v1.43/astro-deployment-create).
* Programmatically, using a Deployment template file. See [Manage Deployments as code](/docs/astro/manage-deployments-as-code).
* Programmatically, using [Astro Terraform Provider](https://registry.terraform.io/providers/astronomer/astro/latest/docs/resources/deployment).
When using the Astro UI, you can select either a quick start template for simplicity or switch to advanced configuration for advanced configuration.
## Execution mode
To create a Deployment, you can specify **Hosted** or **Remote** execution mode in the advanced configuration of the Deployment. Read below for a summary of the two modes and see [Execution mode](/docs/astro/execution-mode) for more information.
### Hosted execution
Hosted execution mode is Astronomer-Hosted execution and orchestration for hands-off infrastructure management. Hosted is the default execution that offers a convenient, secure, and stable way to run Airflow workloads without having to manage workers in your environment.
### Remote Execution
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
Remote Execution mode is available on dedicated clusters to run tasks in your hardware or private clouds with only outbound connections to Astro’s Orchestration Plane. Sensitive data stays local, ideal for regulated or multi-regional deployments. Choose this option if:
* You need to run Airflow tasks in on-prem or edge environments without exposing inbound connections.
* Data locality and sovereignty are critical, ensuring sensitive or compliance-bound data stays in your environment.
* You want to avoid inbound firewall changes, simplifying network security by using only outbound connections.
* Your workloads require runtime flexibility, allowing execution on Kubernetes, bare metal, or other infrastructure.
* Strong isolation of secrets, data, and logs is a priority.
* You need scalability for high-throughput workflows, large-memory tasks, or GPU-accelerated AI workloads.
### Cluster type
To create a Deployment, you must choose a cluster type to host the Deployment:
* A **standard cluster** is the default cluster type and the quickest way to get an Airflow environment up and running on Astro. A standard cluster is a multi-tenant cluster managed by Astronomer where each Deployment exists in its own dedicated Kubernetes namespace. To run a Deployment in a standard cluster, you select a cloud provider and region when you create the Deployment. Then, Astro automatically creates your Deployment in an existing standard cluster based on your configuration.
* A **dedicated cluster** is a single-tenant Kubernetes cluster that's used exclusively by your team. Choose this option if:
* You need private networking support between Astro and your cloud or on-premise data services.
* You want to use a specific cloud provider or region that is not supported on standard clusters.
* You need to run Airflow environments in separate clusters for business or security reasons.
Note that due to expanded resource usage, dedicated clusters cost more than standard clusters. If no dedicated clusters are available to select, see [Create a Dedicated cluster](/docs/astro/create-dedicated-cluster) to create a new one.
If your Organization has the **Enforce Dedicated Clusters** policy enabled, the Standard Cluster option isn't available when creating a Deployment. See [Enforce dedicated clusters for new Deployments](/docs/astro/organization-settings#enforce-dedicated-clusters-for-new-deployments).
After you create a Deployment, you can deploy Dags to it using the Astro CLI on your local machine or a continuous integration/continuous delivery (CI/CD) tool. All Dags and tasks on Astro are executed within a Deployment.
Every Deployment is hosted on an Astro cluster with its own dedicated resources that you can [customize](/docs/astro/deployment-resources) to fine-tune your resource usage. To restrict communication between Deployments, resources for each Deployment are isolated within a corresponding Kubernetes namespace. See [Deployment network isolation](/docs/astro/data-protection#deployment-network-isolation).
If you're migrating to Astro from OSS Airflow or another Astronomer product, and you currently use an older version of Airflow, you can still create Deployments with the corresponding version of Astro Runtime even if it is deprecated according to the [Astro Runtime maintenance policy](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-maintenance-policy). This allows you to migrate your Dags to Astro without needing to make any code changes and then immediately upgrade to a new version of Airflow. Note that after you migrate your Dags, Astronomer recommends upgrading to a supported version of Astro Runtime as soon as you can.
See [Run a deprecated Astro Runtime version](/docs/runtime/upgrade-astro-runtime#run-a-deprecated-astro-runtime-version).
## Prerequisites
* A [Workspace](/docs/astro/manage-workspaces)
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a Deployment
In the Astro UI, go to **Deployments** and click **+ New Deployment**.
Select a **Workspace** from the dropdown.
In the **Quick Start** panel, enter a **Name** and choose a Deployment template:
* **Development**: Low-cost and secure environment for experimentation and rapid iteration.
* **Pre-Production**: Scalable and reliable validation environment for production readiness.
* **Production**: Highly available and reliable environment for business-critical workloads.
For more options, click **Switch to custom configuration**. You can also change these settings after the Deployment is created. See [Deployment resources](/docs/astro/deployment-resources).
Under **Cluster**, select a cluster type:
* For **Standard Cluster**, choose a cloud provider and region.
* For **Dedicated Cluster**, select a cluster from the dropdown, or click **Create New Cluster** if you need a new one.
The cluster can't be modified after the Deployment is created.
Click **Create Deployment**.
The status displays as **Creating** until healthy and the Airflow UI becomes available for use.
Open the **Deployments** section of the Astro UI and click **+ Deployment**. Enter a unique **Deployment Name**.
The **Quick Start** panel appears by default and requires you to select from three templated options:
* **Development**: Low-cost and secure environment for experimentation and rapid iteration.
* **Pre-Production**: Scalable and reliable validation environment for production readiness.
* **Production**: Highly available and reliable environment for business-critical workloads.
To use a template, select the most appropriate card and complete the required fields. For advanced resource or execution configuration, select **Switch to advanced configuration**.
Switching from advanced configuration back to quick start resets all custom settings after confirmation.
When you select the Development template or enable Development Mode, you can define schedules to control when the Deployment is available for task execution. Set timezone, days of the week, and start/end times.
Select a **Cluster Type**.
* For **Standard Cluster**, choose a cloud provider and region.
* For **Dedicated Cluster**, select a cluster from the dropdown or create a new one if required.
For advanced use cases, you can further customize details such as execution mode, executor type, and worker resources by switching to advanced configuration.
If you don't have specific requirements, the default options are suitable for most workflows.
For a complete list of available options and resource settings, see [Deployment resources](/docs/astro/deployment-resources).
Click **Create Deployment**.
The status displays as **Creating** until healthy and the Airflow UI becomes available for use.
For more information about possible Deployment health statuses, see [Deployment health](/docs/astro/deployment-health-incidents).
## Next steps
* [Deployment settings](/docs/astro/deployment-settings)
* [Set environment variables on Astro](/docs/astro/environment-variables)
* [Authenticate an automation tool to Astro](/docs/astro/automation-authentication)
# Customize Otto
Source: https://astronomer.io/docs/astro/customize-otto
Tailor Otto to your team by adding team conventions, reusable skills, and permission rules that Otto applies to every session.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto becomes more useful the more it knows about how your team works. This page describes the ways you can customize Otto so that every engineer on the team benefits from shared conventions, reusable workflows, and team-wide permission rules.
When Otto is customized, new engineers get your conventions from day one, corrections one engineer makes compound across the team, and operational knowledge stops living only in senior engineers' heads.
## What you can customize
Otto draws on four categories of team-specific customization. Each lives in files you commit to your repository, so updates propagate through your standard Git workflow.
* **Memory** — team conventions, naming patterns, connection configs, retry policies, approved operators, and other knowledge you want Otto to apply automatically. Memory files live in `.astro/memory/`. See [Memory](/docs/astro/otto-memory).
* **Skills** — reusable, structured workflows the team runs often, such as deploy patterns, testing patterns, and migration playbooks. Skills live in `.astro/otto/skills/`. See [Skills](/docs/astro/otto-skills).
* **Permissions** — allow, ask, and deny rules that control what Otto can do, including file rules, command patterns, and permission modes. Rules live in `.astro/otto/permissions.json`. See [Permissions](/docs/astro/otto-permissions).
* **Extensions** — toggles for bundled Otto features such as Dag validation, memory commands, and hosted skills. Extension settings live in `.astro/otto/extensions.json`. See [Extensions](/docs/astro/otto-extensions).
In addition to the files in `.astro/`, Otto reads `AGENTS.md` and `CLAUDE.md` files for context. Otto loads them from `~/.astro/otto/AGENTS.md` or `~/.astro/otto/CLAUDE.md`, then walks up from the current working directory to `/`. When both files exist in the same folder, Otto prioritizes `AGENTS.md` over `CLAUDE.md`.
## Recommended project layout
A customized Astro project typically looks like:
```text wrap theme={null}
my-astro-project/
dags/
.astro/
memory/
MEMORY.md
conventions.md
connections.md
operators.md
otto/
skills/
deploy-to-staging/
SKILL.md
permissions.json
extensions.json
```
Commit these files to your repository. When team members pull the latest main branch, their next Otto session loads the updated customizations automatically.
## Get started
Customize Otto by working through the agent. Describe what you want Otto to remember, write, or enforce, and Otto produces the corresponding files in `.astro/`. Each file is plain Markdown or JSON, so you can review, edit, and commit changes in your Git diff like any other code change.
### Seed memory from an established project
Best for teams whose conventions live in code and conversations but aren't documented yet.
Run Otto in your project folder:
```sh wrap theme={null}
astro otto
```
Then run `/bootstrap` in the Otto interface. Otto reviews your git history and available GitHub context to extract durable learnings, then writes memory files for the durable patterns it finds. Every read and write happens as a visible tool call, so you can see what Otto pulls from history and what it persists.
For `/bootstrap` to include GitHub PR history, install and authenticate the [GitHub CLI](https://cli.github.com/). Without it, Otto bootstraps from local git history alone.
### Add memory from existing standards
Best for teams that already have conventions documented elsewhere, such as a wiki page, a `STANDARDS.md` file, or an onboarding guide.
Paste the content into an Otto session and ask Otto to extract memory files from it. For example:
```text wrap theme={null}
> Here is our team's convention doc. Read it and propose memory files for the parts that should apply to every Dag we write.
```
Otto produces draft memory files for review, following the same review pattern as `/bootstrap`.
### Capture learnings with `/remember`
During an active session, run `/remember` to have Otto review the conversation and generate memory files from durable points. Use `/remember` to grow your team's memory organically as you work.
### Ask Otto to write skills and permission rules
For workflows you run often, describe the workflow to Otto. For example:
```text wrap theme={null}
> Write a skill for our staging deploy that runs make test, deploys to the staging Deployment, and tails the scheduler logs.
```
Otto generates a `SKILL.md` under `.astro/otto/skills/` for you to review. The same pattern applies to permission rules. Describe what Otto should and shouldn't do, and Otto produces or updates `.astro/otto/permissions.json`.
### Commit and roll out
After Otto writes a customization, the changes appear in your Git diff. Review, edit if needed, and commit them. On the next pull, every engineer's Otto sessions load the new customizations automatically.
## Choose a model
You can pick your own model for an Otto session. Otto supports models from OpenAI, Anthropic, and Google through the Astronomer Gateway. Run `/model` in an interactive session to browse what's available to you and switch the active model mid-session. To pin a model at launch, pass `--model `.
See [`astro otto` model selection](/docs/cli/v1.43/astro-otto#model-selection) for the full reference.
## Next steps
* [Memory](/docs/astro/otto-memory) — Memory tiers, file format, and how Otto loads context.
* [Skills](/docs/astro/otto-skills) — How to author local skills for reusable workflows.
* [Permissions](/docs/astro/otto-permissions) — Configure allow, ask, and deny rules for tool calls.
* [Settings](/docs/astro/otto-settings) — Configuration files, environment variables, and settings precedence.
# Dag versioning
Source: https://astronomer.io/docs/astro/dag-versioning
Track dag versions across runs using Airflow 3 dag versioning and dag bundles on Astro.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Dag versioning is a feature introduced in Airflow 3. Previously, in Airflow 2, Airflow automatically used the most recent dag code. This meant that changing your dag could affect observability into previous task runs or affect the success of in-progress dags. Airflow 3 addresses these issues with *Dag bundles* and *Dag versioning*.
Airflow automatically versions your dag runs in the Airflow UI. When you make significant changes to your Dags, like changing task behavior, Airflow creates a new version. Each dag run is also associated with a specific version visible in the Airflow UI. This allows you to quickly identify the outcome of particular code changes.
Dag bundles include the dags files and their supporting files and can also be versioned depending on the bundle type you choose. These versions are separate from dag versions, and reflect the version of the source. The default, `LocalDagBundle` is not versioned, but some dag bundles are. The `GitDagBundle` is versioned by the underlying backend, Git. Every commit made to the configured Git repository creates a new version, even if a commit does not change your dag code.
Read more about [Dag versioning](/docs/learn/airflow-dag-versioning), including details about how to configure a dag bundle for OSS Airflow.
## Dag bundles on Astro Hosted
On Astro Hosted, you don't need to configure a dag bundle backend. As a fully managed service, Astro Hosted configures a versioned dag bundle for you that contains the dags pushed to the Deployment.
Astro Hosted does not support configuring custom dag bundles.
## Dag bundles on Astro with Remote Execution
For Remote Execution mode Deployments, you must configure a dag bundle backend for the Remote Execution Agents in your environment. See [Configure dag bundles for Remote Execution](/docs/astro/remote-execution-configure-dag-sources) for more information on how to configure the dag bundle backend as well as differences between bundle types.
# Write and run dags on Astro
Source: https://astronomer.io/docs/astro/dags-overview
Learn how to use code-level features specific to Astro in your Apache Airflow dags.
Astro includes several features that enhance the Apache Airflow development experience, from dag writing to testing. To use these features, you might need to modify how you write your dags and manage the rest of your code.
Use this documentation to learn about the key differences between managing dags on Astro versus on other platforms.
## Project structure
To develop and run dags on Astronomer products, your dags must belong to an Astro project. An *Astro project* contains all files required to run your dags both locally and on Astronomer. In addition to dag files, an Astro project includes Python and OS-level packages, your Astro Runtime version, and any other files your workers need to access when you run tasks.
See [Create an Astro project](/docs/cli/v1.43/get-started-cli) to learn more about how to create and run Astro projects.
## Airflow and Astro Runtime versioning
When you migrate to Astro from another Apache Airflow service, there are a few differences to note with regards to how Astro handles versioning, upgrades, and runtime builds.
* **Astro Runtime versioning scheme**: Each Astro project uses a specific version of Astro Runtime, which is Astronomer's version of Apache Airflow that includes additional observability and performance features. Each Astro Runtime version corresponds to one Apache Airflow version, but the versioning scheme is different. For example, Astro Runtime 11.3.0 corresponds to Airflow 2.9.1. See [Astro Runtime maintenance policy](/docs/runtime/runtime-version-lifecycle-policy).
* **Upgrading Airflow**: As you continue to develop within an Astro project, you'll need to upgrade your Astro Runtime version to take advantage of new Astro and Apache Airflow features and fixes. Your Astro Runtime version is defined in the `Dockerfile` of your Astro project. Unlike with open source Airflow, upgrading Astro Runtime does not require you to manually migrate your metadata database. To upgrade your version of Airflow, you only have to change the Astro Runtime version listed in your project's Dockerfile and rebuild your project. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime) for instructions on how to upgrade.
* **Runtime Arguments**. Your Dockerfile is also where you can define additional runtime arguments that trigger whenever your project builds. You can use these arguments to mount resources, such as API tokens, to your Airflow environment without including the specific resources in your project files. See [Customize your Dockerfile](/docs/cli/v1.43/customize-dockerfile) for more details.
## Testing environments
There are two ways to run dags within the Astro ecosystem: Either in a local Airflow environment or in an Astro Deployment. Each has its own purpose in the development lifecycle.
* **Local Airflow environment**: You can run dags on your local machine using the Astro CLI. This development method is most useful if you need to quickly iterate and test changes, such as when fixing a bug, or you're just getting started with Airflow. Testing locally is free and open source.
* **Deployment**: When you deploy your dags to Astro, they run on a managed Deployment. Use Deployments to run production code, or create a development Deployment to test changes over a longer period of time than you could in a local Airflow environment. To test code on a Deployment, you must have an [Astro account](/docs/astro/log-in-to-astro) and an administrator on your team must grant you access to the Deployment. For more information about how to structure Deployments for specific development workflows, see [Connections and branch-based deploys](/docs/astro/best-practices/connections-branch-deploys).
### Unit tests
Whether you're building your project locally or deploying to Astro, you can run unit tests with the Astro CLI to ensure that your code meets basic standards before you run your dags. The Astro CLI includes a default set of unit tests which you can run alongside your own tests in a single sequence. See [Test your dags](/docs/cli/v1.43/test-your-astro-project-locally) for more information.
## Airflow feature enhancements
Astro includes several features that enhance open source Apache Airflow functionality.
* On Astro, the Astro UI renders [Airflow tags](https://airflow.apache.org/docs/apache-airflow/stable/howto/add-dag-tags.html) defined in your dags. Use tags to filter dags across all Deployments from a single screen.
* The [Astro Environment Manager](/docs/astro/manage-connections-variables#astro-environment-manager) allows you to create and manage Airflow connections directly from the Astro UI. Instead of being limited to defining connections in the Airflow UI or with a secrets manager, you can create connections from the Environment Manager on Astro and use the connections in your local Airflow environment or across multiple Deployments and Workspaces.
* Astro has built-in infrastructure to run the `KubernetesPodOperator` and Kubernetes executor, such as default Pod limits and requests. Task-level resource limits and requests are set by default on Astro Deployments, which means that tasks running in Kubernetes Pods never request more resources than expected. See [Run the Kubernetes executor](/docs/astro/kubernetes-executor) and [Run the `KubernetesPodOperator`](/docs/astro/kubernetespodoperator) for more specific instructions and examples.
## Dag observability
In local Airflow environments, you can use the Airflow UI to check your dag runs, task logs, and component logs just as you would in any other Airflow environment.
In the Astro UI, you have access to the **DAGs** page in addition to the Airflow UI. From here, you can manage dag and task runs for any Deployment in your Workspace.
Astronomer recommends using the UI that best fits the need your team. If you prefer managing your dags from a single place and find the way that the way the Astro page is designed helpful, you don't need to use the Airflow UI. If you're a longtime user of Apache Airflow, you might feel more comfortable in the Airflow UI and don't need to use the Astro UI.
See [View logs](/docs/astro/view-logs) and [Manage dag runs](/docs/astro/manage-dags) for more information.
## Airflow alerts
Astro supports a set of alerting features that in many cases replace Apache Airflow SLAs or failure notification. There are some circumstances where Astronomer recommends configuring Astro alerts instead of Airflow SLAs or failure notifications because it can simplify your dag code and make it easier to manage alerts across multiple dags. See [When to use Airflow or Astro alerts for your pipelines on Astro](/docs/astro/best-practices/airflow-vs-astro-alerts).
## Astronomer Cosmos
In addition to its commercial products, Astronomer maintains [Cosmos](https://www.astronomer.io/cosmos/) an open source tool for orchestrating dbt Core projects from a dag. Cosmos gives you more visibility into every step of your dbt project and lets you use Airflow's data awareness features with your dbt models. See the [Cosmos documentation](https://astronomer.github.io/astronomer-cosmos/) for more information.
# Deploy code to Astro
Source: https://astronomer.io/docs/astro/deploy-code
Learn about the different ways you can deploy code to Astro.
To run your code on Astro, you need to deploy it to a Deployment. You can deploy part or all of an Astro project to an Astro Deployment.
There are several options for deploying code to a Deployment:
* **Project deploys**: Run `astro deploy` to build every non-Dag file in your Astro project as a Docker image and deploy the image to all Airflow components in a Deployment. This includes your `Dockerfile`, plugins, and all Python and OS-level packages. Dags are deployed separately to each Airflow component through a sidecar container. See [Deploy a project image](/docs/astro/deploy-project-image).
* **Dag-only deploys**: Run `astro deploy --dags` to deploy only your Dag files to Astro. If you only need to deploy Dag changes, running this command is faster than running `astro deploy` since it doesn't require installing dependencies. See [Deploy Dags](/docs/astro/deploy-dags).
* **Image-only deploys**: Run `astro deploy --image` to build and deploy your Astro project configurations as a Docker image without deploying your Dags. This is useful if you have a multi-repo CI/CD strategy, and you want to deploy your Dags and project configurations from different repositories or storage buckets. See [Image-only deploys](/docs/astro/deploy-dags#trigger-an-image-only-deploy).
* **dbt deploys**: Run `astro deploy --dbt` to deploy only a dbt project to Astro. See [Deploy dbt projects to Astro](/docs/astro/deploy-dbt-project). You must use this command to deploy dbt projects to Astro.
* **Remote Execution project deploys**: For Deployments configured for [Remote Execution](/docs/astro/execution-mode#remote-execution), use `astro deploy` to build and deploy the Runtime (orchestration plane) image, and use `astro remote deploy` to build and push client images for your Remote Execution Agents. See [Initialize and deploy Remote Execution projects](/docs/astro/deploy-project-remote-execution) for full instructions.
* **GitHub integration deploys**: The Astronomer GitHub integration allows you to map a branch from your GitHub repository to directly deploy to Astro after you merge pull requests to the mapped branch. See [Deploy code with the Astro GitHub integration](/docs/astro/deploy-github-integration).
For each deploy option, you can either trigger the deploy manually or through CI/CD. CI/CD pipelines can include both image deploys and Dag-only deploys, and they can deploy to multiple different Deployments based on different branches in your git repository. See [CI/CD overview](/docs/astro/set-up-ci-cd).
For Dags running on Astro using Hosted [execution mode](/docs/astro/execution-mode), Astro configures a specialized versioned Dag bundle automatically, without any need for additional setup. Configuring custom Dag bundles and using several Dag bundles in the same Astro Deployment is only supported when using [Remote Execution mode](/docs/astro/execution-mode#remote-execution). For more information, see [Configure Dag bundles for Remote Execution](/docs/astro/remote-execution-configure-dag-sources).
If multiple deploys are triggered simultaneously or additional deploys are triggered while a deploy is still processing, whether manually or through CI/CD, the first deploy is processed and then the subsequent deploys are completed. This behavior is different from how Astro processes simultaneous code deploys with the [GitHub integration](/docs/astro/deploy-github-integration#deploys), which cancels the first deploy, and applies the most recent.
## See also
* [Create an Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project)
* [Develop your Astro project](/docs/cli/v1.43/develop-project)
# Deploy Dags to Astro
Source: https://astronomer.io/docs/astro/deploy-dags
Learn about the different ways you can deploy code to Astro.
Dag-only deploys are the fastest way to deploy code to Astro. They are recommended if you only need to deploy changes made to the `dags` directory of your Astro project.
Dag-only deploys are enabled by default on all Deployments on Astro Hosted. When they are enabled, you must still [deploy your project image](/docs/astro/deploy-project-image) when you make a change to any file in your Astro project that is not in the `dags` directory, or when you [upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
Dag-only deploys have the following benefits:
* Dag-only deploys are significantly faster than project deploys.
* Deployments pick up Dag-only deploys without restarting. This results in a more efficient use of workers and no downtime for your Deployments.
* If you have a CI/CD process that includes both Dag and image-based deploys, you can use your repository's permissions to control which users can perform which kinds of deploys. See [Dag deploy templates](/docs/astro/ci-cd-templates/template-overview#dag-deploy-templates) for how you can set this up in your CI/CD pipelines.
* You can use Dag deploys to update your Dags when you have slow upload speeds on your internet connection.
## Trigger a Dag-only deploy
Triggering a Dag-only deploy pushes Dags to Astro and mounts them to the workers and schedulers in your Deployment. Dag-only deploys do not disrupt running tasks and do not cause any components to restart when you push code. If you deploy changes to a Dag that is currently running, active task runs finish executing according to the code from before you triggered a deploy. New task runs are scheduled using the code from your latest deploy.
Run the following command to deploy only your `dags` directory to a Deployment:
```sh wrap theme={null}
astro deploy --dags
```
When you run `astro deploy --dags`, all existing Dags in the Deployment are replaced by the new Dags that you are deploying. The deployment process replaces the entire Dag bundle with the new set of Dags, rather than incrementally adding or updating individual Dag files.
Unlike image deploys, Dag deploys do not include pytest as part of the deploy process by default. This means that Dag deploys might include faulty code that would otherwise be caught in an image deploy.
To have the same testing process in Dag deploys, run `astro deploy --dags --pytest`. Note that this can increase the time your deploys take. See [Test your Astro project](/docs/cli/v1.43/test-your-astro-project-locally) for more information about how to use the Astro CLI's pytest features.
## Trigger an image-only deploy
Even if you primarily use Dag-only deploys, you still need to occasionally make image deploys to update your Astro Runtime version or install dependencies. However, depending on your CI/CD strategy, triggering a full project deploy with `astro deploy` might affect your existing Dags.
When you trigger an image-only deploy, it builds every non-Dag file in your Astro project as a Docker image and deploys the image to all Airflow components in a Deployment. This includes your `Dockerfile`, plugins, and all Python and OS-level packages. Dags are not deployed, and your Deployment Dag folder and Dag bundle version are not affected. Because an image-only deploy ignores files in the `dags` directory during the Docker image build, it's important to place any files needed for the build in an appropriate directory such as the `include` directory. See [Airflow best practices](/docs/learn/dag-best-practices#use-a-consistent-file-structure) for information on recommended file structure and other Dag writing best practices. Running the `astro deploy --image` command will also restart the Kubernetes Pods. Image-only deploys are only available when you have Dag-only deploys enabled.
Run the following command to build and deploy only your non-dag files to a Deployment:
```sh wrap theme={null}
astro deploy --image
```
If you use [prebuilt Docker images](/docs/astro/deploy-project-image#deploy-a-prebuilt-docker-image) for your image deploys, you can use both the `--image-name` and `--image` flags to update your image without updating your `dags` folder.
## Enable or disable Dag-only deploys on a Deployment
If you have Workspace Owner permissions, you can enable or disable Dag-only deploys for a Deployment at any time. After you disable Dag-only deploys and trigger a code deploy:
* Any changes to your Dag code are deployed as part of your Astro project Docker image.
* In the Astro UI, your Deployment **DAG Bundle Version** doesn't update when you deploy code.
To determine if turning off Dag-only deploy functionality is the right choice for your organization, contact [Astronomer support](https://cloud.astronomer.io/open-support-request).
Before you enable or disable Dag-only deploys on a Deployment, ensure the following:
* You have access to the latest version of your Deployment's Astro project.
* You can update your Deployment using the Astro CLI.
Carefully read and complete all of the following steps to ensure that disabling or enabling Dag-only deploys doesn't disrupt your Deployment. **Immediately after you update the setting, you must trigger an image deploy to your Astro Deployment using `astro deploy`**. If you don't complete this step, you can't access your Dags in the Airflow UI.
### Prerequisites
Before you enable or disable Dag-only deploys on a Deployment, ensure the following:
* You have Workspace Owner permissions for the Workspace that hosts the Deployment.
* You have access to the latest version of your Deployment's Astro project.
* You can update your Deployment using the Astro CLI.
### Enable Dag-only deploys
Dag-only deploys are enabled by default on Astro Hosted. While enabled:
* You can run `astro deploy --dags` to deploy only Dags to your Deployment.
* In the Astro UI, your Deployment **DAG Bundle Version** updates when you trigger an image deploy or a Dag-only deploy.
* When you only deploy Dags, it doesn't automatically upgrade your Runtime version. You must periodically complete a full image deploy to [upgrade the Runtime version](/docs/runtime/upgrade-astro-runtime).
* Your Deployment includes infrastructure for deploying your Dags separately from your project image. See [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
1. Run the following command to enable dag-only deploys:
```sh wrap theme={null}
astro deployment update --dag-deploy enable
```
2. Run the following command to deploy all of the files in your Astro project as a Docker image:
```sh wrap theme={null}
astro deploy
```
### Disable Dag-only deploys
After you disable Dag-only deploys:
* You can't run `astro deploy --dags` to trigger a Dag-only deploy to your Deployment.
* Any changes to your Dag code are deployed as part of your Astro project Docker image.
* In the Astro UI, your Deployment **DAG Bundle Version** doesn't update when you deploy code.
* Your Deployment doesn't include infrastructure for deploying your Dags separately from your project image. See [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
1. Run the following command to disable dag-only deploys:
```sh wrap theme={null}
astro deployment update --dag-deploy disable
```
2. Run the following command to deploy all of the files in your Astro project as a Docker image:
```sh wrap theme={null}
astro deploy
```
# Deploy dbt projects to Astro
Source: https://astronomer.io/docs/astro/deploy-dbt-project
Learn how to deploy and run dbt projects with Apache Airflow on Astro.
Astro supports a range of options when it comes to adding your dbt project to your Deployment. To orchestrate dbt jobs with Apache Airflow, you first need to deploy your dbt project to Astro along with your dags and the rest of your Airflow code.
This guide includes information on the different options your team has for deploying dbt code to Apache Airflow and Astro. Your team can choose the option that best fits your team's software development lifecycle.
For more information and recommendations on using dbt with Apache Airflow and Astro, see [Orchestrate dbt Core jobs with Airflow and Cosmos](/docs/learn/airflow-dbt).
## Repository strategy
Depending on your organization's software development lifecycle, there are three ways you can organize your dbt project relative to your Astro project:
* In the same Git repository and directory as your Astro project.
* In the same Git repository but in a separate directory.
* In a separate Git repository.
Astro supports all three methods, but Astronomer recommends having your dbt project in the same Git repository as your Astro project, but in a different directory. Then, you can use dbt deploys to independently deploy dbt code to Astro from your dbt directory without needing to deploy either a full Astro project image or your dags. This strategy allows your team maintaining dbt to work independently from your team managing Airflow dags, but team members can all see shared code in a single Git repository.
You can see additional recommendations for Astro repository strategy, in the [Repo strategy best practices](/docs/astro/best-practices/repo-structure) guide.
## Feature overview
Astro supports two basic dbt code deploy strategies. You can:
* **Include dbt code in your Astro project**: Make dbt code directly available in the Docker image powered by Astro Runtime that contains your Astro project. This approach works best for small teams just starting to integrate dbt code in Astro.
* **Use dbt Deploys**: Independently deploy bundles of dbt code directly to Astro, outside the context of your Astro project and Docker image. Astronomer recommends this approach for teams who have dbt code in a dedicated directory or Git repository.
## Option 1: Include dbt code in your Astro project
The most direct way to set up dbt on Astro is by including dbt code in your full image. To accomplish this, Astronomer recommends adding the directory `/dbt` to the top level of your Astro project and including individual dbt projects inside this directory.
To see an example of this pattern, check out the demo repository of [Astronomer Cosmos](https://github.com/astronomer/cosmos-demo).
Finally, to push your new dbt code to your Deployment, perform a deploy with the Astro CLI by running:
```sh wrap theme={null}
astro deploy
```
While this is the quickest way to get dbt code in your Deployment, there can be drawbacks if your team makes more frequent changes to dbt code or uses more advanced CI/CD. These include:
1. Slower build times when changing only dbt code.
2. dbt code must live in the same repository and directory as your Astro project.
3. Multiple teams developing Airflow and dbt separately must re-deploy the entire Astro project for each iteration.
If these downsides become applicable to your team, try Option 2.
## Option 2: Use dbt Deploys to independently ship dbt code
There is a hard limit of 10 dbt bundles per Astro Deployment
dbt Deploys allow you to easily deploy your dbt project to Astro without needing complex processes to incorporate your two sets of code. When you use a dbt Deploy, Astro bundles all files in your dbt project and pushes them to Astro, where they are mounted on your Airflow containers so that your dags can access them. This allows you to deploy dbt code without requiring you to use a full Astro image deploy.
### Prerequisites
* An Astro Deployment
* An Astro project. Astronomer supports both dbt Cloud and dbt Core.
* A dbt project
* The [Astro CLI v1.28 or greater](/docs/cli/v1.43/install-cli)
### Step 1: (Optional) Deploy your full Astro image
In order to first deploy a dbt project to Astro, Astronomer recommends that you have an Astro project already running on your Deployment with dags that need to read from dbt. That way, your dbt project will be read and used when you deploy it.
If you are using a new Deployment, first deploy your Astro project with the Astro CLI by running:
```sh wrap theme={null}
astro deploy
```
### Step 2: Deploy your dbt project
Next, navigate to the directory of your dbt project. This directory should include the `dbt_project.yml` file, as in the case of the [Classic dbt Jaffle Shop](https://github.com/dbt-labs/jaffle-shop-classic?tab=readme-ov-file) in the following example:
```text wrap theme={null}
.
├── etc
├── models
├── seeds
├── .gitignore
├── LICENSE
├── README.MD
└── dbt_project.yml
```
From the CLI, run the following command to deploy your dbt project. The command prompts you to choose the Deployment that you want to deploy your dbt project to.
```sh wrap theme={null}
astro dbt deploy
```
By default, `astro dbt deploy` attaches the dbt code to the default path of `/usr/local/airflow/dbt/`.
See [`astro dbt deploy`](/docs/cli/v1.43/astro-dbt-deploy) for more information about this command.
If your dbt code is accessed at a different path or folder than the default path, specify a custom mount path with the following flag:
```sh wrap theme={null}
astro dbt deploy --mount-path /usr/local/airflow/dbt/example-dbt-project
```
Congratulations, you've added your dbt code to your Deployment! Check the [Astro UI](https://cloud.astronomer.io/) to see more information about your dbt Deploy.
### Delete your dbt project
If you want to remove dbt code from your deployment, you can also delete the dbt project from the Airflow environments where you deployed it. This command does not delete your dbt project source files. It only removes your project from the Airflow containers where it was mounted. When you run this command, you will be prompted to choose the Deployment from which you want to remove the project.
```sh wrap theme={null}
astro dbt delete
```
See [`astro dbt delete`](/docs/cli/v1.43/astro-dbt-delete) for more information about this command.
# Deploy code with the Astro GitHub integration
Source: https://astronomer.io/docs/astro/deploy-github-integration
Learn how to automatically deploy Apache Airflow code to Astro from GitHub with a built-in integration.
Astronomer's built-in GitHub integration is the fastest way to implement CI/CD for Apache Airflow and deploy code to Astro. Astro’s automatic deploy system both eliminates the need to implement GitHub Actions and gives you greater visibility into the code you’re running on Astro.
To deploy code through an integrated GitHub repository, you first connect a GitHub repository with your Astro project to an Astro Workspace. Then, you map a Git branch in that repository to an Astro Deployment. When a pull request is merged into your mapped branch, your code is automatically deployed to Astro.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
Compared to deploying code manually using the Astro CLI or through a custom CI/CD process, using Astro’s GitHub integration:
* Allows you to enforce software development best practices without maintaining custom CI/CD scripts.
* Enables developers to iterate on Dag code quickly.
* Shows Git metadata directly in the Astro UI, including Git commit descriptions.
* Gives you greater visibility into the status and detailed logs of an individual deploy.
## Best practices
To make the most out of the Astro GitHub integration, Astronomer recommends the following:
* Consider mapping long-lasting `main` and `dev` branches in GitHub to Deployments. For example, you would map a `main` branch to a production Deployment and your `dev` branch to your development Deployment. This approach is described in [Develop a CI/CD strategy](/docs/astro/set-up-ci-cd#multiple-environments).
* Run CI checks on your Dags and project code as part of your pull request review process. There is currently no testing included in the default GitHub deploy process, so ensure that your Dag changes pass unit tests before they’re merged and deployed.
* Write descriptive commit messages or pull request descriptions for any project changes. These messages appear in the Astro UI under **Overview** to give your team more context about each deploy.
## Limitations
The Astro GitHub integration isn't supported if any of the following are true:
* You build a custom Astro Runtime image using `docker build` as part of your deploy process, for example to [pull Python packages from a private repository](https://www.astronomer.io/docs/astro). However, using the `-base` distribution of Astro Runtime is supported.
* You need to deploy images from an external or private Docker registry.
* You use the `--image-only` flag in the Astro CLI, or you need to exclude Dags from specific deploys. This is usually the case if you have a multiple-repository deploy strategy as described in [Develop a CI/CD strategy](/docs/astro/set-up-ci-cd#multiple-repositories).
* Your repository is hosted in an on-premises GitHub Enterprise server. To deploy code from an on-premises repository, see [Private network CI/CD templates](/docs/astro/ci-cd-templates/github-actions-private-network).
* If you trigger a deploy that includes a downgrade of Astro Runtime, the deploy will silently fail. Astronomer recommends only downgrading Deployments using [rollbacks](/docs/astro/deploy-history#roll-back-to-a-past-deploy).
There is currently no limit or additional charge for deploying code to Astro with the GitHub integration, but Astronomer might contact you to discuss your usage if you trigger an unusually large number of deploys.
## Prerequisites
* Workspace Admin permissions on an Astro Workspace.
* At least one Astro Deployment.
**To connect to an existing repository**:
* A GitHub user account with read permissions to the repository containing your Astro project. If you don't have these permissions, send a request to your GitHub repository administrator when prompted by Astro. The read permissions are required so that you can map Deployments to repositories in the Astro UI.
* A GitHub repository that contains an [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project). The Astro project can exist at the root directory or any subdirectory in your repository.
* At least one branch, such as a `dev` or `production` branch, that you want to deploy to Astro.
**To create a new repository**:
* A GitHub user account with permission to create repositories. If you belong to a [GitHub Organization](https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles) and don't have these permissions, send a request to your GitHub repository administrator when prompted by Astro.
* After you create and connect to your repository from Astro, you need to add an [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project). The Astro project can exist at the root directory or any subdirectory in your repository.
* After you create and connect to your repository from Astro, you need to make at least one branch, such as a `dev` or `production` branch, that you want to deploy to Astro.
## Connect a GitHub repository to a Workspace
Before you begin, ensure that you’re logged in to GitHub with permissions to read code from the repository where you want to deploy code.
Open the **Git Deploys** page for your Workspace:
In the Astro UI, go to **Settings** > **Workspaces**, select your Workspace, then click **Git Deploys**.
In your Workspace, click **Workspace Settings** > **Git Deploys**.
Then, connect your repository:
1. Click **Authorize GitHub Application** to authorize Astro to a new GitHub account. A window appears instructing you to authorize the **Astro App** on your personal GitHub account. Follow the prompts to authorize the application.
You only need to authorize the GitHub application once. Afterwards, you can connect to additional repositories directly from the Astro UI.
2. Return to the Astro UI. From the **Git Deploys** screen, click **Connect Repository**.
3. Select the organization that contains the repository you want to connect to your Deployment. If your GitHub organization isn't available, click **Add Organization on GitHub**. Select the organization that contains the repository you want to integrate with Astro, then click **Continue**. A new window prompts you to allow **Astro App** to access either all repositories or specific repositories within your GitHub Organization. Astronomer recommends **Only select repositories**. After you return to the Astro UI, refresh the page to make the GitHub organization appear as a selectable option.
4. Choose which repositories you want to enable the app for. You can either select an existing repository, or create a new repository. Then, click **Create and Connect Repository.**
5. Configure the following fields:
* **Repository:** Select the repository you want to integrate with Astro.
* **Astro Project Path:** Specify the path to your Astro project relative to your GitHub repository directory, up to and including the Astro project folder. For example, for a project in `github-repository/myorg/myprojects/my-astro-project`, enter `myorg/myprojects/my-astro-project`. If the path is configured incorrectly, code doesn't deploy to Astro from GitHub. You can change this path after you create the integration by editing the **Branch Configuration** setting in the Astro UI.
6. Click **Connect Repository**.
7. Map specific branches in your repository to Deployments in your Workspace. For example, you can map a development branch and your production branch to separate Deployments, so that bugs in development don’t affect your production data pipelines. When you map a branch to a Deployment, any future commits to the Astro project in that branch trigger a code deploy to Astro.
You can add and edit branch mappings to connected GitHub repositories at any time from the **Git Deploy** page in the Astro UI.
Any commits to your mapped branches will now trigger a code deploy to the corresponding Deployment.
## Deploy from GitHub to Astro
To deploy code from your GitHub repository to Astro, you can:
* Make a direct commit to one of your mapped branches.
* Merge a pull request against one of your mapped branches.
* Select **Trigger Git Deploy** from the **More actions** menu in your Deployment settings. This deploys the latest commit from your branch. Astronomer recommends this action when your Git branch and Astro fall out of sync and you don't want to create a new commit to get them back in sync.
* Select **Trigger Git Deploy** from the **More actions** menu for a previously failed deploy. This redeploys that particular Git commit even if it's not necessarily the latest commit in your repository or branch. Astronomer recommends this action when a deploy fails and you want to try it again without creating a new commit.
Any of these actions triggers the Astro App to deploy your Astro project to the mapped Astro Deployment. When Dag-only deploys are enabled, your GitHub repository triggers:
* A Dag-only deploy if only your Dags are changed.
* A full project image deploy if you change a configuration in your project.
If Dag-only deploys are disabled, all code changes will trigger a full project image deploy. To learn more about Dag-only deploys, see [Deploy Dags to Astro](/docs/astro/deploy-dags).
You can check the status of your deploy in the Astro UI in the Deploy History listing on your Deployment's **Overview** tab.
## Review code deploys from the Astro UI
When you trigger a code deploy by committing a change to one of your mapped branches, details about the code deploy appear in the Astro UI. For past and currently running deploys, you can review:
* Whether a deploy was triggered by the integration.
* At what time the deploy was triggered.
* Which pull request or commit triggered the deploy. This includes the Git commit description and a link to your pull request if applicable.
To review code deploys:
1. In the Astro UI, open your Deployment.
2. Click **Overview**.
3. Deploys triggered by the Astro App include a commit ID in their **Description** and are **Deployed By** the **GitHub App.** Click on a deploy triggered by the Astro App to see the logs for the deploy.
## How it works
The Astro GitHub integration works through a [GitHub app](https://docs.github.com/en/apps/overview) that you install in your GitHub repository. The app is also authorized to act on behalf of your personal account so that it can see the GitHub organizations and repositories you have access to.
### Deploys
When you make a commit or merge a pull request to a mapped branch in your repository, the GitHub app sends a push event to the Astro API. After the Astro API confirms that the push event should result in a deploy, your project code is sent to Deployment-specific workers on Astro that deploy the code to your Deployment.
If an additional deploy is triggered while a deploy is currently processing for the same Deployment, Astro will terminate the first deploy and begin processing the second deploy. The first deploy will appear with a **Failed** state in your deploy history.
### Rollbacks
When you roll back a deploy created by the GitHub integration, Astro doesn't roll back the code in your GitHub repository. Therefore, rollbacks should only be used as a last resort due to the potential for your repository code to become out of sync with your deploy code.
If you do roll back a deploy, manually revert the code in your GitHub repository as soon as possible so that it matches the code running in your rolled back deploy. For more information, see [What happens during a rollback](/docs/astro/deploy-history#what-happens-during-a-deploy-rollback).
# Roll back to previous deploys using deploy histories
Source: https://astronomer.io/docs/astro/deploy-history
View a historical record of code deploys to an Astro Deployment and roll back to specific deploys when something goes wrong.
The **Overview** tab in the Astro UI shows you a record of all code deploys to your Deployment. Use this page to track the development of a Deployment and to pinpoint when your team made key changes to code.
Astronomer stores the image and Dags for all deploys made in the last 90 days. You can trigger a rollback to any of these deploys so that your Deployment starts running a previous version of your code.
Deploy rollbacks are an emergency option if a Deployment unexpectedly stops working after a recent deploy. For example, if one of your Dags worked in development but suddenly fails in a mission-critical production Deployment, you can roll back to your previous deploy to quickly get your pipeline running again. This allows you to troubleshoot the issue more thoroughly in development before redeploying to production. You can roll back to any deploy in the last three months regardless of your Runtime version, Dag code, or Deployment settings.
Astro supports rolling back from Airflow 3 to Airflow 2 but not all Airflow 3.x Deployments can be reverted to all Airflow 2.x versions. Review the [Airflow 3 to Airflow 2 rollback requirements](/docs/astro/airflow3/upgrade-af3#airflow-3-to-airflow-2-rollback-support-and-requirements).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## View deploy history
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Overview**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click **Overview**.
For each deploy, the **Deploy History** table shows the user who made the deploy, when they made the deploy, what image they used, the type of deploy, and any descriptions they added to the deploy.
### Types of deploys
There are different types of deploys, which are shared in the Deploy History table. You can read more about the different deploy options in [Deploy code to Astro](/docs/astro/deploy-code). These deploy types include:
* Image-only deploy
* Dag-only deploy
* GitHub deploy
* dbt project deploy
## Add a description to a deploy
Adding a description to a deploy is a helpful way to let other users know why you made a deploy and what the deploy contains. Descriptions appear in your deploy's entry in the **Deploy History** table.
To add a description to a deploy, specify the `--description` flag when you run `astro deploy`. For example:
```sh wrap theme={null}
astro deploy --description "Added a new 'monitor_weather' dag"
```
If you deploy to Astro through CI/CD, Astronomer recommends adding the Git commit ID or equivalent version ID as the description for your deploy. This serves as a reference if you need to roll back your Git repository when you roll back your Deployment.
## Roll back to a past deploy
Astronomer recommends triggering Deployment rollbacks only as a last resort for recent deploys that aren't working as expected. Deployment rollbacks can be disruptive, especially if you triggered multiple deploys between your current version and the rollback version. See [What happens during a deploy rollback](#what-happens-during-a-deploy-rollback) before you trigger a rollback to anticipate any unexpected effects.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Overview**.
3. Locate the deploy you want to roll back to. In the **Rollback to** column for the deploy, click **Deploy**.
4. Provide a description for your rollback, then complete the confirmation to trigger the rollback.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click **Overview**.
3. Locate the deploy you want to roll back to. In the **Rollback to** column for the deploy, click **Deploy**.
4. Provide a description for your rollback, then complete the confirmation to trigger the rollback.
You can roll back to any deploy within the last three months. If your last deploy was more than three months ago, you can only roll back to that deploy. After the rollback completes, the **Deploy History** table shows your rollback deploy as the most recent deploy and includes both your rollback description and rollback deploy time. Your Docker image tag, Dag bundle name, and dbt bundles are the same as the previous version you rolled back to. The historic deploy that you rolled back to still appears in chronological order in the table.
For example, consider a user who, on November 8, 2023 at 13:00, rolled back to a deploy from November 6, 2023 at 14:00. At the top of the **Deploy History** table, an entry for the rollback deploy would have the following information:
* **Time**: **14:00 11/8/2023**
* **Docker image**: **deploy-2023-11-6T14-00** (Or the custom name of your historical image tag)
* **DAG Bundle Version**: **2023-11-16T14:00:00.0000000Z**
* **Deploy description**: Your rollback description.
### What happens during a deploy rollback
A deploy rollback is a new deploy of a previous version of your code. This means that the rollback deploy appears as a new deploy in **Deploy History**, and the records for any deploys between your current version and rollback version are still preserved. In Git terms, this is equivalent to `git revert`.
When you trigger a rollback, the following information is rolled back:
* All project code, including Dags.
* Your Astro Runtime version.
* Your Deployment's Dag deploy setting.
The following information isn't rolled back:
* Your Deployment's resource configurations, such as executor and scheduler configurations.
* Your Deployment's environment variable values.
* Any other Deployment settings that you configure through the Astro UI, such as your Deployment name and description.
* For Runtime version downgrades, any data related to features that are not available in the rollback version are erased from the metadata database and not recoverable.
A rollback's effect on running tasks depends on whether the rollback downgrades your Deployment:
* If a rollback downgrades a Deployment to a previous version of Astro Runtime, all currently running tasks fail immediately. If a task has any remaining retries, those retries will run after the rollback is complete.
* If a rollback doesn't include a downgrade, any currently running tasks from before the rollback continue to run your latest code, while new Pods for downstream tasks run the code from the rollback version. This is identical behavior to pushing new code as described in [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
## Roll back a Remote Execution Deployment
Remote Execution Agent Deployments require special handling for rollbacks.
The standard Astro deploy rollback doesn't manage Agent versions. This means you must manually roll back Remote Execution Agents before rolling back your Deployment in Astro.
Failing to do so can result in incompatibility between your Remote Agent and Astro Deployment causing interrupted workflows.
Update each Remote Execution Agent to the desired target Runtime/Agent version by reverting their containers to the appropriate image. Ensure all agents are successfully reverted before proceeding to the next step.
Trigger a [Astro Deployment rollback](#roll-back-to-a-past-deploy) to a deployment that is compatible with your Remote Agent's updated version.
# Deploy an Astro project as an image
Source: https://astronomer.io/docs/astro/deploy-project-image
Deploy a complete Astro project to a Deployment as a Docker image.
In a full deploy, the Astro CLI takes every file in your Astro project to builds them into a Docker image. This includes your `Dockerfile`, dags, plugins, and all Python and OS-level packages. The CLI then deploys the image to all Airflow components in a Deployment.
Use this document to learn how full deploys work and how to manually push your Astro project to a Deployment. For production environments, Astronomer recommends automating all code deploys with CI/CD. See [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
See [dags-only deploys](/docs/astro/deploy-dags) to learn more about how to deploy your dags and images separately.
## Prerequisites
* The [Astro CLI](/docs/cli/v1.43/overview) is installed in an empty directory. If you're using an Apple M1 system with Astro Runtime 6.0.4 or later for local development, you must install Astro CLI 1.4.0 or later to deploy to Astro.
* An Astro Workspace with at least one [Deployment](/docs/astro/create-deployment).
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Step 1: Authenticate to Astro
Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
After running this command, you are prompted to open your web browser and log in to the Astro UI. After you complete this login, you are automatically authenticated to the CLI.
If you have API credentials set as OS-level environment variables on your local machine, you can deploy directly to Astro without needing to manually authenticate. This setup is required for automating code deploys with [CI/CD](/docs/astro/set-up-ci-cd).
## Step 2: Push your Astro project to an Astro Deployment
To deploy your Astro project, run:
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
After you select a Deployment, the CLI parses your dags and runs a suite of pytests to ensure that they don't contain basic errors. This testing process is equivalent to running `astro dev parse` and `astro dev pytest` in a local Airflow environment. If any of your dags fail this testing process, the deploy to Astro also fails. To force a deploy even if your project has errors, you can run `astro deploy --force`. For more information about using pytests, see [Troubleshoot your local Airflow environment](/docs/cli/v1.43/run-airflow-locally) and [Testing Airflow dags](/docs/learn/testing-airflow).
If your code passes the testing phase, the Astro CLI deploys your project in two separate, simultaneous processes:
* The Astro CLI uploads your `dags` directory to Astronomer-hosted blob storage. Your Deployment downloads the dags from the blob storage and applies the code to all of its running Airflow containers.
* The Astro CLI builds all other project files into a Docker image and deploys this to an Astronomer-hosted Docker registry. The Deployment then applies the image to all of its running Airflow containers.
See [What happens during a project deploy](#what-happens-during-a-project-deploy) for a more detailed description of how the Astro CLI and Astro work together to deploy your code.
If you use Docker Desktop, ensure that the [**Use containerd for pulling and storing images**](https://docs.docker.com/desktop/containerd/#turn-on-the-containerd-image-store-feature) setting is turned off. Otherwise, you might receive errors when you run `astro deploy` such as:
```text wrap theme={null}
Push access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
# or
Unable to find image 'barren-ionization-0185/airflow:latest' locally
Error response from daemon: pull access denied for barren-ionization-0185/airflow, repository does not exist or may require 'docker login'
```
## Step 3: Validate your changes
When you start a code deploy to Astro, the status of the Deployment is **DEPLOYING** until it is determined that the underlying Airflow components are running the latest version of your code. During this time, you can hover over the status indicator to determine whether your entire Astro project or only dags were deployed .
When the deploy completes, the **Docker Image** field in the Astro UI are updated depending on the type of deploy you completed.
* The **Docker Image** field displays a unique identifier generated by a Continuous Integration (CI) tool or a timestamp generated by the Astro CLI after you complete an image deploy.
To confirm a deploy was successful, verify that the running versions of your Docker image and dag bundle have been updated.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Review the information in the **Docker Image** and **DAG Bundle Version** field to determine the Deployment code version.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Review the information in the **Docker Image** and **DAG Bundle Version** field to determine the Deployment code version.
## What happens during a project deploy
### Hosted execution mode
Read this section for a more detailed description of the project deploy process to a [Hosted execution mode](/docs/astro/execution-mode) Airflow 3 Deployment.
Your Deployment uses the following components to process your code deploy:
* A proprietary operator for deploying Docker images to your Airflow containers
* An Astro bundle backend for retrieving dags and non-dag bundles from versioned storage
* A blob storage container hosted by Astronomer
When you run `astro deploy`, the Astro CLI deploys all non-dag files in your project as an image to an Astronomer-hosted Docker registry. The proprietary operator pulls the images from a Docker registry, then updates the running image for all Airflow containers in your Deployment. Dag changes are deployed through a separate and simultaneous process.
For Airflow 3 Deployments with dag deploys enabled, the Astro bundle backend ensures [dag versioning](/docs/astro/dag-versioning) and dag rollbacks work out of the box. If dag deploys are disabled, the dags are stored in the image and can only be updated by image deploys. The Astro bundle backend also supports bundle deploys, enabling deployment of non-dag bundles such as `astro dbt deploy`. The backend downloads these bundles and mounts them at the configured path in the Airflow containers.
This process is different if your Deployment has dag-only deploys disabled. See [Enable/disable dag-only deploys on a Deployment](/docs/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment) for how the process changes when dag-only deploys are disabled.
### Remote execution mode
For [Remote execution mode](/docs/astro/execution-mode) Deployments, dag deploys are always disabled, and you must configure either the `LocalDagBundle` or the `GitDagBundle` so that [Remote Execution Agents](/docs/astro/remote-execution-configure-agents) in your environment can access your dags whether they are locally stored or in a git repository.
`LocalDagBundle` is the default Dag bundle type for the `dagBundleConfigList` config option but you can alternatively configure a git connection with `GitDagBundle` for extended versioning capabilities. See [Dag bundles](/docs/astro/remote-execution-configure-dag-sources) for more information.
### How Deployments handle code deploys
After a Deployment receives an image deploy, Astro gracefully terminates all of it's Airflow component containers, which means the existing worker Pods are allowed to finish their running tasks but the new worker Pods run your new code. For dag-only deploys, the Airflow component containers, including any workers or Kubernetes worker Pods that are currently running tasks, are preserved.
If you deploy code to a Deployment that is running a previous version of your code, then the following happens:
* Tasks that are `running` continue to run on existing workers and are not interrupted unless the task does not complete within 24 hours of the code deploy.
* One or more new workers are created alongside your existing workers and immediately start executing scheduled tasks based on your latest code.
These new workers execute downstream tasks of dag runs that are in progress. For example, if you deploy to Astronomer when `Task A` of your dag is running, `Task A` continues to run on an old Celery worker. If `Task B` and `Task C` are downstream of `Task A`, they are both scheduled on new Celery workers running your latest code.
This means that dag runs could fail due to downstream tasks running code from a different source than their upstream tasks. Dag runs that fail this way need to be fully restarted from the Airflow UI so that all tasks are executed based on the same source code.
Astronomer sets a grace period of 24 hours for all workers to allow running tasks to continue executing. This grace period is not configurable. If a task does not complete within 24 hours, its worker is terminated. Airflow marks the task as a [zombie](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#zombie-undead-tasks) and it retries according to the task's retry policy. This is to ensure that our team can reliably upgrade and maintain Astro as a service.
If you want to force long-running tasks to terminate sooner than 24 hours, specify an [`execution_timeout`](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#timeouts) in your dag's task definition.
Alternatively, if you find you have many long-running tasks that exceed 24 hours, you might want to refactor your dags using [deferrable operators](/docs/learn/deferrable-operators), as Astro does not guarantee reliability for tasks with a duration that exceeds 24 hours.
## Deploy a prebuilt Docker image
By default, running `astro deploy` with the Astro CLI builds your Astro project into a Docker image and deploys it to Astro. In some cases, you might want to skip the build step and deploy a prebuilt Docker image instead.
Deploying a prebuilt Docker image allows you to:
* Test a single Docker image across Deployments instead of rebuilding it each time.
* Reduce the time it takes to deploy. If your Astro project has a number of packages that take a long time to install, it can be more efficient to build it separately.
* Enforce separation between build and deploy stages in your CI/CD pipeline.
* Specify additional mounts and arguments in your project, which is required for setups such as [installing Python packages from private sources](/docs/cli/v1.43/private-python-packages#install-python-packages-from-a-private-pypi-index).
### Build and deploy a local image
To build an image locally and deploy it to Astro:
1. Run `docker build` from an Astro project directory or specify the command in a CI/CD pipeline. This Docker image must be based on Astro Runtime and be available in a local Docker registry. If you run this command on an Apple M1 computer or on a computer with an ARM64 processor, you must specify `--platform=linux/amd64` or else the deploy will fail. Astro Deployments require an AMD64-based image and do not support ARM64 architecture.
2. (Optional) Test your Docker image in a local Airflow environment by adding the `--image-name ` flag to any of the following commands:
* `astro dev start`
* `astro dev restart`
* `astro dev parse`
* `astro dev pytest`
3. Run `astro deploy --image-name ` or specify the command in a CI/CD pipeline.
### Pull and deploy from an artifact registry
If your organization builds and stores Astro Runtime images in an external artifact registry, you can pull the image and deploy it to Astro without rebuilding. This is useful when your CI/CD pipeline separates build and deploy stages, or when a centralized build process publishes images that multiple teams consume.
1. Authenticate to your artifact registry. The following examples show authentication commands for common registries:
**Google Artifact Registry:**
```sh wrap theme={null}
gcloud auth configure-docker -docker.pkg.dev
```
**Amazon ECR:**
```sh wrap theme={null}
aws ecr get-login-password --region | docker login --username AWS --password-stdin .dkr.ecr..amazonaws.com
```
**Azure Container Registry:**
```sh wrap theme={null}
az acr login --name
```
2. Pull the prebuilt image from the registry:
```sh wrap theme={null}
docker pull /:
```
3. Deploy the pulled image to Astro:
```sh wrap theme={null}
astro deploy --image-name /:
```
The image must be based on Astro Runtime. No rebuild occurs during this process. The Astro CLI pushes the pulled image directly to Astro.
For a complete CI/CD example, see the [Prebuilt image GitHub Actions template](/docs/astro/ci-cd-templates/github-actions-private-network#setup).
### Additional options
If you have dag-only deploys enabled, you can also use the `--image` flag to deploy a prebuilt image without also deploying your dags folder. Use `astro deploy --image-name --image`.
For more information about the `--image-name` option, see the [CLI command reference](/docs/cli/v1.43/astro-deploy).
If you build an AMD64-based image and run `astro deploy` from an Apple M1 computer, you might see a warning in your terminal. You can ignore the warning.
```text wrap theme={null}
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform
(linux/arm64/v8) and no specific platform was requested
```
## Related documentation
* [Choose a CI/CD Strategy for deploying code to Astro](/docs/astro/set-up-ci-cd)
* [Develop your project](/docs/cli/v1.43/develop-project)
* [Set environment variables](/docs/astro/environment-variables)
# Initialize and deploy Remote Execution projects
Source: https://astronomer.io/docs/astro/deploy-project-remote-execution
Initialize and deploy an Astro project for Remote Execution.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Remote Execution Deployments require two sets of container images:
* **Astro Runtime images**: Astronomer's managed distribution of Apache Airflow, powering all Deployments on Astro.
* **Remote Execution Agent images**: Specifically built for Remote Execution Agents.
When using Remote Execution mode, the server (Deployment on Astro) and client (Remote Execution Agents) are deployed separately. You must maintain dedicated client images for the Remote Execution Agents. These client images are based on the [Astro Remote Execution Agent](/docs/astro/agent-release-notes) image and must be pushed to a remote image registry accessible by your Agents.
Because these client images are distinct from the usual Astro Runtime images, you need to use dedicated commands to build and deploy them.
This guide explains how to initialize an Astro project for Remote Execution and how to build and push client images for Remote Execution Agents.
For details about Astro project image deploys with Remote Execution, see [Deploy an Astro project](/docs/astro/deploy-project-image#remote-execution-mode).
For best practices and procedures to upgrade your Astro Runtime version, including for Remote Execution Deployments, see [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
## Prerequisites
* The [Astro CLI](/docs/cli/v1.43/overview).
* An Astro Workspace with at least one [Remote Execution Deployment](/docs/astro/execution-mode).
* [Remote Execution Agents](/docs/astro/remote-execution-configure-agents) registered with your Deployment.
* A remote Docker registry accessible from your environment where Remote Execution Agents run.
## Build and deploy your Remote Execution project
Run:
```sh wrap theme={null}
astro dev init my-remote-project --remote-execution-enabled --remote-image-repository
```
This generates the required files for building client images.
If you omit `--remote-image-repository`, you can configure it later with:
```sh wrap theme={null}
astro config set remote.client_registry
```
* `Dockerfile.client` – Dockerfile for client images
* `requirements-client.txt` – Python dependencies for client images
* `packages-client.txt` – OS-level packages for client images
Set up dag access for your Remote Execution Agents using either `LocalDagBundle` or `GitDagBundle`.
Update your Agent's Helm chart `values.yaml` accordingly. See [Dag bundles](/docs/astro/remote-execution-configure-dag-sources).
Before you can deploy a client image, you must be logged in to your remote Docker registry.
The Astro CLI does not manage authentication for your registry.
Log in using:
```sh wrap theme={null}
docker login --username --password-stdin
```
Replace `` and `` with the details for your registry.
From your project directory, deploy the Astro Runtime image to your Remote Execution Deployment:
```sh wrap theme={null}
astro deploy
```
This command builds your project and pushes the updated Astro Runtime image to Astro, updating the Airflow components in your managed Astro Deployment.
Monitor the Deployment to confirm that the new version is running in the Astro UI.
The [`astro deploy`](/docs/cli/v1.43/astro-deploy) command updates the orchestration plane only. To update the execution plane, follow the Remote Execution Agent image steps below.
From your project directory, run:
```sh wrap theme={null}
astro remote deploy
```
You can use additional flags as needed, such as:
```sh wrap theme={null}
astro remote deploy --platform linux/amd64
astro remote deploy --platform linux/amd64,linux/arm64
astro remote deploy --image-name my-custom-image:tag
astro remote deploy --build-secret id=mysecret,src=secrets.txt
```
**Platform mismatch can cause build failures**
By default, `astro remote deploy` builds an image for your computer’s platform. For example, if you are on a Mac with Apple silicon, it will build for `linux/arm64`.
If your Agents need `linux/amd64`, the image may not work.
To avoid issues, always set the `--platform` flag:
`astro remote deploy --platform linux/amd64,linux/arm64`
This command only pushes the client image to your remote registry. See [`astro remote`](/docs/cli/v1.43/astro-remote) for more information.
After pushing the image, you must update your Agent configuration to actually use it:
1. Edit your Agent Helm chart `values.yaml`.
2. Update the `image` field for each of the `worker`, `dagProcessor`, and `triggerer` component sections to the new client image reference (as just pushed).
3. Apply the changes by running:
```sh wrap theme={null}
helm upgrade -f values.yaml
```
Agents will not use the new client image until this update is performed.
**CI/CD pipeline**
If you manage your Agent deployments via a CI/CD pipeline, update your pipeline to set the new client image in the Helm `values.yaml` file, and trigger the deployment process to roll out the change automatically.
This ensures that updates to the client image are reliably applied across all agents without manual intervention.
## Related documentation
* [Remote Execution mode overview](/docs/astro/execution-mode)
* [Remote Execution Agents](/docs/astro/remote-execution-configure-agents)
* [Dag bundles](/docs/astro/remote-execution-configure-dag-sources)
* [`astro remote` CLI reference](/docs/cli/v1.43/astro-remote)
* [`astro dev init` CLI reference](/docs/cli/v1.43/astro-dev-init)
# Deployment details
Source: https://astronomer.io/docs/astro/deployment-details
Edit information about your Deployment, like metadata settings, observability settings, and user access settings.
Deployment details define how users can view and interact with your Deployment. They include metadata settings, observability settings, and user access settings.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Update a Deployment name and description
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Basic** section, update the Deployment **Name** or **Description**.
4. Click **Update Deployment**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **More Actions** menu of the Deployment you want to update, and select **Edit Deployment**.
3. In the **Basic** section, update the Deployment **Name** or **Description**.
4. Click **Update Deployment**.
## Configure Deployment contact emails
Configure a contact email to get proactive alerts directly from Astronomer support. Astronomer support uses contact emails to notify recipients in case there's an issue with the infrastructure for your Deployment, such as a problem with your scheduler or worker components.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the **Details** tab. In the **Advanced** section, click **Edit**.
3. To add an alert email:
* In the **Contact Emails** section, click **Add Email**.
* Enter an email address and then click **Add**.
4. To delete an alert email address:
* In the **Contact Emails** section, click **Delete** next to the email you want to delete.
* Click **Yes, Continue**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Details** tab. In the **Advanced** section, click **Edit**.
3. To add an alert email:
* In the **Contact Emails** section, click **Add Email**.
* Enter an email address and then click **Add**.
4. To delete an alert email address:
* In the **Contact Emails** section, click **Delete** next to the email you want to delete.
* Click **Yes, Continue**.
In addition to alert emails for your Deployments, Astronomer recommends configuring [Astro alerts](/docs/astro/alerts) and subscribing to the [Astro status page](https://status.astronomer.io). When you subscribe to the status page, you'll receive email notifications about system-wide incidents as they happen.
### Fallback emails
For Deployments without a contact email set, Astronomer sets a fallback value to ensure critical issues don’t get missed. To see the fallback values for a Deployment without a contact email, go to the **Details** tab and find **Contact Emails** in the **Advanced** section. To override the fallback values displayed, set a contact email. We recommend that every Astro Deployment have a contact email set to ensure timely receipt of notifications.
For Deployments without a contact email, Astronomer uses the Deployment Creator as the fallback. For Deployments without a valid Deployment Creator, Astro uses Workspace Owners. In Workspaces without an Owner, Astro uses Organization Owners. Check that your Deployments, Workspaces, and Organizations each have a valid owner to ensure that key support communications don’t get missed.
## Enforce CI/CD deploys
This is feature is only available if you are on the **Business** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
By default, any user can deploy code either directly from the Astro CLI or from a CI/CD process that is authenticated with an API token. To help your team protect production environments from manual code deploys that circumvent your organization's CI/CD processes and checks, you can configure a Deployment so that users can't deploy code manually using the Astro CLI.
After you enable CI/CD enforcement on a Deployment, the Deployment accepts a deploy only if the deploy is authenticated using a Deployment API token, Workspace API token, or Organization API token. Astronomer recommends enabling this setting for all production environments.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Advanced** section, find **CI/CD Enforcement** and click the toggle to **On**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **More Actions** menu of the Deployment you want to update, and select **Edit Deployment**.
3. In the **Advanced** section, find **CI/CD Enforcement** and click the toggle to **On**.
You can also update your Workspace so that any new Deployments in the Workspace enforce CI/CD deploys by default. See [Update general Workspace settings](/docs/astro/manage-workspaces#update-general-workspace-settings).
When CI/CD enforcement is enabled for a Deployment, you can't enable or disable [Dag-only deploys](/docs/astro/deploy-dags) for the Deployment.
To enable or disable dag-only deploys when CI/CD enforcement is turned on:
1. Turn **CI/CD Enforcement** to **Off**.
2. Enable or disable the dag-only deploy feature. See [Enable or disable dag-only deploys](/docs/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment).
3. Turn **CI/CD Enforcement** back to **On**.
You have to only complete these steps once. Once the dag-only deploy feature is enabled or disabled, you can turn CI/CD enforcement on or off at any time.
## Delete a Deployment
When you delete a Deployment, all infrastructure resources assigned to the Deployment are immediately deleted.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Delete Deployment**.
3. Enter the Deployment name shown in the dialog, then click **Yes, Continue**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **More Actions** menu of the Deployment you want to delete, and select **Delete Deployment**.
3. Enter `Delete` and click **Yes, Continue**.
## Find Deployment external IP addresses
Each Astro Deployment has its own external IP addresses. Allowlist these addresses on any external service as a first step to create a connection between the Deployment and the service.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Select the **Details** tab.
3. In the **Other** section, find the **External IPs** associated with the Deployment.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Select the **Details** tab.
3. In the **Other** section, you can find the **External IPs** associated with the Deployment.
# Configure Deployment resources
Source: https://astronomer.io/docs/astro/deployment-resources
Configure your Deployment resource settings to optimize Deployment performance.
Your Deployment resources are the computational resources Astro uses to run Airflow in the cloud. Update Deployment resource settings to optimize performance and reduce the cost of running Airflow in the cloud.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Update Airflow configurations
To update a Deployment's [Airflow configurations](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html), you set the configurations as environment variables on Astro. See [Set Airflow configurations using environment variables](/docs/astro/manage-env-vars).
## Update environment objects
You can add, update, and delete Airflow connections that were added through the Astro UI from your Deployment page. To edit a Deployment's [linked connections](/docs/astro/manage-connections-variables#astro-environment-manager), click the **Environment** tab, and then select the connection you want to **Edit**. See [Create connections with the Astro UI](/docs/astro/create-and-link-connections) for more options.
## Deployment executor
Astro supports three executors: the Astro, Celery, and Kubernetes executors. Only Celery and Kubernetes executors are available in the Apache Airflow open source project.
* [Celery executor](/docs/astro/celery-executor)
* [Kubernetes executor](/docs/astro/kubernetes-executor) (*Requires Astro Runtime version 8.1.0 or later*)
* [Astro executor](/docs/astro/astro-executor) (*Only available for Airflow 3.x Deployments*)
See [Choose an executor](/docs/astro/executors-overview#choose-an-executor) to understand the benefits and limitations of each executor. When you've determined the right executor type for your Deployment, complete the steps in the following topic to update your Deployment's executor type.
### Update the Deployment executor
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Execution** section, select **Astro**, **Celery**, or **Kubernetes** in the **Executor** list.
If you're moving from the Astro or Celery to the Kubernetes executor, all existing worker queues are deleted. Running tasks stop gracefully and all new tasks start with the selected executor.
4. Click **Update Deployment**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Details** tab and then click **Edit** in the **Execution** section.
3. In the **Execution** section, select **Astro**, **Celery** or **Kubernetes** in the **Executor** list.
If you're moving from the Astro or Celery to the Kubernetes executor, all existing worker queues are deleted. Running tasks stop gracefully and all new tasks start with the selected executor.
4. Click **Update Deployment**.
See [Configure an executor](/docs/astro/executors-overview) for more information about each available executor type, including how to optimize executor usage.
## Configure Kubernetes Pod resources
The [Kubernetes executor](/docs/astro/kubernetes-executor) and [`KubernetesPodOperator`](/docs/astro/kubernetespodoperator) both use Kubernetes Pods to execute tasks. While you still need to configure Pods in your Dag code to define individual task environments, you can set some safeguards on Astro so that tasks in your Deployment don't request more CPU or memory than expected.
Set safeguards by configuring default Pod limits and requests from the Astro UI. If a task requests more CPU or memory than is currently allowed in your configuration, the task fails.
By default, Astro supports a maximum `KubernetesExecutor` Pod size of 43 vCPU and 86 GiB of memory. Astro can support Pod sizes up to 86 vCPU and 172 GiB of memory on request. If your workloads require more resources, contact [Astronomer support](/docs/astro/astro-support) to request larger Pod sizes for your Deployment.
To customize the resources for individual task Pods beyond the defaults, see [Customize a task's Kubernetes Pod](/docs/astro/kubernetes-executor#customize-a-task’s-kubernetes-pod).
To manage Kubernetes resources programmatically, you can set default Pod limits and resources with the [`astro deployment create`](/docs/cli/v1.43/astro-deployment-create) and [`astro deployment update`](/docs/cli/v1.43/astro-deployment-update) Astro CLI commands, or by adding the configurations to a [Deployment file](/docs/astro/deployment-file-reference).
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Execution** section, configure the following values:
* **CPU Quota**: The maximum combined CPU usage across all running Pods on your Deployment.
* **Memory Quota**: The maximum combined memory usage across all running Pods on your Deployment.
* **Default Pod Size**:
* **CPU**: The amount of CPUs that your tasks run with if no CPU usage is specified in their Pod configuration.
* **Memory**: The amount of memory that your tasks run with if no memory usage is specified in their Pod configuration.
* **Storage**: Choose the amount of ephemeral storage in GiB assigned to each pod in the Astro UI. This storage volume is transient and allows for the temporary storage and processing of data. The pod is assigned the minimum 0.25 GiB by default. The maximum possible quota is 100 GiB. Only ephemeral storage requests that are greater than the default minimum of 0.25 GiB are chargeable. Note that this feature is in [Preview](/docs/astro/feature-previews).
For a Deployment running in a Hosted dedicated or shared cluster, the maximum possible **CPU** quota is 6400 vCPU and maximum **Memory** quota is 12800 GiB.
**Astro Hosted**
On Astro Hosted, Astro automatically sets resource requests equal to limits for task Pods. This ensures Pods receive a Kubernetes [Guaranteed Quality of Service (QoS) class](https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed), which prevents resource contention and eviction. Because Astro uses the limit values as both requests and limits, your Pods are billed based on the **CPU** and **Memory** limits you configure, even if actual usage is lower. To avoid unexpected charges, set limits close to the resources your tasks require.
Check your [Billing and usage](/docs/astro/manage-billing) to view your resource use and associated charges.
4. Click **Update Deployment**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Options** menu and select **Edit Deployment**.
3. In the **Execution** section, configure the following values:
* **CPU Quota**: The maximum combined CPU usage across all running Pods on your Deployment.
* **Memory Quota**: The maximum combined memory usage across all running Pods on your Deployment.
* **Default Pod Size**:
* **CPU**: The amount of CPUs that your tasks run with if no CPU usage is specified in their Pod configuration.
* **Memory**: The amount of memory that your tasks run with if no memory usage is specified in their Pod configuration.
* **Storage**: Choose the amount of ephemeral storage in GiB assigned to each pod in the Astro UI. This storage volume is transient and allows for the temporary storage and processing of data. The pod is assigned the minimum 0.25 GiB by default. The maximum possible quota is 100 GiB. Only ephemeral storage requests that are greater than the default minimum of 0.25 GiB are chargeable. Note that this feature is in [Preview](/docs/astro/feature-previews).
For a Deployment running in a Hosted dedicated or shared cluster, the maximum possible **CPU** quota is 6400 vCPU and maximum **Memory** quota is 12800 GiB.
**Astro Hosted**
On Astro Hosted, Astro automatically sets resource requests equal to limits for task Pods. This ensures Pods receive a Kubernetes [Guaranteed Quality of Service (QoS) class](https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed), which prevents resource contention and eviction. Because Astro uses the limit values as both requests and limits, your Pods are billed based on the **CPU** and **Memory** limits you configure, even if actual usage is lower. To avoid unexpected charges, set limits close to the resources your tasks require.
Check your [Billing and usage](/docs/astro/manage-billing) to view your resource use and associated charges.
4. Click **Update Deployment**.
## Workers and worker queues
Workers are the Airflow components that execute your tasks. How workers are configured depends on the executor your Deployment uses:
* **Astro and Celery executors**: Workers run in configurable *worker queues*. Each worker queue defines the worker type (size), concurrency, autoscaling limits, and ephemeral storage for its workers. You can create multiple worker queues to optimize execution environments for different types of tasks. For example, you can assign resource-intensive machine learning tasks to a queue with larger workers, while running lightweight SQL tasks on smaller workers. See [Configure worker queues](/docs/astro/configure-worker-queues) for setup instructions.
* **Kubernetes executor**: Each task runs in its own dedicated Kubernetes Pod rather than in a shared worker. You configure Pod resources through default Pod size settings and per-task `pod_override` configurations. See [Configure Kubernetes Pod resources](#configure-kubernetes-pod-resources) and [Customize a task's Kubernetes Pod](/docs/astro/kubernetes-executor#customize-a-task’s-kubernetes-pod).
For details on worker autoscaling behavior, see [Configure the Celery executor](/docs/astro/celery-executor) or [Configure the Astro executor](/docs/astro/astro-executor).
## Scheduler
The [Airflow scheduler](https://airflow.apache.org/docs/apache-airflow/stable/concepts/scheduler.html) is responsible for monitoring task execution and triggering downstream tasks when the dependencies are met.
Scheduler resources must be set for each Deployment and are managed separately from cluster-level infrastructure. To ensure that your tasks have the CPU and memory required to complete successfully on Astro, you can provision the scheduler with varying amounts of CPU and memory.
**Remote Execution Deployments**
The scheduler always receives a fixed allocation of **1 vCPU and 2 GiB memory** in [remote execution](/docs/astro/execution-mode) mode. You can't change scheduler resources for remote execution Deployments.
You can enable [High Availability](#enable-high-availability) to run two schedulers in this mode, each with the same fixed resources.
Unlike workers, schedulers don't autoscale. The resources you set for them are the resources you have regardless of usage. For more information about how scheduler configuration affects resources usage, see [Pricing](https://astronomer.io/pricing).
Astronomer Deployments run a single scheduler by default. You can configure your scheduler to have different amounts of resources based on how many tasks you need to schedule for hosted execution Deployments. For [remote execution](/docs/astro/execution-mode) Deployments, scheduler resources are fixed and not configurable.
You can also enable [High Availability](#enable-high-availability) to run two instances of PgBouncer and the Airflow Scheduler.
### Size options
Astro separates the scheduler and Dag processor for some Deployment sizes, which improves security and reliability because the `SchedulerJob` and `DAGProcessorJob` can run on separate Pods. Consider the following details when choosing your scheduler and Dag processor sizes:
* To use the separate scheduler and Dag processor, you must use at least version 9.7.0 of Astro Runtime. If your Deployment uses a lower Runtime version, then the scheduler and Dag processor run on the same Pod, and the Extra Large Deployment size isn't available.
* For **Small** Deployments, the scheduler and Dag processor run on the same Pod.
* **Extra Large** Deployments have two Dag processors allocated per Deployment.
Astronomer recommends using **Medium** or larger for production Deployments for improved reliability and performance. This aligns with Apache Airflow best practices of running the scheduler and Dag processor as separate processes. For Airflow 3.x Deployments, **Medium** or larger is highly recommended, as open source Airflow 3 has fully separated the scheduler and Dag processor into distinct processes.
The following table lists all possible scheduler and Dag processor sizes for Astro Hosted:
| Size | vCPU | Memory | Ephemeral Storage |
| ------------------------------- | --------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- |
| Small (Up to \~50 Dags) | 1 | 2GiB | 5 GiB |
| Medium (Up to \~250 Dags) | **Scheduler**: 1 **DAG Processor**: 1 | **Scheduler**: 2 GiB **DAG Processor**: 2 GiB | **Scheduler**: 1 GiB **DAG Processor**: 4 GiB |
| Large (Up to \~1000 Dags) | **Scheduler**: 1 **DAG Processor**: 3 | **Scheduler**: 2 GiB **DAG Processor**: 6 GiB | **Scheduler**: 1 GiB **DAG Processor**: 4 GiB |
| Extra Large (Up to \~2000 Dags) | **Scheduler**: 1 **DAG Processor (x2)**: 3.5 | **Scheduler**: 4 GiB **DAG Processor (x2)**: 6 GiB | **Scheduler**: 1 GiB **DAG Processor (x2)**: 4 GiB |
### Update scheduler size
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Advanced** section, choose a scheduler size. See [Scheduler](#scheduler).
4. Click **Update Deployment**.
The Airflow components of your Deployment automatically restart to apply the updated resource allocations. This action is equivalent to deploying code and triggers a rebuild of your Deployment image. If you're using the Celery executor, currently running tasks have 24 hours to complete before their running workers are terminated. See [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Options** menu of the Deployment you want to update, and select **Edit Deployment**.
3. In the **Advanced** section, choose a scheduler size. See [Scheduler](#scheduler).
4. Click **Update Deployment**.
The Airflow components of your Deployment automatically restart to apply the updated resource allocations. This action is equivalent to deploying code and triggers a rebuild of your Deployment image. If you're using the Celery executor, currently running tasks have 24 hours to complete before their running workers are terminated. See [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
## Triggerer
The Airflow triggerer executes deferred tasks in an [`asyncio` event loop](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio-event-loop). Running a triggerer is essential for using [deferrable operators](/docs/learn/deferrable-operators).
One replica of the Airflow triggerer with 0.5 vCPU and 1.875 GiB is automatically included in your Deployment, and is the same size for all Deployments. The included triggerer can typically support up to 1000 concurrent running triggers with low to medium memory requirements. If your use case requires over 1000 concurrent running triggers and/or medium to heavy memory requirements, Astro supports customizing the count and size of the triggerer. Leverage the triggerer metrics available in Deployment Analytics to right-size the triggerer. Additional requested compute beyond the default specs will be charged at the A5 worker unit rate, similar to [KE/KPO chargeback](https://www.astronomer.io/pricing/#:~:text=How%20will%20I%20be%20charged%20for%20the%20Kubernetes%20Executor%20and%20Kubernetes%20Pod%20Operator%3F).
The following table lists all available environment variables for customizing the count and size of the triggerer. Set each variable to the value shown in the **Default** or **Max** column, or to any value in between.
| Environment Variable | Default | Max | Equivalent range |
| ---------------------------------- | -------- | --------- | ---------------- |
| `ASTRO_TRIGGERER_REPLICAS` | `1` | `8` | 1–8 replicas |
| `ASTRO_TRIGGERER_RESOURCES_CPU` | `500m` | `5000m` | 0.5–5 vCPU |
| `ASTRO_TRIGGERER_RESOURCES_MEMORY` | `1920Mi` | `15360Mi` | 1.875–15 GiB |
The CPU and memory variables use Kubernetes resource units: `m` is millicores, where `1000m` equals 1 vCPU, and `Mi` is mebibytes, where `1024Mi` equals 1 GiB.
## API server
**Airflow 3**
This component applies only to Airflow 3.x Deployments. Airflow 2.x Deployments use the Airflow webserver, which doesn't support horizontal autoscaling on Astro.
The Airflow API server serves the Airflow UI, the Airflow REST API, and the task execution API used by Astro and Celery workers. Every Airflow 3 Deployment runs with two API server replicas by default.
For workloads with high task concurrency or spikes in UI and REST API traffic, you can enable horizontal autoscaling so that Astro adds API server replicas when load is high and removes them when load decreases. Autoscaling is implemented as a Kubernetes Horizontal Pod Autoscaler (HPA) that targets 80 percent average CPU utilization across the running replicas.
When you enable autoscaling, Astro maintains a minimum of two replicas and scales up to a maximum that you configure from `2` to `10`. Astro charges for replicas above the included two based on their CPU usage, and the charges appear on your invoice as **API Server** under **Runtime Compute**.
For configuration steps, supported deployment types, and the API payload, see [Configure API server autoscaling](/docs/astro/api-server-autoscaling).
## Enable high availability
This is feature is only available if you are on the **Team** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
By default, the Pods running your Deployment's Airflow components are distributed across multiple nodes. When you enable high availability, Astro re-configures the Deployment to be more resilient and avoid a single point of failure by running replicas of key infrastructure components across different availability zones. Changes in high availability mode include:
* Running two schedulers so that at least one is always available
* Running two Dag processors in [Deployments with a standalone Dag processor](#size-options)
* Running two webservers
* Running the following components on different nodes with [preferred zone-level anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#types-of-inter-pod-affinity-and-anti-affinity):
* Scheduler
* Dag processor
* PG Bouncer
* Webserver
This ensures that your Dags can continue to run if there's an issue with one of your Airflow components in a specific node or availability zone.
High availability mode is recommended for production Deployments to increase reliability and availability of scheduling, Dag processing and the UI/API, while also providing protection against zonal outages.
Because this setting results in more resource usage, it increases the cost of your Deployment. See [Pricing](https://astronomer.io/pricing).
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Basic** section, click the toggle to **On** for **High Availability**.
4. Select **Update Deployment** to save your changes.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Options** menu of the Deployment you want to update, and select **Edit Deployment**.
3. In the **Basic** section, click the toggle to **On** for **High Availability**.
4. Select **Update Deployment** to save your changes.
## Enable development mode
Enabling **Development Mode** on a Deployment allows you to safely separate development and production environments on Astro. Deployments in **Development Mode** can be hibernated to control costs. In addition to marking a Deployment as **Development Mode**, you can also control development and testing environments by creating ephemeral preview Deployments. To learn more about which approach is right for you, see [Manage development Deployments on Astro](/docs/astro/best-practices/manage-dev-deployments).
**Development Mode** is a prerequisite to [hibernate a Deployment](#hibernate-a-development-deployment) and must be enabled at Deployment creation. It can't be turned on after a Deployment has been created, but it can be turned off after a Deployment is created.
Development Deployments have the following constraints:
* The **Small Scheduler** (1 vCPU, 2 GiB RAM) is the only scheduler size supported.
* Development Deployments can't have a [P1 ticket](/docs/astro/astro-support#p1-critical-impact) raised against them.
* Development Deployments won't be treated as [“production”](/docs/astro/astro-support#ticket-priorities) by support.
## Hibernate a development Deployment
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
When you create a Deployment on Astro, you pay for the infrastructure resources that are required to run the Deployment for the duration that it's active. In development environments when you aren't always running tasks, you can *hibernate*, or scale down, all Deployment resources on a specified schedule. When you hibernate a Deployment, all Deployment configurations are preserved, but computing resources are scaled to zero.
For example, if you only need to test a Dag during working hours, you can set a hibernation schedule for 5:00 PM until 9:00 AM on Monday through Friday. During this time, your Deployment settings are preserved and your cost on Astro for the Deployment is \$0. When the hibernation schedule ends, you can resume using the Deployment. Waking up a Deployment from hibernation is faster than creating a new Deployment and preserves all of your configurations.
Use Deployment hibernation to ensure that:
* You only pay for the resources that you need, when you need them.
* You don't have to delete a Deployment in order to avoid the cost of the Deployment.
* You don't have to recreate development environments and re-enter Deployment configurations.
### Prerequisites
You can hibernate a Deployment only if you enabled **Development Mode** when you [created the Deployment](/docs/astro/create-deployment). Deployments without this setting enabled can't be hibernated.
### Create a wake schedule
Before you create or edit a wake schedule for a Deployment, consider the following constraints:
* The Deployment must have the **Development Mode** setting turned on. This setting can be turned on only when you create a Deployment.
* The **High Availability** feature isn't supported. A Deployment with a hibernation schedule can't be highly available.
* Deployments with hibernation schedules aren't required to meet the uptime SLAs of standard production Deployments.
The following instructions show you how to configure wake schedules in the Astro UI. You can also configure wake schedules programmatically through the [Astro API](https://www.astronomer.io/docs/astro/api/v-1/deployment/create-a-deployment#request.body.CreateStandardDeploymentRequest.scalingSpec).
To manage wake schedules:
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Edit Deployment**.
3. In the **Advanced** section, find **Wake Schedules** and set one or more schedules using either the calendar-based interface or cron expressions. You can switch between the two interfaces by clicking the **Switch to cron scheduling** or **Switch to simple scheduling** buttons.
To keep the Deployment hibernated indefinitely, select the **Never Wake** schedule type in the simple scheduling interface. You can also configure **Never Wake** in the cron scheduling interface by setting `@always` as the hibernate expression and `@never` as the wake expression. You can only enable one **Never Wake** schedule at a time. You can wake up the Deployment by clicking **Wake Up Deployment** in the Deployment's **More actions** menu (⋯), or programmatically through the [Astro API](https://www.astronomer.io/docs/astro/api/v-1/deployment/configure-a-hibernation-override-for-a-deployment).
4. Click **Update Deployment**.
1. In the Astro UI, select a Workspace, click Deployments, then select a Deployment.
2. Click Details. In the Advanced section of your Deployment configuration, click Edit.
3. In the **Wake Schedules** section, set one or more schedules using either the calendar-based interface or cron expressions. You can switch between the two interfaces by clicking the **Switch to cron scheduling** or **Switch to simple scheduling** buttons.
To keep the Deployment hibernated indefinitely, select the **Never Wake** schedule type in the simple scheduling interface. You can also configure **Never Wake** in the cron scheduling interface by setting `@always` as the hibernate expression and `@never` as the wake expression. You can only enable one **Never Wake** schedule at a time. You can wake up the Deployment by clicking **Wake Up Deployment** in the Deployment's **More actions** menu, or programmatically through the [Astro API](https://www.astronomer.io/docs/astro/api/v-1/deployment/configure-a-hibernation-override-for-a-deployment).
4. Click **Update Deployment**.
Astro sets all cron schedules for hibernation in UTC. If you're running a Deployment in another time zone, you must convert the cron expression for your time zone to UTC. For example, if you want your Deployment to hibernate at 17:00 EST, you use `0 22 * * *` (22:00 UTC) as the cron expression.
When your hibernation schedule starts:
* Your Deployment shows a **Hibernating** status in the Astro UI:
* Any task that was previously running will be killed and marked as failed.
* Tasks and Dags don't run. Task instances that were already running or scheduled at the time of hibernation will fail and trigger any related notifications.
* No Deployment resources are available. This includes the scheduler, webserver, and all workers.
* You can't access the Airflow UI for the Deployment.
* You can't deploy project images or Dags to the Deployment.
When your hibernation schedule ends, the Deployment will start any Dag runs for data intervals that were missed during hibernation for Dags with `catchup=True`. To avoid incurring additional resource costs, Astronomer recommends disabling catchup on Dags in hibernating Deployments.
### Manually hibernate a Deployment
Instead of creating a regular hibernation schedule, you can manually hibernate a development Deployment from the Astro UI. This is recommended if you're not sure when you'll need to use the Deployment again after hibernating it.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Hibernate Deployment**.
3. Configure the manual hibernation period, then click **Confirm**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **More Actions** menu of the Deployment you want to update, then select **Hibernate Deployment**.
3. Configure the manual hibernation period, then click **Confirm**.
If you need to run a task or Dag on a Deployment that is currently in hibernation, you can manually wake up a Deployment from hibernation before the end of its schedule.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the Deployment's **More actions** menu (⋯), then select **Wake Up Deployment**.
3. Select one of the following options for how you want your Deployment to wake up:
* **Wake until further notice**: Your Deployment wakes up immediately for an indefinite period and ignores any configured hibernation schedules.
* **Wake until set time and date**: Specify a time that the Deployment should go back into hibernation after waking up.
* **Remove override and return to normal schedule**: The Deployment returns to following your configured hibernation schedules.
4. Click **Confirm**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **More Actions** menu of the Deployment you want to update, then select **Wake Up Deployment**.
3. Select one of the following options for how you want your Deployment to wake up:
* **Wake until further notice**: Your Deployment wakes up immediately for an indefinite period and ignores any configured hibernation schedules.
* **Wake until set time and date**: Specify a time that the Deployment should go back into hibernation after waking up.
* **Remove override and return to normal schedule**: The Deployment returns to following your configured hibernation schedules.
4. Click **Confirm**.
# Overview
Source: https://astronomer.io/docs/astro/deployment-settings
View details and options for your Deployment.
After you create an Astro Deployment, you can modify its settings using the Astro UI and Astro CLI to tailor its performance. There are two categories of Deployment configurations: Deployment *details* and *resources*.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
You can also view more details about your Deployment including:
* **Overview**: View information about your Deployment including recent Dag usage and the [code deploy history](/docs/astro/deploy-history).
* **Analytics**: Find [detailed metrics](/docs/astro/deployment-metrics) about the historical resource consumption when you run Dags.
* **Logs**: See the [Airflow and task logs](/docs/astro/view-logs) for a Deployment.
* **Environment**: Manage [environment variables](/docs/astro/environment-variables), [connections](/docs/astro/create-and-link-connections), [metrics exports](/docs/astro/export-metrics), and [Airflow variables](/docs/astro/create-and-link-variables).
* **Access**: Manage user, team, and API token access to the Deployment.
* **Alerts**: Create, manage, and delete [notification channels and alerts](/docs/astro/alerts).
* **Incident History**: Review [Deployment health incidents](/docs/astro/deployment-health-incidents).
* **AI Agents**: Configure [Otto investigation guidance](/docs/astro/otto-investigate) for the Deployment.
* **Details**: Make changes or reference your Deployment configurations.
* **Overview**: View information about your Deployment including recent dag usage and the [code deploy history](/docs/astro/deploy-history).
* **Analytics**: Find [detailed metrics](/docs/astro/deployment-metrics) about the historical resource consumption when you run dags.
* **Logs**: See the [Airflow and task logs](/docs/astro/view-logs) for a Deployment.
* **Environment**: Manage [environment variables](/docs/astro/environment-variables), [connections](/docs/astro/create-and-link-connections), [metrics exports](/docs/astro/export-metrics), and [Airflow variables](/docs/astro/create-and-link-variables).
* **Access**: Manage user, team, and API token access to the Deployment.
* **Alerts**: Create, manage, and delete [notification channels and alerts](/docs/astro/alerts).
* **Details**: Make changes or reference your Deployment configurations.
## Deployment details
[Deployment details](/docs/astro/deployment-details) are high level settings that define how users can interact with the Deployment. These settings include:
* Deployment names and descriptions.
* Deployment contact emails.
* Rules for what types of deploys are allowed.
* Your Deployment's current Workspace.
## Deployment resources
[Deployment resources](/docs/astro/deployment-resources) let you customize the resource use, infrastructure, and performance of your Deployment. Use these settings to optimize Deployment processing, optimize compute resources and cost, and enable advanced use cases with intensive workloads. The following configuration options are available for customizing your resource use:
* Change the Deployment executor.
* Configure Kubernetes Pod resources.
* Change Scheduler and Dag processor resources.
* Enforce CI/CD Deploys.
* Enable High Availability.
* Customize your Airflow environment using environment variables.
For advanced Deployment resource configurations, see [Manage Airflow executors on Astro](/docs/astro/executors-overview) and [Configure worker queues](/docs/astro/configure-worker-queues).
## Configure Otto investigation guidance
Otto investigation guidance is custom text you provide to tailor [Otto investigations](/docs/astro/otto-investigate) for a Deployment. By default, a Deployment inherits the Otto investigation guidance set at the [Workspace level](/docs/astro/manage-workspaces#configure-otto-investigation-guidance). You can override the inherited guidance with Deployment-specific instructions.
1. In the Astro UI, select a Deployment.
2. Click the **AI Agents** tab, then click **Edit**.
3. Enter up to 10,000 characters of markdown guidance, then click **Save**.
1. In the Astro UI, select a Deployment.
2. Click the **AI Agents** tab.
3. Enter up to 10,000 characters of markdown guidance, then save your changes.
Deployment-level guidance takes precedence over Workspace-level guidance for investigations on this Deployment.
**CLI**
These documents focuses on configuring Deployments through the Astro UI. To configure Deployments as code using the Astro CLI, see [Manage Deployments as code](/docs/astro/manage-deployments-as-code).
## See also
* [Set environment variables on Astro](/docs/astro/environment-variables)
* [Authenticate an automation tool to Astro](/docs/astro/automation-authentication)
* [Manage Deployments as Code](/docs/astro/manage-deployments-as-code)
# Toggle AI features for your Organization
Source: https://astronomer.io/docs/astro/enable-disable-astro-ai
Configure Organization-wide access to AI features, including Otto and AI-driven capabilities in the Astro IDE.
Organization Owners can enable or disable AI features throughout the Astro platform. Disabling AI features removes access to all AI-driven enhancements for all users in your Organization, including:
* [Otto](/docs/astro/otto-overview), Astronomer's data engineering agent in the Astro CLI.
* AI-powered authoring in the [Astro IDE](/docs/astro/ide-overview).
* [Investigations and log summaries](/docs/astro/root-cause-analysis) in Astro Observe.
Use this setting if your Organization has security, privacy, or compliance requirements regarding AI use.
In the Astro UI, click **Organization Settings**.
This opens the **General** Organization page.
In the **Organization Detail** section, click **Edit Details**.
Find the **AI Features** option. Set the toggle to **Enabled** to turn on AI features or **Disabled** to turn them off.
Click **Update Organization** to apply your changes.
When AI features are disabled, the Astronomer LLM gateway stops issuing model tokens for the Organization, so Otto and other Astronomer-managed AI features stop working.
# Astro Environment Manager overview
Source: https://astronomer.io/docs/astro/environment-manager-overview
Learn how the Astro Environment Manager stores Airflow connections, Airflow variables, and environment variables and shares them across Deployments and Astro IDE projects.
The Astro Environment Manager is a built-in secrets backend that you use in the Astro UI to create Airflow connections, Airflow variables, environment variables, and metrics exports, then share them across multiple Deployments and [Astro IDE](/docs/astro/ide-overview) projects. The Environment Manager stores each object in an Astro-managed secrets backend, so you can create objects once and reuse them without setting up your own secrets backend.
Using the Environment Manager, you can configure an object with the credentials for a sandbox or development environment, apply it to all Deployments in a Workspace by default, and later override its values to point to production resources on a per-Deployment basis. When you create new Deployments, they automatically have access to any objects that are linked to all Deployments in the Workspace.
To open the Environment Manager, click **Environment** in the left menu of the Astro UI.
## What you can manage
The Environment Manager supports the following object types. See the corresponding page for each type's full capabilities, prerequisites, and permissions:
* **Airflow connections**: Store credentials and configuration for connecting to external services. See [Create Airflow connections in the Astro UI](/docs/astro/create-and-link-connections).
* **Airflow variables**: Store and retrieve arbitrary content or settings as key-value pairs within Airflow. See [Create Airflow variables in the Astro UI](/docs/astro/create-and-link-variables).
* **Environment variables**: Store key-value configurations that configure Airflow settings, store credentials, or pass configuration to your Dags. See [Create environment variables in the Astro UI](/docs/astro/create-and-link-environment-variables).
* **Metrics exports**: Send Deployment metrics to an external monitoring tool. See [Export metrics from Astro](/docs/astro/export-metrics).
Creating these objects in the Astro UI, rather than the Airflow UI, lets you share them across Deployments and Astro IDE projects, override their values per Deployment or project, and use them in local development and branch-based deploys.
## How objects are stored
Astro stores each object in an Astronomer-hosted secrets manager and applies it to Deployments as a Kubernetes Secret. See [How connections are stored](/docs/astro/create-and-link-connections#how-connections-are-stored), [How variables are stored](/docs/astro/create-and-link-variables#how-variables-are-stored), and [How environment variables are stored](/docs/astro/create-and-link-environment-variables#how-environment-variables-are-stored) for the mechanics of each object type.
## Use objects in local development
The Astro CLI can retrieve connections and variables from the Astro UI for use in local Airflow environments. By default, connections can't be exported locally. To work with connections locally, an Organization Owner can enable [**Environment Secrets Fetching**](/docs/astro/organization-settings#configure-environment-secrets-fetching-for-the-astro-environment-manager) in the Astro UI. See [Import and export connections and variables](/docs/cli/v1.43/local-connections).
## Link objects to Astro IDE projects
In addition to Deployments, you can link Workspace-level objects to [Astro IDE](/docs/astro/ide-overview) projects. When you link an object to an Astro IDE project, the project's ephemeral test Deployments start with that object available, without affecting Deployments that aren't started from the IDE. See [Link connections to Astro IDE projects](/docs/astro/create-and-link-connections#link-connections-to-astro-ide-projects).
For Remote Execution Deployments, you can only manage environment variables and Metrics export with the Environment Manager. You can't create, update, or assign Airflow connections or Airflow variables.
## Migrate and promote existing objects
If you already define connections, Airflow variables, or environment variables in a Deployment, you can move them into the Environment Manager so that they can be reused across Deployments and Astro IDE projects. You can also promote a Deployment-scoped object to the Workspace level to reuse it elsewhere. See [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager).
## See also
* [Manage Airflow connections, variables, and environment variables](/docs/astro/manage-connections-variables)
* [Import and export connections and variables](/docs/astro/import-export-connections-variables)
# Execution mode
Source: https://astronomer.io/docs/astro/execution-mode
Overview of Remote and Hosted execution
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
## Overview
Starting with Airflow 3.x Deployments on Astro, you can choose Remote Execution mode to securely run your tasks in your own environments, whether it is on-prem or edge, without opening inbound connections. Only essential scheduling and health data leave the execution plane.
You can still use the default Hosted execution mode for Astronomer-Hosted execution and orchestration for hands-off infrastructure management. Hosted execution mode on Astro is the quickest and easiest way to run data pipelines on Airflow.
## Hosted execution
Hosted execution mode is Astronomer-Hosted execution and orchestration for hands-off infrastructure management. Hosted is the default execution mode and supports dag versioning for Airflow 3 Deployments and autoscaling workers out of the box.
Hosted execution offers a convenient, secure, and stable way to run Airflow workloads without having to manage workers in your environment.
## Remote Execution
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
[Remote Execution](/docs/astro/remote-execution-overview) on Astro is built on a decoupled architecture that separates the orchestration layer from the execution layer so sensitive data never leaves local infrastructure, and your code remains in secure repositories.
* **Orchestration Plane** (Managed by Astronomer): The centralized control layer that contains the Scheduler, Web/API Server, metadata DB, and at its core, the Remote Execution API. The Remote Execution API securely manages all communication with your Remote Execution Agents—assigning tasks, tracking agent health, and maintaining observability without accessing your data or code.
* **Execution Plane** (Customer-Controlled): Your infrastructure—on-prem or in the cloud—where tasks actually run. This is where your code, data, task logs, and secrets stay. Inside this environment are [Remote Execution Agents](/docs/astro/remote-execution-configure-agents), lightweight services that pull tasks from the Remote Execution API, run them locally, and report status and metrics back to Astro. The Remote Execution Agent includes a Dag processor, Triggerer, and Worker(s). This means that dag parsing, task execution (deferrable and non-deferrable), sourcing of secrets at runtime, and logging all happen in the execution plane. Remote Execution Agent can be configured for different workloads, offering full flexibility without compromising security, and you can deploy them on platforms and hardware of your choosing.
Add `https://.external.astronomer.run/` to your organization's outbound network allowlist so the Remote Execution Agents in your environment are able to heartbeat to the API server in the Astro orchestration plane.
# Astro features
Source: https://astronomer.io/docs/astro/features
Set environment variables on Astro to specify Airflow configurations and custom logic.
Astro offers a suite of first-class features that make it easy to author, run, and monitor Airflow dags.
### Enhanced Developer Productivity
* **Otto:** Accelerate dag authoring, Airflow upgrades, and pipeline investigation with Otto, a data engineering AI agent that understands your environment and your team's conventions. See [Otto overview](/docs/astro/otto-overview).
* **Astro API:** Standardize and simplify data exchange, accelerate development, and better leverage third-party services. See [Astro API](/docs/astro/api/v-1/overview).
* **GitHub Integration:** Enforce DevOps best practices directly from the Astro UI, eliminating manual setup. See [Astro GitHub integration](/docs/astro/deploy-github-integration).
* **Astro CLI:** Install, run, and test Airflow from your command line in under five minutes. See [Astro CLI](/docs/cli/v1.43/overview).
* **Branch-Based Deploys:** Create isolated development environments to run, test, and deploy your dags. See [Preview Deployment templates](/docs/astro/ci-cd-templates/github-actions-deployment-preview).
* **Registry:** Discover over 1,500 integrations and dag templates to accelerate workflow development. See [Airflow Registry](https://airflow.apache.org/registry/).
* **dbt Deploys:** Unify the management and deployment of dbt and Airflow on Astro. See [dbt Deploys](/docs/astro/deploy-dbt-project).
### Elastic Infrastructure at Scale and Increased Operational Efficiency
* **Connection Management:** Set up Airflow connections in one central location with our out-of-the-box, native solution. See [Create connections in Astro](/docs/astro/create-and-link-connections).
* **Dynamic Workers:** Automatically adjust the number of worker nodes based on workload fluctuations.
* **Scale-to-Zero Deployment:** Schedule zero-cost downtime for development Deployment savings. See [Hibernate a development Deployment](/docs/astro/deployment-resources#hibernate-a-development-deployment).
* **High Availability:** Ensure the dependable delivery of mission-critical data pipelines with high availability schedulers. See [Enable high availability](/docs/astro/deployment-resources#enable-high-availability).
* **In-Place Upgrades:** Update to the latest Airflow version without costly downtime or a lengthy migration process.
* **Deployment Rollbacks:** Roll back your Airflow Deployments on Astro to any prior code deploy. See [Deploy history and rollbacks](/docs/astro/deploy-history).
* **CI/CD:** Automate reliable code deployment, enforce reviews, promote code across environments, and ensure testing. Seamlessly integrated with your favorite CI/CD tools. See [Enforce CI/CD deploys](/docs/astro/deployment-details#enforce-ci/cd-deploys).
* **Astro Terraform Provider:** Automate the management and scaling of Airflow environments with Terraform. See [Astro Terraform Provider](https://registry.terraform.io/providers/astronomer/astro/latest/docs).
* **Data-Centric Alerting:** Configure alerts based on dag run and task states, receiving real-time notifications for proactive monitoring. See [Astro Alerts](/docs/astro/alerts).
* **Organizational Dashboards:** Get actionable insight into real-time platform data for streamlined decision-making. See [Organization dashboards](/docs/astro/organization-dashboard).
* **Cross Deployment Visibility + Health:** Gain visibility of your dags and metadata across Deployments. See [Astro Observe](/docs/astro/astro-observe)
* **Lineage:** Visualize task relationships and track data movement within workflows, including data movement in external systems. See [Data lineage](/docs/astro/create-data-products).
* **Universal Metrics Export:** Export detailed metrics from your Airflow Deployments to Prometheus. See [Export metrics](/docs/astro/export-metrics).
### Robust Enterprise-Grade Security
* **Role-Based Access Control (RBAC):** Granular role-based access control spanning Workspaces, Teams, and Deployments. See [Astro user permissions reference](/docs/astro/user-permissions).
* **Customer Managed Workload Identity:** Securely authorize data services from Airflow on Astro, mitigating data exposure. See [Authorize Deployments to cloud resources](/docs/astro/authorize-deployments-to-your-cloud).
* **Custom Deployment Roles:** Ensure your data remains secure with enterprise-level security features. See [Customize Deployment roles](/docs/astro/customize-deployment-roles).
* **Private Networking:** Establish secure connections by VPC peering directly with your private networks. See [Create network connections between Astro and external resources](/docs/astro/networking-overview).
* **Secrets Management:** Automate secret management across Airflow deployments, ensuring a unified interface for seamless handling of secrets. See [Secrets management](/docs/astro/secrets-management).
* **Encryption:** Automatically encrypts all data, both at rest and in transit, including databases, file systems, and network transmissions. See [Data protection](/docs/astro/data-protection).
* **Compliance Readiness:** Meet SOC 2, GDPR, HIPAA, and PCI DSS security standards compliance.
### Committer-led Support
* **24x7x365 Support:** Access to the world's leading Airflow experts and committers. See [Submit a support request](/docs/astro/astro-support).
* **Education, Enablement, and Certification:** Build Airflow expertise across your organization with diverse training and certification options. See [Astronomer Academy](https://academy.astronomer.io/).
# Run your first Dag with the Astro CLI
Source: https://astronomer.io/docs/astro/first-dag-cli
Learn how to run your first Apache Airflow® Dag on Astro with the Astro CLI.
Astro is the industry's leading managed service for [Apache Airflow®](https://airflow.apache.org/). To quickly learn how Astro works, follow the steps in this quickstart to create an Airflow environment and run your first Dag with the Astro CLI.
Specifically, you will:
* Install the CLI.
* Authenticate and sign in to Astro.
* Create a Deployment.
* Create an Astro project.
* Deploy Dags to Astro with the Astro CLI.
* Trigger a run of an example Dag in the Airflow UI.
This tutorial takes about 15 minutes. If you're new to Airflow and want a more in-depth tutorial, see [Airflow 101 Learning Path](https://academy.astronomer.io/path/airflow-101).
If you want to deploy your first Dag without installing any software to your local machine, see [Run your first Dag with GitHub Actions](/docs/astro/first-dag-github-actions).
## Prerequisites
* An Astro account. To start an Astro trial and create your free trial account, see [Start a trial](/docs/astro/trial).
You don't need Docker or Podman to run Airflow locally. Standalone mode runs Airflow directly on your machine in a virtual environment. See [Step 4](#step-4-test-your-project-locally) for details.
If you're on your organization's network and can't access Astro, make a request to add the following domains to the allowlist on your network:
* `https://cloud.astronomer.io/`
* `https://api.astronomer.io/`
* `https://images.astronomer.cloud/`
* `https://auth.astronomer.io/`
* `https://updates.astronomer.io/`
* `https://install.astronomer.io/`
* `https://astro-.datakin.com/`
* `https://.astronomer.run/`
## Step 1: Install the Astro CLI
If you're encountering problems with installing the CLI or don't want to install software locally, see [Run your first Dag with GitHub Actions](/docs/astro/first-dag-github-actions).
Use [Homebrew](https://brew.sh/) to install the latest version of the [Astro CLI](/docs/cli/v1.43/overview).
```sh wrap theme={null}
brew install astro
```
For more information about Astro CLI install options and troubleshooting, see [Install the Astro CLI](/docs/cli/v1.43/install-cli).
If you're encountering problems with installing the CLI or don't want to install software locally, see [Run your first Dag with GitHub Actions](/docs/astro/first-dag-github-actions).
The winget command line tool is supported on Windows 10 1709 (build 16299) or later, and is bundled with Windows 11 and modern versions of Windows 10 by default as the App Installer. If you don't have winget, you can [Install the CLI on Windows manually](/docs/cli/v1.43/install-cli) instead.
1. Make sure you have the following:
* Windows Subsystem for Linux (WSL) 2 enabled: See [Enable the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install), [WSL basic commands](https://learn.microsoft.com/en-us/windows/wsl/basic-commands), and [Troubleshooting WSL 2](https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#error-0x80370102-the-virtual-machine-could-not-be-started-because-a-required-feature-is-not-installed).
* After you enable WSL, run:
```sh wrap theme={null}
wsl --update
wsl --install --no-distribution
```
* The latest version of the Windows [App Installer](https://apps.microsoft.com/store/detail/app-installer/9NBLGGH4NNS1?hl=en-ca\&gl=ca).
* Windows 10 1709 (build 16299) or later or Windows 11.
2. Open Windows PowerShell as an administrator and then run the following command:
```sh wrap theme={null}
winget install -e --id Astronomer.Astro
```
3. Run the following command to access the location of the CLI executable:
```sh wrap theme={null}
$env:path.split(";")
```
From the text that appears, copy the path for the Astro CLI executable. It should be similar to `C:\Users\myname\AppData\Local\Microsoft\WinGet\Packages\Astronomer.Astro_Microsoft.Winget.Source_8wekyb3d8bbwe`.
4. Paste the path into File Explorer or open the file path in terminal, then rename the Astro executable to `astro.exe`.
For more information about Astro CLI install options and troubleshooting, see [Install the Astro CLI](/docs/cli/v1.43/install-cli).
If you're encountering problems with installing the CLI or don't want to install software locally, see [Run your first Dag with GitHub Actions](/docs/astro/first-dag-github-actions).
Run the following command to install the latest version of the Astro CLI directly to `PATH`:
```sh wrap theme={null}
curl -sSL install.astronomer.io | sudo bash -s
```
For more information about Astro CLI install options and troubleshooting, see [Install the Astro CLI](/docs/cli/v1.43/install-cli).
## Step 2: Create a Deployment
An Astro *Deployment* is an instance of Apache Airflow that is powered by all core Airflow components, including a webserver, scheduler, and one or more workers. You deploy Dags to a Deployment, and you can have one or more Deployments within a Workspace.
1. Log in to the [Astro UI](https://cloud.astronomer.io), then on the **Deployments** page click **+ Deployment**.
2. In the **Name** field, enter a name for your Deployment. You can leave the other fields at their default values. This creates a basic Deployment on a standard Astronomer-hosted cluster. You can delete the Deployment after you finish testing your example Dag runs.
3. Click **Create Deployment**.
A confirmation message appears indicating that the Deployment status is **Creating** until all underlying components in the Deployment are healthy. During this time, the Airflow UI is unavailable and you can't deploy code or modify Deployment settings. When the Deployment is ready, the status changes to **Healthy**.
For more information about possible Deployment health statuses, see [Deployment health](/docs/astro/deployment-health-incidents). Or, to learn more about how to customize your Deployment settings, see [Deployment settings](/docs/astro/deployment-settings).
## Step 3: Create an Astro project
An *Astro project* contains the set of files necessary to run Airflow, including dedicated folders for your Dag files, plugins, and dependencies. All new Astro projects contain two example Dags. In this tutorial, you'll be deploying these example Dags to your Deployment on Astro.
1. Open your terminal or IDE.
2. Create a new folder for your Astro project:
```sh wrap theme={null}
mkdir
```
3. Open the folder:
```sh wrap theme={null}
cd
```
4. Run the following Astro CLI command to initialize an Astro project in the folder:
```sh wrap theme={null}
astro dev init
```
The command generates the following files in your folder:
```text wrap theme={null}
.
├── .env # Local environment variables
├── dags # Where your dags go
│ ├── example-dag-basic.py # Example dag that showcases a simple ETL data pipeline
│ └── example-dag-advanced.py # Example dag that showcases more advanced Airflow features, such as the TaskFlow API
├── Dockerfile # For the Astro Runtime Docker image, environment variables, and overrides
├── include # For any other files you'd like to include
├── plugins # For any custom or community Airflow plugins
│ └── example-plugin.py
├── tests # For any dag unit test files to be run with pytest
│ └── test_dag_example.py # Example test that checks for basic errors in your dags
├── airflow_settings.yaml # For your Airflow connections, variables and pools (local only)
├── packages.txt # For OS-level packages
└── requirements.txt # For Python packages
```
## Step 4: Test your project locally
Before deploying to Astro, you can test your Dags locally. This step is optional, but Astronomer recommends testing locally to catch issues before deploying.
Run the following command from your project folder:
```sh wrap theme={null}
astro dev start
```
This command builds your project and spins up 4 containers on your machine, one each for the Airflow webserver, scheduler, triggerer, and metadata database.
Standalone mode runs on macOS, Linux, and Windows Subsystem for Linux (WSL) for both Airflow 2 and Airflow 3. It doesn't support native Windows because of Apache Airflow limitations. For more information, see [Apache Airflow prerequisites](https://airflow.apache.org/docs/apache-airflow/stable/installation/prerequisites.html).
Run the following command from your project folder:
```sh wrap theme={null}
astro dev start --standalone
```
This command runs Airflow directly on your machine in a virtual environment, without Docker or Podman. To make standalone mode the default for your project, run:
```sh wrap theme={null}
astro config set dev.mode standalone
```
After your project starts, open the Airflow UI at `http://localhost:8080/` and verify that the example Dags appear. When you're done testing, run `astro dev stop` to stop the local environment.
## Step 5: Deploy example Dags to your Astro Deployment
Dag-only deploys are an Astro feature that you can use to quickly update your Astro Deployment by only deploying the `dags` folder of your Astro project. You'll now trigger a Dag-only deploy to push your example Dags to Astro.
1. Run the following command to authenticate to Astro on the CLI:
```sh wrap theme={null}
astro login astronomer.io
```
After running this command, you are prompted to open your web browser and enter your credentials to the Astro UI. The Astro UI then automatically authenticates you to the CLI. The next time you sign in, you can run `astro login` without specifying a domain. If you run into issues signing in, check to make sure that you have the latest version of the Astro CLI. See [Upgrade the CLI](/docs/cli/v1.43/upgrade-cli).
2. Run the following command to deploy your Dags to Astro:
```sh wrap theme={null}
astro deploy --dags
```
If you have modified any files other than those in the `dags` directory, make sure to run `astro deploy` instead.
This command returns a list of Deployments available in your Workspace and prompts you to confirm where you want to deploy your Dag code. After you select a Deployment, the CLI parses your Dags to ensure that they don't contain basic syntax and import errors. If your code passes the parse, the Astro CLI deploys your Dags to Astro. If you run into issues deploying your Dags, check to make sure that you have the latest version of the Astro CLI. See [Upgrade the CLI](/docs/cli/v1.43/upgrade-cli).
## Step 6: Trigger your Dag on Astro
Newly deployed Dags are paused by default and won't start running automatically. To run one of the example Dags in your Astro project according to its schedule, you must unpause it from the Airflow UI hosted on your Deployment.
1. In the Deployment page of the Astro UI, click the **Open Airflow** button.
2. In the main Dags view of the Airflow UI, click the slider button next to `example-dag-basic` to unpause it. If you hover over the Dag, it says `dag is Active`. When you do this, the Dag starts to run on the schedule that is defined in its code.
3. Manually trigger a Dag run of `example-dag-basic` by clicking the play button in the **Actions** column. When you develop Dags on Astro, triggering a Dag run instead of waiting for the Dag schedule can help you quickly identify and resolve issues.
After you press **Play**, the **Runs** and **Recent Tasks** sections for the Dag start to populate with data.
These circles represent different [states](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#task-instances) that your Dag and task runs can be in.
4. Click the name of the Dag, `example-dag-basic`, to open the **Grid** view for the Dag. To see if your Dag ran successfully, the most recent entry in the grid should have green squares for all of your tasks.
5. Pause your Dag by clicking the slider button next to `example-dag-basic`. This prevents your example Dag from running automatically and consuming your Deployment resources.
## Step 7: View your Dag status in the Astro UI
The Astro UI shows you information about the health of your Deployment, including analytics and logs for your Dag runs.
Go back to your Deployment page in the Astro UI. Because you ran your example Dag, your Deployment information page now has data about your Deployment and Dag runs. The following example shows what you might find in the **Overview** page for your Deployment.
When you're done exploring, you can delete your Deployment from your **Deployments** page.
## Next Steps
Now that you've created and run your first Dag on Astro, the next step is to add your own Dags, build out the rest of your Astro project, and start testing real data. See:
* [Develop a project](/docs/cli/v1.43/develop-project).
* [Write your first Dag](/docs/learn/get-started-with-airflow).
* [Deploy code to Astro](/docs/astro/deploy-code).
# Run your first Dag with GitHub Actions
Source: https://astronomer.io/docs/astro/first-dag-github-actions
Learn how to run your first Apache Airflow® Dag on Astro with GitHub Actions.
The Astro GitHub integration can automatically deploy code from a GitHub repository to Astro without you needing to configure a GitHub action. In addition, the Astro UI shows Git metadata for each deploy on your Deployment information screen. See [Deploy code with the Astro GitHub integration](/docs/astro/deploy-github-integration) for setup steps.
Astro is the industry's leading managed service for [Apache Airflow®](https://airflow.apache.org/). To quickly learn how Astro works, follow the steps in this quickstart to create an Airflow environment and run your first Dag with GitHub Actions.
Specifically, you will:
* Authenticate and sign in to Astro.
* Create a Deployment.
* Fork an example GitHub repository with a new Astro project.
* Configure GitHub Actions.
* Trigger the GitHub Action to deploy an example Dag to Astro.
* Trigger a run of the example Dag in the Airflow UI.
The steps take about 15 minutes. If you prefer to use a CLI, you can alternatively create and run your first Dag [using the Astro CLI](/docs/astro/first-dag-cli) in the same amount of time.
This tutorial assumes that you're familiar with basic Apache Airflow concepts. If you're new to Airflow and want a more general introduction, see the [Airflow 101 Learning Path](https://academy.astronomer.io/path/airflow-101).
## Prerequisites
* An Astro account. To start an Astro trial and create your free trial account, see [Start a trial](/docs/astro/trial).
* A [GitHub account](https://docs.github.com/en/get-started/signing-up-for-github).
If you're on your organization's network and can't access Astro, make a request to add the following domains to the allowlist on your network:
* `https://cloud.astronomer.io/`
* `https://api.astronomer.io/`
* `https://images.astronomer.cloud/`
* `https://auth.astronomer.io/`
* `https://updates.astronomer.io/`
* `https://install.astronomer.io/`
* `https://install.astronomer.io/`
* `https://astro-.datakin.com/`
* `https://.astronomer.run/`
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Step 1: Create a Deployment
An Astro *Deployment* is an instance of Apache Airflow that is powered by all core Airflow components, including a webserver, scheduler, and one or more workers. You deploy Dags to a Deployment, and you can have one or more Deployments within your Workspace.
1. Log in to the [Astro UI](https://cloud.astronomer.io), then on the **Deployments** page click **+ Deployment**.
2. In the **Name** field, enter a name for your Deployment. You can leave the other fields at their default values. This creates a basic Deployment on a standard Astronomer-hosted cluster. You can delete the Deployment after you finish testing your example Dag runs.
3. Click **Create Deployment**.
A confirmation message appears indicating that the Deployment status is **Creating** until all underlying components in the Deployment are healthy. During this time, the Airflow UI is unavailable and you can't deploy code or modify Deployment settings. When the Deployment is ready, the status changes to **Healthy**.
For more information about possible Deployment health statuses, see [Deployment health](/docs/astro/deployment-health-incidents). Or, to learn more about how to customize your Deployment settings, see [Deployment settings](/docs/astro/deployment-settings).
Astro contains an in-product tutorial that guides you through Steps 2-4 of this document and includes shortcut buttons for some key Astro actions. If you prefer to finish the quickstart this way, open your **Deployments** page in the Astro UI and choose your Deployment. In the **Deploy your first dag** section, click **With GitHub Actions** and follow the steps in the window that appears.
If you don't see the **Deploy your first dag** option your Deployment page, click **Deploy dags?** to open it.
## Step 2: Fork the example project repository
This repository contains an *Astro project*, which is a collection of files required for running Airflow on Astro. An Astro project includes folders for Dag files, plugins, dependencies, and more. Specifically, this Astro project includes an example Dag which is a simple ETL pipeline example that queries the list of astronauts currently in space from the Open Notify API and prints a statement for each astronaut. The Dag uses the TaskFlow API to define tasks in Python, and dynamic task mapping to dynamically print a statement for each astronaut.
1. Open [the example project repository](https://github.com/astronomer/astro-example-dags/fork) in a new tab or browser window.
2. **Choose an owner** from your available options.
3. Keep the selection to **Copy the `main` branch only**.
4. Click **Create fork**.
## Step 3: Set up the GitHub Actions Workflow
This example repository also includes a pre-configured [Astronomer deploy action](https://github.com/astronomer/deploy-action), which you can use to set up a CI/CD deployment pipeline. In this step, you'll configure the GitHub action to deploy code from your forked repository to Astro and run the workflow.
1. Open two browser windows: one with the [Astro UI](https://cloud.astronomer.io), and one with your forked GitHub repository.
2. In the Astro UI, choose the Deployment where you want to deploy your Astro project.
3. In GitHub, open your forked repository and click **Actions**.
4. Click **I understand my workflows, go ahead and enable them.**
The [workflow](https://github.com/astronomer/astro-example-dags/blob/main/.github/workflows/deploy-to-astro.yaml) is a script that uses API tokens to deploy Dags from a GitHub repository to your Deployment, without requiring any local development.
5. Choose the **Astronomer CI - Deploy Code** workflow.
6. Click **Run workflow**. This opens a window to enter information about your Astro Deployment.
7. In the Astro UI, copy your **Deployment ID** from the Deployment information.
8. In GitHub, paste your **Deployment ID**.
9. In the Astro UI, click the **Access** tab on the Deployment screen.
10. Click **API Tokens**.
11. Click **+ Add API Token** and select **New Deployment API Token** to create a new API token, and give the token a **Name** and an **Expiration**.
12. Click **Create API Token**, then copy the token that appears.
For security reasons, this is the only opportunity you have to copy your API token. After you exit the modal window, you can't copy it again. Be sure to save your token in a safe place or paste it immediately.
13. In GitHub, paste the API Token in the **API Token** field on your GitHub Actions workflow page.
14. Click **Run workflow**.
1. Open two browser windows: one with the [Astro UI](https://cloud.astronomer.io), and one with your forked GitHub repository.
2. In the Astro UI, choose the Deployment where you want to deploy your Astro project.
3. In GitHub, open your forked repository and click **Actions**.
4. Click **I understand my workflows, go ahead and enable them.**
The [workflow](https://github.com/astronomer/astro-example-dags/blob/main/.github/workflows/deploy-to-astro.yaml) is a script that uses API tokens to deploy Dags from a GitHub repository to your Deployment, without requiring any local development.
5. Choose the **Astronomer CI - Deploy Code** workflow.
6. Click **Run workflow**. This opens a window to enter information about your Astro Deployment.
7. In the Astro UI, copy your **Deployment ID** from the Deployment information.
8. In GitHub, paste your **Deployment ID**.
9. In the Astro UI, click the **Access** tab on the Deployment screen.
10. Click **API Tokens**.
11. Click **+ API Token** and select **Add Deployment API Token** to create a new API token, and give the token a **Name** and an **Expiration**.
12. Click **Create API Token**, then copy the token that appears.
For security reasons, this is the only opportunity you have to copy your API token. After you exit the modal window, you can't copy it again. Be sure to save your token in a safe place or paste it immediately.
13. In GitHub, paste the API Token in the **API Token** field on your GitHub Actions workflow page.
14. Click **Run workflow**.
This automatically deploys the example Dags in your Astro project to your Deployment.
## Step 4: View your Dag run results
Open your Deployment in the Astro UI and click **DAGs** in the left sidebar, then click **Open in Airflow** for **example\_astronauts**. This opens the Dag details page for **example\_astronauts** in the Airflow UI. Each column in the grid represents a complete Dag run, and each block in the column represents a specific task instance.
Congratulations! You deployed and ran your first Dag on Astro with GitHub Actions.
## Next Steps
* Develop your [Astro project](/docs/cli/v1.43/run-airflow-locally).
* Read more about [Developing CI/CD workflows](/docs/astro/set-up-ci-cd).
* Install [the CLI](/docs/cli/v1.43/install-cli) to test Dags or run Airflow locally.
* [Write your first Dag](/docs/learn/get-started-with-airflow).
# Run your first dag on Astro
Source: https://astronomer.io/docs/astro/first-dag-onboarding
Learn how to run your first Apache Airflow® dag on Astro when you sign up for Astro.
Astro is the industry's leading managed service for [Apache Airflow®](https://airflow.apache.org/). To quickly learn how Astro works, follow the steps in this quickstart to create an Airflow environment and run your first dag.
When you first sign up for Astro, you can choose to tailor your experience based on how you plan to use Astro. The onboarding process includes:
* Creating an Organization, Workspace, and Deployment
* Choosing an example Airflow project template to clone into your own sample GitHub Repository
* Connecting your Astro Deployment to your sample GitHub Repository, so you can deploy code from GitHub
* Running your first dag on Astro
This tutorial takes about 15 minutes. If you're new to Airflow and want a more in-depth tutorial, see [Airflow 101 Learning Path](https://academy.astronomer.io/path/airflow-101).
## Prerequisites
* An Astro account. To start an Astro trial and create your free trial account, see [Start a trial](/docs/astro/trial).
* (Recommended) A [GitHub account](https://docs.github.com/en/get-started/signing-up-for-github).
If you're on your organization's network and can't access Astro, make a request to add the following domains to the allowlist on your network:
* `https://cloud.astronomer.io/`
* `https://api.astronomer.io/`
* `https://images.astronomer.cloud/`
* `https://auth.astronomer.io/`
* `https://updates.astronomer.io/`
* `https://install.astronomer.io/`
* `https://astro-.datakin.com/`
* `https://.astronomer.run/`
## Step 1: Tailor your Astro experience
Based on how you plan to use Astro, you can find more resources for particular topics relevant to your needs.
* **Business** or **Personal** use
* Familiarity with Apache Airflow
* Use cases, including:
* AI/ML
* Business Operations
* Reporting and Analytics
* Extract, transform, and loading operations (ETL)
* Other
## Step 2: Create your Organization and Workspace
Enter a name for your Organization and Workspace. These can be changed later in the Astro UI.
An Astro *Organization* is the highest level entity in Astro and represents a shared space for your company on Astro. An Organization is automatically created when you first sign up for Astronomer. At the Organization level, you can manage all of your users, Deployments, Workspaces, and clusters from a single place in the Astro UI. A *Workspace* is a collection of Deployments that can be accessed by a specific group of users.
## Step 3: Select a template
An *Astro project* contains the set of files necessary to run Airflow, including dedicated folders for your dag files, plugins, and dependencies. Select a template Astro project to immediately get a demonstration of Airflow's orchestration capabilities.
* **Generative AI**: Airflow is a common orchestration engine for AI/Machine Learning jobs, especially for retrieval-augmented generation (RAG). This [generative AI project](https://github.com/astronomer/templates/blob/main/generative-ai/README.md) shows a simple example of building vector embeddings for text and then performing a semantic search on the embeddings.
* **ETL**: Use a template to make an example [ETL pipeline](https://github.com/astronomer/templates/blob/main/etl/README.md). This template shows an example pattern for defining an ETL workload using DuckDB as the data warehouse of choice.
* **Learning Airflow**: This example project is generated when you run `astro dev init` using the Astro CLI. It shows a basic Astro project with Airflow components and dags.
* **dbt on Astro**: This template showcases using [dbt and Airflow together with Cosmos](https://github.com/astronomer/templates/blob/main/dbt-on-astro/README.md), allowing you to deploy dbt in production according to Airflow best practices.
* **None**: This option allows you to manually deploy a project after making a Deployment. See [Deploy code with GitHub](/docs/astro/deploy-github-integration) to use a GitHub connection with an existing project in a repo. Or, you can choose to manually build and Deploy an example dag by following the steps in [Run your first dag with the Astro CLI](/docs/astro/first-dag-cli) or [Run your first dag with GitHub Actions](/docs/astro/first-dag-github-actions).
## Step 4: Set up your Astro Deployment
You can now confirm your selected template and finish configuring your Deployment resources and whether you want to use a GitHub connection for code deploys.
An Astro *Deployment* is an instance of Apache Airflow that is powered entirely by core Airflow components, including a webserver, scheduler, and one or more workers. You deploy dags to a Deployment, and you can have one or more Deployments within a Workspace.
* **Selected template**: When you finalize your Deployment, you can confirm or change the template option you selected in Step 3.
* **Git connection**: Enter your **GitHub Owner** and **Repository Owner** information to deploy code directly to an Astro Deployment when you merge changes to a specific branch. If you choose to skip connecting to GitHub, later, you can return and manually build and Deploy an example dag by following the steps in [Run your first dag with the Astro CLI](/docs/astro/first-dag-cli) or [Run your first dag with GitHub Actions](/docs/astro/first-dag-github-actions).
* **Review Deployment**: Enter a **Name** for your Deployment and choose the **Provider** that you want to use and **Region** where you'd like to host your resources.
After you finish configuring your Deployment, click **Create your Project Repository and Deploy to Astro**.
## Step 5: Run your first dag on Astro
When you create your project and deploy it to Astro, this automatically creates a new Deployment and makes a private GitHub repository in your account with the template that you selected. Then, you can open Airflow and run your dag.
Newly-deployed dags are paused by default and will not start running automatically. To run one of the example dags in your Astro project according to its schedule, you must unpause it from the Airflow UI hosted on your Deployment.
If you did not connect to GitHub or choose a sample template to use, you can instead follow the steps in [Run your first dag with the Astro CLI](/docs/astro/first-dag-cli) or [Run your first dag with GitHub Actions](/docs/astro/first-dag-github-actions) to start working in Astro.
1. Click **Go to your Deployment**.
2. Click **Deployments** and then choose your active Deployment to view details about it.
3. Select **Deploy History** to see when your code successfully deploys from your GitHub repository.
4. After your deploy is successful, click **Open Airflow** to access the Airflow UI.
5. Manually trigger a dag run by clicking the play button in the **Actions** column. When you develop dags on Astro, triggering a dag run instead of waiting for the dag schedule can help you quickly identify and resolve issues.
6. (Optional) Depending on the template you use, you might be prompted to configure some parameters for your dag to use. You can choose to keep the default parameters, or make changes from the default. When you finish making changes, click **Trigger** to run your dag.
After you press **Play**, the **Runs** and **Recent Tasks** sections for the dag start to populate with data.
These circles represent different [states](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#task-instances) that your dag and task runs can be in.
7. Click the name of the dag to view more details about its execution.
To learn more about the Airflow UI and running dags, see [An introduction to the Airflow UI](/docs/learn/airflow-ui)
8. After your dag finishes executing, click **Logs** to view any printed output of your dag's results.
Congratulations! You deployed and ran your first dag on Astro!
## Next Steps
* Develop your [Astro project](/docs/cli/v1.43/run-airflow-locally).
* Read more about [Developing CI/CD workflows](/docs/astro/set-up-ci-cd).
* Install [the CLI](/docs/cli/v1.43/install-cli) to test dags or run Airflow locally.
* [Write your First dag](/docs/learn/get-started-with-airflow).
# Otto quickstart
Source: https://astronomer.io/docs/astro/get-started-otto
Run your first Otto session to author, debug, and manage Airflow Dags with AI assistance.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
This quickstart walks you through your first Otto session. By the end, Otto is running in your project and ready to help you author, debug, and manage Dags. You can also optionally start local Airflow so Otto can query Dag runs, task logs, connections, and variables.
Otto requires an Astro account. [Start a free trial](/docs/astro/trial) if you don't have one.
## Prerequisites
* [Astro CLI v1.42+](/docs/cli/v1.43/install-cli) installed.
* An [Astro account](/docs/astro/trial). Run `astro login`.
* (Optional) An Astro project folder. Otto works without an Astro project, but project context makes it more useful.
## Step 1: Launch Otto
From your Astro project folder, run:
```sh wrap theme={null}
astro otto
```
Otto opens an interactive terminal interface. The CLI handles authentication automatically.
**Have Otto start local Airflow**
You can also prompt Otto to start a local Airflow environment:
> "Configure this project for standalone mode and start local Airflow."
With Airflow running, Otto can use the [`af` CLI](/docs/astro/otto-tools#af-cli) to query Dag runs, task logs, connections, and variables on the live instance, and [automatic Dag validation](/docs/astro/otto-tools#automatic-dag-validation) runs after each edit. See [Local Airflow overview](/docs/cli/v1.43/local-airflow-overview) for the standalone vs Docker comparison.
## Step 2: Run your first prompt
Enter a prompt in the input area. To explore your project, try:
> "Look at my Dags and summarize each one."
Otto reads your Dag files, checks the running Airflow instance for metadata, and provides a summary of each Dag with its schedule, tasks, and dependencies.
### Other prompts to try
> "Check my Dags for deprecated patterns."
Otto validates your code against your Airflow version.
> "Why did my last Dag run fail?"
Otto checks task logs and run history to diagnose failures.
> "Create a new Dag that pulls data from Snowflake and loads it into Postgres."
Otto authors a Dag using your project's conventions and connection IDs.
## Step 3: Resume a session
Otto persists session history automatically. To continue your most recent session:
```sh wrap theme={null}
astro otto --continue
```
To pick from a list of previous sessions in an interactive picker:
```sh wrap theme={null}
astro otto --resume
```
To open a specific session file:
```sh wrap theme={null}
astro otto --session
```
Session files are stored as JSONL at `~/.astro/otto/sessions/`.
## What Otto knows about your project
When you launch Otto in an Astro project folder, it automatically detects:
* **Project root**: The folder containing `.astro/` configuration. If Otto doesn't find one, it falls back to the current working directory.
* **Airflow URL**: The local Airflow instance started by `astro dev start`.
* **Memory**: Existing memory files in `.astro/memory/` (shared project memory), `~/.astro/memory//` (local project memory), or `~/.astro/memory/` (local user memory). See [Memory](/docs/astro/otto-memory).
## Next steps
* [Skills](/docs/astro/otto-skills) — Browse Otto's bundled skills and author your own for team-specific workflows.
* [Tools](/docs/astro/otto-tools) — Explore the full set of tools Otto uses, including the af CLI for Airflow.
* [Memory](/docs/astro/otto-memory) — Learn how Otto accumulates and uses team-specific knowledge.
# Author dags with the Astro IDE
Source: https://astronomer.io/docs/astro/ide-author-dags
Author Airflow dags in the Astro IDE with AI-assisted code generation and project rules.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
The Astro IDE supports building, updating, understanding, and customizing Airflow dags with or without the Astronomer AI assistant. The AI features in the IDE are powered by [Otto](/docs/astro/otto-overview), Astronomer's data engineering agent. Otto brings Airflow-specific context, team memory, and specialized skills to code generation. For more details on Otto's capabilities, including memory, skills, and Airflow tools, see the [Otto overview](/docs/astro/otto-overview).
AI features can be enabled or disabled Organization-wide by an Organization Owner. When disabled, all AI-driven capabilities in the IDE are unavailable for all users. To learn how to configure this setting, see [Enable or disable AI features for your Organization](/docs/astro/enable-disable-astro-ai).
## Author dag code with or without AI
The Astro IDE allows you to write or modify dag code directly. Or, you can use AI-powered features to generate or refactor code, including:
* Use context-aware AI tools to suggest, generate, or improve dag code, operator logic, and project structure.
* Ask the Astro IDE questions about the project to better understand existing dag code structure, logic, and dependencies.
* View the Astro IDE's reasoning, streaming live in the AI panel as it proposes changes.
* Review all proposed code changes before choosing to accept or reject them.
* Manually edit Python scripts, dag files, and supporting resources in the built-in editor.
When you author dags in the Astro IDE, this consumes some of your Workspace AI credits. See the [Preview FAQs](https://www.astronomer.io/product/ide/#faq) for more details.
## Add custom project rules for code generation
You can define custom instructions or rules that guide the AI for all code generation tasks within your Airflow project.
Open the **Project Settings** from the **More Actions** menu in the toolbar.
Enter your linting rules, conventions, or any special instructions for the Astro IDE in the **Custom Instructions** field.
Click **Update Project** to apply your custom rules. These instructions will be used for all AI-generated code in this project.
# Blueprint
Source: https://astronomer.io/docs/astro/ide-blueprint
Use Blueprint to create Airflow Dags from platform-defined templates in the Astro IDE, without writing Airflow code.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Blueprint is a template-based Dag authoring mode in the Astro IDE. Platform teams define reusable building blocks in Python. Analysts, analytics engineers, and data scientists assemble those blocks into production Dags through a visual builder and form-driven configuration, without writing Airflow code.
The open-source [astronomer/blueprint](https://github.com/astronomer/blueprint) library powers Blueprint in the Astro IDE, handling blueprint definition, YAML parsing, validation, and Dag generation. See the GitHub repository for the full API reference, blueprint authoring guide, and examples.
## How Blueprint works
Blueprint has two sides: platform teams define blueprints; other team members use them.
| Concept | What it is |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Blueprint** | A reusable building block defined in Python by the platform team. Each blueprint has a configuration schema that controls what users see and configure. |
| **Step** | An instance of a blueprint placed on the canvas and configured with specific values. |
| **Workflow** | A collection of steps with dependencies and a schedule, stored as a Dag YAML file in your project repository. |
| **Airflow Dag** | The production Dag generated automatically from the workflow Dag YAML. |
## Prerequisites
* An Astro Workspace with Astro IDE access.
* [Workspace Author](/docs/astro/user-permissions) permissions to use the Astro IDE. You need [Workspace Operator](/docs/astro/user-permissions) permissions to start ephemeral test Deployments.
* The [`airflow-blueprint`](https://github.com/astronomer/blueprint) library (version 0.2.0 or later) added to your project's `requirements.txt`.
* At least one blueprint defined in your project with its JSON schema generated. See [Set up blueprints](#set-up-blueprints).
## Set up blueprints
Platform teams complete this setup so blueprints appear in the Astro IDE library for other team members to use.
Add the following line to your project's `requirements.txt`:
```text title="requirements.txt" wrap theme={null}
airflow-blueprint>=0.2.0
```
Create blueprint files in your project under `dags/templates/`. Each blueprint is a Python class that defines a configuration schema and a `render()` method. The field descriptions you write become the form labels users see in the IDE.
The Astro IDE renders supported Pydantic field types as interactive form fields. The following types are supported:
| Pydantic type | UI field | Notes |
| --------------------------------- | -------------------- | ------------------------------------------------------------------ |
| `str` | StringField | |
| `int` | NumberField | step=1 |
| `float` | NumberField | |
| `bool` | BooleanField | |
| `Literal["a","b"]` | EnumField | |
| `list[str]` | ArrayField | |
| `list[int]` | ArrayField | Validates whole numbers on entry |
| `list[float]` | ArrayField | Validates numeric input on entry |
| `list` (untyped) | ArrayField | Treated as string array |
| `Field(ge=, le=, pattern=, etc.)` | Constraint props | Includes `exclusiveMin`/`exclusiveMax`, converted to ±1 |
| `Field(multiple_of=)` | NumberField step | Only for `float`; `int` always uses step=1 |
| `Optional[T]` / `T \| None` | Unwraps to T's field | Constraints from inner type preserved |
| `Optional[Literal["a","b"]]` | EnumField | |
| Multi-version blueprint | Matched variant | Matches by discriminator and `selectedVersion`; defaults to latest |
The following types are not supported and render as an unsupported field with a warning in the IDE:
| Pydantic type | Notes |
| -------------------------- | ---------------------------------------- |
| `str \| int` (true unions) | Shows "unsupported schema type" warning |
| Nested `BaseModel` | |
| `list[Model]` | |
| `list[bool]` | Text input doesn't fit true/false values |
| `dict[str, T]` | |
For full details on defining blueprints, including configuration models, field validation, and versioning, see the [Blueprint GitHub repository](https://github.com/astronomer/blueprint).
Create a file at `dags/loader.py` with the following content:
```python title="dags/loader.py" wrap theme={null}
from blueprint import build_all
build_all()
```
Airflow scans the `dags/` folder for Python files that contain Dag objects. This file tells Blueprint to discover all `.dag.yaml` files in your project, parse them, and register the resulting Dags with Airflow automatically.
For the Astro IDE to discover your blueprints, generate a JSON schema for each blueprint and output it to `blueprint/generated-schemas/` in your project:
```sh wrap theme={null}
blueprint schema > blueprint/generated-schemas/.schema.json
```
Repeat this command for each blueprint. The IDE reads this folder to determine which blueprints are available and uses the schemas to render configuration forms.
After you add or update a blueprint, regenerate its schema so the Astro IDE picks up the changes.
Commit the generated schema files in `blueprint/generated-schemas/` to your repository so the IDE can read them when you or your team members open the project.
## Build a workflow with Blueprint
After your platform team has set up blueprints, other team members can build workflows in the Astro IDE without writing Airflow code.
1. Open your project in the Astro IDE.
2. Click the **Blueprint** toggle in the top navigation bar. The interface switches to Blueprint mode.
Click **New DAG** to create a new workflow. Enter a Dag ID and click **Generate DAG**. Blueprint creates a new Dag YAML file in your project's `dags/` folder.
To open an existing workflow, select it from the workflow list.
1. Browse the library panel on the left side of the canvas. The library shows all blueprints your platform team has defined and registered.
2. Drag a blueprint from the library onto the canvas. Each item you add to the canvas is a *step*.
3. Repeat to add more steps.
To configure Dag properties such as a description, Dag ID, or schedule, click **DAG Properties**.
1. Click a step on the canvas to open its configuration form in the right panel.
2. Fill in the fields your platform team has exposed. The IDE marks required fields. Field descriptions explain what each value controls.
The configuration form only shows fields your platform team has explicitly exposed. Operational settings like retry logic, connection credentials, and default values are baked into the blueprint.
To define the order in which steps run, draw a dependency line between them:
1. Hover over the step that should run first. A connection point appears at the edge.
2. Click and drag from that connection point to the next step.
3. Release to create the dependency. An arrow appears between the two steps.
Steps with no dependencies run in parallel.
1. Open the **DAG Properties** panel.
2. Enter a cron expression in the **Schedule** field.
3. Configure any additional pipeline-level settings such as **Description**.
## Test a workflow
After building your workflow, test it in an ephemeral Deployment. See [Test and run code with the Astro IDE](/docs/astro/ide-test-run) for instructions.
### Fix issues
If a task fails or produces unexpected output:
* **Edit the configuration directly**: Click the step on the canvas to reopen its configuration form and adjust the values.
* **Use Ask AI to Fix**: Click **Ask AI to Fix** next to an error message for AI-generated suggestions on how to resolve the issue.
After making changes, click **Sync to Test** to push the updated configuration to the running Deployment without restarting it.
## Commit and deploy
After testing, commit your workflow and deploy it. See [Deploy code from the Astro IDE](/docs/astro/ide-deploy) or [Deploy code from the Astro IDE to Git](/docs/astro/ide-deploy-git).
# Deploy code from the Astro IDE
Source: https://astronomer.io/docs/astro/ide-deploy
Deploy Airflow dag changes from the Astro IDE directly to an Astro Deployment.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
The Astro IDE offers an integrated workflow for deploying Airflow dag changes. This allows you to deploy your latest changes from the Astro IDE to your Astro environment.
## Deploy to an Astro Deployment
Follow these steps to deploy your latest changes from the Astro IDE to your Astro environment.
### Prerequisites
* An [Astro Deployment](/docs/astro/create-deployment).
* The project must have been:
* Imported using the [Astro GitHub integration](/docs/astro/deploy-github-integration), or
* Imported with the Astro CLI, or
* Created directly in the Astro IDE.
Projects imported via manual Git provider configuration cannot be deployed directly from the IDE. Commit and push your changes to your Git provider, then use your organization's standard CI/CD pipeline to deploy.
### Deploy your changes
In the Astro IDE, click the **More Actions** menu toolbar and select **Deploy Project...**.
In the **Deploy Project** dialog:
* Review or edit the **Version** you want to deploy.
* Select the **Deployment** target from your available Deployments.
Click **Deploy Project** to start the code deploy.
In the Astro UI, open the target Deployment and check **Deploy History** in the **Overview** tab.
Confirm that the latest deployment entry shows **Astro IDE** in the **Deployed By** column to verify your code was successfully deployed from the IDE.
# Deploy code from the Astro IDE to Git
Source: https://astronomer.io/docs/astro/ide-deploy-git
Review, commit, and push Airflow dag changes from the Astro IDE to a connected Git repository.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
The Astro IDE provides an integrated workflow for reviewing, committing, and deploying Airflow dag changes directly to a connected Git repository.
## Review, commit, and push changes with Git
The Astro IDE allows you to review, accept, and commit code updates directly to a connected Git repository.
### Prerequisites
* An Astro IDE project connected to a Git provider:
* [Imported from GitHub](/docs/astro/ide-import-github-project) using the Astro GitHub integration, or
* [Manually imported from any Git provider](/docs/astro/ide-import-git-project).
### Commit and push your changes
1. Review the suggested code changes directly in the code view and evaluate the AI’s suggestions and reasoning, visible in the left panel.
2. Accept or reject each proposed change using the **Accept** or **Reject** button.
1. After accepting changes, click **Commit changes...** in the toolbar.
2. In the commit dialog, you can enter a commit message manually, or click the wand icon to generate an AI summary. You can edit the AI-generated message before saving.
3. Review the list of staged changes and confirm or switch the branch you are committing to.
There are two ways to create a new branch for your commits in Astro IDE:
* Click the branch selector dropdown in the toolbar. In the input field that appears, type a new branch name and select the option to create a new branch from your current branch. Click **Create Branch**.
* In the commit dialog, click the **Edit branch** button next to the branch name. Enter your new branch name, then click **Commit and push**.
Both methods allow you to isolate your changes in a new branch.
1. Click **Commit and push** to sync your changes with the selected branch in your remote Git repository.
2. Confirm the commit in Git. Your message and all accepted changes appear in the repository history.
# Import CLI projects to the Astro IDE
Source: https://astronomer.io/docs/astro/ide-import-cli-project
Import an existing local Astro project into the Astro IDE using the CLI.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Import an existing project into the Astro IDE by uploading a local CLI project.
## Connect a CLI project
### Prerequisites
* A [local Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) directory that you want to import.
* The [Astro CLI](/docs/cli/v1.43/install-cli) installed and authenticated locally.
* [Workspace Author](/docs/astro/user-permissions) permissions.
### Import your project
From the Astro UI main menu, select **Astro IDE**.
Click **Projects** to open the Projects tab.
Click **+ Add Project**, then select **Import CLI Project** from the dropdown menu.
Copy the command from the dialog and run it in your terminal from the root of your existing Astro CLI project directory. This command uploads your local project files to the Astro IDE:
```sh wrap theme={null}
astro ide project export
```
Return to the Astro IDE and refresh the page to see your imported project.
## Start a new session with your imported project
After importing your project, you can start a new session with it.
### Prerequisites
You need to have an imported project in the Astro IDE. Follow the steps in [Connect a CLI project](#connect-a-cli-project) to import a CLI project if you haven't already.
### Open your project in a new session
From the Astro UI main menu, select **Astro IDE**.
Click **Projects** to open the Projects tab.
Click **New Session** next to the project you imported to start a new session with that project.
**Resume a previous session**
Once you have created a session with your imported project, you can close it, and later resume it. In the Astro IDE, go to the **Sessions** tab, and click the session you want to resume.
# Import a Git project to the Astro IDE
Source: https://astronomer.io/docs/astro/ide-import-git-project
Import an existing Git-based project from any provider into the Astro IDE.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Import an existing Git-based project from your preferred provider into the Astro IDE.
You can't deploy code directly to an Astro Deployment from projects imported with a manual Git provider configuration.
To deploy, commit and push your changes back to your Git provider, then trigger your usual CI/CD deployment process.
Direct deploy from the IDE is only supported for projects imported with the Astro GitHub integration, the Astro CLI, or projects created in the IDE. See [Deploy code from the Astro IDE](/docs/astro/ide-deploy).
## Import a Git project
To import a GitHub project using the Astro GitHub integration, see the [GitHub import guide](/docs/astro/ide-import-github-project).
### Prerequisites
* [Workspace Author](/docs/astro/user-permissions) permissions.
* A remote Git repository containing an Astro project.
* Access permissions to the repository.
* Project size under 200 MB and individual file sizes under 1 MB. See [Project requirements](/docs/astro/ide-overview#project-requirements).
### Import your project
From the Astro UI, select **Astro IDE**.
Click **Projects** to open the **Projects** tab.
Click **+ Add Project**, then select **Import Git Project** from the dropdown menu.
* Select your Git provider: **GitHub**, **GitLab**, **Bitbucket**, **Azure Repos**, or **Generic**.
If you use self-hosted GitHub Enterprise Server, select **Generic** instead of **GitHub**. The **GitHub** option is only for GitHub.com (cloud-hosted) repositories.
* Fill in the following fields:
* **Account**: The organization or user as shown in the provider URL.
* **Repository/Project**: The repository or project name.
* **Astro Project Path**: The subdirectory where your Astro project is located, if not at repository root.
* **Branch**: The branch to use. Defaults to the provider's default branch.
* Select authentication type. Available authentication types may differ slightly for each Git provider:
* **Basic**
* **Personal access token**
* **Deploy key or Personal SSH key**
* **None (public repository)**: Select if you are connecting to a public repository that doesn't require authentication. You can't push changes to the remote repository without authentication.
Click **Connect** to begin importing.
After connecting, the Astro IDE clones your code and prepares the environment.
Your imported project appears in the Astro IDE.
## Start a new session with your imported project
After importing your project, you can start a new session with it.
### Prerequisites
* An imported project in the Astro IDE. See [Import a Git project](#import-a-git-project) to import one if you haven't already.
### Open your project in a new session
From the Astro UI main menu, select **Astro IDE**.
Click **Projects** to open the Projects tab.
Click **New Session** next to the project you imported to start a new session with that project.
**Resume a previous session**
Once you have created a session with your imported project, you can close it, and later resume it. In the Astro IDE, go to the **Sessions** tab, and click the session you want to resume.
# Import GitHub projects to the Astro IDE
Source: https://astronomer.io/docs/astro/ide-import-github-project
Import an existing project into the Astro IDE by connecting your GitHub repository.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Import an existing project into the Astro IDE by connecting your GitHub repository.
## Connect a GitHub project
### Prerequisites
* A configured [Astro GitHub integration](/docs/astro/deploy-github-integration).
* [Workspace Author](/docs/astro/user-permissions) permissions.
* Project size under 200 MB and individual file sizes under 1 MB. See [Project requirements](/docs/astro/ide-overview#project-requirements).
### Connect your GitHub repository
From the Astro UI main menu, select **Astro IDE**.
Click **Projects** to open the Projects tab.
Click **+ Add Project**, then select **Import Git Project** from the dropdown menu.
Click **Connect to GitHub project...**, then select a GitHub organization:
* Choose your organization or personal GitHub account from the list.
* Click **Add an organization from GitHub** if your organization isn't listed, and follow the prompts.
Select a repository.
* Choose from the **Repository** list of options. The Astro IDE only allows you to select from repositories that the GitHub app is authorized to access.
* (Optional) Enter the **Astro Project Path** if your Astro project isn't in the repository root.
* (Optional) Set a **Git Branch**. If not specified, the Astro IDE uses the default branch of the repository.
Click **Connect** to import your project. The Astro IDE can now load your repository and set up your environment.
## Start a new session with your imported project
After importing your project, you can start a new session with it.
### Prerequisites
You need to have an imported project in the Astro IDE. Follow the steps in [Connect a GitHub project](#connect-a-github-project) to import a GitHub project if you haven't already.
### Open your project in a new session
From the Astro UI main menu, select **Astro IDE**.
Click **Projects** to open the Projects tab.
Click **New Session** next to the project you imported to start a new session with that project.
**Resume a previous session**
Once you have created a session with your imported project, you can close it, and later resume it. In the Astro IDE, go to the **Sessions** tab, and click the session you want to resume.
# Astro IDE overview
Source: https://astronomer.io/docs/astro/ide-overview
Learn about the Astro IDE, a browser-based workspace for writing, testing, and deploying Airflow Dags.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
The Astro IDE provides a browser-based workspace for Apache Airflow. In the IDE, you can write code, validate and test changes, and deploy or push your work directly, without a local development environment.
With Blueprint, the IDE also supports template-based Dag creation. Platform teams define reusable step templates with built-in guardrails, and team members such as analysts, analytics engineers, and data scientists can assemble them into production Dags through forms and a visual builder, without writing Airflow code or learning Airflow concepts.
## What is the Astro IDE?
The Astro IDE is an integrated development environment designed specifically for Airflow Dag development. The AI features are powered by [Otto](/docs/astro/otto-overview), Astronomer's data engineering agent, and help write and edit Dag code with awareness of your Airflow version, existing repository patterns, and Deployment environment. The Astro IDE has additional features that help you build, test, and ship Dags directly in the browser.
## Why use the Astro IDE?
General-purpose AI tools generate Dag code without understanding the specifics of your project, often resulting in output that requires significant modification. Traditional Dag development also demands manual local configuration and container management, which slows iteration. The Astro IDE removes these barriers, enabling you to:
* Write and update Airflow Dags more efficiently, with context-aware code generation.
* Test and deploy code directly from the browser with no extra steps or tools required.
* Apply project rules to help maintain code quality.
* Scale Dag creation beyond the platform team by letting analysts and other team members build workflows from governed templates using Blueprint.
## Core features
* **AI powered by Otto**: Generate Dag code that follows Airflow best practices, tailored to your project history, connections, and Astro Workspace. Otto brings Astronomer's proprietary knowledge about Airflow compatibility, team-specific memory, and specialized skills. [Learn more about authoring Dags](/docs/astro/ide-author-dags). For details on Otto's capabilities, see [Otto overview](/docs/astro/otto-overview).
* **No local setup required**: Run everything in the browser.
* **Project checks and guardrails**: Maintain project standards and code quality through linting and project rules. [Add custom project rules](/docs/astro/ide-author-dags#add-custom-project-rules-for-code-generation).
* **Integrated deployment and version control**: Deploy to Astro and push changes to branches. [See Deployment workflows](/docs/astro/ide-deploy).
* **Blueprint (Preview)**: Create Dags by assembling platform-defined templates through a visual builder. Platform teams control defaults, guardrails, and operational settings while other team members focus on their SQL or Python logic. [Learn more about Blueprint](/docs/astro/ide-blueprint).
## What can you do with the Astro IDE?
* **Create new Dags**: Generate Airflow-compliant code, including common operators and projects, with AI assistance. [Author Dags](/docs/astro/ide-author-dags).
* **Create Dags from templates with Blueprint**: Browse a curated library of templates defined by your platform team, assemble them into workflows on a visual canvas, configure each step through simple forms, and test the result in an ephemeral deployment — all without writing Airflow code. [Use Blueprint](/docs/astro/ide-blueprint). *(Preview)*
* **Update and refactor**: Edit existing Dags, including performing Airflow version upgrades.
* **Import projects**: Bring code into the IDE from any supported Git provider:
* [Import from GitHub](/docs/astro/ide-import-github-project) using the Astro GitHub integration.
* [Import from any Git provider manually](/docs/astro/ide-import-git-project).
* [Import a local project with the Astro CLI](/docs/astro/ide-import-cli-project).
* **Customize and extend**: Build custom operators or orchestrate dbt projects using [Cosmos](https://astronomer.github.io/astronomer-cosmos/).
* **Isolate test configuration per project**: Link connections, Airflow variables, and environment variables to specific Astro IDE projects so that ephemeral test Deployments start with the values you need, without affecting production Deployments. See [Link connections to Astro IDE projects](/docs/astro/create-and-link-connections#link-connections-to-astro-ide-projects). You can also [migrate existing connections and variables](/docs/astro/migrate-metadata-db-to-environment-manager) from a Deployment's metadata database into the Environment Manager.
* **Test and deploy**: Start an ephemeral test Deployment for quick feedback or test against an existing Astro Deployment, then deploy changes to Astro or GitHub. See [Test and run code](/docs/astro/ide-test-run), [Deploy code to Astro](/docs/astro/ide-deploy), and [Deploy code to Git](/docs/astro/ide-deploy-git).
## Project requirements
The following size limits apply to Astro IDE projects:
* **Maximum project size**: 200MB
* **Maximum file size**: 1MB
You cannot import or sync projects that exceed these limits. If your project exceeds these limits, consider excluding large files or folders that are not required for Dag development.
To get started, see the [IDE quickstart](/docs/astro/ide-quickstart).
# Astro IDE Quickstart
Source: https://astronomer.io/docs/astro/ide-quickstart
Create your first project in the Astro IDE and run it on an ephemeral test Deployment.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Get started with Astro IDE by entering a prompt, deploying to an ephemeral test Deployment, and testing your Airflow Dag.
## Prerequisites
* Workspace Operator permissions in an [Astro Workspace](/docs/astro/manage-workspaces).
Workspace Author permissions let you create and edit projects with the Astro IDE, but you need Workspace Operator permissions to start an ephemeral test Deployment.
## Build and deploy your first Dag
1. Log in to the Astro UI.
2. Click **Astro IDE** in the menu. If you are the first person in your Workspace to use the Astro IDE, the **Projects** page is empty.
3. You have several options to get started in the Astro IDE:
* [**Connect GitHub Project**](/docs/astro/ide-import-github-project) – Use the Astro GitHub integration to directly import a repository.
* [**Connect a project from any Git provider**](/docs/astro/ide-import-git-project) – Configure a manual connection for GitLab, Bitbucket, Azure Repos, or any generic Git provider.
* [**Connect CLI Project**](/docs/astro/ide-import-cli-project) – Upload a local Astro project using the CLI.
* Enter a prompt in the text box describing what kind of pipeline you want to build. The Astro IDE will generate a new project from your prompt.
4. This quickstart guides you through creating a new project from a prompt.
Projects in the Astro IDE are visible to all members of your Workspace, but sessions are private. Only you can see and access your own sessions and conversation history.
1. In the Astro IDE, enter the following prompt in the text box describing the Hello World Dag you want to build. The more specific the prompt is, the better the agent performs. For this quickstart, enter:
```text wrap theme={null}
Generate a dag called hello_world_dag that prints 'Hello World' to the logs. The dag should:
- Not require the scheduler to be running.
- Contain a single PythonOperator task named print_hello.
```
The Astro IDE ephemeral test environment sets `AIRFLOW__SCHEDULER__USE_JOB_SCHEDULE=false` by default. This means scheduled or downstream tasks do not run automatically. This setting enables the **Test** tab to give you direct, manual control over when tasks run, instead of relying on Airflow’s scheduler.
2. The Astro IDE generates the code and display the proposed changes in the suggested changes panel.
3. Review the changes, and iterate on them with the AI panel. Once you are satisfied with the changes, click the **Keep changes** (✔️) button in the panel to approve the new Dag.
1. After you accept a code change, click **Start Test Deployment** to test your changes. This deploys the generated code to an ephemeral test Deployment that allows you to run tasks and view logs.
Instead of starting an ephemeral test Deployment, you can open the **Test** tab and click **Use an existing Deployment** to test against an Astro Deployment your team already runs. See [Test against an existing Deployment](/docs/astro/ide-test-run#test-against-an-existing-deployment).
AI can make mistakes, and the generated code can sometimes throw an import error. If you have an import error, the `hello_world_dag` doesn't appear in the **Test** tab, and the IDE lists the error in the **Import Errors** of the **Test Output** pane. To fix the error, paste the error message into the prompt box, so the IDE can suggest edits. Review the suggested changes, accept them, and click **Sync to Test** to update the Deployment.
2. Open the **Test** tab and select **hello\_world\_dag** from the Dag options.
3. Click **Run Task** to execute the Dag.
4. Confirm the task ran successfully by checking the **Task Logs**.
You can also view your ephemeral test Deployment in the Airflow UI by clicking **Open Airflow** from the toolbar menu.
Your session persists even if you close your browser. The AI agent continues processing prompts in the background, and your full conversation history is preserved. Return to the Astro IDE at any time to resume where you left off.
# Test and run code with the Astro IDE
Source: https://astronomer.io/docs/astro/ide-test-run
Test and run Airflow Dags in the Astro IDE using ephemeral test Deployments or an existing Astro Deployment.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
The Astro IDE enables you to quickly test, validate, and iterate on Airflow Dags without needing a local Airflow or Docker environment. You can test your code in two ways:
* Start an ephemeral test Deployment to run your code in a temporary, isolated environment based on your project configuration.
* Test against an existing Astro Deployment in your Workspace to reuse the configuration, connections, and resources it already runs.
In both cases, you can see how your code runs in a real environment, adjust Deployment settings, and troubleshoot using built-in interfaces.
## How ephemeral test Deployments work
Ephemeral test Deployments offer a temporary environment to run and validate your Airflow Dag changes before merging or deploying to production.
* Start an ephemeral test Deployment to launch an isolated environment based on your project configuration.
* Run your Dag and validate behavior using real dependencies, environment variables, and integrations.
* Detect import errors, syntax issues, or runtime problems as they occur in a realistic environment.
* Tear down the environment automatically when testing is complete, with no impact on existing Deployments.
Using ephemeral Deployments in the Astro IDE consumes some of your Workspace AI credits. See the [Preview FAQs](https://www.astronomer.io/product/ide/#faq) for more details.
## Test against an existing Deployment
Instead of starting an ephemeral test Deployment, you can point your session at an existing Astro Deployment in your Workspace and test your Dags against the configuration, connections, and resources it already runs. This skips provisioning and lets you validate changes against a Deployment your team owns.
When you attach a session to an existing Deployment, the Astro IDE deploys your session's image and Dags to that Deployment, overwriting the image and Dags currently running there. The Deployment keeps its own connections, Airflow variables, environment variables, and resource configuration, so your Dags run against the values already configured on that Deployment rather than the objects linked to your Astro IDE project.
Unlike ephemeral test Deployments, an existing Deployment runs with its own configuration, so the presets optimized for ephemeral testing don't apply. For example, the Astro IDE doesn't set `AIRFLOW__SCHEDULER__USE_JOB_SCHEDULE=false`, so the Airflow scheduler runs as configured on that Deployment.
You need the `workspace.deployments.create` permission to test against an existing Deployment. Workspace Operator and higher roles have this permission. If you don't have it, the option appears dimmed.
### Select a target Deployment
1. On the **Test** tab, with no active test Deployment, click **Use an existing Deployment** beneath **Start Test Deployment**.
2. In the **Use an existing Deployment** dialog, select a Deployment from your Workspace. Type to search by name, and scroll to load more results.
3. If the Deployment is already in use by another session, selecting it opens a confirmation dialog with a warning.
4. Click **Use Deployment** to confirm. If another session was using the Deployment, this takes over that session. The Astro IDE deploys your session's image and Dags to the selected Deployment.
The picker excludes Astro IDE test Deployments. A Deployment appears in the list but is dimmed and you can't select it if any of the following apply:
* It isn't healthy.
* CI/CD is enforced on it.
* Dag deploys are disabled on it.
* Remote execution is enabled on it.
### Sync changes to an existing Deployment
While your session is attached to an existing Deployment, click **Sync to Test** to deploy your latest changes to that Deployment.
### Stop using an existing Deployment
When your session is attached to an existing Deployment, the toolbar shows **Deployment** instead of **Test Deployment**. To detach your session:
1. Click the **Deployment** dropdown arrow.
2. Select **Stop using Deployment**.
Detaching leaves the Deployment running with the code you deployed to it. This differs from stopping an ephemeral test Deployment, which deletes the Deployment.
## Configure ephemeral test Deployment settings
Ephemeral test Deployments in the Astro IDE inherit default settings from your Workspace-level Astro IDE test Deployment configuration. You can adjust session-specific settings per Deployment, such as environment variables and connections, as needed within the IDE. To make connections, Airflow variables, or environment variables available to a project's ephemeral test Deployments, link them to the Astro IDE project from the Workspace Environment Manager. See [Make connections, Airflow variables, and environment variables available](#make-connections-airflow-variables-and-environment-variables-available).
#### Workspace-level Astro IDE test Deployment settings
You can control default resource behavior for ephemeral test Deployments in your Workspace under **Workspace Settings** > **General** > **Astro IDE**:
* **Test Deployment Timeout:** The amount of idle time before an ephemeral test Deployment is automatically stopped.
* **Test Deployment Cluster:** The cluster on which all new ephemeral test Deployments are provisioned.
* **Auto-Start Test Deployments:** When enabled, the Astro IDE automatically starts an ephemeral test Deployment for every session.
These workspace-level settings apply to all ephemeral test Deployments in the Astro IDE and you can tailor them to your Organization's needs.
Ephemeral test Deployments have some preset configurations optimized for testing. For example, `AIRFLOW__SCHEDULER__USE_JOB_SCHEDULE=false` disables automatic task scheduling, so tasks run only when manually triggered in the **Test** tab. This is by design for better test control.
## Make connections, Airflow variables, and environment variables available
Ephemeral test Deployments need access to the same connections, Airflow variables, and environment variables your Dags use against external systems, databases, and cloud services. Linking these objects to your Astro IDE project from the Workspace Environment Manager lets you validate code, integrations, and data dependencies in a realistic environment without sharing those values with your production Deployments.
Astronomer recommends linking environment objects to the specific Astro IDE project that needs them. Project-linked objects only affect that project's ephemeral test Deployments. See:
* [Link a connection to an Astro IDE project](/docs/astro/create-and-link-connections#link-a-connection-to-an-astro-ide-project)
* [Link an Airflow variable to an Astro IDE project](/docs/astro/create-and-link-variables#link-a-variable-to-an-astro-ide-project)
* [Link an environment variable to an Astro IDE project](/docs/astro/create-and-link-environment-variables#link-an-environment-variable-to-an-astro-ide-project)
If you want a value to be available to every Astro IDE project in the Workspace, configure project sharing on the object so that it auto-links to all projects. See [Configure project sharing for a Workspace](/docs/astro/create-and-link-connections#configure-project-sharing-for-a-workspace).
If you already define connections or Airflow variables in a Deployment's Airflow metadata database, you can move them into the Environment Manager and then link them to your Astro IDE projects. See [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager).
## Use a `.env` file for ephemeral test Deployments
When you start an ephemeral test Deployment, the Astro IDE automatically imports environment variables from a `.env` file in your project root. This lets you configure environment variables for testing without adding them through the Environment Manager.
### `.env` file format
Add a `.env` file to your project root with one variable per line:
```text wrap theme={null}
MY_API_KEY=your-api-key
DATABASE_URL=postgresql://user:password@host:5432/db
FEATURE_FLAG=true
```
### Variable precedence
[System environment](/docs/astro/platform-variables) variables always take precedence. If a variable in your `.env` file has the same name as a system variable, such as an Airflow or scheduler setting, the system variable overrides the `.env` value.
The Deployment does not store variables from your `.env` file as secrets. Use the [Environment Manager](/docs/astro/create-and-link-environment-variables) for sensitive credentials.
If the `.env` file is missing or invalid, the Deployment starts normally without importing variables.
## Access the Airflow UI
While testing, open the Airflow UI for your ephemeral Deployment to inspect Dags, tasks, and metadata using Airflow-native tools.
1. Click **Start Test Deployment** from your Dag in Astro IDE. After the Deployment starts, a dropdown arrow appears.
2. Click the dropdown arrow and select **Open Airflow**. The Airflow UI for your ephemeral test Deployment will open in a new browser tab, where you can inspect Dags, tasks, logs, and environment details.
# Import and export Airflow connections and variables
Source: https://astronomer.io/docs/astro/import-export-connections-variables
Learn how to import and export Apache Airflow objects between Airflow environments on Astro
After you create connections and variables in an Airflow environment, you might want to move them between environments for any of the following reasons:
* You are launching a production Airflow environment on Astro based on a locally running Airflow environment.
* You need to replicate a production Airflow environment on your local machine.
* Your team is migrating old Airflow environments to a new location.
Based on the [management strategy for your connections and variables](/docs/astro/manage-connections-variables), their storage location will vary. Use this document to learn how to export and import them from one environment to another.
If you use the Astro Environment Manager to [create connections](/docs/astro/create-and-link-connections), instead of importing and exporting connections from Airflow, you can configure the CLI to automatically retrieve connection details from Astro when you're working locally. See [Work locally with Airflow connections hosted on Astro](/docs/cli/v1.43/local-connections) to set up this configuration and learn more about how Astro stores and syncs connection information.
## From the Airflow UI and metadata database
When you use the Airflow UI to store your Airflow connections and variables, they are stored in Airflow's metadata database. If your variables are stored in Airflow's metadata database, you can use the Airflow UI to import and export them in bulk.
### Using the Airflow UI
To export variables from a local Airflow environment or Astro Deployment, complete the following steps:
1. In the Airflow UI, go to **Admin** > **Variables**.
2. Select the variables you want to export, then click **Export** in the **Actions** dropdown menu.
The selected variables are exported to your local machine in a file named `variables.json`.
To import variables to a local Airflow environment or Astro Deployment from a `json` file, complete the following steps:
1. Either create a new `json` file with environment variables or follow the previous steps to export a `json` file from an existing Airflow environment. Your `json` file should look similar to the following:
```json title="variables.json" wrap theme={null}
{
"my_string_var": "test",
"my_int_var": 1234,
"my_secret_var": "my_secret",
"my_json_var": {
"key1": "val1",
"key2": 123
}
}
```
2. In the Airflow UI, go to **Admin** > **Variables**.
3. Click **Choose file** and select the file containing your environment variables. Then, click **Import Variables**.
After the variables are updated, the UI will show a confirmation message.
For security reasons, you can't bulk import or export connections from the Airflow UI.
### Using the Astro CLI (Local environments only)
Use [`astro dev object export`](/docs/cli/v1.43/astro-dev-object-export), [`astro dev object import`](/docs/cli/v1.43/astro-dev-object-import), and [`astro dev run`](/docs/cli/v1.43/astro-dev-run) to import and export connections and variables from a local Airflow environment to various formats. For example:
* To export all Airflow objects including connections, variables, and pools to your Astro project `.env` file in a URI format, run:
```sh wrap theme={null}
astro dev object export --env-export
```
* To print only your connections in JSON format to STDOUT, run:
```sh wrap theme={null}
astro dev run connections export - --file-format=env --serialization-format=json
```
* To import all Airflow objects from a file named `myairflowobjects.yaml` to a locally running Airflow environment, run:
```sh wrap theme={null}
astro dev object import --settings-file="myairflowobjects.yaml"
```
## From a secrets backend
If you use a secrets backend to store connections and variables, you need to use your secrets backend's API to manage connections and variables between environments. Note that importing/exporting from a secrets backend is necessary only in rare circumstances, such as when:
* You want to migrate your secrets backend to a different account.
* You want to use your secrets as a reference for another Deployment and then customize it. Astronomer recommends maintaining separate `development` and `production` secrets backend.
* You want to migrate to a different cloud provider.
Refer to your secrets backend provider's documentation to learn how to manage resources using API calls:
* Google secret manager's [Python SDK](https://cloud.google.com/secret-manager/docs/reference/libraries#client-libraries-install-python) and [REST API](https://cloud.google.com/secret-manager/docs/reference/rest) reference.
* AWS secret manager's [Python SDK](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html) and [other SDKs](https://docs.aws.amazon.com/secretsmanager/latest/apireference/Welcome.html).
* Azure key vault's [SDK and API](https://learn.microsoft.com/en-us/azure/key-vault/general/developers-guide#apis-and-sdks-for-key-vault-management) reference.
* Hashicorp Vault's [Python SDK](https://developer.hashicorp.com/vault/docs/get-started/developer-qs#step-2-install-a-client-library)
To set up a secrets backend on Astro, see [configure secrets backend](/docs/astro/secrets-backend).
## From environment variables
This section covers **Deployment-level environment variables**. For information about **Workspace-level environment variables** managed through the Environment Manager, see [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables). Workspace-level environment variables cannot be bulk exported, similar to connections and Airflow variables in the Environment Manager.
If you use an `.env` file to manage your connections and variables as Deployment-level environment variables in a local Astro project, you can import your Airflow objects to another local Airflow Astro project by copying the `.env` file into the destination project.
The `.env` file is not pushed to your Deployment when you run `astro deploy`. However, you can use Astro CLI commands to import the contents of your `.env` file to an Astro Deployment using `astro deployment` commands.
If your connections and variables are stored in a local Airflow metadata database, you can also export these to a `.env` file and then import them to an Astro Deployment as environment variables.
* To export all Airflow objects from your local Airflow environment, including connections and variables, to an `.env` file in URI format, run:
```sh wrap theme={null}
astro dev object export --env-export
```
* To import all Airflow objects from an `.env` file to an Astro Deployment, run:
```sh wrap theme={null}
astro deployment variable create -d --load --env .env
```
If your connections and variables are defined as environment variables on an Astro Deployment, you can export them to a local Airflow environment using the Astro CLI.
* To export variables from your Deployment, run:
```sh wrap theme={null}
astro deployment variable list --deployment-id --save
```
This command exports your variables to a local file named `.env`. The values of secret environment variables will be redacted.
See [Set environment variables on Astro](/docs/astro/manage-env-vars).
## From the Airflow REST API
You can use the [Airflow REST API](/docs/astro/airflow-api) to import and export connections and variables from a Deployment or local Airflow environment. Note that the Airflow REST API can only access connections and variables that are stored in the Airflow metadata database.
To export connections from any Airflow environment, you can use the [List Connections API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_connections) and [Get Connection API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_connection).
To export variables from any Airflow environment, you can use the [List Variables API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_variables) and [Get Variable API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/get_variable).
To import connections or variables to any Airflow environment, you can use the [Create Connection API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_connection) and [Create Variable API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_variables) respectively.
# Run images from Amazon Elastic Container Registry (ECR)
Source: https://astronomer.io/docs/astro/kpo-ecr
Configure KPO to pull container images from Amazon ECR.
Policy-based setup is available only on Astro dedicated clusters. To run images from a private registry on Astro standard clusters, follow the steps in [Private Registry](/docs/astro/kpo-private-registry).
By default, the `KubernetesPodOperator` expects to pull container images that are hosted publicly. If your images are hosted on the container registry native to your cloud provider, you can grant access to the images directly.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/get-started-cli).
* An [Astro Deployment](/docs/astro/deployment-settings).
* Access to an Amazon ECR registry.
## Setup
If your Docker image is hosted in an Amazon ECR repository, add a permissions policy to the repository to allow the `KubernetesPodOperator` to pull the Docker image. You don't need to create a Kubernetes secret, or specify the Kubernetes secret in your dag. Docker images hosted in Amazon ECR repositories can only be pulled from AWS clusters.
1. Log in to the Amazon ECR Dashboard and then select **Menu** > **Repositories**.
2. Click the **Private** tab and then click the name of the repository that hosts the Docker image.
3. Click **Permissions** in the left menu.
4. Click **Edit policy JSON**.
5. Copy and paste the following policy into the **Edit JSON** pane:
```json wrap theme={null}
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowImagePullAstro",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam:::role/EKS-NodeInstanceRole-"
},
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
]
}
]
}
```
* Replace `` with your Astro AWS account ID.
* Replace `` with your Cluster ID. To find the Cluster ID, in the Astro UI go to **Settings** > **Clusters** (in the legacy UI, go to **Organization Settings** > **Clusters**), then select the cluster. The **ID** is displayed at the top, along with other information about the Astro Cluster.
6. Click **Save** to create a new permissions policy named **AllowImagePullAstro**.
The following snippet is the minimum configuration you'll need to create a `KubernetesPodOperator` task on Astro:
```python wrap theme={null}
from airflow.configuration import conf
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
namespace = conf.get("kubernetes", "NAMESPACE")
KubernetesPodOperator(
namespace=namespace,
image="",
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
task_id="",
get_logs=True,
in_cluster=True,
)
```
For each instantiation of the `KubernetesPodOperator`, you must specify the following values:
* `namespace = conf.get("kubernetes", "NAMESPACE")`: Every Deployment runs on its own Kubernetes namespace within a cluster. Information about this namespace can be programmatically imported as long as you set this variable.
* `image`: This is the Docker image that the operator will use to run its defined task, commands, and arguments. Astro assumes that this value is an image tag that's publicly available on [Docker Hub](https://hub.docker.com/). To pull an image from a private registry, see [Pull images from a Private Registry](/docs/astro/kpo-private-registry).
* `in_cluster`: If a Connection object is not passed to the `KubernetesPodOperator`'s `kubernetes_conn_id` parameter, specify `in_cluster=True` to run the task in the Deployment's Astro cluster.
Replace `` in the instantiation of the `KubernetesPodOperator` with the Amazon ECR repository URI that hosts the Docker image. To locate the URI:
* In the Amazon ECR Dashboard, click **Repositories** in the left menu.
* Open the **Private** tab and then copy the URI of the repository that hosts the Docker image.
# Run images from Google Artifact Registry
Source: https://astronomer.io/docs/astro/kpo-google-artifact-registry
Configure KPO to pull images from Google Artifact Registry.
Passwordless setup is available only on Astro dedicated clusters. For Astro standard clusters, follow the steps in [Private Registry](/docs/astro/kpo-private-registry) to create a Kubernetes secret containing your registry credentials.
By default, the `KubernetesPodOperator` expects to pull container images that are hosted publicly. If your images are hosted on the container registry native to your cloud provider, you can grant access to the images directly.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/get-started-cli).
* An [Astro Deployment](/docs/astro/deployment-settings).
* Access to your Google Artifact Registry repository.
## Setup
If your container image is hosted in Google Artifact Registry repository, add a permissions policy to the repository to allow the `KubernetesPodOperator` to pull the Docker image. You don't need to create a Kubernetes secret or specify the Kubernetes secret in your dag. Docker images hosted in Google Artifact Registry repositories can be pulled only to Deployments hosted on GCP clusters.
Contact [Astronomer support](https://support.astronomer.io) to request the Compute Engine default service account ID for your cluster.
1. Log in to Google Artifact Registry.
2. Click the checkbox next to the repository that you want to use.
3. In the **Properties** pane that appears, click **ADD PRINCIPAL** in the **PERMISSIONS** tab.
4. In the **Add Principals** text box, paste the Compute Engine default service account ID that was provided to you by Astronomer Support.
5. In the **Assign Roles** selector, search for `Artifact Registry Reader` and select the role that appears.
6. Click **Save** to grant read access for the registry to Astro.
The following snippet is the minimum configuration you'll need to create a `KubernetesPodOperator` task on Astro:
```python wrap theme={null}
from airflow.configuration import conf
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
namespace = conf.get("kubernetes", "NAMESPACE")
KubernetesPodOperator(
namespace=namespace,
image="",
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
task_id="",
get_logs=True,
in_cluster=True,
)
```
For each instantiation of the `KubernetesPodOperator`, you must specify the following values:
* `namespace = conf.get("kubernetes", "NAMESPACE")`: Every Deployment runs on its own Kubernetes namespace within a cluster. Information about this namespace can be programmatically imported as long as you set this variable.
* `image`: This is the Docker image that the operator will use to run its defined task, commands, and arguments. Astro assumes that this value is an image tag that's publicly available on [Docker Hub](https://hub.docker.com/). To pull an image from a private registry, see [Pull images from a Private Registry](/docs/astro/kpo-private-registry).
* `in_cluster`: If a Connection object is not passed to the `KubernetesPodOperator`'s `kubernetes_conn_id` parameter, specify `in_cluster=True` to run the task in the Deployment's Astro cluster.
When you configure an instantiation of the `KubernetesPodOperator`, replace `` with the Google Artifact Registry image URI. To retrieve the URI:
* In the Google Artifact Registry, click the registry containing the image.
* Click the image you want to use.
* Click the copy icon next to the image in the top corner. The string you copy should be in the format `-docker.pkg.dev///`.
# Mount temporary directory
Source: https://astronomer.io/docs/astro/kpo-mount-temporary-directory
Learn how to mount a temporary directory for the KubernetesPodOperator on Astro.
You can run a task run the `KubernetesPodOperator` that uses your [Deployment's ephemeral storage](/docs/astro/deployment-resources#configure-kubernetes-pod-resources), mount an [emptyDir volume](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir-configuration-example) to the `KubernetesPodOperator`.
## Prerequisites
* Set up the [`KubernetesPodOperator` on Astro](/docs/astro/kubernetespodoperator).
## Setup
Add the following code example to your `KubernetesPodOperator` configuration.
```python {5-14,26-27} wrap theme={null}
from airflow.configuration import conf
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from kubernetes.client import models as k8s
volume = k8s.V1Volume(
name="cache-volume",
emptyDir={},
)
volume_mounts = [
k8s.V1VolumeMount(
mount_path="/cache", name="cache-volume"
)
]
example_volume_test = KubernetesPodOperator(
namespace=namespace,
image="",
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
task_id="",
get_logs=True,
in_cluster=True,
volume_mounts=volume_mounts,
volumes=[volume],
)
```
# Run images from a private registry
Source: https://astronomer.io/docs/astro/kpo-private-registry
Configure KPO to pull privately hosted container images.
By default, the `KubernetesPodOperator` expects to pull container images that are hosted publicly. If your images are hosted on the container registry native to your cloud provider, you can grant access to the images directly. Otherwise, if you are using any other private registry, you need to create a Kubernetes Secret containing credentials to the registry, then specify the Kubernetes Secret in your dag.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/get-started-cli).
* An [Astro Deployment](/docs/astro/deployment-settings).
* Access to a private Docker registry.
## Setup
To run Docker images from a private registry on Astro, a Kubernetes Secret that contains credentials to your registry must be created. Injecting this secret into your Deployment's namespace will give your tasks access to Docker images within your private registry.
By default, the `KubernetesPodOperator` looks for publicly hosted images. However, you can pull images from a private registry.
1. Retrieve a `config.json` file that contains your Docker credentials by following the [Docker documentation](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials). The generated file looks similar to the following:
```json title="config.json" wrap theme={null}
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "c3R...zE2"
}
}
}
```
2. Submit a request to [Astronomer support](https://cloud.astronomer.io/open-support-request) for creating a Kubernetes Secret to enable pulling images from private registries. Astronomer Support can provide you the necessary instructions on how to generate and securely send the credentials.
1. Astronomer adds the Kubernetes secret to your Deployment, Astronomer notifies you and provides you with the name of the secret.
2. After you receive the name of your Kubernetes secret from Astronomer, you can run images from your private registry by importing `models` from `kubernetes.client` and configuring `image_pull_secrets` in your `KubernetesPodOperator` instantiation:
```python {1,5} wrap theme={null}
from kubernetes.client import models as k8s
KubernetesPodOperator(
namespace=namespace,
image_pull_secrets=[k8s.V1LocalObjectReference("")],
image="",
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
task_id="",
get_logs=True,
in_cluster=True,
)
```
# Run your Deployment's current Airflow image
Source: https://astronomer.io/docs/astro/kpo-run-current-image
Configure KPO to run your Deployment's current Airflow image.
## Run the current Airflow image
You can run your Deployment's current Airflow image with the `KubernetesPodOperator` by using the environment variable, `ASTRONOMER_AIRFLOW_IMAGE`. This environment variable allows you to run KPO tasks using the same Runtime image that your Deployment uses, in a way that won't be affected by underlying cluster infrastructure changes that might change the base image repository URL. The `ASTRONOMER_AIRFLOW_IMAGE` environment variable allows you to ensure that your Deployment retrieves the correct image URL.
## Setup
Add the `ASTRONOMER_AIRFLOW_IMAGE` environment variable to your KPO configuration. For example:
```python {10-14} wrap theme={null}
import os
from airflow.configuration import conf
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from kubernetes.client import models as k8s
KubernetesPodOperator(
namespace=conf.get("kubernetes", "NAMESPACE"),
image=os.getenv("ASTRONOMER_AIRFLOW_IMAGE"),
image_pull_secrets=[
k8s.V1LocalObjectReference("image-pull-secret"),
k8s.V1LocalObjectReference("per-dp-registry-pull-secret"),
],
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
task_id="",
get_logs=True,
in_cluster=True,
)
```
# Use secret environment variables
Source: https://astronomer.io/docs/astro/kpo-secret-env-var
Use secret environment variables in tasks running on the Kubernetes executor.
Astro [environment variables](/docs/astro/environment-variables) marked as secrets are stored in a Kubernetes secret called `env-secrets`. To use a secret value in a task running on the Kubernetes executor, you pull the value from `env-secrets` and mount it to the Pod running your task as a new Kubernetes Secret.
## Setup
Add the `Secret` import to your dag file:
```python wrap theme={null}
from airflow.kubernetes.secret import Secret
```
Define a Kubernetes `Secret` in your dag instantiation using the following format:
```python wrap theme={null}
secret_env = Secret(deploy_type="env", deploy_target="", secret="env-secrets", key="")
namespace = conf.get("kubernetes", "NAMESPACE")
```
Reference the key for the environment variable, formatted as `$VARIABLE_KEY` in the task using the `KubernetesPodOperator`.
## Example
In the following example, a secret named `MY_SECRET` is pulled from `env-secrets` and printed to logs.
```python wrap theme={null}
import pendulum
from airflow.kubernetes.secret import Secret
from airflow.models import DAG
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from airflow.configuration import conf
with DAG(
dag_id="test-kube-pod-secret",
start_date=pendulum.datetime(2022, 1, 1, tz="UTC"),
end_date=pendulum.datetime(2022, 1, 5, tz="UTC"),
schedule="@once",
catchup=False,
) as dag:
secret_env = Secret(deploy_type="env", deploy_target="MY_SECRET", secret="env-secrets", key="MY_SECRET")
namespace = conf.get("kubernetes", "NAMESPACE")
k = KubernetesPodOperator(
namespace=namespace,
image="ubuntu:16.04",
cmds=["bash", "-cx"],
arguments=["echo $MY_SECRET && sleep 150"],
name="test-name",
task_id="test-task",
get_logs=True,
in_cluster=True,
secrets=[secret_env],
)
```
# Use the @task.kubernetes decorator
Source: https://astronomer.io/docs/astro/kpo-task-decorator
Learn how to run the task.kubernetes decorator on Astro.
The `@task.kubernetes` decorator provides a TaskFlow alternative to the traditional `KubernetesPodOperator`, which allows you to run a specified task in its own Kubernetes pod. Note that the Docker image provided to the `@task.kubernetes` decorator's `image` parameter must support executing Python scripts in order to leverage the `KubernetesPodOperator` decorator.
Like regular `@task` decorated functions, XComs can be passed to the Python script running in the dedicated Kubernetes pod. If `do_xcom_push` is set to `True` in the decorator parameters, the value returned by the decorated function is pushed to XCom.
Astronomer recommends using the `@task.kubernetes` decorator instead of the `KubernetesPodOperator` when using XCom with Python scripts in a dedicated Kubernetes pod.
```python expandable wrap theme={null}
from pendulum import datetime
from airflow.configuration import conf
from airflow.decorators import dag, task
import random
# get the current Kubernetes namespace Airflow is running in
namespace = conf.get("kubernetes", "NAMESPACE")
@dag(
start_date=datetime(2023, 1, 1),
catchup=False,
schedule="@daily",
)
def kubernetes_decorator_example_dag():
@task
def extract_data():
# simulating querying from a database
data_point = random.randint(0, 100)
return data_point
@task.kubernetes(
# specify the Docker image to launch, it needs to be able to run a Python script
image="python",
# launch the Pod on the same cluster as Airflow is running on
in_cluster=True,
# launch the Pod in the same namespace as Airflow is running in
namespace=namespace,
# Pod configuration
# naming the Pod
name="my_pod",
# log stdout of the container as task logs
get_logs=True,
# log events in case of Pod failure
log_events_on_failure=True,
# enable pushing to XCom
do_xcom_push=True,
)
def transform(data_point):
multiplied_data_point = 23 * int(data_point)
return multiplied_data_point
@task
def load_data(**context):
# pull the XCom value that has been pushed by the KubernetesPodOperator
transformed_data_point = context["ti"].xcom_pull(
task_ids="transform", key="return_value"
)
print(transformed_data_point)
load_data(transform(extract_data()))
kubernetes_decorator_example_dag()
```
# Configure task-level Pod resources
Source: https://astronomer.io/docs/astro/kpo-task-level-resources
Learn how to configure task-level Pod resources for the KubernetesPodOperator on Astro.
Astro automatically allocates resources to Pods created by the `KubernetesPodOperator`. Unless otherwise specified in your task-level configuration, the amount of resources your task Pod can use is defined by your [default Pod resource configuration](/docs/astro/deployment-resources#configure-kubernetes-pod-resources). To optimize your resource usage, Astronomer recommends specifying [compute resource requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for each task.
## Setup
Define a `kubernetes.client.models.V1ResourceRequirements` object and provide that to the `container_resources` argument of the `KubernetesPodOperator`. For example:
The following code example ensures that when this dag runs, it launches a Kubernetes Pod with exactly 800m of CPU and 3Gi of memory as long as that infrastructure is available in your Deployment. After the task finishes, the Pod terminates gracefully.
```python {19} wrap theme={null}
from airflow.configuration import conf
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from kubernetes.client import models as k8s
compute_resources = k8s.V1ResourceRequirements(
limits={"cpu": "800m", "memory": "3Gi"},
requests={"cpu": "800m", "memory": "3Gi"}
)
namespace = conf.get("kubernetes", "NAMESPACE")
KubernetesPodOperator(
namespace=namespace,
image="",
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
container_resources=compute_resources,
task_id="",
get_logs=True,
in_cluster=True,
)
```
When you add custom labels, do not remove or modify the default Airflow labels that Astro applies to KPO Pods. See [Known limitations](/docs/astro/kubernetespodoperator#known-limitations).
On Astro Hosted, Astro automatically sets resource requests equal to limits for `KubernetesPodOperator` task Pods. This ensures Pods receive a Kubernetes [Guaranteed Quality of Service (QoS) class](https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed), which prevents resource contention and eviction. Because Astro uses the limit values as both requests and limits, your Pods are billed based on the limits you configure, even if actual usage is lower. To avoid unexpected charges, set limits close to the resources your task requires. Check your [Billing and usage](/docs/astro/manage-billing) to view your resource use and associated charges.
# Run the KubernetesPodOperator on Astro
Source: https://astronomer.io/docs/astro/kubernetespodoperator
Learn how to run the KubernetesPodOperator on Astro. This operator dynamically launches a Pod in Kubernetes for each task and terminates each Pod when the task is complete.
The [`KubernetesPodOperator`](https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes/stable/operators.html) is one of the most customizable Apache Airflow operators. A task using the `KubernetesPodOperator` runs in a dedicated, isolated Kubernetes Pod that terminates after the task completes. To learn more about the benefits and usage of the `KubernetesPodOperator`, see the [`KubernetesPodOperator` Learn guide](/docs/learn/kubepod-operator).
On Astro, the infrastructure required to run the `KubernetesPodOperator` is built into every Deployment and is managed by Astronomer. Astro supports setting a default Pod configuration so that any task Pods without specific resource requests and limits cannot exceed your expected resource usage for the Deployment.
Some task-level configurations will differ on Astro compared to other Airflow environments. Use this document to learn how to configure individual task Pods for different use cases on Astro. To configure the default Pod resources for all `KubernetesPodOperator` Pods, see [Configure Kubernetes Pod resources](/docs/astro/deployment-resources#configure-kubernetes-pod-resources).
## Known limitations
By default, Astro supports a maximum `KubernetesPodOperator` Pod size of 43 vCPU and 86 GiB of memory. Astro can support Pod sizes up to 86 vCPU and 172 GiB of memory on request. Contact [Astro support](/docs/astro/astro-support) if you need to run larger jobs on `KubernetesPodOperator`.
* Cross-account service accounts are not supported on Pods launched in an Astro cluster. To allow access to external data sources, you can provide credentials and secrets to tasks.
* Astro uses the following default Airflow labels on KPO Pods for internal health management:
* `kubernetes_pod_operator`
* `dag_id`
* `task_id`
* `run_id`
* `map_index`
* `try_number`
Do not remove or modify these labels. Changing them prevents Astro from reconciling Pods with running task instances, which can cause the KPO healer to incorrectly handle your Pods. You can add your own custom labels to KPO Pods without affecting this behavior. See [Configure task-level Pod resources](/docs/astro/kpo-task-level-resources) for an example.
* PersistentVolumes (PVs) are not supported on Pods launched in an Astro cluster.
* You can't use an image built for an ARM architecture in the `KubernetesPodOperator`. To build images using the x86 architecture on a Mac with an Apple chip, include the `--platform` flag in the `FROM` command of the `Dockerfile` that constructs your custom image. For example:
```dockerfile wrap theme={null}
FROM --platform=linux/amd64 postgres:latest
```
If you use an ARM image, your KPO task will fail with the error: `base] exec /usr/bin/psql: exec format error`.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project).
* An Astro [Deployment](/docs/astro/create-deployment).
## Set up the `KubernetesPodOperator` on Astro
The following snippet is the minimum configuration you'll need to create a `KubernetesPodOperator` task on Astro:
```python wrap theme={null}
from airflow.configuration import conf
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
namespace = conf.get("kubernetes", "NAMESPACE")
KubernetesPodOperator(
namespace=namespace,
image="",
cmds=[""],
arguments=[""],
labels={"": ""},
name="",
task_id="",
get_logs=True,
in_cluster=True,
)
```
For each instantiation of the `KubernetesPodOperator`, you must specify the following values:
* `namespace = conf.get("kubernetes", "NAMESPACE")`: Every Deployment runs on its own Kubernetes namespace within a cluster. Information about this namespace can be programmatically imported as long as you set this variable.
* `image`: This is the Docker image that the operator will use to run its defined task, commands, and arguments. Astro assumes that this value is an image tag that's publicly available on [Docker Hub](https://hub.docker.com/). To pull an image from a private registry, see [Pull images from a Private Registry](/docs/astro/kpo-private-registry).
* `in_cluster`: If a Connection object is not passed to the `KubernetesPodOperator`'s `kubernetes_conn_id` parameter, specify `in_cluster=True` to run the task in the Deployment's Astro cluster.
## Related documentation
* [How to use cluster ConfigMaps, Secrets, and Volumes with Pods](https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes/stable/operators.html#how-to-use-cluster-configmaps-secrets-and-volumes-with-pod)
* [`KubernetesPodOperator` Airflow Guide](/docs/learn/kubepod-operator)
# Launch a Pod in an EKS cluster on AWS
Source: https://astronomer.io/docs/astro/launch-pod-external-cluster-aws
Use the KubernetesPodOperator to launch Pods in an external EKS cluster on AWS from your Airflow instance.
If some of your tasks require specific resources such as a GPU, you might want to run them in a different cluster than your Airflow instance. In setups where both clusters are used by the same AWS, Azure, or GCP account, you can manage separate clusters with roles and permissions.
To launch Pods in external clusters from a local Airflow environment, you must have valid authentication for the external cluster so that your local Airflow environment has permissions to launch a Pod in the external cluster. For managed Kubernetes services from public cloud providers, authentication is federated through the native IAM service. To grant the Astro role permissions to launch pods on your cluster, you can either include static credentials or use workload identity to authorize the Astro role to your cluster.
This example shows how to set up an EKS cluster on AWS and run a Pod on it from an Airflow instance where cross-account access is not available.
## Prerequisites
* Network connectivity between your Airflow execution environment and the external Kubernetes cluster:
* **Hosted execution mode**: A [network connection](/docs/astro/networking-overview) between your Astro Deployment and the external cluster.
* **Remote execution mode**: Network connectivity between the environment where your [Remote Execution Agent](/docs/astro/remote-execution-overview) runs and the external cluster. You are responsible for managing this connectivity. A direct network connection between Astro and the external cluster is not required.
## Setup
1. [Create an EKS cluster IAM role](https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html#create-service-role) with a unique name and add the following permission policies:
* `AmazonEKSWorkerNodePolicy`
* `AmazonEKS_CNI_Policy`
* `AmazonEC2ContainerRegistryReadOnly`
Record the ARN of the new role, as it will be needed below.
2. [Update the trust policy](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/edit_trust.html) of this new role to include the [workload identity](/docs/astro/authorize-deployments-to-your-cloud) of your Deployment. This step ensures that the role can be assumed by your Deployment.
```json wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam:::",
"Service": [
"ec2.amazonaws.com",
"eks.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
```
3. If you don't already have a cluster, [create a new EKS cluster](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html) and assign the new role to it.
1. Use a `KubeConfig` file to remotely connect to your new cluster. On AWS, you can run the following command to retrieve it:
```sh wrap theme={null}
aws eks --region update-kubeconfig --name --kubeconfig my_kubeconfig.yaml
```
This command creates a new `KubeConfig` file called `my_kubeconfig.yaml`.
2. Ensure that the file below matches your generated KubeConfig. The newly generated KubeConfig must be edited to instruct the [AWS IAM Authenticator for Kubernetes](https://github.com/kubernetes-sigs/aws-iam-authenticator) to assume your new IAM Role created in Step 1. Replace `` with the IAM Role ARN from Step 1.
```yaml title="my_kubeconfig.yaml" expandable wrap theme={null}
apiVersion: v1
clusters:
- cluster:
certificate-authority-data:
server:
name:
contexts:
- context:
cluster:
user:
name:
current-context:
kind: Config
preferences: {}
users:
- name:
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
-
- eks
- get-token
- --cluster-name
-
- --role
-
command: aws
interactiveMode: IfAvailable
provideClusterInfo: false
```
Astronomer recommends creating a Kubernetes cluster connection because it's more secure than adding an unencrypted `kubeconfig` file directly to your Astro project.
1. Convert the `kubeconfig` configuration you retrieved from your cluster to JSON format.
2. In either the Airflow UI or the Astro environment manager, create a new **Kubernetes Cluster Connection** connection. In the **Kube config (JSON format)** field, paste the `kubeconfig` configuration you retrieved from your cluster after converting it from `yaml` to `json` format.
3. Click **Save**.
You can now specify this connection in the configuration of any `KubernetesPodOperator` task that needs to access your external cluster.
To connect to your external EKS cluster, you need to install the AWS CLI in your Astro project.
1. Add the following to your `Dockerfile` to install the AWS CLI:
```dockerfile title="Dockerfile" wrap theme={null}
USER root
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
# Note: if you are testing your pipeline locally you may need to adjust the zip version to your dev local environment
RUN unzip awscliv2.zip
RUN ./aws/install
USER astro
```
2. Add the `unzip` package to your `packages.txt` file to make the `unzip` command available in your Docker container:
```text title="packages.txt" wrap theme={null}
unzip
```
If you are working locally, you need to restart your Astro project to apply the changes.
In your `KubernetesPodOperator` task configuration, ensure that you set `cluster-context` and `namespace` for your remote cluster. In the following example, the task launches a Pod in an external cluster based on the configuration defined in the `k8s` connection.
```python wrap theme={null}
run_on_EKS = KubernetesPodOperator(
task_id="run_on_EKS",
kubernetes_conn_id="k8s",
cluster_context="",
namespace="",
name="example_pod",
image="ubuntu",
cmds=["bash", "-cx"],
arguments=["echo hello"],
get_logs=True,
startup_timeout_seconds=240,
)
```
## Example dag
The following dag uses several classes from the [Amazon provider package](https://airflow.apache.org/registry/providers/amazon/) to dynamically spin up and delete Pods for each task in a newly created node group. If your remote Kubernetes cluster already has a node group available, you only need to define your task in the `KubernetesPodOperator` itself.
The example dag contains 5 consecutive tasks:
* Create a node group according to the user's specifications (For the example that uses GPU resources).
* Use a sensor to check that the cluster is running correctly.
* Use the `KubernetesPodOperator` to run any valid Docker image in a Pod on the newly created node group on the remote cluster. The example dag uses the standard `Ubuntu` image to print "hello" to the console using a `bash` command.
* Delete the node group.
* Verify that the node group has been deleted.
```python expandable wrap theme={null}
# import DAG object and utility packages
from airflow import DAG
from pendulum import datetime
from airflow.configuration import conf
# import the KubernetesPodOperator
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import (
KubernetesPodOperator,
)
# import EKS related packages from the Amazon Provider
from airflow.providers.amazon.aws.hooks.eks import EksHook, NodegroupStates
from airflow.providers.amazon.aws.operators.eks import (
EksCreateNodegroupOperator,
EksDeleteNodegroupOperator,
)
from airflow.providers.amazon.aws.sensors.eks import EksNodegroupStateSensor
# custom class to create a node group with Nodes on EKS
class EksCreateNodegroupWithNodesOperator(EksCreateNodegroupOperator):
def execute(self, context):
# instantiating an EKSHook on the basis of the AWS connection (Step 5)
eks_hook = EksHook(
aws_conn_id=self.aws_conn_id,
region_name=self.region,
)
# define the Node group to create
eks_hook.create_nodegroup(
clusterName=self.cluster_name,
nodegroupName=self.nodegroup_name,
subnets=self.nodegroup_subnets,
nodeRole=self.nodegroup_role_arn,
scalingConfig={"minSize": 1, "maxSize": 1, "desiredSize": 1},
diskSize=20,
instanceTypes=["g4dn.xlarge"],
amiType="AL2_x86_64_GPU", # get GPU resources
updateConfig={"maxUnavailable": 1},
)
# instantiate the DAG
with DAG(
start_date=datetime(2022, 6, 1),
catchup=False,
schedule="@daily",
dag_id="KPO_remote_EKS_cluster_example_dag",
) as dag:
# task 1 creates the node group
create_gpu_nodegroup = EksCreateNodegroupWithNodesOperator(
task_id="create_gpu_nodegroup",
cluster_name="",
nodegroup_name="gpu-nodes",
nodegroup_subnets=["", ""],
nodegroup_role_arn="",
aws_conn_id="",
region="",
)
# task 2 check for node group status, if it is up and running
check_nodegroup_status = EKSNodegroupStateSensor(
task_id="check_nodegroup_status",
cluster_name="",
nodegroup_name="gpu-nodes",
mode="reschedule",
timeout=60 * 30,
exponential_backoff=True,
aws_conn_id="",
region="",
)
# task 3 the KubernetesPodOperator running a task
# here, cluster_context and the kubernetes_conn_id are defined at the task level.
run_on_EKS = KubernetesPodOperator(
task_id="run_on_EKS",
cluster_context="",
namespace="airflow-kpo-default",
name="example_pod",
image="ubuntu",
cmds=["bash", "-cx"],
arguments=["echo hello"],
get_logs=True,
in_cluster=False,
kubernetes_conn_id="k8s",
startup_timeout_seconds=240,
)
# task 4 deleting the node group
delete_gpu_nodegroup = EksDeleteNodegroupOperator(
task_id="delete_gpu_nodegroup",
cluster_name="",
nodegroup_name="gpu-nodes",
aws_conn_id="",
region="",
)
# task 5 checking that the node group was deleted successfully
check_nodegroup_termination = EksNodegroupStateSensor(
task_id="check_nodegroup_termination",
cluster_name="",
nodegroup_name="gpu-nodes",
aws_conn_id="",
region="",
mode="reschedule",
timeout=60 * 30,
target_state=NodegroupStates.NONEXISTENT,
)
# setting the dependencies
create_gpu_nodegroup >> check_nodegroup_status >> run_on_EKS
run_on_EKS >> delete_gpu_nodegroup >> check_nodegroup_termination
```
# Launch a Pod in an AKS cluster on Azure
Source: https://astronomer.io/docs/astro/launch-pod-external-cluster-azure
Use the KubernetesPodOperator to launch Pods in an external AKS cluster on Azure from your Airflow instance.
If some of your tasks require specific resources such as a GPU, you might want to run them in a different cluster than your Airflow instance. In setups where both clusters are used by the same AWS, Azure or GCP account, you can manage separate clusters with roles and permissions.
To launch Pods in external clusters from a local Airflow environment, you must have valid authentication for the external cluster so that your local Airflow environment has permissions to launch a Pod in the external cluster. For managed Kubernetes services from public cloud providers, authentication is federated through the native IAM service. To grant the Astro role permissions to launch pods on your cluster, you can either include static credentials or use workload identity to authorize the Astro role to your cluster.
This example shows how to configure an Azure Managed Identity (MI) to run a Pod on an AKS cluster from an Airflow instance where cross-account access is not available.
## Prerequisites
* Network connectivity between your Airflow execution environment and the external Kubernetes cluster:
* **Hosted execution mode**: A [network connection](/docs/astro/networking-overview) between your Astro Deployment and the external cluster.
* **Remote execution mode**: Network connectivity between the environment where your [Remote Execution Agent](/docs/astro/remote-execution-overview) runs and the external cluster. You are responsible for managing this connectivity. A direct network connection between Astro and the external cluster is not required.
## Setup
1. Create a [Microsoft Entra ID tenant](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-create-new-tenant) with Global Administrator or Application Administrator privileges.
2. Create a [user-assigned managed identity on Azure](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?source=recommendations\&pivots=identity-mi-methods-azp#create-a-user-assigned-managed-identity).
3. Authorize your Astro Deployment to Azure using Azure Managed Identity (MI) by following steps 1 and 2 described in the [Deployment Workload identity](/docs/astro/authorize-deployments-to-your-cloud?tab=azure#setup) set up.
4. Confirm that the OIDC credentials appear in the Managed Identity's Federated credentials tab.
5. From the Managed Identity's Properties tab, note the **Client ID**.
From your Azure Portal, go to Azure Active Directory (Microsoft Entra ID) and note the **Tenant ID**.
Both the **Client ID** and **Tenant ID** will be needed in Step 3 to configure your `kubeconfig` file.
To trigger remote Pods on an Azure AKS Cluster, the following packages and dependencies need to be added to your Docker image.
* Azure CLI
* Kubectl
* Kubelogin
To do so, add the following commands to your Dockerfile:
```dockerfile title="Dockerfile" wrap theme={null}
FROM quay.io/astronomer/astro-runtimeX.Y.Z
USER root
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
RUN az aks install-cli
USER astro
```
The following configuration file below is a sample Kubernetes `kubeconfig` file that allows the Kubernetes command-line tool, `kubectl`, or other clients to connect to a remote Kubernetes cluster, `remote-kpo`, using Azure Workload Identity for authentication.
```yaml title="kubeconfig" expandable wrap theme={null}
# Specifies the version of the Kubernetes API for this configuration file.
# v1 is the standard version used for kubeconfig files.
apiVersion: v1
# List of Kubernetes clusters that the configuration can connect to.
clusters:
- cluster:
# base64-encoded certificate for the Kubernetes API server to verify SSL communication.
certificate-authority-data:
# URL of the Kubernetes API server.
# This is the endpoint of the remote cluster you want to interact with.
server:
# Name of the cluster, which is referenced in the contexts section.
name:
# List of contexts that define which cluster and user combination to use when interacting with Kubernetes.
contexts:
# Describes the context for connecting to the cluster.
- context:
# References the cluster from the clusters section.
cluster:
# Associates the user configuration to be used for authentication with the cluster.
user:
# The name of the context, which is referenced by current-context.
name:
# Specifies the active context that will be used by default when running kubectl commands.
current-context:
# Identifies the file type as a Kubernetes Config.
kind: Config
preferences: {}
# List of users and the method they use for authentication.
users:
# Defines the user that is being used in the context.
# This user is responsible for authenticating with the Kubernetes cluster.
- name:
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- get-token
- --login
- workloadidentity
- --tenant-id
-
- --client-id
-
# The server ID for Azure Kubernetes Service (AKS). This is a static ID representing AKS.
- --server-id
- 6dae42f8-4368-4678-94ff-3960e28e3630
# Specifies the path to the federated token that the managed identity uses to authenticate.
- --federated-token-file
- /var/run/secrets/azure/tokens/azure-identity-token
- --environment
- AzurePublicCloud
command: kubelogin
# Specifies if the kubelogin command should not attempt to provide additional cluster information beyond the authentication token.
provideClusterInfo: false
```
To use the `kubeconfig` file, you will need to create a new Kubernetes Airflow Connection.
There are multiple ways to pass the `kubeconfig` file to your Airflow Connection. If your `kubeconfig` file contains any sensitive information, we recommend storing it as JSON inside the connection, described in option 3.
1. **External File in the default location**
If the `kubeconfig` file resides in the default location on the machine (\~/.kube/config), you can leave all fields empty in the connection configuration. Airflow will automatically use the `kubeconfig` from the default location.
Add the following `COPY` command at the end of your Dockerfile to add your `kubeconfig` file inside your Astro Runtime Docker Image.
```dockerfile wrap theme={null}
COPY kubeconfig ~/.kube/config/airflow/kubeconfig
```
2. **External file with a Custom Path**:
You can specify a custom path to the `kubeconfig` file by inserting the path into the ***Kube config path*** field of your Airflow Connection.
Add the following `COPY` command at the end of your Dockerfile to add your `kubeconfig` file inside your Astro Runtime Docker Image.
```dockerfile wrap theme={null}
COPY kubeconfig /usr/local/airflow/kubeconfig
```
3. **JSON Format**
You can convert the `kubeconfig` file to JSON format and paste it into the Kube config (JSON format) field in the connection configuration.
Use an online converter like [https://jsonformatter.org/yaml-to-json](https://jsonformatter.org/yaml-to-json) to convert YAML to JSON. Remove any sensitive information first.
Run a Kubernetes Pod with Airflow `KubernetesPodOperator`.
```python expandable wrap theme={null}
from datetime import datetime
# import the DAG object
from airflow.models import DAG
# import the KubernetesPodOperator
from airflow.providers.cncf.kubernetes.operators.pod import (
KubernetesPodOperator,
)
default_args = {
"owner": "Astronomer",
"depends_on_past": False,
}
# instantiate the dag
with DAG(
dag_id="remote_kpo",
default_args=default_args,
schedule=None,
start_date=datetime(2024, 1, 1),
tags=["KPO"],
):
# launch a pod in the Kubernetes cluster
remote_kpo = KubernetesPodOperator(
task_id="az_remote_kpo",
kubernetes_conn_id="",
namespace="",
image="debian",
cmds=["bash", "-cx"],
arguments=["echo", "hello world!"],
name="hello-world",
get_logs=True,
in_cluster=False,
)
```
# Launch a Pod in a GKE cluster on GCP
Source: https://astronomer.io/docs/astro/launch-pod-external-cluster-gcp
Use the KubernetesPodOperator to launch Pods in an external GKE cluster on Google Cloud from your Airflow instance.
If some of your tasks require specific resources such as a GPU, you might want to run them in a different cluster than your Airflow instance. In setups where both clusters belong to the same Google Cloud project, you can manage separate clusters with roles and permissions.
This document shows how to configure a Google Kubernetes Engine (GKE) cluster on Google Cloud and run a Pod on it from an Airflow instance where cross-project access isn't available.
To launch Pods in external clusters from a local Airflow environment, you must have valid authentication for the external cluster. For managed Kubernetes services from public cloud providers, authentication is federated through the native IAM service. To grant the Astro role permissions to launch Pods on your cluster, you can either include static credentials or use workload identity to authorize the Astro role to your cluster.
## Prerequisites
* Network connectivity between your Airflow execution environment and the external Kubernetes cluster:
* **Hosted execution mode**: A [network connection](/docs/astro/networking-overview) between your Astro Deployment and the external cluster.
* **Remote execution mode**: Network connectivity between the environment where your [Remote Execution Agent](/docs/astro/remote-execution-overview) runs and the external cluster. You are responsible for managing this connectivity. A direct network connection between Astro and the external cluster isn't required.
## Setup
Follow Google Cloud's documentation to prepare a GKE cluster that your Astro Deployment can authenticate to:
1. [Create a GKE cluster](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster) if you don't already have one.
2. Authorize your Astro Deployment to Google Cloud by following the [Deployment workload identity setup](/docs/astro/authorize-deployments-to-your-cloud?tab=gcp).
3. Grant the service account [IAM and Kubernetes RBAC permissions](https://cloud.google.com/kubernetes-engine/docs/how-to/role-based-access-control) in the namespace where your `KubernetesPodOperator` tasks run.
At a minimum, provision the following permissions for your service account in your specified namespace:
* `container.clusters.get`
* `container.events.list`
* `container.pods.get`
* `container.pods.getLogs`
* `container.pods.list`
* `container.pods.create`
* `container.pods.delete`
* `container.pods.update`
If your Dag uses `do_xcom_push=True`, also grant the `container.pods.exec` permission.
To connect to your external GKE cluster, the [`gcloud` CLI](https://cloud.google.com/sdk/docs/install) and the [`gke-gcloud-auth-plugin`](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_plugin) must be available inside your Astro Runtime image.
Add the following to your `Dockerfile`:
```dockerfile title="Dockerfile" wrap theme={null}
USER root
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates gnupg curl \
&& curl -sL https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \
> /etc/apt/sources.list.d/google-cloud-sdk.list \
&& apt-get update \
&& apt-get install -y google-cloud-cli google-cloud-cli-gke-gcloud-auth-plugin \
&& rm -rf /var/lib/apt/lists/*
USER astro
```
For production deployments, consider pinning the `google-cloud-cli-gke-gcloud-auth-plugin` version for build reproducibility, or using a multi-stage build with the `google/cloud-sdk:slim` image to copy only the plugin binary into your final image and reduce its size.
Add the following line to your `requirements.txt` to include the CNCF Kubernetes provider:
```text title="requirements.txt" wrap theme={null}
apache-airflow-providers-cncf-kubernetes
```
The following sample Kubernetes `kubeconfig` file allows the Kubernetes command-line tool, `kubectl`, or other clients to connect to a remote Kubernetes cluster using Google Cloud workload identity for authentication.
```yaml title="kubeconfig" expandable wrap theme={null}
# Specifies the version of the Kubernetes API for this configuration file.
# v1 is the standard version used for kubeconfig files.
apiVersion: v1
# List of Kubernetes clusters that the configuration can connect to.
clusters:
- cluster:
# base64-encoded certificate for the Kubernetes API server to verify SSL communication.
certificate-authority-data:
# Endpoint of the remote cluster you want to interact with.
server: https://
# Name of the cluster, which is referenced in the contexts section.
name:
# List of contexts that define which cluster and user combination to use when interacting with Kubernetes.
contexts:
# Describes the context for connecting to the cluster.
- context:
# References the cluster from the clusters section.
cluster:
# Associates the user configuration to be used for authentication with the cluster.
user:
# The name of the context, which is referenced by current-context.
name:
# Specifies the active context that will be used by default when running kubectl commands.
current-context:
# Identifies the file type as a Kubernetes Config.
kind: Config
preferences: {}
# List of users and the method they use for authentication.
users:
# Defines the user that is being used in the context.
# This user is responsible for authenticating with the Kubernetes cluster.
- name:
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: gke-gcloud-auth-plugin
provideClusterInfo: true
```
Fetch the `certificate-authority-data` and `cluster-endpoint` fields from the GKE cluster details page or using the Google Cloud SDK.
**Scaling considerations**
If you run a high number of concurrently deferred tasks against this connection, consider a static bearer token instead of the exec-based plugin shown in the preceding `kubeconfig`. At high triggerer concurrency, the plugin's subprocess invocation on each credential refresh can block the triggerer's shared event loop.
To use the `kubeconfig` file, create a new Kubernetes Airflow connection.
There are multiple ways to pass the `kubeconfig` file to your Airflow connection. If your `kubeconfig` file contains any sensitive information, Astronomer recommends storing it as JSON inside the connection, as described in the JSON format tab.
Convert the `kubeconfig` file to JSON format and paste it into the **Kube config (JSON format)** field in the connection configuration.
If the `kubeconfig` file resides in the default location on the machine (`~/.kube/config`), you can leave all fields empty in the connection configuration. Airflow automatically uses the `kubeconfig` from the default location. Add the following `COPY` command at the end of your Dockerfile to add your `kubeconfig` file inside your Astro Runtime Docker image:
```dockerfile wrap theme={null}
COPY kubeconfig ~/.kube/config/airflow/kubeconfig
```
You can specify a custom path to the `kubeconfig` file by inserting the path into the **Kube config path** field of your Airflow connection. Add the following `COPY` command at the end of your Dockerfile to add your `kubeconfig` file inside your Astro Runtime Docker image:
```dockerfile wrap theme={null}
COPY kubeconfig /usr/local/airflow/kubeconfig
```
In your `KubernetesPodOperator` task, set `kubernetes_conn_id` to the connection you created, `namespace` to the namespace in your GKE cluster where the Pod should run, and `in_cluster=False` so that the operator uses the connection's `kubeconfig` instead of looking for an in-cluster service account.
```python wrap theme={null}
from airflow.decorators import dag
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from pendulum import datetime
@dag(
dag_id="remote_kpo",
start_date=datetime(2024, 1, 1),
schedule=None,
tags=["kubernetes", "gke"],
)
def remote_kpo():
KubernetesPodOperator(
task_id="run_on_gke",
kubernetes_conn_id="",
namespace="",
image="ubuntu:latest",
cmds=["echo"],
arguments=["External KPO is working!"],
name="example-pod",
get_logs=True,
in_cluster=False,
)
remote_kpo()
```
# Log in to Astro
Source: https://astronomer.io/docs/astro/log-in-to-astro
Learn how you can use the Cloud user interface (UI) and the Astro command-line interface (CLI) to log in to Astro.
You can use the Astro UI and the Astronomer CLI to view and modify your Workspaces, Deployments, environment variables, tasks, and users. You need to authenticate your user credentials when you're using the Astro UI or the Astro CLI for development on Astro. See the Astronomer CLI documentation for more details, including available commands and flags.
## Prerequisites
* An Astronomer account.
* The [Astro CLI](/docs/cli/v1.43/overview).
* An email address with a domain that matches the domain configured for your Organization.
## Log in to the Astro UI
Go to `https://cloud.astronomer.io`, and select one of the following options to access the Astro UI:
* To authenticate with single sign-on (SSO), enter your email and click **Continue**. If your Organization has SSO enabled, you'll be redirected to your IdP authentication screen.
* To authenticate with your GitHub account, click **Continue with GitHub**, enter your username or email address, enter your password, and then click **Sign in**. If your Organization selects this log in option, you’ll receive an email invitation from your Organization Owner. You can't access the Organization without an invitation.
* To authenticate with your Google account, click **Continue with Google**, choose an account, enter your username and password, and then click **Sign In**. If your Organization selects this log in option, you’ll receive an email invitation from your Organization Owner. You can't access the Organization without an invitation.
## Log in to the Astro CLI
Developing locally with the Astro CLI does not require an Astro account. This includes commands such as `astro dev start` and `astro dev pytest`. If you want to use functionality specific to Astro, including managing users and [deploying code](/docs/astro/deploy-code), you must first log in to Astro with the Astro CLI.
Astronomer uses refresh tokens to make sure that you don’t need to log in to the Astro CLI every time you run a command.
1. In the Astro CLI, run the following command:
```sh wrap theme={null}
astro login
```
2. Enter your email address and press **Enter**.
3. Press **Enter** to connect your account to Astronomer.
If this is your first time logging in, the Astronomer Authorize App dialog appears. Click **Accept** to allow Astronomer to access your profile and email and allow offline access.
4. Select one of the following options to access the Astro UI:
* Enter your email and click **Continue**.
* To authenticate with your GitHub account, click **Continue with GitHub**, enter your username or email address, enter your password, and then click **Sign in**.
* To authenticate with your Google account, click **Continue with Google**, choose an account, enter your username and password, and then click **Sign In**.
Confirmation messages appear in the Astro UI and in the Astro CLI indicating that your login was successful and that your computer is now connected. The name of your default Workspace in the Astro CLI also appears. To switch Workspace contexts after you log in, run [astro workspace switch](/docs/cli/v1.43/astro-workspace-switch).
## Log in from a browserless system
The following options are available if you're unable to use a browser for authentication:
* Run `astro login -t` to log in with an authentication token. To obtain an authentication token on a separate machine, go to `https://cloud.astronomer.io/token`.
* Run `astro login -l` to retrieve an Astro UI log in URL and then copy the URL. In a separate terminal session, run `curl -u :`. This option doesn't work if you're using an identity provider (IdP) for account authentication.
## Access a different base domain
When you need to access Astro and Astro Private Cloud with the Astro CLI at the same time, you need to authenticate to each product individually by specifying a base domain for each Astronomer installation.
A base domain or URL is the static element of a website address. For example, when you visit the Astronomer website, the address bar always displays `https://www.astronomer.io` no matter what page you access on the Astronomer website.
For Astro users, the base domain is `cloud.astronomer.io`. For Astro Private Cloud, every cluster has a base domain that you must authenticate to in order to access it. If your organization has multiple clusters, you can run Astro CLI commands to quickly move from one base domain to another. This can be useful when you need to move from an Astro Private Cloud installation to Astro and are using the Astro CLI to perform actions on both accounts.
1. Run the following command to view a list of Astronomer base domains that you can access. Your current base domain is highlighted.
```sh wrap theme={null}
astro context list
```
2. In the Astro CLI, run the following command to re-authenticate to the target base domain:
```sh wrap theme={null}
astro login
```
3. Run the following command to switch to a different base domain:
```sh wrap theme={null}
astro context switch
```
## Switch Organizations
You can belong to more than one Astro Organization. Having a role in an Organization does not guarantee access to the Organization through the Astro UI. To access another Organization, you need to be able to authenticate with one of the enabled authentication methods.
1. Log in to the Astro UI. By default, the Astro UI opens the first Organization that you joined.
2. Open your profile menu, then click **Switch Organization** (in the legacy UI, click the name of your current Organization in the top navigation bar, then click **Switch Organization**).
3. Select the Organization that you want to switch to.
## Reset your Astro password
If you log in to Astro with a text password, you can reset your password from the Astro UI login screen.
1. Go to `cloud.astronomer.io`. If you are logged in, log out.
2. On the login screen, enter your email address, then click **Continue**.
3. Click **Forgot password?**
4. Confirm your user email address is correct, then click **Continue**. Astronomer sends an email with a password reset option to the user email address.
5. Follow the instructions in the email sent by Astronomer to reset your password.
# Manage Airflow connections, variables, and environment variables
Source: https://astronomer.io/docs/astro/manage-connections-variables
Learn about different strategies for managing Airflow connections, variables, and environment variables in local environments and on Astro
*Airflow connections* are used for storing credentials and other information necessary for connecting to external services. *Airflow variables* are a generic way to store and retrieve arbitrary content or settings as a simple key value store within Airflow. *Environment variables* are key-value configurations that can be used to configure Airflow settings, store credentials, or pass configuration to your DAGs.
Use this document to select the right Airflow connection, variable, and environment variable management strategies for your team.
Airflow supports several different methods for managing connections, variables, and environment variables. Each of these strategies has benefits and limitations related to their security and ease of use. The strategies you choose should be compatible with both your local environments and Astro Deployments, allowing you to [import and export objects](/docs/astro/import-export-connections-variables) between the two contexts.
For in-depth information on managing connections and variables, see [Connection Basics](/docs/learn/connections) and [Variable Basics](/docs/learn/airflow-variables).
## Prerequisites
* A locally hosted Astro project created with the Astro CLI. See [Create a project](/docs/cli/v1.43/get-started-cli).
* A Deployment on Astro. See [Create a Deployment](/docs/astro/create-deployment).
## Choose a connection, variable, and environment variable management strategy
The following table suggests possible management strategies for specific use cases.
| Scenario | Strategy |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| I'm getting started and want to quickly create Airflow objects | [Astro Environment Manager](#astro-environment-manager) |
| I prefer to manage my Airflow variables in a Git repository and to upload directly to Airflow | [Airflow UI](#airflow-ui) |
| I need to keep my connections, variables, and environment variables stored in a centralized and secure location. | [Secrets backend](#secrets-backend) or [Astro Environment Manager](#astro-environment-manager) |
| I want to create Connections, Airflow Variables, or environment variables once, and then apply them to multiple Deployments in a Workspace. | [Astro Environment Manager](#astro-environment-manager) |
| I want to share connections or variables with Astro IDE projects and their ephemeral test Deployments without affecting production Deployments. | [Astro Environment Manager](#astro-environment-manager) |
| I have existing connections or variables in a Deployment's Airflow metadata database and want to manage them centrally. | [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager) |
| I don't have a secrets backend, but I still want some security and permissions attached to Airflow objects. | [Astro Environment Manager](#astro-environment-manager) or [Environment variables](#environment-variables) |
### How Airflow finds connections
Because connections serve different purposes in Airflow, you might want to use a different strategy for each object type. For example, you can use a secrets backend for connections and use combination of a `json` files and the Airflow UI for variables.
If you use a mix of strategies for managing connections, it's important to know which connection value that Airflow gives precedence to in the case of a conflict. The order of precedence for connections is:
1. Secrets Backend
2. Astro Environment Manager
3. Environment Variables
4. Airflow's metadata database (Airflow UI)
Airflow checks for connections in order from highest (secrets backend) to lowest (Airflow UI) precedence. Airflow uses the first configuration for a given connection ID that it finds.
For example, if you store a connection with the same connection ID in both a secrets backend and the Airflow UI, Airflow reads and uses the connection configured in the secrets backend first, instead of using a connection configuration with the same connection ID stored in the Airflow UI.
If you only want to test connections or export connections in a JSON or URI format, use the Airflow UI to [manage your connection](/docs/learn/connections#defining-connections-in-the-airflow-ui). You can then use the Astro CLI commands to export the connections in a URI or JSON format. See [Import and export connections and variables](/docs/astro/import-export-connections-variables#from-the-airflow-ui-and-metadata-database).
## Compare strategies
The following sections explain the benefits, limitations, and implementations of each strategy in more detail.
### Astro Environment Manager
Astro includes a built-in secrets backend for managing connections, Airflow variables, and environment variables. After you create a connection, variable, or environment variable in the Astro UI, you can share it with multiple Deployments in a Workspace, override values on a per-Deployment basis, or hide secret values after creating them. See [Create connections in Astro](/docs/astro/create-and-link-connections), [Create variables in Astro](/docs/astro/create-and-link-variables), or [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables) for setup steps.
You can also link environment objects to [Astro IDE](/docs/astro/ide-overview) projects so that the project's ephemeral test Deployments start with the connections and variables they need. Project-scoped objects don't affect Deployments that aren't started from the Astro IDE. See [Link connections to Astro IDE projects](/docs/astro/create-and-link-connections#link-connections-to-astro-ide-projects).
If you already define connections, Airflow variables, or environment variables in a Deployment, you can move them into the Environment Manager so that they can be reused across Deployments and Astro IDE projects. See [Migrate existing objects to the Environment Manager](/docs/astro/migrate-metadata-db-to-environment-manager).
For Remote Execution Deployments, you can only manage environment variables and Metrics export with the Environment Manager. You cannot create, update, or assign Connections or Airflow Variables.
#### Benefits
* It securely stores your connection, variable, and environment variable configuration and authentication information on Astro, without a secrets backend.
* You can create a configuration once and then add it to multiple Deployments in a Workspace.
* Authenticate connections using credentials other than what the Airflow UI supports.
* Hide the values for Airflow Variable keys and environment variables in the Astro UI, after you finish creating them.
* After you configure a connection, variable, or environment variable, the authentication information is securely stored in an Astro-managed secrets backend.
* Control whether connections, Airflow variables, or environment variables can be used in a single Deployment or shared across Deployments in a Workspace.
* Override certain fields in connections, variable values, or environment variable values per Deployment, so you can create a general configuration and then customize its behavior.
#### Limitations
* If you create a connection in the Astro UI, you also need to add its related provider package to the `requirements.txt` file in your Astro project.
* Only available with Astro Runtime 9.3.0 and greater.
* You can't see connections, Airflow variables, or environment variables defined in the Astro UI in the Airflow UI.
* You need `WORKSPACE_OPERATOR` or `WORKSPACE_OWNER` user permissions.
* You can't programmatically import connections, Airflow variables, or environment variables to the Environment Manager from your local environment.
To see how you can use connections set in the Astro Environment Manager in a best practice, branch-based Deployment setup, see the [Manage Astro connections in branch-based deploy workflows](/docs/astro/best-practices/connections-branch-deploys) use case.
### Airflow UI
You can create Airflow connections and variables is through the Airflow UI. This experience is the same for both local Airflow environments and Astro Deployments. Astronomer recommends this method if you're just getting started with Airflow, you want to get your dags running quickly, or if you want to export connections in a URI/JSON format.
#### Benefits
* The UI has features for correctly formatting and testing your connections.
* It's easy to change variables or connections to test different use cases on the fly.
* You can export and import your variables from the Airflow UI using JSON files and the Astro CLI. See [Import and export connections and variables](/docs/astro/import-export-connections-variables#from-the-airflow-ui-and-metadata-database).
* Connections and variables are encrypted and stored in the Airflow metadata database.
#### Limitations
* You cannot export or import connections from the UI for security reasons.
* Managing many connections or variables can become unwieldy.
* In a local environment, you lose your connections and variables if you delete your metadata database with `astro dev kill`.
### Secrets backend
A secrets backend is the most secure way to store connections and variables. You can access a secrets backend both locally and on Astro by configuring the appropriate credentials in your Airflow environment. Astronomer recommends this method for all staging and production deployments. See the following documentation for setup steps:
* [Authenticate to clouds locally](/docs/cli/v1.43/authenticate-to-clouds)
* [Configure a secrets backend](/docs/astro/secrets-backend)
#### Benefits
* Store objects in a centralized location alongside other secrets used by your organization.
* Comply with internal security postures and policies that protect your organization.
* Recover objects if your Airflow environments go down.
* Share secrets across different Airflow environments.
* Allow selective access to connections and variables by using `connections_prefix` and `variables_prefix`.
* Limit the number of open connections to your metadata database, especially if you are using your connections and variables outside of task definitions.
#### Limitations
* A third-party secrets manager is required.
* Separate configurations might be required for using a secrets backend locally and on Astro.
* You cannot use the Airflow UI to view connections and variables.
* You are responsible for ensuring that secrets are encrypted.
### Environment variables
You can use Airflow's system-level environment variables to store connections and variables, or to configure general Airflow settings and pass configuration to your DAGs. There are two ways to manage environment variables on Astro:
* **Workspace-level environment variables** (Astro Environment Manager): Create environment variables at the Workspace level and share them across multiple Deployments. This is the recommended approach when you want to standardize environment variables across Deployments. See [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables).
* **Deployment-level environment variables**: Set environment variables specific to a single Deployment through the Deployment UI or your Dockerfile. This is recommended when you don't have a secrets backend, but you still want to take advantage of security and RBAC features. See [Manage environment variables on Astro](/docs/astro/manage-env-vars).
Airflow connections and variables are stored in the Airflow metadata database. Calling them outside of task definitions and operators requires an additional connection to the Airflow metadata database which is used every time the scheduler parses a dag. By adding connections and variables as environment variables, you can lower the amount of open connections and improve the performance of your database and resources.
#### Benefits
* If you use an `.env` file for your local Airflow environment and your local metadata database is corrupted or accidentally deleted, you still have access to all of your connections and variables.
* You can export environment variables from a local Airflow environment to Astro using the Astro CLI. See [Import and export connections and variables](/docs/astro/import-export-connections-variables#from-environment-variables).
* You can override Airflow variables set in the Airflow UI. See [Environment variable priority](/docs/astro/environment-variables#environment-variable-priority)
* You can create your environment variables from the Astro UI at both the Workspace and Deployment level. See [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables) or [Manage environment variables on Astro](/docs/astro/manage-env-vars).
* Environment variables marked as **Secret** are encrypted in the Astronomer control plane. See [How environment variables are stored on Astro](/docs/astro/environment-variables#how-environment-variables-are-stored-in-the-astro-ui) for details.
* This approach limits the number of open connections to your metadata database, especially if you are using your connections and variables outside of task definitions.
* Workspace-level environment variables can be shared across multiple Deployments with override capabilities per Deployment.
#### Limitations
* You can't view connections and variables from the Airflow UI when they are stored as environment variables.
* You must restart your local environment using `astro dev restart` whenever you make changes to your `.env` file.
* When stored in your `.env` file or Dockerfile, environment variables are defined in plain text.
* Connections must be formatted as either a URI or serialized JSON.
* Deployment-level environment variables are not as secure or centralized compared to a [secrets backend](/docs/astro/secrets-backend) or the Workspace Environment Manager.
* You cannot directly export Deployment-level environment variables from the Astro UI to a local Airflow environment. See [Import and export Airflow objects](/docs/astro/import-export-connections-variables#from-environment-variables).
## Other strategies
While it's possible to manage Airflow connections and variables with these strategies, Astronomer doesn't recommend them at scale:
* You can use the Airflow REST API to programmatically create Airflow connections and variables for a Deployment. Airflow objects created with the API are stored in the Airflow metadata database and visible in the Airflow UI.
* For local Astro projects, you can use `airflow_settings.yaml` for defining your connections and variables. See [Configure `airflow_settings.yaml`](/docs/cli/v1.43/develop-project#configure-airflow_settings-yaml-local-development-only) for more details.
## See also
* [Import and export Airflow objects](/docs/astro/import-export-connections-variables)
* [Authenticate to cloud services with user credentials](/docs/cli/v1.43/authenticate-to-clouds)
# Manage Dag runs
Source: https://astronomer.io/docs/astro/manage-dags
View, retry, and troubleshoot Dag runs across your Astro Workspace from the Dags page.
As a data engineer or data scientist, you might need to view details about your Dags' performance, including task logs, run status, and retries. You might additionally have to manually retry Dag runs or mark them as a specific status when troubleshooting any issues.
**Dag-level access control**
For Deployments running Astro Runtime 3.1-12 or later, you can control who has access to individual Dags using Dag-level roles. See [Dag-level access control](/docs/astro/dag-level-access-control).
## Dags overview
The **DAGs** page in the Astro UI lets you view all Dags in your Workspace from a single place. You can view high level metrics about each Dag in a summary table.
To access the **DAGs** page, either click **DAGs** on the left sidebar or click **DAGs** on a Deployment's information page.
The **DAGs** page shows the following summary information about the Dag runs for all Deployments in your Workspace. You can filter through these Dags using the left menu:
* Total Dag runs over the last 14 days, expressed as a bar chart.
Each bar in the chart represents an individual Dag run. A bar's color represents whether the Dag run was a success or a failure, while its length represents the total duration of the Dag run. If there are more than 14 Dag runs in the last 14 days, then the chart shows only the 14 most recent Dag runs.
* **State**: Indicates whether the Dag is **Active** or **Paused**. If a Dag has a purple lightning symbol next to its name, that Dag is **Active**.
* **Last Run**: The duration of the last Dag run and the ending time of the Dag's most recent Dag run, expressed relative to the current time.
* **Schedule**: The frequency that the Dag runs and the starting time of the next Dag run, expressed relative to the current time.
* **Deployment**: The Deployment ID of the Deployment for the current Dag Run.
* **Owner(s)**: The Airflow Dag owner attribute. You can change the owner attribute when you write or update your Dag.
* **Tags**: The custom tags that you marked your Dag with. To add custom tags to a Dag, see [Airflow documentation](https://airflow.apache.org/docs/apache-airflow/stable/howto/add-Dag-tags.html).
## Access the Airflow UI for a Deployment
Every Astro Deployment runs its own webserver and instance of the Airflow UI. If you want to manage your Dag and task runs through the Airflow UI, you can access it either through the Astro UI or the Astro CLI.
To access the Airflow UI for your Deployment in the Astro UI:
1. In the Astro UI, open your Deployment.
2. Click **Open Airflow**.
To access a Deployment's Airflow UI from the Astro CLI:
1. Run the following command to retrieve the URL for the Deployment's Airflow UI:
```sh wrap theme={null}
astro deployment inspect -n -k metadata.webserver_url
```
2. Copy the URL into a web browser and hit enter to directly open the Airflow UI for your Deployment.
### Access the Dags page in the Airflow UI
1. In the Astro UI, Click **DAGs**.
2. Click **Open in Airflow** for the Dag that you want to manage.
# Migrate to Astro from Google Cloud Composer
Source: https://astronomer.io/docs/astro/migrate-gcc
Get started on Astro by migrating your Airflow code from Google Cloud Composer (GCC).
This is where you'll find instructions for migrating an Airflow environment from [Google Cloud Composer (GCC)](https://cloud.google.com/composer/docs/concepts/overview) to Astro.
To complete the migration process, you will:
* Prepare your source Airflow and set up your Astro Airflow environment.
* Migrate metadata from your source Airflow environment.
* Migrate dags and additional Airflow components from your source Airflow environment.
* Complete the cutover process to Astro.
## Prerequisites
Before starting the migration, ensure that the following are true:
* You have an Astro user account and can [log in to Astro](/docs/astro/log-in-to-astro).
* (Optional) You created a network connection from Astro to your external cloud resources..
* (Optional) You [configured your identity provider (IdP)](/docs/astro/configure-idp).
On your local machine, make sure you have:
* An [Astro account](/docs/astro/log-in-to-astro).
* The [Astro CLI](/docs/cli/v1.43/install-cli).
On the cloud service from which you're migrating, ensure that you have:
* A source Airflow environment on Airflow 2 or later.
* Read access to the source Airflow environment.
* Read access to any cloud storage buckets that store your DAGs.
* Read access to any source control tool that hosts your current Airflow code, such as GitHub.
* Permission to create new repositories on your source control tool.
* (Optional) Access to your secrets backend.
* (Optional) Permission to create new CI/CD pipelines.
All source Airflow environments on 1.x need to be upgraded to at least Airflow 2.0 before you can migrate them. Astronomer professional services can help you with the upgrade process.
If you're migrating to Astro from OSS Airflow or another Astronomer product, and you currently use an older version of Airflow, you can still create Deployments with the corresponding version of Astro Runtime even if it is deprecated according to the [Astro Runtime maintenance policy](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-maintenance-policy). This allows you to migrate your DAGs to Astro without needing to make any code changes and then immediately upgrade to a new version of Airflow. Note that after you migrate your DAGs, Astronomer recommends upgrading to a supported version of Astro Runtime as soon as you can.
See [Run a deprecated Astro Runtime version](https://www.astronomer.io/docs/astro/upgrade-runtime#run-a-deprecated-astro-runtime-version).
You can additionally use the `gcloud` CLI to expedite some steps in this guide.
## Step 1: Install Astronomer Starship
The [Astronomer Starship](https://astronomer.github.io/starship/) migration utility connects your source Airflow environment to your Astro Deployment and migrates your Airflow connections, Airflow variables, environment variables, and dags.
The Starship migration utility works as a [plugin](https://github.com/astronomer/starship/blob/main/README.md) with a user interface, or as an [Airflow operator](https://astronomer.github.io/starship/operator/) if you are migrating from a more restricted Airflow environment.
See the following table for information on which versions of Starship are available depending on your source Airflow environment:
| Source Airflow environment | Starship plugin | Starship operator |
| ------------------------------ | --------------- | ----------------- |
| Airflow 1.x | ❌ | ❌ |
| Cloud Composer 1 - Airflow 2.x | | ✔️️ |
| Cloud Composer 2 - Airflow 2.x | ✔️️ | |
To install the Starship plugin on your Cloud Composer 1 or Cloud Composer 2 instance, install the `astronomer-starship` package in your source Airflow environment. See [Install packages from PyPI](https://cloud.google.com/composer/docs/composer-2/install-python-dependencies#install-pypi)
You can alternatively complete this installation with the `gcloud` CLI by running the following command:
```sh wrap theme={null}
gcloud composer environments update [GCC_ENVIRONMENT_NAME] \
--location [LOCATION] \
--update-pypi-package=astronomer-starship
```
## Step 2: Create an Astro Workspace
In your Astro Organization, you can create *Workspaces*, which are a collection of users that have access to the same Deployments. Workspaces are typically owned by a single team.
You can choose to use an existing Workspace, or create a new one. However, you must have at least one Workspace to complete your migration.
1. Follow the steps in [Manage Workspaces](/docs/astro/manage-workspaces) to create a Workspace in the Astro UI for your migrated Airflow environments. Astronomer recommends naming your first Workspace after your data team or initial business use case with Airflow. You can update these names in the Astro UI after you finish the migration.
2. Follow the steps in [Manage Astro users](/docs/astro/manage-workspace-users#add-a-user-to-a-workspace) to add users from your team to the Workspace. See [Astro user permissions](/docs/astro/user-permissions#workspace-roles) for details about each available Workspace user role.
**CLI**
You can add users to a Workspace an Organization using the Astro CLI. See:
* [`astro workspace user add`](/docs/cli/v1.43/astro-workspace-user-add)
* [`astro organization user invite`](/docs/cli/v1.43/astro-organization-user-invite)
You can also automate adding batches of users to Astro with shell scripts. See [Add a group of users to Astro using the Astro CLI](/docs/astro/manage-workspace-users#add-a-group-of-users-to-a-workspace-using-the-astro-cli).
## Step 3: Create an Astro Deployment
A *Deployment* is an Astro Runtime environment that is powered by the core components of Apache Airflow. In a Deployment, you can deploy and run DAGs, configure worker resources, and view metrics.
You can choose to use an existing Deployment, or create a new one. However, you must have at least one Deployment to complete your migration.
Before you create your Deployment, copy the following information from your source Airflow environment:
* Environment name
* Airflow version
* Environment class or size
* Number of schedulers
* Minimum number of workers
* Maximum number of workers
* Execution role permissions
* Airflow configurations
* Environment variables
**Alternative setup for Astro Hybrid**
This setup varies slightly for Astro Hybrid users. See [Deployment settings](/docs/astro/deployment-settings) for all configurations related to Astro Hybrid Deployments.
1. In the Astro UI, select a Workspace.
2. On the **Deployments** page, click **Deployment**.
3. Complete the following fields:
* **Name**: Enter the name of your source Airflow environment.
* **Astro Runtime**: Select the Runtime version that's based on the Airflow version in your source Airflow environment. See the following table to determine which version of Runtime to use. Where exact version matches are not available, the nearest Runtime version is provided with its supported Airflow version in parentheses.
| Airflow Version | Runtime Version |
| --------------- | ---------------------- |
| 2.0 | 3.0.4 (Airflow 2.1.1)¹ |
| 2.2 | 4.2.9 (Airflow 2.2.5) |
| 2.4 | 6.3.0 (Airflow 2.4.3) |
¹The earliest available Airflow version on Astro Runtime is 2.1.1. There are no known risks for upgrading directly from Airflow 2.0 to Airflow 2.1.1 during migration. For a complete list of supported Airflow versions, see [Astro Runtime release and lifecycle schedule](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-lifecycle-schedule).
* **Description**: (Optional) Enter a description for your Deployment.
* **Cluster**: Choose whether you want to run your Deployment in a **Standard cluster** or **Dedicated cluster**. If you don't have specific networking or cloud requirements, Astronomer recommends using the default **Standard cluster** configurations.
To configure and use dedicated clusters, see [Create a dedicated cluster](/docs/astro/create-dedicated-cluster). If you don't have the option of choosing between standard or dedicated, that means you are an Astro Hybrid user and must choose a cluster that has been configured for your Organization.
* **Executor**: Choose the same executor as in your source Airflow environment.
* **Scheduler**: Use the following table to determine the Deployment size you need based on the size of your source Airflow environment.
| Environment size | Scheduler size | vCPU | Memory | Ephemeral Storage |
| ------------------------------- | -------------- | --------------------------------------------------- | ---------------------------------------------------------- | ----------------- |
| Small (Up to \~50 DAGs) | Small | 1 | 2Gi | 5 GiB |
| Medium (Up to \~250 DAGs) | Medium | **Scheduler**: 1 **DAG Processor**: 1 | **Scheduler**: 2 GiB **DAG Processor**: 2 GiB² | 5 GiB |
| Large (Up to \~1000 DAGs) | Large | **Scheduler**: 1 **DAG Processor**: 3 | **Scheduler**: 2 GiB **DAG Processor**: 6 GiB² | 5 GiB |
| Extra Large (Up to \~2000 DAGs) | Extra-large | **Scheduler**: 1 **DAG Processor (x2)**: 3.5 | **Scheduler**: 4 GiB **DAG Processor (x2)**: 6 GiB² | 5 GiB |
²Some of the following recommendations for CPU and memory might be less than what you currently allocate to Airflow components in your source environment. If you notice significant performance differences or your Deployment on Astro parses DAGs more slowly than your source Airflow environment, adjust your resource use on Astro. See [Configure Deployment resources](/docs/astro/deployment-resources)
* **Worker Type**: Select the worker type for your default worker queue. See [Worker queues](/docs/astro/configure-worker-queues).
* **Min / Max # Workers**: Set the same minimum and maximum worker count as in source Airflow environment.
* **KPO Pods**: (Optional) If you use the `KubernetesPodOperator` or Kubernetes Executor, set limits on how many resources your tasks can request.
4. Click **Create Deployment**.
5. Specify any system-level environment variables as Astro environment variables. See [Environment variables](/docs/astro/manage-env-vars#use-the-astro-ui).
6. Set an email to receive alerts from Astronomer support about your Deployments. See [Configure Deployment contact emails](/docs/astro/deployment-details#configure-deployment-contact-emails).
This option is available only on Astro Hybrid.
1. On your local machine, create a directory with the name of the source Airflow environment. In this directory, create a file called `config.yaml`.
2. Open `config.yaml` and add the following:
```yaml wrap theme={null}
deployment:
environment_variables:
- is_secret:
key:
value:
configuration:
name:
description:
runtime_version:
dag_deploy_enabled: false
scheduler_au:
scheduler_count:
cluster_name:
workspace_name:
worker_queues:
- name: default
max_worker_count:
min_worker_count:
worker_concurrency: 16
worker_type:
alert_emails:
-
```
3. Replace the placeholder values in the configuration:
* `` / `` / ``: Set system-level environment variables for your Deployment and specify whether they should be secret. Repeat this configuration in the file for any additional variables you need to set.
* ``: Enter the same name as your source Airflow environment.
* ``: (Optional) Enter a description for your Deployment.
* ``: Select the Runtime version that's based on the Airflow version in your source Airflow environment. See the following table to determine which version of Runtime to use. Where exact version matches are not available, the nearest Runtime version is provided with its supported Airflow version in parentheses.
| Airflow Version | Runtime Version |
| --------------- | ---------------------- |
| 2.0 | 3.0.4 (Airflow 2.1.1)¹ |
| 2.2 | 4.2.9 (Airflow 2.2.5) |
| 2.4 | 6.3.0 (Airflow 2.4.3) |
¹The earliest available Airflow version on Astro Runtime is 2.1.1. There are no known risks for upgrading directly from Airflow 2.0 to Airflow 2.1.1 during migration. For a complete list of supported Airflow versions, see [Astro Runtime release and lifecycle schedule](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-lifecycle-schedule).
* ``: Set your scheduler size in Astronomer Units (AU). An AU is a unit of CPU and memory allocated to each scheduler in a Deployment. Use the following table to determine how many AUs you need based on the size of your source Airflow environment.
| Environment size | AUs | CPU / memory |
| ------------------------- | --- | ----------------- |
| Small (Up to \~50 DAGs) | 5 | .5vCPU, 1.88GiB |
| Medium (Up to \~250 DAGs) | 10 | 1vCPU, 3.75GiB² |
| Large (Up to \~1000 DAGs) | 15 | 1.5vCPU, 5.64GiB² |
² Some of the following recommendations for CPU and memory are smaller than what you have in the equivalent source environment. Although you might not need more CPU or memory than what's recommended, some environments might parse DAGs slower than in your source Airflow environment to start. Use these recommendations as a starting point, then adjust your resource usage after tracking your performance on Astro.
* ``: Specify the same number of schedulers as in your source Airflow environment.
* ``: Specify name of the Astro cluster in which you want to create this Deployment.
* ``: The name of the Workspace you created.
* `/ `: Specify the same minimum and maximum worker count as in source Airflow environment.
* ``: Specify the worker type for your default worker queue. You can see which worker types are available for your cluster in the **Clusters** menu of the Astro UI. If you did not customize the available worker types for your cluster, the default available worker types are:
| AWS | GCP | Azure |
| --------- | ------------- | ----------------- |
| M5.XLARGE | E2-STANDARD-4 | `STANDARD_D4D_V5` |
* ``: Set an email to receive alerts from Astronomer support about your Deployments. See [Set up Astro alerts](/docs/astro/alerts).
After you finish entering these values, your `config.yaml` file should look something like the following:
```yaml wrap theme={null}
deployment:
environment_variables:
- is_secret: true
key: MY_VARIABLE_KEY
value: MY_VARIABLE_VALUE
- is_secret: false
key: MY_VARIABLE_KEY_2
value: MY_VARIABLE_VALUE_2
configuration:
name: My Deployment
description: The Deployment I'm using for migration.
runtime_version: 6.3.0
dag_deploy_enabled: false
scheduler_au: 5
scheduler_count: 2
cluster_name: My Cluster
workspace_name: My Workspace
worker_queues:
- name: default
max_worker_count: 10
min_worker_count: 1
worker_concurrency: 16
worker_type: E2-STANDARD-4
alert_emails:
- myalertemail@cosmicenergy.org
```
4. Run the following command to push your configuration to Astro and create your Deployment:
```sh wrap theme={null}
astro deployment create --deployment-file config.yaml
```
## Step 4: Use Starship to Migrate Airflow Connections and Variables
You might have defined Airflow connections and variables in the following places on your source Airflow environment:
* The Airflow UI (stored in the Airflow metadata database).
* Environment variables
* A secrets backend.
If you defined your Airflow variables and connections in the Airflow UI, you can migrate those to Astro with [Starship](https://astronomer.github.io/starship/). You can check which resources will be migrated by going to **Admin** > **Variables** and **Admin** > **Connections** in the Airflow UI to find your source Airflow environment information.
Some environment variables or Airflow Settings, like global environment variable values, can't be migrated to Astro. See [Global environment variables](/docs/astro/platform-variables) for a list of variables that you can't migrate to Astro.
1. Log in to Astro. In the Astro UI, open the Deployment you're migrating to.
2. Click **Open Airflow** to open the Airflow UI for the Deployment. Copy the URL for the home page. It should look similar to `https://.astronomer.run//home`.
3. Create a Deployment API token for the Deployment. The token should minimally have permissions to update the Deployment and deploy code. Copy this token. See [Create and manage Deployment API tokens](/docs/astro/deployment-api-tokens) for additional setup steps.
4. Open the Airflow UI for your source Airflow environment, then go to **Astronomer** > **Migration Tool 🚀**.
5. Ensure that the **Astronomer Product** toggle is set to **Astro**.
6. In the **Airflow URL** section, fill in the fields so that the complete URL on the page matches the URL of the Airflow UI for the Deployment you're migrating to.
7. Specify your API token in the **Token** field. Starship will confirm that it has access to your Deployment.
8. Click **Connections**. In the table that appears, click **Migrate** for each connection that you want to migrate to Astro. After the migration is complete, the status **Migrated ✅** appears.
9. Click **Pools**. In the table that appears, click **Migrate** for each connection that you want to migrate to Astro. After the migration is complete, the status **Migrated ✅** appears.
10. Click **Variables**. In the table that appears, click **Migrate** for each variable that you want to migrate to Astro. After the migration is complete, the status **Migrated ✅** appears.
11. Click **Environment variables**. In the table that appears, check the box for each environment variable that you want to migrate to Astro, then click **Migrate**. After the migration is complete, the status **Migrated ✅** appears.
12. Click **DAG History**. In the table that appears, check the box for each DAG whose history you want to migrate to Astro, then click **Migrate**. After the migration is complete, the status **Migrated ✅** appears.
Refer to the [Configuration](https://astronomer.github.io/starship/operator/#usage) detailed instructions on using the operator.
1. Log in to Astro. In the Astro UI, open the Deployment you're migrating to.
2. Click **Open Airflow** to open the Airflow UI for the Deployment. Copy the URL for the home page. It should look similar to `https://.astronomer.run//home`.
3. Create a Deployment API token for the Deployment. The token should minimally have permissions to update the Deployment and deploy code. Copy this token. See [Create and manage Deployment API tokens](/docs/astro/deployment-api-tokens) for additional setup steps.
4. Add the following DAG to your source Airflow environment:
```python wrap theme={null}
from airflow.models.dag import DAG
from astronomer.starship.operators import AstroMigrationOperator
from datetime import datetime
with DAG(
dag_id="astronomer_migration_dag",
start_date=datetime(1970, 1, 1),
schedule_interval=None,
) as dag:
AstroMigrationOperator(
task_id='export_meta',
deployment_url='{{ dag_run.conf["deployment_url"] }}',
token='{{ dag_run.conf["astro_token"] }}',
)
```
5. Deploy this DAG to your source Airflow environment.
6. Once the DAG is available in the Airflow UI, click **Trigger DAG**, then click **Trigger DAG w/ config**.
7. In **Configuration JSON**, add the following configuration:
```json wrap theme={null}
{
"deployment_url": "",
"astro_token": ""
}
```
8. Replace the following placeholder values:
* ``: The Deployment URL you copied in Step 2.
* ``: The token you copied in Step 3.
9. Click **Trigger**. After the DAG successfully runs, all connections, variables, and environment variables that are available from the Airflow UI are migrated to Astronomer.
## Step 5: Create an Astro project
1. Create a new directory for your Astro project:
```sh wrap theme={null}
mkdir
```
2. Open the directory:
```sh wrap theme={null}
cd
```
3. Run the following Astro CLI command to initialize an Astro project in the directory:
```sh wrap theme={null}
astro dev init
```
This command generates a set of files that will build into a Docker image that you can both run on your local machine and deploy to Astro.
4. Add the following line to your Astro project `requirements.txt` file:
```sh wrap theme={null}
astronomer-starship
```
When you deploy your code, this line installs the Starship migration tool on your Deployment so that you can migrate Airflow resources from your source environment to Astro.
5. (Optional) Run the following command to initialize a new git repository for your Astro project:
```sh wrap theme={null}
git init
```
## Step 6: Migrate project code and dependencies to your Astro project
1. Open your Astro project Dockerfile. Update the Runtime version in first line to the version you selected for your Deployment in [Step 3](#step-3-create-an-astro-deployment). For example, if your Runtime version was 6.3.0, your Dockerfile would look like the following:
```dockerfile title="Dockerfile" wrap theme={null}
FROM quay.io/astronomer/astro-runtime:6.3.0
```
The `Dockerfile` defines the environment where all your Airflow components run. You can modify it to include build-time arguments for your Airflow environment, such as environment variables or credentials. For this migration, you only need to modify the Dockerfile to update your Astro Runtime version.
2. Open your Astro project `requirements.txt` file and add all Python packages that you installed in your source Airflow environment. See [Google documentation](https://cloud.google.com/composer/docs/composer-2/install-python-dependencies#view-custom) for how to view a list of Python packages in your source Airflow environment.
To avoid breaking dependency upgrades, Astronomer recommends pinning your packages to the versions running in your source Airflow environment. For example, if you're running `apache-airflow-providers-snowflake` version 3.3.0 on Cloud composer, you would add `apache-airflow-providers-snowflake==3.3.0` to your Astro `requirements.txt` file.
3. Open your Astro project `dags` folder. Copy your dag files to `dags` from either your source control platform or GCS Bucket.
4. If you used the [`plugins` folder](https://cloud.google.com/composer/docs/concepts/cloud-storage#folders_in_the_bucket) in your Cloud Composer storage bucket, copy the contents of this folder from your source control platform or GCS Bucket to your Astro project `/plugins` folder.
5. If you used the [`data` folder](https://cloud.google.com/composer/docs/concepts/cloud-storage#data) in Cloud Composer, copy the contents of that folder from your source control platform or GCS Bucket to your Astro project `include` folder.
After you confirm that your Astro project has all necessary dependencies, deploy the project to your Astro Deployment.
1. Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
2. Run the following command to deploy your project
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
1. Open your Astro project Dockerfile. Update the Runtime version in first line to the version you selected for your Deployment in [Step 3](#step-3-create-an-astro-deployment). For example, if your Runtime version was 6.3.0, your Dockerfile would look like the following:
```dockerfile title="Dockerfile" wrap theme={null}
FROM quay.io/astronomer/astro-runtime:6.3.0
```
The `Dockerfile` defines the environment where all your Airflow components run. You can modify it to include build-time arguments for your Airflow environment, such as environment variables or credentials. For this migration, you only need to modify the Dockerfile to update your Astro Runtime version.
2. Open your Astro project in your terminal. Run the following command to copy your PyPI packages from GCC to your `requirements.txt` file:
```sh wrap theme={null}
gcloud composer environments describe --format="value(config.softwareConfig.pypiPackages)" > requirements.txt
```
Review the output in `requirements.txt` after running this command to ensure that all packages were imported on their own line of text.
To avoid breaking dependency upgrades, Astronomer recommends pinning your packages to the versions running in your source Airflow environment. For example, if you're running `apache-airflow-providers-snowflake` version 3.3.0 on Cloud composer, you would add `apache-airflow-providers-snowflake==3.3.0` to your Astro `requirements.txt` file.
3. Run the following command to copy your dags from Cloud Composer to your `dags` folder:
```sh wrap theme={null}
gcloud composer environments storage dags export --destination=dags
```
Review your dag files in `dags` after running this command to ensure that all dags were successfully exported.
4. If you utilized the [`plugins` folder](https://cloud.google.com/composer/docs/concepts/cloud-storage#folders_in_the_bucket) in your Cloud Composer storage bucket, run the following command to copy your `plugins` folder contents to your Astro project:
```sh wrap theme={null}
gcloud composer environments storage plugins export --destination=plugins
```
Review the contents of your Astro project `plugins` folder to ensure that all files were successfully exported.
5. If you utilized the [`data` folder](https://cloud.google.com/composer/docs/concepts/cloud-storage#data) in Cloud Composer, run the following command to copy your `data` folder contents to your Astro project:
```sh wrap theme={null}
gcloud composer environments storage data export --destination=include
```
After you confirm that your Astro project has all necessary dependencies, deploy the project to your Astro Deployment.
1. Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
2. Run the following command to deploy your project
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
## Step 7: Configure additional data pipeline infrastructure
The core migration of your project is now complete. Read the following topics to see whether you need to set up any additional infrastructure on Astro before cutting over your dags.
### Set up CI/CD
If you used CI/CD to deploy code to your source Airflow environment, read the following documentation to learn about setting up a similar CI/CD pipeline for your Astro project:
* [Set-Up CI/CD](/docs/astro/set-up-ci-cd)
* [CI/CD templates](/docs/astro/ci-cd-templates/template-overview)
Similarly to GCC, you can deploy dags to Astro directly from a Google Cloud Storage (GCS) bucket. See [Deploy dags to from Google Cloud Storage to Astro](/docs/astro/ci-cd-templates/gcs).
### Set up a secrets backend
If you currently store Airflow variables or connections in a secrets backend, you need to integrate your secrets backend with Astro to access those objects from your migrated dags. See [Configure a Secrets Backend](/docs/astro/secrets-backend) for setup steps.
#### Instance permissions and trust policies
You can utilize Workload Identity or Service Account Keys to grant your Astro Deployment the same level of access to Google Services as your source Airflow environment. See [Connect GCP - Authorization options](/docs/astro/connect-gcp).
## Step 8: Test locally and check for import errors
Depending on how thoroughly you want to test your Airflow environment, you have a few options for testing your project locally before deploying to Astro.
* In your Astro project directory, run `astro dev parse` to check for any parsing errors in your dags.
* Run `astro run ` to test a specific dag. This command compiles your dag and runs it in a single Airflow worker container based on your Astro project configurations.
* Run `astro dev start` to start a complete Airflow environment on your local machine. After your project starts up, you can access the Airflow UI at `localhost:8080`. See [Troubleshoot your local Airflow environment](/docs/cli/v1.43/run-airflow-locally).
Note that your migrated Airflow variables and connections are not available locally. You must deploy your project to Astro to test these resources.
## Step 9: Deploy to Astro
1. Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
2. Run the following command to deploy your project
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
3. In the Astro UI, open your Deployment and click **Open Airflow**. Confirm that you can see your deployed DAGs in the Airflow UI.
## Step 10: Cut over from your source Airflow environment to Astro
After you successfully deploy your code to Astro, you need to migrate your workloads from your source Airflow environment to Astro on a DAG-by-DAG basis. Depending on how your workloads are set up, Astronomer recommends letting DAG owners determine the order to migrate and test DAGs.
You can complete the following steps in the few days or weeks following your migration set up. Provide updates to your Astronomer Data Engineer as they continue to assist you through the process and any solve any difficulties that arise.
Continue to validate and move your DAGs until you have fully cut over your source Airflow instance. After you finish migrating from your source Airflow environment, repeat the complete migration process for any other Airflow instances in your source Airflow environment.
#### Confirm connections and variables
In the Airflow UI for your Deployment, [test all connections](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html#testing-connections) that you migrated from your source Airflow environment.
Additionally, check Airflow variable values in **Admin** > **Variables**.
#### Test and validate DAGs in Astro
To create a strategy for testing DAGs, determine which DAGs need the most care when running and testing them.
If your DAG workflow is idempotent and can run twice or more without negative effects, you can run and test these DAGs with minimal risk. If your DAG workflow is non-idempotent and can become invalid when you rerun it, you should test the DAG with more caution and downtime.
#### Cut over DAGs to Astro using Starship
Starship includes features for simultaneously pausing DAGs in your source Airflow environment and starting them on Astro. This allows you to cut over your production workflows without downtime.
For each DAG in your Astro Deployment:
1. Confirm that the DAG ID in your Deployment is the same as the DAG ID in your source Airflow environment.
2. In the Airflow UI for your source Airflow environment, go to **Astronomer** > **Migration Tool 🚀**.
3. Click **DAGs cutover**. In the table that appears, click the Pause icon in the **Local** column for the DAG you're cutting over.
4. Click the Start icon in the **Remote** column for the DAG you're cutting over.
5. After completing this cutover, the Start and Pause icons switch. If there's an issue after cutting over, click the **Remote** pause button and then the **Local** start button to move your workflow back to your source Airflow environment.
The Starship operator does not contain cut-over functionality.
To cut over a DAG, pause the DAG in the source Airflow and unpause the DAG in Astro. Keep both Airflow environments open as you test and ensure that the cutover was successful.
### Optimize Deployment resource usage
#### Review DAG development features
Astro includes several features that enhance the Apache Airflow development experience, from DAG writing to testing. To make the most of these features, you might want to make adjustments to your existing DAG development workflows.
As you get started on Astro, review the list of features and changes that Astro brings to the Airflow development experience and consider how you want to implement these details in your development experience. See [Write and run DAGs on Astro](/docs/astro/dags-overview).
#### Monitor analytics
As you cut over DAGs, view [Deployment metrics](/docs/astro/deployment-metrics) to get a sense of how many resources your Deployment is using. Use this information to adjust your worker queues and resource usage accordingly, or to tell when a DAG isn't running as expected.
#### Modify instance types or use worker queues
If your current worker type doesn't have the right amount of resources for your workflows, see [Deployment settings](/docs/astro/deployment-settings) to learn about configuring worker types on your Deployments.
You can additionally configure [worker queues](/docs/astro/configure-worker-queues) to assign each of your tasks to different worker instance types. View your [Deployment metrics](/docs/astro/deployment-metrics) to help you determine what changes are required.
#### Enable DAG-only deploys
Deploying to Astro with DAG-only deploys enabled can make deploys faster in cases where you've only modified your `dags` directory. To enable the DAG-only deploy feature, see [Deploy DAGs only](/docs/astro/deploy-dags).
# Migrate existing objects to the Environment Manager
Source: https://astronomer.io/docs/astro/migrate-metadata-db-to-environment-manager
Move existing Airflow connections, Airflow variables, and Deployment environment variables into the Astro Environment Manager.
**Preview**
The migration and promotion flows on this page are in [Preview](/docs/astro/feature-previews).
You can bring existing Airflow connections, Airflow variables, environment variables, and metrics exports into the [Astro Environment Manager](/docs/astro/manage-connections-variables#astro-environment-manager). After an object is in the Environment Manager, you can manage it centrally in the Workspace and link it to other Deployments or to [Astro IDE](/docs/astro/ide-overview) projects.
This page covers two flows:
* **Migrate from Airflow.** Bulk migrate connections and Airflow variables from a Deployment's Airflow metadata database into the Environment Manager.
* **Promote to Workspace Environment.** Promote a single Deployment-scoped connection, Airflow variable, environment variable, or metrics export to the Workspace level.
Each flow keeps the source object available on the Deployment by linking the new Workspace environment object back to that Deployment.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Migrate Airflow connections and variables from a Deployment
The **Migrate from Airflow** flow reads connections and Airflow variables from a Deployment's Airflow metadata database, copies each one into a Workspace environment object linked to the source Deployment, and removes it from the metadata database.
Migration deletes the source connection or Airflow variable from the Deployment's metadata database. This action can't be undone. After migration, there is a short delay, around one minute, before the migrated objects are available to Dags running on the Deployment.
### Prerequisites
* Workspace Owner [user permissions](/docs/astro/user-permissions).
* A standard Astro Deployment with one or more connections or Airflow variables stored in its metadata database. Remote Execution Deployments aren't supported.
### Migrate a connection or Airflow variable
The migration page provides separate entry points for connections and Airflow variables. The steps are equivalent for both object types.
1. In the Astro UI, click **Deployments**, select the Deployment that contains the objects you want to migrate, then click the **Environment** tab.
2. Click **Connections** or **Airflow Variables** in the Deployment Environment menu.
3. Click **Migrate from Airflow**. The action appears dimmed when the Deployment's metadata database doesn't contain any objects of that type.
4. In the migration page, select the connections or Airflow variables you want to migrate. Each row shows whether the object is new to the Workspace or whether a Workspace object with the same key already exists. If a matching Workspace object already exists, Astro creates a Deployment-level override on that Workspace object rather than a duplicate.
5. Click **Migrate**, then confirm in the dialog. The confirmation warns that Astro removes the source objects from the Deployment's metadata database.
1. In the Astro UI, select a Workspace, click **Deployments**, select the Deployment that contains the objects you want to migrate, then click the **Environment** tab.
2. Click **Connections** or **Airflow Variables** in the Deployment Environment menu.
3. Click **Migrate from Airflow**. The action appears dimmed when the Deployment's metadata database doesn't contain any objects of that type.
4. In the migration page, select the connections or Airflow variables you want to migrate. Each row shows whether the object is new to the Workspace or whether a Workspace object with the same key already exists. If a matching Workspace object already exists, Astro creates a Deployment-level override on that Workspace object rather than a duplicate.
5. Click **Migrate**, then confirm in the dialog. The confirmation warns that Astro removes the source objects from the Deployment's metadata database.
After the migration completes, the new objects appear in the Workspace **Environment** page. Each migrated object is linked to the source Deployment, so the Deployment continues to use the same values. The objects aren't automatically available to other Deployments or Astro IDE projects. To use a migrated object elsewhere, link it from the Workspace **Environment** page. See [Link connections to Deployments](/docs/astro/create-and-link-connections#link-connections-to-deployments) or [Link connections to Astro IDE projects](/docs/astro/create-and-link-connections#link-connections-to-astro-ide-projects).
## Promote a Deployment environment object to the Workspace
You can promote a Deployment-scoped connection, Airflow variable, environment variable, or metrics export to the Workspace level. After promotion, the object is managed in the Workspace and remains linked to the source Deployment, so the Deployment continues to use the same values.
### Prerequisites
* `workspace.envObjects.create` and `deployment.update` permissions, included with Workspace Operator or Workspace Owner [user permissions](/docs/astro/user-permissions).
* A Deployment-scoped object that isn't already an override of a Workspace-level object.
### Promote an object
1. In the Astro UI, click **Deployments**, then select the Deployment that contains the object.
2. Click the **Environment** tab in the Deployment menu, then open **Connections**, **Airflow Variables**, **Environment Variables**, or **Metrics Exports**.
3. Open the row-level more actions menu for the object you want to promote.
4. Select **Promote to Workspace Environment**.
5. Confirm the promotion in the dialog. For environment variables, enter the environment variable key to confirm.
1. In the Astro UI, select a Workspace, click **Deployments**, then select the Deployment that contains the object.
2. Click the **Environment** tab in the Deployment menu, then open **Connections**, **Airflow Variables**, **Environment Variables**, or **Metrics Exports**.
3. Open the row-level more actions menu for the object you want to promote.
4. Select **Promote to Workspace Environment**.
5. Confirm the promotion in the dialog. For environment variables, enter the environment variable key to confirm.
After promotion, the object appears in the Workspace **Environment** page. You can link it to additional Deployments and Astro IDE projects from there.
If a Workspace object with the same type and key already exists, Astro adds a Deployment-level override on the existing Workspace object instead of creating a duplicate.
## See also
* [Manage Airflow connections, variables, and environment variables](/docs/astro/manage-connections-variables)
* [Create connections in Astro](/docs/astro/create-and-link-connections)
* [Create Airflow variables in Astro](/docs/astro/create-and-link-variables)
* [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables)
# Migrate to Astro from Amazon MWAA
Source: https://astronomer.io/docs/astro/migrate-mwaa
Get started on Astro Hosted by migrating your Airflow code from Amazon Managed Workflows for Apache Airflow (MWAA).
Migrate your Airflow environment from [Amazon Managed Workflows for Apache Airflow (MWAA)](https://aws.amazon.com/managed-workflows-for-apache-airflow/resources/) to Astro.
To complete the migration process, you will:
* Prepare your source Airflow and create a Deployment on Astro.
* Migrate metadata from your source Airflow environment.
* Migrate dags and additional Airflow components from your source Airflow environment.
* Complete the cutover process to Astro.
## Prerequisites
Before starting the migration, ensure that the following are true:
* You have an Astro user account and can [log in to Astro](/docs/astro/log-in-to-astro).
* (Optional) You created a network connection from Astro to your external cloud resources..
* (Optional) You [configured your identity provider (IdP)](/docs/astro/configure-idp).
On your local machine, make sure you have:
* An [Astro account](/docs/astro/log-in-to-astro).
* The [Astro CLI](/docs/cli/v1.43/install-cli).
On the cloud service from which you're migrating, ensure that you have:
* A source Airflow environment on Airflow 2 or later.
* Read access to the source Airflow environment.
* Read access to any cloud storage buckets that store your DAGs.
* Read access to any source control tool that hosts your current Airflow code, such as GitHub.
* Permission to create new repositories on your source control tool.
* (Optional) Access to your secrets backend.
* (Optional) Permission to create new CI/CD pipelines.
All source Airflow environments on 1.x need to be upgraded to at least Airflow 2.0 before you can migrate them. Astronomer professional services can help you with the upgrade process.
If you're migrating to Astro from OSS Airflow or another Astronomer product, and you currently use an older version of Airflow, you can still create Deployments with the corresponding version of Astro Runtime even if it is deprecated according to the [Astro Runtime maintenance policy](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-maintenance-policy). This allows you to migrate your DAGs to Astro without needing to make any code changes and then immediately upgrade to a new version of Airflow. Note that after you migrate your DAGs, Astronomer recommends upgrading to a supported version of Astro Runtime as soon as you can.
See [Run a deprecated Astro Runtime version](https://www.astronomer.io/docs/astro/upgrade-runtime#run-a-deprecated-astro-runtime-version).
(Optional) You can use the [AWS CLI](https://aws.amazon.com/cli/) to expedite some of the steps in this guide.
## Step 1: Install Astronomer Starship
The [Astronomer Starship](https://astronomer.github.io/starship/) migration utility connects your source Airflow environment to your Astro Deployment and migrates your Airflow connections, Airflow variables, environment variables, and dags.
The Starship migration utility works as a [plugin](https://github.com/astronomer/starship/blob/main/README.md) with a user interface, or as an [Airflow operator](https://astronomer.github.io/starship/operator/) if you are migrating from a more restricted Airflow environment.
If you are migrating from an MWAA instance with a private webserver, you will need to use the `StarshipOperator` pattern.
See the following table for information on which versions of Starship are available, depending on your source Airflow environment:
| Source Airflow environment | Starship plugin | Starship operator |
| -------------------------- | --------------- | ----------------- |
| Airflow 1.x | ❌ | ❌ |
| MWAA v2.0.2 | | ✔️️ |
| MWAA v2.2.2 | ✔️️ | |
| MWAA v2.4.3 | ✔️️ | |
1. Download the `requirements.txt` file for your source Airflow environment from S3. See [AWS documentation](https://docs.aws.amazon.com/mwaa/latest/userguide/best-practices-dependencies.html#best-practices-dependencies-different-ways).
2. Add `astronomer-starship` on a new line to your `requirements.txt` file.
3. Reupload the file to your S3 bucket.
4. Update your Airflow environment to use the new version of this file.
To complete this setup from the command line:
1. Run the following commands to set environment variables on your local machine:
```sh wrap theme={null}
export MWAA_NAME="MWAA"
export MWAA_BUCKET="MWAA BUCKET"
```
2. Run the following AWS CLI commands to install Starship:
```sh wrap theme={null}
aws s3 cp "s3://$MWAA_BUCKET/requirements.txt" requirements.txt
echo 'astronomer-starship' >> requirements.txt
aws s3 cp requirements.txt "s3://$MWAA_BUCKET/requirements.txt"
aws mwaa update-environment "$MWAA_NAME" --requirements-s3-object-version="$(aws s3api head-object --bucket=$MWAA_BUCKET --key=requirements.txt --query="VersionId")"
```
## Step 2: Create an Astro Workspace
In your Astro Organization, you can create *Workspaces*, which are a collection of users that have access to the same Deployments. Workspaces are typically owned by a single team.
You can choose to use an existing Workspace, or create a new one. However, you must have at least one Workspace to complete your migration.
1. Follow the steps in [Manage Workspaces](/docs/astro/manage-workspaces) to create a Workspace in the Astro UI for your migrated Airflow environments. Astronomer recommends naming your first Workspace after your data team or initial business use case with Airflow. You can update these names in the Astro UI after you finish the migration.
2. Follow the steps in [Manage Astro users](/docs/astro/manage-workspace-users#add-a-user-to-a-workspace) to add users from your team to the Workspace. See [Astro user permissions](/docs/astro/user-permissions#workspace-roles) for details about each available Workspace user role.
**CLI**
You can add users to a Workspace an Organization using the Astro CLI. See:
* [`astro workspace user add`](/docs/cli/v1.43/astro-workspace-user-add)
* [`astro organization user invite`](/docs/cli/v1.43/astro-organization-user-invite)
You can also automate adding batches of users to Astro with shell scripts. See [Add a group of users to Astro using the Astro CLI](/docs/astro/manage-workspace-users#add-a-group-of-users-to-a-workspace-using-the-astro-cli).
## Step 3: Create an Astro Deployment
A *Deployment* is an Astro Runtime environment that is powered by the core components of Apache Airflow. In a Deployment, you can deploy and run DAGs, configure worker resources, and view metrics.
You can choose to use an existing Deployment, or create a new one. However, you must have at least one Deployment to complete your migration.
Before you create your Deployment, copy the following information from your source Airflow environment:
* Environment name
* Airflow version
* Environment class or size
* Number of schedulers
* Minimum number of workers
* Maximum number of workers
* Execution role permissions
* Airflow configurations
* Environment variables
**Alternative setup for Astro Hybrid**
This setup varies slightly for Astro Hybrid users. See [Deployment settings](/docs/astro/deployment-settings) for all configurations related to Astro Hybrid Deployments.
1. In the Astro UI, select a Workspace.
2. On the **Deployments** page, click **Deployment**.
3. Complete the following fields:
* **Name**: Enter the name of your source Airflow environment.
* **Astro Runtime**: Select the Runtime version that's based on the Airflow version in your source Airflow environment. See the following table to determine which version of Runtime to use. Where exact version matches are not available, the nearest Runtime version is provided with its supported Airflow version in parentheses.
| Airflow Version | Runtime Version |
| --------------- | ---------------------- |
| 2.0 | 3.0.4 (Airflow 2.1.1)¹ |
| 2.2 | 4.2.9 (Airflow 2.2.5) |
| 2.4 | 6.3.0 (Airflow 2.4.3) |
¹The earliest available Airflow version on Astro Runtime is 2.1.1. There are no known risks for upgrading directly from Airflow 2.0 to Airflow 2.1.1 during migration. For a complete list of supported Airflow versions, see [Astro Runtime release and lifecycle schedule](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-lifecycle-schedule).
* **Description**: (Optional) Enter a description for your Deployment.
* **Cluster**: Choose whether you want to run your Deployment in a **Standard cluster** or **Dedicated cluster**. If you don't have specific networking or cloud requirements, Astronomer recommends using the default **Standard cluster** configurations.
To configure and use dedicated clusters, see [Create a dedicated cluster](/docs/astro/create-dedicated-cluster). If you don't have the option of choosing between standard or dedicated, that means you are an Astro Hybrid user and must choose a cluster that has been configured for your Organization.
* **Executor**: Choose the same executor as in your source Airflow environment.
* **Scheduler**: Use the following table to determine the Deployment size you need based on the size of your source Airflow environment.
| Environment size | Scheduler size | vCPU | Memory | Ephemeral Storage |
| ------------------------------- | -------------- | --------------------------------------------------- | ---------------------------------------------------------- | ----------------- |
| Small (Up to \~50 DAGs) | Small | 1 | 2Gi | 5 GiB |
| Medium (Up to \~250 DAGs) | Medium | **Scheduler**: 1 **DAG Processor**: 1 | **Scheduler**: 2 GiB **DAG Processor**: 2 GiB² | 5 GiB |
| Large (Up to \~1000 DAGs) | Large | **Scheduler**: 1 **DAG Processor**: 3 | **Scheduler**: 2 GiB **DAG Processor**: 6 GiB² | 5 GiB |
| Extra Large (Up to \~2000 DAGs) | Extra-large | **Scheduler**: 1 **DAG Processor (x2)**: 3.5 | **Scheduler**: 4 GiB **DAG Processor (x2)**: 6 GiB² | 5 GiB |
²Some of the following recommendations for CPU and memory might be less than what you currently allocate to Airflow components in your source environment. If you notice significant performance differences or your Deployment on Astro parses DAGs more slowly than your source Airflow environment, adjust your resource use on Astro. See [Configure Deployment resources](/docs/astro/deployment-resources)
* **Worker Type**: Select the worker type for your default worker queue. See [Worker queues](/docs/astro/configure-worker-queues).
* **Min / Max # Workers**: Set the same minimum and maximum worker count as in source Airflow environment.
* **KPO Pods**: (Optional) If you use the `KubernetesPodOperator` or Kubernetes Executor, set limits on how many resources your tasks can request.
4. Click **Create Deployment**.
5. Specify any system-level environment variables as Astro environment variables. See [Environment variables](/docs/astro/manage-env-vars#use-the-astro-ui).
6. Set an email to receive alerts from Astronomer support about your Deployments. See [Configure Deployment contact emails](/docs/astro/deployment-details#configure-deployment-contact-emails).
This option is available only on Astro Hybrid.
1. On your local machine, create a directory with the name of the source Airflow environment. In this directory, create a file called `config.yaml`.
2. Open `config.yaml` and add the following:
```yaml wrap theme={null}
deployment:
environment_variables:
- is_secret:
key:
value:
configuration:
name:
description:
runtime_version:
dag_deploy_enabled: false
scheduler_au:
scheduler_count:
cluster_name:
workspace_name:
worker_queues:
- name: default
max_worker_count:
min_worker_count:
worker_concurrency: 16
worker_type:
alert_emails:
-
```
3. Replace the placeholder values in the configuration:
* `` / `` / ``: Set system-level environment variables for your Deployment and specify whether they should be secret. Repeat this configuration in the file for any additional variables you need to set.
* ``: Enter the same name as your source Airflow environment.
* ``: (Optional) Enter a description for your Deployment.
* ``: Select the Runtime version that's based on the Airflow version in your source Airflow environment. See the following table to determine which version of Runtime to use. Where exact version matches are not available, the nearest Runtime version is provided with its supported Airflow version in parentheses.
| Airflow Version | Runtime Version |
| --------------- | ---------------------- |
| 2.0 | 3.0.4 (Airflow 2.1.1)¹ |
| 2.2 | 4.2.9 (Airflow 2.2.5) |
| 2.4 | 6.3.0 (Airflow 2.4.3) |
¹The earliest available Airflow version on Astro Runtime is 2.1.1. There are no known risks for upgrading directly from Airflow 2.0 to Airflow 2.1.1 during migration. For a complete list of supported Airflow versions, see [Astro Runtime release and lifecycle schedule](/docs/runtime/runtime-version-lifecycle-policy#astro-runtime-lifecycle-schedule).
* ``: Set your scheduler size in Astronomer Units (AU). An AU is a unit of CPU and memory allocated to each scheduler in a Deployment. Use the following table to determine how many AUs you need based on the size of your source Airflow environment.
| Environment size | AUs | CPU / memory |
| ------------------------- | --- | ----------------- |
| Small (Up to \~50 DAGs) | 5 | .5vCPU, 1.88GiB |
| Medium (Up to \~250 DAGs) | 10 | 1vCPU, 3.75GiB² |
| Large (Up to \~1000 DAGs) | 15 | 1.5vCPU, 5.64GiB² |
² Some of the following recommendations for CPU and memory are smaller than what you have in the equivalent source environment. Although you might not need more CPU or memory than what's recommended, some environments might parse DAGs slower than in your source Airflow environment to start. Use these recommendations as a starting point, then adjust your resource usage after tracking your performance on Astro.
* ``: Specify the same number of schedulers as in your source Airflow environment.
* ``: Specify name of the Astro cluster in which you want to create this Deployment.
* ``: The name of the Workspace you created.
* `/ `: Specify the same minimum and maximum worker count as in source Airflow environment.
* ``: Specify the worker type for your default worker queue. You can see which worker types are available for your cluster in the **Clusters** menu of the Astro UI. If you did not customize the available worker types for your cluster, the default available worker types are:
| AWS | GCP | Azure |
| --------- | ------------- | ----------------- |
| M5.XLARGE | E2-STANDARD-4 | `STANDARD_D4D_V5` |
* ``: Set an email to receive alerts from Astronomer support about your Deployments. See [Set up Astro alerts](/docs/astro/alerts).
After you finish entering these values, your `config.yaml` file should look something like the following:
```yaml wrap theme={null}
deployment:
environment_variables:
- is_secret: true
key: MY_VARIABLE_KEY
value: MY_VARIABLE_VALUE
- is_secret: false
key: MY_VARIABLE_KEY_2
value: MY_VARIABLE_VALUE_2
configuration:
name: My Deployment
description: The Deployment I'm using for migration.
runtime_version: 6.3.0
dag_deploy_enabled: false
scheduler_au: 5
scheduler_count: 2
cluster_name: My Cluster
workspace_name: My Workspace
worker_queues:
- name: default
max_worker_count: 10
min_worker_count: 1
worker_concurrency: 16
worker_type: E2-STANDARD-4
alert_emails:
- myalertemail@cosmicenergy.org
```
4. Run the following command to push your configuration to Astro and create your Deployment:
```sh wrap theme={null}
astro deployment create --deployment-file config.yaml
```
## Step 4: Use Starship to Migrate Airflow Connections and Variables
You might have defined Airflow connections and variables in the following places on your source Airflow environment:
* The Airflow UI (stored in the Airflow metadata database).
* Environment variables
* A secrets backend.
If you defined your Airflow variables and connections in the Airflow UI, you can migrate those to Astro with [Starship](https://astronomer.github.io/starship/). You can check which resources will be migrated by going to **Admin** > **Variables** and **Admin** > **Connections** in the Airflow UI to find your source Airflow environment information.
Some environment variables or Airflow Settings, like global environment variable values, can't be migrated to Astro. See [Global environment variables](/docs/astro/platform-variables) for a list of variables that you can't migrate to Astro.
1. Log in to Astro. In the Astro UI, open the Deployment you're migrating to.
2. Click **Open Airflow** to open the Airflow UI for the Deployment. Copy the URL for the home page. It should look similar to `https://.astronomer.run//home`.
3. Create a Deployment API token for the Deployment. The token should minimally have permissions to update the Deployment and deploy code. Copy this token. See [Create and manage Deployment API tokens](/docs/astro/deployment-api-tokens) for additional setup steps.
4. Open the Airflow UI for your source Airflow environment, then go to **Astronomer** > **Migration Tool 🚀**.
5. Ensure that the **Astronomer Product** toggle is set to **Astro**.
6. In the **Airflow URL** section, fill in the fields so that the complete URL on the page matches the URL of the Airflow UI for the Deployment you're migrating to.
7. Specify your API token in the **Token** field. Starship will confirm that it has access to your Deployment.
8. Click **Connections**. In the table that appears, click **Migrate** for each connection that you want to migrate to Astro. After the migration is complete, the status **Migrated ✅** appears.
9. Click **Pools**. In the table that appears, click **Migrate** for each connection that you want to migrate to Astro. After the migration is complete, the status **Migrated ✅** appears.
10. Click **Variables**. In the table that appears, click **Migrate** for each variable that you want to migrate to Astro. After the migration is complete, the status **Migrated ✅** appears.
11. Click **Environment variables**. In the table that appears, check the box for each environment variable that you want to migrate to Astro, then click **Migrate**. After the migration is complete, the status **Migrated ✅** appears.
12. Click **DAG History**. In the table that appears, check the box for each DAG whose history you want to migrate to Astro, then click **Migrate**. After the migration is complete, the status **Migrated ✅** appears.
Refer to the [Configuration](https://astronomer.github.io/starship/operator/#usage) detailed instructions on using the operator.
1. Log in to Astro. In the Astro UI, open the Deployment you're migrating to.
2. Click **Open Airflow** to open the Airflow UI for the Deployment. Copy the URL for the home page. It should look similar to `https://.astronomer.run//home`.
3. Create a Deployment API token for the Deployment. The token should minimally have permissions to update the Deployment and deploy code. Copy this token. See [Create and manage Deployment API tokens](/docs/astro/deployment-api-tokens) for additional setup steps.
4. Add the following DAG to your source Airflow environment:
```python wrap theme={null}
from airflow.models.dag import DAG
from astronomer.starship.operators import AstroMigrationOperator
from datetime import datetime
with DAG(
dag_id="astronomer_migration_dag",
start_date=datetime(1970, 1, 1),
schedule_interval=None,
) as dag:
AstroMigrationOperator(
task_id='export_meta',
deployment_url='{{ dag_run.conf["deployment_url"] }}',
token='{{ dag_run.conf["astro_token"] }}',
)
```
5. Deploy this DAG to your source Airflow environment.
6. Once the DAG is available in the Airflow UI, click **Trigger DAG**, then click **Trigger DAG w/ config**.
7. In **Configuration JSON**, add the following configuration:
```json wrap theme={null}
{
"deployment_url": "",
"astro_token": ""
}
```
8. Replace the following placeholder values:
* ``: The Deployment URL you copied in Step 2.
* ``: The token you copied in Step 3.
9. Click **Trigger**. After the DAG successfully runs, all connections, variables, and environment variables that are available from the Airflow UI are migrated to Astronomer.
## Step 5: Create an Astro project
1. Create a new directory for your Astro project:
```sh wrap theme={null}
mkdir
```
2. Open the directory:
```sh wrap theme={null}
cd
```
3. Run the following Astro CLI command to initialize an Astro project in the directory:
```sh wrap theme={null}
astro dev init
```
This command generates a set of files that will build into a Docker image that you can both run on your local machine and deploy to Astro.
4. Add the following line to your Astro project `requirements.txt` file:
```sh wrap theme={null}
astronomer-starship
```
When you deploy your code, this line installs the Starship migration tool on your Deployment so that you can migrate Airflow resources from your source environment to Astro.
5. (Optional) Run the following command to initialize a new git repository for your Astro project:
```sh wrap theme={null}
git init
```
## Step 6: Migrate project code and dependencies to your Astro project
1. Open your Astro project Dockerfile. Update the Runtime version in first line to the version you selected for your Deployment in [Step 3](#step-3-create-an-astro-deployment). For example, if your Runtime version was 6.3.0, your Dockerfile would look like the following:
```dockerfile title="Dockerfile" wrap theme={null}
FROM quay.io/astronomer/astro-runtime:6.3.0
```
The `Dockerfile` defines the environment that all your Airflow components run in. You can modify it to make certain resources available to your Airflow environment like certificates or keys. For this migration, you only need to update your Runtime version.
2. Open your Astro project `requirements.txt` file and add all Python packages from your source Airflow environment's `requirements.txt` file. See [AWS documentation](https://docs.aws.amazon.com/mwaa/latest/userguide/working-dags-dependencies.html) to find this file in your S3 bucket.
To avoid breaking dependency upgrades, Astronomer recommends pinning your packages to the versions running in your source Airflow environment. For example, if you're running `apache-airflow-providers-snowflake` version 3.3.0 on MWAA, you would add `apache-airflow-providers-snowflake==3.3.0` to your Astro `requirements.txt` file.
3. Open your Astro project `dags` folder. Add your dag files from either your source control platform or S3.
4. If you used the [`plugins` folder](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-folders.html) in your MWAA project, copy the contents of this folder from your source control platform or S3 to the `/plugins` folder of your Astro project.
After you confirm that your Astro project has all necessary dependencies, deploy the project to your Astro Deployment.
1. Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
2. Run the following command to deploy your project
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
1. Open your Astro project Dockerfile. Update the Runtime version in first line to the version you selected for your Deployment in [Step 3](#step-3-create-an-astro-deployment). For example, if your Runtime version was 6.3.0, your Dockerfile would look like the following:
```dockerfile title="Dockerfile" wrap theme={null}
FROM quay.io/astronomer/astro-runtime:6.3.0
```
The `Dockerfile` defines the environment that all your Airflow components run in. You can modify it to make certain resources available to your Airflow environment like certificates or keys. For this migration, you only need to update your Runtime version.
2. Run the following command to copy your PyPI packages from AWS to your Astro project `requirements.txt` file:
```sh wrap theme={null}
aws s3 cp s3://[BUCKET]/requirements.txt requirements.txt
```
See [AWS documentation](https://docs.aws.amazon.com/mwaa/latest/userguide/working-dags-dependencies.html) to find this file in your S3 bucket. Review the output in your Astro project `requirements.txt` file after running this command to ensure that all packages were imported on their own line of text.
3. Run the following command to copy your PyPI packages from AWS to your Astro project `requirements.txt` file:
```sh wrap theme={null}
aws s3 cp --recursive s3://[BUCKET]/dags dags
```
Review your dag files in `dags` after running this command to ensure that all dags were successfully exported.
To avoid breaking dependency upgrades, Astronomer recommends pinning your packages to the versions running in your source Airflow environment. For example, if you're running `apache-airflow-providers-snowflake` version 3.3.0 on MWAA, you would add `apache-airflow-providers-snowflake==3.3.0` to your Astro `requirements.txt` file.
4. If you used the [`plugins` folder](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-folders.html) in your MWAA project, run the following command to directly copy your PyPI packages from AWS to your Astro project `requirements.txt` file:
```sh wrap theme={null}
aws s3 cp --recursive s3://[BUCKET]/plugins.zip plugins.zip
unzip plugins.zip
```
Review the contents of your Astro project `plugins` folder after running this command to ensure that all files were successfully exported.
After you confirm that your Astro project has all necessary dependencies, deploy the project to your Astro Deployment.
1. Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
2. Run the following command to deploy your project
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
## Step 7: Configure additional data pipeline infrastructure
The core migration of your project is now complete. Read the following to decide whether you need to set up any additional infrastructure on Astro before you cut over your dags.
### Set up CI/CD
If you used CI/CD to deploy code to your source Airflow environment, read the following documentation to learn about setting up a similar CI/CD pipeline for your Astro project:
* [Set-Up CI/CD](/docs/astro/set-up-ci-cd)
* [CI/CD templates](/docs/astro/ci-cd-templates/template-overview)
Similarly to MWAA, you can deploy dags to Astro directly from an S3 bucket. See [Deploy dags from an AWS S3 bucket to Astro using AWS Lambda](/docs/astro/ci-cd-templates/aws-s3).
### Set up a secrets backend
If you currently store Airflow variables or connections in a secrets backend, you also need to integrate your secrets backend with Astro to access those objects from your migrated dags. See [Configure a Secrets Backend](/docs/astro/secrets-backend) for setup steps.
## Step 8: Test locally and check for import errors
Depending on how thoroughly you want to test your Airflow environment, you can test your project locally before deploying to Astro.
* In your Astro project directory, run `astro dev parse` to check for any parsing errors in your dags.
* Run `astro run ` to test a specific dag. This command compiles your dag and runs it in a single Airflow worker container based on your Astro project configurations.
* Run `astro dev start` to start a complete Airflow environment on your local machine. After your project starts up, you can access the Airflow UI at `localhost:8080`. See [Troubleshoot your local Airflow environment](/docs/cli/v1.43/run-airflow-locally).
Your migrated Airflow variables and connections are not available locally. You must deploy your project to Astro to test these Airflow objects.
## Step 9: Deploy to Astro
1. Run the following command to authenticate to Astro:
```sh wrap theme={null}
astro login
```
2. Run the following command to deploy your project
```sh wrap theme={null}
astro deploy
```
This command returns a list of Deployments available in your Workspace and prompts you to pick one.
3. In the Astro UI, open your Deployment and click **Open Airflow**. Confirm that you can see your deployed DAGs in the Airflow UI.
## Step 10: Cut over from your source Airflow environment to Astro
After you successfully deploy your code to Astro, you need to migrate your workloads from your source Airflow environment to Astro on a DAG-by-DAG basis. Depending on how your workloads are set up, Astronomer recommends letting DAG owners determine the order to migrate and test DAGs.
You can complete the following steps in the few days or weeks following your migration set up. Provide updates to your Astronomer Data Engineer as they continue to assist you through the process and any solve any difficulties that arise.
Continue to validate and move your DAGs until you have fully cut over your source Airflow instance. After you finish migrating from your source Airflow environment, repeat the complete migration process for any other Airflow instances in your source Airflow environment.
#### Confirm connections and variables
In the Airflow UI for your Deployment, [test all connections](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html#testing-connections) that you migrated from your source Airflow environment.
Additionally, check Airflow variable values in **Admin** > **Variables**.
#### Test and validate DAGs in Astro
To create a strategy for testing DAGs, determine which DAGs need the most care when running and testing them.
If your DAG workflow is idempotent and can run twice or more without negative effects, you can run and test these DAGs with minimal risk. If your DAG workflow is non-idempotent and can become invalid when you rerun it, you should test the DAG with more caution and downtime.
#### Cut over DAGs to Astro using Starship
Starship includes features for simultaneously pausing DAGs in your source Airflow environment and starting them on Astro. This allows you to cut over your production workflows without downtime.
For each DAG in your Astro Deployment:
1. Confirm that the DAG ID in your Deployment is the same as the DAG ID in your source Airflow environment.
2. In the Airflow UI for your source Airflow environment, go to **Astronomer** > **Migration Tool 🚀**.
3. Click **DAGs cutover**. In the table that appears, click the Pause icon in the **Local** column for the DAG you're cutting over.
4. Click the Start icon in the **Remote** column for the DAG you're cutting over.
5. After completing this cutover, the Start and Pause icons switch. If there's an issue after cutting over, click the **Remote** pause button and then the **Local** start button to move your workflow back to your source Airflow environment.
The Starship operator does not contain cut-over functionality.
To cut over a DAG, pause the DAG in the source Airflow and unpause the DAG in Astro. Keep both Airflow environments open as you test and ensure that the cutover was successful.
### Optimize Deployment resource usage
#### Review DAG development features
Astro includes several features that enhance the Apache Airflow development experience, from DAG writing to testing. To make the most of these features, you might want to make adjustments to your existing DAG development workflows.
As you get started on Astro, review the list of features and changes that Astro brings to the Airflow development experience and consider how you want to implement these details in your development experience. See [Write and run DAGs on Astro](/docs/astro/dags-overview).
#### Monitor analytics
As you cut over DAGs, view [Deployment metrics](/docs/astro/deployment-metrics) to get a sense of how many resources your Deployment is using. Use this information to adjust your worker queues and resource usage accordingly, or to tell when a DAG isn't running as expected.
#### Modify instance types or use worker queues
If your current worker type doesn't have the right amount of resources for your workflows, see [Deployment settings](/docs/astro/deployment-settings) to learn about configuring worker types on your Deployments.
You can additionally configure [worker queues](/docs/astro/configure-worker-queues) to assign each of your tasks to different worker instance types. View your [Deployment metrics](/docs/astro/deployment-metrics) to help you determine what changes are required.
#### Enable DAG-only deploys
Deploying to Astro with DAG-only deploys enabled can make deploys faster in cases where you've only modified your `dags` directory. To enable the DAG-only deploy feature, see [Deploy DAGs only](/docs/astro/deploy-dags).
# Review code with Otto
Source: https://astronomer.io/docs/astro/otto-code-review
Use Otto to review pull requests and merge requests automatically with the Otto review action for GitHub and GitLab.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto reviews your Airflow code automatically when you open a pull request or merge request. The Otto review action runs Otto with a dedicated reviewer persona, posts inline review comments where the code has issues, and offers commit suggestions where a concrete fix is available.
The review runs Otto with `--persona reviewer`. The persona bundles the Astro and Airflow review prompt, a read-only tool allowlist, plan-mode permissions, and a structured verdict schema, so Otto returns review results tuned for Airflow projects rather than generic code review. See [Personas](/docs/cli/v1.43/astro-otto#personas).
The action supports both GitHub and GitLab:
* **GitHub**: A composite GitHub Action that runs on `pull_request` and posts the review to the pull request.
* **GitLab**: A CI/CD template and Docker image that run on merge request events and post the review to the merge request.
## What Otto reviews
Otto reviews changes against three layers of knowledge, so it catches issues that generic code review misses:
* **Astronomer compatibility knowledge**: Version-specific operator behavior, provider compatibility, deprecated patterns, and failure signatures drawn from the Astronomer compatibility knowledge base. This is the same knowledge base that powers [Airflow upgrades with Otto](/docs/astro/otto-upgrades).
* **Airflow community standards**: Current Dag patterns, testing approaches, and structure recommendations from the Apache Airflow community.
* **Your team's conventions**: Standards, retry policies, approved operators, and patterns captured in [Otto Memory](/docs/astro/otto-memory). Otto surfaces deviations from your conventions before they reach a human reviewer.
## How it works
On each run, the action:
1. Checks out the changed code and gathers the pull request or merge request metadata, the diff, and the prior review conversation.
2. Runs `astro otto --mode json --persona reviewer` against the gathered context.
3. Posts the result back to the pull request or merge request.
The reviewer persona returns a structured verdict with these fields:
* **`verdict`**: `approve`, `comment`, or `request_changes`.
* **`summary`**: A one-sentence summary of the change.
* **`reasoning`**: One to three sentences on the change as a whole.
* **`comments`**: Line-anchored findings, each with a severity of `high`, `medium`, or `low` and an optional commit suggestion.
On re-runs, the action edits its existing comments in place rather than re-posting. It keeps one sticky summary comment, updates or leaves its prior inline comments instead of duplicating them, and only re-posts the merge-gating review when the verdict changes.
## Prerequisites
* An Astro [Organization API token](/docs/astro/organization-api-tokens). The token only needs the Organization member permission.
* A GitHub repository or GitLab project that contains an Airflow project.
## Set up the review action
On GitHub, the review runs as the [Otto Review](https://github.com/marketplace/actions/otto-review) action from the GitHub Marketplace. Add it to a workflow that runs on pull requests. To get the latest version, click **Use latest version** on the Marketplace listing.
In your repository, create a workflow file at `.github/workflows/otto-review.yml` with the following content:
```yaml title=".github/workflows/otto-review.yml" wrap theme={null}
name: Astronomer CI - Review Code
on:
pull_request:
branches:
- main
permissions:
contents: read
pull-requests: write
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
ASTRO_ORGANIZATION: ${{ secrets.ASTRO_ORGANIZATION }}
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Otto Review
uses: astronomer/otto-review-action@v0.2.0
```
In your repository, go to **Settings** > **Secrets and variables** > **Actions** and add the following repository secrets:
* `ASTRO_API_TOKEN`: Your Astro Organization API token.
* `ASTRO_ORGANIZATION`: Your Astronomer Organization ID.
Open a pull request against the `main` branch. The action runs Otto, posts a sticky summary comment, and adds inline comments where it finds issues.
GitLab has no marketplace for the action. Copy the CI/CD template into your project, or point your agent to the [otto-review-action repository](https://github.com/astronomer/otto-review-action).
In your project's `.gitlab-ci.yml`, add the `otto_review` job:
```yaml title=".gitlab-ci.yml" wrap theme={null}
otto_review:
image: ghcr.io/astronomer/otto-review:v0
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
variables:
OTTO_MAX_DIFF_LINES: "50000"
OTTO_DRY_RUN: "false"
script:
- bash /opt/otto-review/gitlab/run-review.sh
```
The image bakes the Astro CLI and the review scripts, so the job needs no repository clone and no per-run install. Pin the image tag to `:v0` to track the latest `v0.x` release, or use `:vX.Y.Z` to pin an exact version.
In your project, go to **Settings** > **CI/CD** > **Variables** and add the following masked variables:
* `ASTRO_API_TOKEN`: Your Astro Organization API token.
* `ASTRO_ORGANIZATION`: Your Astronomer Organization ID.
* `GITLAB_TOKEN`: A personal access token or project access token with the `api` scope. The `CI_JOB_TOKEN` isn't sufficient for the notes and discussions API.
Open a merge request. The job runs Otto, posts a sticky summary note, and adds inline comments where it finds issues.
On GitLab, the action posts the verdict through the sticky summary and inline notes. It never approves or blocks the merge request, because GitLab has no native request-changes review event.
## Run a review on demand
Code review also works outside a CI/CD pipeline. Run the reviewer persona from your terminal to review changes before you push, or to audit existing pipelines that haven't been through a structured review:
```sh wrap theme={null}
astro otto --persona reviewer "review the Dags in this project"
```
See [`astro otto`](/docs/cli/v1.43/astro-otto#personas) for the full persona reference.
## Configure the review
Both platforms accept settings that change how the review runs. On GitHub, pass them as action inputs under `with:`. On GitLab, set them as CI/CD variables. The most common settings are:
| GitHub input | GitLab variable | Description |
| ---------------- | --------------------- | -------------------------------------------------------------------------------------------------- |
| `model` | `OTTO_MODEL` | Override the model Otto uses. The default uses the model that the reviewer persona's tier maps to. |
| `allowed-tools` | `OTTO_ALLOWED_TOOLS` | Override the reviewer persona's read-only tool allowlist (`read`, `grep`, `find`, `ls`, `bash`). |
| `max-diff-lines` | `OTTO_MAX_DIFF_LINES` | Truncate diffs longer than this value. The default is `50000`. |
| `dry-run` | `OTTO_DRY_RUN` | When `true`, post the summary and inline comments but no merge-gating review. |
For the complete list of inputs, variables, and outputs, see the [otto-review-action repository](https://github.com/astronomer/otto-review-action).
## Related
* [Otto overview](/docs/astro/otto-overview)
* [Investigate with Otto](/docs/astro/otto-investigate)
* [`astro otto`](/docs/cli/v1.43/astro-otto)
* [Deploy code with the Astro GitHub integration](/docs/astro/deploy-github-integration)
* [Skills](/docs/astro/otto-skills)
# Otto extensions
Source: https://astronomer.io/docs/astro/otto-extensions
Enable and disable Otto's bundled extensions, which add optional tools, slash commands, and behaviors to every session.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Extensions are opt-in capabilities that ship inside the Otto binary and add tools, slash commands, or background behaviors to a session. Some are on by default because they catch common mistakes or add useful slash commands; others are off by default because they spawn subprocesses, consume credits, or materially change behavior.
## Bundled extensions
| Name | Default | What it does |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ask-user` | on | Registers the `ask_user` tool so Otto can ask 1-4 focused questions in a single batch rather than many one-at-a-time prompts. |
| `dag-validation` | on | After any edit or write to `dags/*.py`, runs `af dags errors` and surfaces import errors so Otto self-corrects in the same turn. Only fires when a local Airflow is reachable. |
| `memory` | on | Registers `/bootstrap` (seed memories from git and GitHub history) and `/remember` (save learnings from the current conversation). |
| `skills` | on | Provides the hosted-skill surface: the `skill` tool, the `/skills` picker, and `/skill:` commands for hosted skills. Disabling removes hosted skills entirely; local skills still work. See [Skills](/docs/astro/otto-skills). |
| `spinner-verbs` | on | Replaces the default loader with space-themed verbs and an elapsed-time counter. Cosmetic only. |
| `subagent` | off | Registers a `subagent` tool that delegates tasks to isolated `otto` subprocesses. Supports single (`task`) or parallel (`tasks: [...]`) delegation, with `fast` and `deep` model tiers. |
## Enable or disable an extension
Four layers control whether an extension is on, merged in order (highest priority first):
| Layer | Where | Example |
| -------------------- | --------------------------------------------------------------- | ---------------------------------------------------- |
| CLI flag | `--extension `, `--no-extension ` (repeatable) | `astro otto --no-extension dag-validation` |
| Environment variable | `OTTO_EXTENSIONS`, `OTTO_DISABLED_EXTENSIONS` (comma-separated) | `OTTO_DISABLED_EXTENSIONS=dag-validation astro otto` |
| Project settings | `.astro/otto/extensions.json` | `{ "dag-validation": false }` |
| User settings | `~/.astro/otto/extensions.json` | `{ "memory": false }` |
Within a layer, an explicit disable beats an explicit enable. For example, `--extension foo --no-extension foo` disables `foo`.
## Manage extensions interactively
Run `/extensions` inside an Otto session to open an interactive editor.
The main picker shows each bundled extension with its current state and a `*` marker when a CLI flag or environment variable is overriding the settings files. Select an extension to open a per-extension editor with two rows: a User scope row and a Project scope row. Each row has a three-state checkbox:
* `[x]` on — writes `enabled: true` to that settings file.
* `[ ]` off — writes `enabled: false` to that settings file.
* `[~]` unset — removes the `enabled` field so lower layers win.
Press `Enter` or `Space` to cycle the focused row. The title bar updates to show the predicted next-session state and which layer is winning. Press `Escape` to save and close.
To apply the change:
* Run `/reload` to re-run the extension list against the fresh settings while keeping your conversation history.
* Run `/new` to start a fresh session.
* Restart Otto for a full reset.
## Configure an extension
The settings file accepts either a boolean shorthand or an object with `enabled` plus any extension-specific config. Both forms can coexist in the same file:
```json title="extensions.json" wrap theme={null}
{
"memory": false,
"dag-validation": {
"enabled": true,
"timeout": 60000
},
"subagent": {
"enabled": true,
"tiers": { "fast": "gpt-5.4-nano", "deep": "gpt-5.4" }
}
}
```
Project settings shadow user settings per extension (whole-entry replace, not a deep merge).
### Configurable fields
| Extension | Field | Type | Default | Description |
| ---------------- | ------------ | ------ | -------------- | --------------------------------------------------------------------------------------------------- |
| `dag-validation` | `timeout` | number | `30000` | Timeout in milliseconds for `af dags errors`. |
| `subagent` | `tiers.fast` | string | `gpt-5.4-nano` | Model used when a subagent call uses `tier: "fast"`. |
| `subagent` | `tiers.deep` | string | parent's model | Model used when a subagent call uses `tier: "deep"`. Omit to inherit the main conversation's model. |
Extensions that don't appear in the table take no configuration — they're either on or off.
# Investigate with Otto
Source: https://astronomer.io/docs/astro/otto-investigate
Use Otto to investigate Dag failures on Astro with Airflow, infrastructure, and observability context from the Astro UI, Astro alerts, or the Astro API.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto investigates Dag failures on Astro using proprietary Airflow, Astro, and Observe context that no general-purpose agent has access to. Each investigation produces a structured diagnosis with a root cause type, severity, suggested fix, and a checklist of Dag- and task-level checks.
This page covers Otto investigations that run in the Astro control plane and are triggered from the Astro UI, Astro alerts, or the Astro API. To investigate a Dag failure interactively from the terminal, ask Otto in the Astro CLI. See [Otto overview](/docs/astro/otto-overview).
Astronomer recommends wiring a Dag failure to an investigation automatically. The diagnosis is ready before your team starts triaging, and it can route the failure to the right escalation or remediation path.
## How to access investigations
You can trigger an investigation from any of these surfaces:
* **Astro UI**: From the **DAGs** list, click a Dag to open its detail page, then select a failed run to trigger an investigation.
* **Astro Observe homepage**: Click **Investigate** next to a Dag to investigate its most recent failed run, or open a specific run in the Dag's run history.
* **Catalog**: Open a Dag in the new Astro UI **Catalog** (the **Asset Catalog** in the legacy UI) and select a failed run from its run history.
* **Astro alerts**: When a Dag failure alert fires, open the failed Dag run from the alert notification to start an investigation. See [Set up Astro alerts](/docs/astro/alerts).
* **Astro API**: Trigger an investigation programmatically, poll for status, and read the result. Combine this with the **Dag Trigger** notification channel on an Astro alert to investigate critical Dag failures automatically.
## What Otto investigates
Otto draws on Airflow context (including Dag code and task logs), Astro context (including Deployment configuration, component logs, and recent deploys), and Observe context (including lineage, run history, and operational metrics).
Organizations that use Astro Observe get a richer investigation, since Otto has access to lineage, the Asset Catalog, and operational metrics in addition to Airflow and Astro context.
## Run an automatic investigation
To automatically investigate your critical Dags as soon as they fail, configure Astro alerts to call the [investigation API](/docs/astro/api/v-1-labs/observability/start-a-dag-failure-diagnosis-run) on Dag failure. Otto runs the investigation, and your investigation Dag handles the response.
1. Create a Dag that calls the [investigation API](/docs/astro/api/v-1-labs/observability/start-a-dag-failure-diagnosis-run) and routes the response to the right downstream action.
2. Deploy the Dag to Astro.
3. Set up a Dag failure [Astro alert](/docs/astro/alerts) that monitors your critical Dags.
4. Set the notification channel to **Dag Trigger** and select the Dag you deployed in step 2.
5. Optionally, tailor investigations by adding Otto investigation guidance at the Workspace or Deployment level. See [Customize Otto investigation guidance](#customize-otto-investigation-guidance).
When a critical Dag fails, the alert fires, the **Dag Trigger** channel calls your investigation Dag, and Otto returns the diagnosis for downstream handling. Common downstream actions include:
* **Notify**: Post the investigation results to Slack, email, or another notification channel.
* **Open a PR**: Apply the suggested fix as a pull request.
* **Open an incident**: Create an incident in ServiceNow, PagerDuty, or another incident management system.
### Example: Post the diagnosis to Slack
The following Dag accepts the **Dag Trigger** notification payload, calls the [investigation API](/docs/astro/api/v-1-labs/observability/start-a-dag-failure-diagnosis-run), reads the streamed diagnosis, and posts a Slack message with the root cause type, severity, summary, and suggested fix.
Before deploying, configure these as Airflow variables or environment variables on the Deployment:
* `astro_organization_id` or `ASTRO_ORGANIZATION_ID`: The ID of the Organization that owns the Deployment you investigate.
* `astro_deployment_id` or `ASTRO_DEPLOYMENT_ID`: The ID of the Deployment you investigate.
* `astro_api_token` or `ASTRO_API_TOKEN`: A [Deployment API token](/docs/astro/deployment-api-tokens) with permission to read the Deployment.
* `slack_webhook_url` or `SLACK_WEBHOOK_URL`: A Slack incoming webhook URL.
* `slack_channel` or `SLACK_CHANNEL`: Optional. The Slack channel to post to, if not the webhook's default.
```python expandable wrap theme={null}
"""Triggered by Astro DAG trigger notifications to investigate a failed DAG run and post the diagnosis to Slack.
Required settings. Each can be set as an environment variable OR an Airflow
Variable of the same name (set BEFORE enabling the alert):
- ASTRO_ORGANIZATION_ID (your Astro organization ID)
- ASTRO_DEPLOYMENT_ID (deployment to run diagnoses against)
- ASTRO_API_TOKEN (Astro API token with labs/v1 access)
- SLACK_WEBHOOK_URL (Slack incoming webhook URL)
- SLACK_CHANNEL (optional; overrides the webhook's default channel)
Set these in the Astro UI under Deployment → Environment (Environment Variables
or Airflow Variables). Missing any required value will raise
`ValueError: Missing required setting ...` at task runtime.
Expected dag_run.conf keys (sent by the Astro Alert trigger):
- alertId (Astro alert ID; surfaced in the Slack message)
- alertType (DAG_FAILURE — other alert types are ignored)
- dagName (target DAG being triggered — this DAG; not used, the failed source DAG comes from `message`)
- message (free-form alert text; the failed source DAG ID is parsed from `"... for DAG "`)
- airflowDagRunId (the failed source DAG's run ID, e.g. `scheduled__2026-06-03T23:40:00+00:00`)
- logFailureSummaries (dict keyed by failed task ID; if exactly one key, it's used as the failed task ID)
Example payload (DAG_FAILURE alert from `always_failing_dag`):
{
"alertId": "cmpyms67v000m01pxkfaqoe5t",
"alertType": "DAG_FAILURE",
"dagName": "alert_investigation_agent",
"message": "DAG run failed for DAG always_failing_dag",
"airflowDagRunId": "scheduled__2026-06-03T23:40:00+00:00",
"logFailureSummaries": {"fail_on_purpose": "..."}
}
"""
from __future__ import annotations
import json
import logging
import os
import re
from typing import Any
import requests
from airflow.sdk import Variable, dag, task
from pendulum import datetime
ASTRO_API_BASE = "https://api.astronomer.io/labs/v1"
# This demo investigates DAG-failure alerts. Other alert types are logged
# and skipped.
ALLOWED_ALERT_TYPES = {"DAG_FAILURE"}
log = logging.getLogger(__name__)
def _get_setting(key: str) -> str:
# Resolve a setting from an environment variable or an Airflow Variable of
# the same name. Env var wins if both are set.
env_value = os.environ.get(key, "")
if env_value:
return env_value
try:
return Variable.get(key)
except Exception:
return ""
def _get_required_setting(key: str) -> str:
value = _get_setting(key)
if value:
return value
raise ValueError(f"Missing required setting: '{key}' (set it as an env var or Airflow Variable)")
def _extract_source_dag_id(message: str) -> str:
# Astro Alert payloads don't include the failed source DAG ID as a
# top-level key (`dagName` in conf is the *target* DAG being triggered,
# i.e. this one). Parse it out of the DAG_FAILURE alert `message`:
# "DAG run failed for DAG "
match = re.search(r"for DAG\s+['\"]?([a-zA-Z0-9_.-]+)['\"]?", message, re.IGNORECASE)
if match:
return match.group(1)
raise ValueError(
"Could not determine the failed source DAG ID from the alert message. "
f"Expected a 'for DAG ' phrase; got message={message!r}"
)
def _extract_run_id(conf: dict[str, Any]) -> str:
value = conf.get("airflowDagRunId")
if value:
return str(value)
raise ValueError("Missing required dag_run.conf key: airflowDagRunId")
def _extract_task_id(conf: dict[str, Any]) -> str | None:
# DAG_FAILURE payloads include a `logFailureSummaries` dict keyed by the
# failed task ID(s). If exactly one task failed, use it.
summaries = conf.get("logFailureSummaries")
if isinstance(summaries, dict) and len(summaries) == 1:
return next(iter(summaries))
return None
def _call_investigation_agent(
organization_id: str,
deployment_id: str,
api_token: str,
dag_id: str,
run_id: str,
task_id: str | None,
) -> dict[str, Any]:
auth_headers = {"Authorization": f"Bearer {api_token}"}
deployment_base = (
f"{ASTRO_API_BASE}/organizations/{organization_id}"
f"/observability/deployments/{deployment_id}/dag-failure-diagnosis/runs"
)
start_response = requests.post(
deployment_base,
headers={**auth_headers, "Content-Type": "application/json"},
json={
"dagId": dag_id,
"runId": run_id,
**({"taskId": task_id} if task_id else {}),
},
timeout=30,
)
start_response.raise_for_status()
diagnosis_run_id = start_response.json()["runId"]
response = requests.get(
f"{deployment_base}/{diagnosis_run_id}/events",
headers={**auth_headers, "Accept": "text/event-stream"},
stream=True,
timeout=(30, 300),
)
response.raise_for_status()
event_type: str | None = None
data_lines: list[str] = []
text_chunks: list[str] = []
diagnosis: dict[str, Any] | None = None
def flush_event() -> None:
nonlocal event_type, data_lines, diagnosis
if not event_type:
data_lines = []
return
payload = "\n".join(data_lines)
if event_type == "rca_diagnosis" and payload:
diagnosis = json.loads(payload)
elif event_type == "text_delta" and payload:
text_chunks.append(json.loads(payload).get("text", ""))
elif event_type == "error" and payload:
raise RuntimeError(json.loads(payload).get("message", "Investigation Agent returned an error"))
event_type = None
data_lines = []
for raw_line in response.iter_lines(decode_unicode=True):
if raw_line is None:
continue
line = raw_line.rstrip("\r")
if not line:
flush_event()
if diagnosis:
break
continue
if line.startswith(":"):
continue
if line.startswith("event:"):
event_type = line.split(":", 1)[1].strip()
continue
if line.startswith("data:"):
data_lines.append(line.split(":", 1)[1].lstrip())
flush_event()
if diagnosis:
return diagnosis
if text_chunks:
return {"title": f"Investigation for {dag_id}", "summary": "".join(text_chunks).strip()}
raise RuntimeError("Investigation Agent returned no diagnosis payload")
def _format_slack_message(
diagnosis: dict[str, Any],
alert_id: str,
alert_type: str,
dag_id: str,
run_id: str,
task_id: str | None,
) -> dict[str, Any]:
title = diagnosis.get("title") or f"Investigation for {dag_id}"
summary = diagnosis.get("summary") or "No summary returned."
suggested_fix = diagnosis.get("suggested_fix") or "No suggested fix returned."
severity = diagnosis.get("severity") or "UNKNOWN"
priority = diagnosis.get("priority") or "UNKNOWN"
root_cause_type = diagnosis.get("root_cause_type") or "UNKNOWN"
confidence = diagnosis.get("confidence")
fields = [
{"type": "mrkdwn", "text": f"*Alert ID*\n`{alert_id}`"},
{"type": "mrkdwn", "text": f"*Alert Type*\n`{alert_type}`"},
{"type": "mrkdwn", "text": f"*DAG*\n`{dag_id}`"},
{"type": "mrkdwn", "text": f"*Run ID*\n`{run_id}`"},
{"type": "mrkdwn", "text": f"*Severity*\n`{severity}`"},
{"type": "mrkdwn", "text": f"*Root Cause Type*\n`{root_cause_type}`"},
]
if task_id:
fields.append({"type": "mrkdwn", "text": f"*Task ID*\n`{task_id}`"})
if confidence is not None:
fields.append({"type": "mrkdwn", "text": f"*Confidence*\n`{confidence}`"})
if priority != "UNKNOWN":
fields.append({"type": "mrkdwn", "text": f"*Priority*\n`{priority}`"})
blocks: list[dict[str, Any]] = [
{"type": "header", "text": {"type": "plain_text", "text": title[:150]}},
{"type": "section", "fields": fields[:10]},
{"type": "section", "text": {"type": "mrkdwn", "text": f"*Summary*\n{summary[:2900]}"}},
{"type": "section", "text": {"type": "mrkdwn", "text": f"*Suggested Fix*\n{suggested_fix[:2900]}"}},
]
text = (
f"[{severity}] {title}\n"
f"Root cause type: {root_cause_type}\n"
f"Summary: {summary}\n\n"
f"Suggested fix: {suggested_fix}"
)
return {"text": text[:4000], "blocks": blocks}
def _post_to_slack(webhook_url: str, channel: str | None, payload: dict[str, Any]) -> None:
body = dict(payload)
if channel:
body["channel"] = channel
response = requests.post(webhook_url, json=body, timeout=30)
response.raise_for_status()
@dag(
dag_id="alert_investigation_agent",
start_date=datetime(2025, 1, 1),
schedule=None,
catchup=False,
tags=["alerts", "investigation-agent", "slack"],
default_args={"owner": "Astro", "retries": 0},
doc_md=__doc__,
)
def alert_investigation_agent():
@task
def handle_alert(**context) -> None:
dag_run = context.get("dag_run")
conf = dict(dag_run.conf or {}) if dag_run else {}
alert_id = str(conf.get("alertId", "unknown"))
alert_type = str(conf.get("alertType", "unknown"))
message = str(conf.get("message", ""))
if alert_type not in ALLOWED_ALERT_TYPES:
log.info(
"Ignoring alert: alertType %r is not a DAG failure. "
"This demo only investigates DAG-failure alerts.",
alert_type,
)
return
dag_id = _extract_source_dag_id(message)
run_id = _extract_run_id(conf)
task_id = _extract_task_id(conf)
organization_id = _get_required_setting("ASTRO_ORGANIZATION_ID")
deployment_id = _get_required_setting("ASTRO_DEPLOYMENT_ID")
api_token = _get_required_setting("ASTRO_API_TOKEN")
slack_webhook_url = _get_required_setting("SLACK_WEBHOOK_URL")
slack_channel = _get_setting("SLACK_CHANNEL") or None
diagnosis = _call_investigation_agent(
organization_id=organization_id,
deployment_id=deployment_id,
api_token=api_token,
dag_id=dag_id,
run_id=run_id,
task_id=task_id,
)
log.info(
"Diagnosis completed for %s run %s: title=%s severity=%s root_cause_type=%s summary=%s suggested_fix=%s",
dag_id,
run_id,
diagnosis.get("title") or f"Investigation for {dag_id}",
diagnosis.get("severity") or "UNKNOWN",
diagnosis.get("root_cause_type") or "UNKNOWN",
diagnosis.get("summary") or "No summary returned.",
diagnosis.get("suggested_fix") or "No suggested fix returned.",
)
slack_payload = _format_slack_message(
diagnosis=diagnosis,
alert_id=alert_id,
alert_type=alert_type,
dag_id=dag_id,
run_id=run_id,
task_id=task_id,
)
_post_to_slack(slack_webhook_url, slack_channel, slack_payload)
handle_alert()
alert_investigation_agent()
```
## Customize Otto investigation guidance
You can add Otto investigation guidance at the Workspace or Deployment level to tailor investigations to your environment. For example, you can instruct Otto to treat tasks that begin with `validate` as non-blocking, or to interpret specific log patterns in a particular way. Deployments inherit Workspace guidance by default and can override it.
See [Configure Otto investigation guidance for a Workspace](/docs/astro/manage-workspaces#configure-otto-investigation-guidance) and [Configure Otto investigation guidance for a Deployment](/docs/astro/deployment-settings#configure-otto-investigation-guidance).
## Related
* [Otto overview](/docs/astro/otto-overview)
* [Skills](/docs/astro/otto-skills)
* [Troubleshoot Dag failures in Astro Observe](/docs/astro/root-cause-analysis)
* [Set up Astro alerts](/docs/astro/alerts)
# Otto memory
Source: https://astronomer.io/docs/astro/otto-memory
Learn how Otto's memory system accumulates team-specific knowledge across sessions, including conventions, corrections, and environmental details.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto's memory system transforms it from an agent that starts fresh every session into a knowledgeable team member that remembers your environment, your conventions, and lessons learned from past interactions. Memory is stored locally as Markdown files split between your project repository and your home directory.
## How memory works
Memory lives in two places: your project repository and your home directory.
```text wrap theme={null}
your-project/ # Astro project root
└── .astro/
└── memory/ # Shared project memory (committed, team-visible)
├── MEMORY.md
└── conventions.md
~/ # Your home directory
└── .astro/
└── memory/
├── MEMORY.md # Local user memory (all projects, this computer)
├── preferences.md
└── / # Local project memory (this project, this computer)
├── MEMORY.md
└── notes.md
```
Each location serves a different purpose:
* **Shared project memory** (`.astro/memory/`): Conventions, architecture decisions, and environment details that should travel with the project. Committed to your repository so the whole team picks them up.
* **Local project memory** (`~/.astro/memory//`): Your personal notes for one specific project. Lives in your home directory and isn't committed.
* **Local user memory** (`~/.astro/memory/`): Preferences and patterns that apply to every project you work on. Lives in your home directory and isn't committed.
At the start of every session, Otto loads `MEMORY.md` from each location. Other `.md` files are indexed by name so Otto knows they exist, but they're read on demand rather than loaded upfront.
In addition to `.astro/memory/`, Otto reads `AGENTS.md` and `CLAUDE.md` files for context. Otto loads them from `~/.astro/otto/AGENTS.md` or `~/.astro/otto/CLAUDE.md`, then walks up from the current working directory to `/`. When both files exist in the same folder, Otto prioritizes `AGENTS.md` over `CLAUDE.md`.
## How memories get created
Otto creates memory in several ways:
### From the current conversation with `/remember`
Run `/remember` in an interactive session to have Otto review the conversation and generate memory files for the reusable learnings it identifies. Otto proposes the memories before writing them, and you approve or reject each one.
### From history with `/bootstrap`
Run `/bootstrap` to seed shared project memory from your git history and available GitHub PR history (when the GitHub CLI is installed and authenticated). This is useful when you're starting with Otto on an established project and want to capture existing team knowledge without building it up organically.
### Manually
Platform teams can add Markdown files directly to `.astro/memory/` to seed Otto with explicit constraints before organic memory accumulates. Upload files with conventions, approved operators, retry policies, and other standards, and add each file to `MEMORY.md` so Otto knows they exist.
For example:
```text wrap theme={null}
.astro/memory/
MEMORY.md # Index of all memory files
conventions.md # Naming conventions, preferred patterns
approved-operators.md # Operators the team has approved for use
retry-policy.md # Standard retry configuration
```
### Autonomously during a session
Otto can also write memory on its own when it detects something worth retaining, without you running `/remember` or `/bootstrap`. This happens when Otto:
* Discovers a project convention not represented in the codebase.
* Learns important environment facts such as versions, connections, or team structure.
* Corrects a prior mistake and wants to avoid repeating it.
## Memory file format
Each memory file is a Markdown file with the following structure:
```markdown wrap theme={null}
#
### Source
user-interaction | debugging-session | customer-call | documentation | experiment | code-review
## Memory
## Context
## Evidence
```
The `MEMORY.md` file in each folder serves as an index. Otto reads it at the start of every session to understand what memory files are available, and adds entries for new memories as they're created.
## When Otto does not write memory
Otto avoids writing memory for:
* Information already in `README.md`, `CLAUDE.md`, or committed documentation.
* Ephemeral task state or in-progress work.
* Code patterns that are readable directly from source.
## Memory and team collaboration
Because shared project memory lives in `.astro/memory/` within your project repository, it follows your team's standard Git workflow:
1. Otto creates or updates a memory file during a session.
2. You review the change in your Git diff.
3. You commit and push the change.
4. Other team members pull the update.
5. In their next Otto session, the new memory is loaded automatically.
Local project memory and local user memory are scoped to you and aren't shared with the team.
# Models and regions
Source: https://astronomer.io/docs/astro/otto-models-and-regions
Reference for the models and hosting regions that Otto and the Astro IDE currently use through the Astronomer Gateway.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto and the AI features in the [Astro IDE](/docs/astro/ide-overview) access models from OpenAI, Anthropic, and Google through the Astronomer Gateway. Astronomer hosts these models on Azure OpenAI Service and Google Cloud Vertex AI rather than calling the model providers directly.
This document is the source of truth for the specific models and hosting regions currently in use. Astronomer updates it as the available models change.
## Azure OpenAI Service
These models run in the East US 2 region.
| Model provider | Model |
| -------------- | ------------------- |
| OpenAI | `gpt-5.5` |
| OpenAI | `gpt-5.4` |
| OpenAI | `gpt-5.4-mini` |
| OpenAI | `gpt-5.4-nano` |
| OpenAI | `gpt-5.3-codex` |
| Anthropic | `claude-opus-4-8` |
| Anthropic | `claude-opus-4-7` |
| Anthropic | `claude-opus-4-6` |
| Anthropic | `claude-sonnet-4-6` |
| Anthropic | `claude-haiku-4-5` |
## Google Cloud Vertex AI
These models run with the location set to `global`, which routes each request to whichever regional resource is available.
| Model provider | Model |
| -------------- | ------------------------------- |
| Anthropic | `claude-opus-4-7` |
| Anthropic | `claude-opus-4-6` |
| Anthropic | `claude-sonnet-4-6` |
| Anthropic | `claude-haiku-4-5` |
| Google | `google/gemini-3.1-pro-preview` |
| Google | `google/gemini-3.5-flash` |
| Google | `google/gemini-3-flash-preview` |
| Google | `google/gemini-2.5-pro` |
## Choose a model
To select a model for an Otto session, run `/model` in an interactive session to browse what's available to you, or pass `--model ` to pin a model at launch. See [Customize Otto](/docs/astro/customize-otto#choose-a-model) and [`astro otto` model selection](/docs/cli/v1.43/astro-otto#model-selection).
# Otto overview
Source: https://astronomer.io/docs/astro/otto-overview
Otto is Astronomer's data engineering agent, purpose built for Apache Airflow and designed to get smarter the longer your team uses it.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto, Astronomer's data engineering agent, is purpose built for the work data engineers do on Apache Airflow. It builds and debugs pipelines, investigates production failures, plans and executes upgrades and migrations, explores and profiles your data, and gets meaningfully better the longer your team uses it.
Otto is grounded in context that no general-purpose agent has access to. Public Airflow knowledge forms the baseline. On top of that sits a proprietary compatibility knowledge base maintained by Astronomer, built from eight years of running Airflow at enterprise scale. The third layer is your team's own accumulated memory: conventions, corrections, connection configs, and operational history that compound every session.
## Key capabilities
**Exploration**: Query your warehouse, trace lineage, and profile tables from your agent session. Otto answers business questions about your data, checks freshness, and surfaces upstream and downstream dependencies.
**Dag Authoring and Debugging**: Describe what you need in natural language. Otto writes the Dag, configures connections, triggers a run, and iterates until it works. When something breaks, it pulls task logs, reads the Dag source, inspects variables and connections, and edits the code to fix the failure.
**Investigate production failures**: When a Dag fails, ask Otto to diagnose it. Otto reads task logs, run history, connections, and Dag source, then works through the diagnosis interactively. Otto can also investigate Dag failures automatically from the Astro UI, Astro alerts, or the Astro API. See [Investigate with Otto](/docs/astro/otto-investigate).
**Code review**: Otto reviews pull requests and merge requests automatically. The Otto review action runs Otto with a dedicated reviewer persona, posts inline comments where the code has issues, and offers commit suggestions where a concrete fix is available. See [Review code with Otto](/docs/astro/otto-code-review).
**Airflow Upgrades**: Otto analyzes your Dag fleet against Astronomer's proprietary compatibility knowledge base, identifies breaking changes, proposes specific code fixes, and produces a prioritized upgrade plan.
**Migrations**: Otto helps you move workflows to Airflow on Astro from legacy and third-party orchestration systems.
Otto extends these capabilities through skills it loads on demand. See [Skills](/docs/astro/otto-skills).
## How to access Otto
Otto is available through the [`astro otto`](/docs/cli/v1.43/astro-otto) command in the Astro CLI and in the [Astro IDE](/docs/astro/ide-overview).
* **Astro CLI** — Run `astro otto` from any Astro project folder to launch the interactive terminal user interface (TUI). The command is pre-authenticated with your Astro credentials and pre-configured with skills and proprietary context. See the [quickstart](/docs/astro/get-started-otto).
* **Astro IDE** — The AI features in the [Astro IDE](/docs/astro/ide-overview) are powered by Otto. Code generation, Dag authoring, and project-aware suggestions use Otto's context and skills.
## How Otto is versioned
Otto ships as a standalone binary that versions independently of the Astro CLI. The first time you run [`astro otto`](/docs/cli/v1.43/astro-otto), the CLI downloads Otto to `~/.astro/bin/otto`. On subsequent launches, the CLI checks for newer releases and applies them automatically before launching the agent.
To opt out of automatic updates, set `otto.auto_update` to `false`. The CLI then prints an upgrade hint instead, and you apply updates manually with `astro otto update`. See [Configure the Astro CLI](/docs/cli/v1.43/configure-cli) for the config option.
You don't need to upgrade the Astro CLI to pick up new Otto features or fixes. Check your installed version with `astro otto version`.
## Next steps
* [Quickstart: Run your first Otto session](/docs/astro/get-started-otto)
* [Usage modes](/docs/cli/v1.43/astro-otto#usage-modes)
* [Investigate with Otto](/docs/astro/otto-investigate)
* [Review code with Otto](/docs/astro/otto-code-review)
* [Tools](/docs/astro/otto-tools)
* [Skills](/docs/astro/otto-skills)
* [Memory](/docs/astro/otto-memory)
* [Customize Otto](/docs/astro/customize-otto)
# Otto permissions
Source: https://astronomer.io/docs/astro/otto-permissions
Configure how Otto asks, allows, and denies tool calls, including file and command rules, permission modes, and built-in safety checks.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto ships a first-party permission layer that gates every tool call. Each call resolves to **allow**, **ask** (prompt the user), or **deny** based on the active permission mode and your configured rules.
Out of the box, Otto asks before running destructive Astro and Airflow commands, prompts before writing to sensitive files like `.env` or `.ssh/*`, and restricts writes outside your project folder. You can extend or relax these behaviors through config files and permission modes.
## Permission modes
Otto runs in one of five modes. Cycle through modes interactively with `Ctrl+]` or the `/permissions` command.
| Mode | Behavior |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `default` | Normal behavior. Tools are allowed, denied, or prompted based on your rules. |
| `acceptEdits` | Auto-allows `edit` and `write` inside the project. Other tools fall through to the normal rules. Safety checks still fire. |
| `confirmEdits` | Prompts before `edit`, `write`, and non-read-only `bash`. Allow rules can't bypass the prompt. Read tools and read-only `bash` fall through to the normal rules. |
| `plan` | Blocks `edit` and `write` entirely. Restricts `bash` to a read-only allowlist (`ls`, `cat`, `git`, `rg`, `af`, `astro`, etc.). |
| `bypassPermissions` | Allows everything except bypass-immune safety checks on sensitive files and out-of-project writes. |
Set the starting mode with the `--permission-mode ` flag or the `OTTO_PERMISSION_MODE` environment variable.
## Where configuration lives
Otto reads permissions from three files, merged in order (later wins):
| Scope | Path | Purpose |
| ------- | ------------------------------------ | ----------------------------------------------- |
| User | `~/.astro/otto/permissions.json` | Your personal rules across all projects |
| Project | `.astro/otto/permissions.json` | Team-wide rules committed to Git |
| Local | `.astro/otto/permissions.local.json` | Your local-only overrides (gitignore this file) |
Commit project-scope rules to your repository so every engineer on the team gets the same posture.
## Configuration file shape
```json expandable wrap theme={null}
{
"enabled": true,
"defaultMode": "default",
"restrictToProjectDir": true,
"rules": {
"allow": ["Bash(ls:*)"],
"deny": ["Bash(rm -rf /:*)"],
"ask": ["Bash(git push:*)"]
},
"pathDeny": [
{
"id": "no-root-writes",
"patterns": ["/etc/**", "/usr/**"],
"tools": ["write", "edit", "bash"],
"message": "Refusing to write outside user-space."
}
],
"commandPatterns": [
{
"id": "my-dangerous",
"pattern": "\\bdrop\\s+database\\b",
"regex": true,
"behavior": "ask",
"description": "drop database"
}
],
"contentPatterns": [
{
"id": "no-eval-in-dags",
"pattern": "eval\\(",
"regex": true,
"onTool": ["write", "edit"],
"pathGlobs": ["**/dags/**/*.py"],
"behavior": "deny",
"message": "Avoid eval() inside Dag code."
}
]
}
```
### Rule strings
Rules use the format `Tool` or `Tool(content)`. Content can be a command prefix, a path glob, or `*` to match everything.
| Rule | Effect |
| ---------------------- | ------------------------------------------------------- |
| `Bash` | Matches every `bash` call |
| `Bash(astro deploy:*)` | Matches bash commands starting with `astro deploy` |
| `Write(/etc/**)` | Matches `write` calls whose path glob-matches `/etc/**` |
| `Read(~/.ssh/**)` | Matches `read` calls with `~` expansion |
### Path deny
`pathDeny` blocks writes and edits against a glob list, including bash redirects. Use it to protect folders regardless of the command used to reach them.
### Command patterns
Bash-only patterns that match the full command string. Use `regex: true` for regular expressions. `commandPatterns` with `behavior: "ask"` fire even in `bypassPermissions` mode.
### Content patterns
Scan the body of `write` and `edit` calls against a pattern. `behavior: "deny"` blocks the write before it hits disk. `behavior: "warn"` appends an advisory without blocking.
## Built-in safety checks
Otto ships compiled-in protections that fire regardless of configuration:
* **Sensitive files** — prompts before any tool touches `.env*`, `~/.ssh/**`, `~/.aws/**`, shell rc files, or similar common secret locations.
* **Destructive Astro and Airflow commands** — prompts before `astro deploy`, `astro deployment delete`, `astro workspace delete`, `astro organization delete`, `astro dev kill`, `af dags delete`, `af runs delete`, `af tasks clear`, `af connections delete`, `af variables delete`, and similar destructive commands.
* **Out-of-project writes** — prompts before `write`, `edit`, or a `bash` command targets a path outside your project folder.
These checks are bypass-immune — they fire even when the mode is `bypassPermissions` or `--skip-permissions` is set.
Disable an individual destructive-command entry in your config by id:
```json wrap theme={null}
{
"commandPatterns": [
{ "id": "astro-deploy", "enabled": false }
]
}
```
## Inspect the current state
Run `/permissions` in an Otto session to see the current mode, rule counts, and the file paths for each config scope.
## Disable permissions for a session
```sh wrap theme={null}
astro otto --skip-permissions
```
This coerces the mode to `bypassPermissions` and prevents `Ctrl+]` from cycling out of it for the session. Bypass-immune safety checks still fire. Use it only for scripted flows you're reviewing by hand.
# Otto settings
Source: https://astronomer.io/docs/astro/otto-settings
Reference for Otto configuration files, environment variables, CLI overrides, settings precedence, session storage, and auto-update behavior.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
This page is the reference for every place Otto reads configuration from. For deep dives on specific subsystems, see [Permissions](/docs/astro/otto-permissions), [Extensions](/docs/astro/otto-extensions), [Memory](/docs/astro/otto-memory), and [Skills](/docs/astro/otto-skills).
## File layout
Otto reads from your project repository and your home directory:
```text expandable wrap theme={null}
your-project/ # Astro project root
├── .agents/
│ └── skills/ # Project skills shared across agent harnesses
│ └── /SKILL.md
└── .astro/
├── config.yaml # Astro CLI project config (Otto reads otto.* and dev.mode)
├── memory/ # Shared project memory (committed, team-visible)
│ ├── MEMORY.md
│ └── *.md
└── otto/
├── permissions.json # Allow, ask, and deny rules
├── extensions.json # Per-project extension toggles
└── skills/ # Project skills authored by your team
└── /SKILL.md
~/ # Your home directory
├── .agents/
│ └── skills/ # User skills shared across agent harnesses
│ └── /SKILL.md
├── .astro/
│ ├── config.yaml # Astro CLI global config
│ ├── bin/
│ │ └── otto # Otto binary, downloaded on first launch
│ ├── memory/
│ │ ├── MEMORY.md # Local user memory (all projects, this computer)
│ │ ├── *.md
│ │ └── / # Local project memory (this project, this computer)
│ │ └── *.md
│ └── otto/
│ ├── settings.json # Otto user settings
│ ├── sessions/ # Session history (JSONL)
│ ├── skills/ # User skills authored by you
│ │ └── /SKILL.md
│ ├── cache/skills/ # Hosted skill cache (1-hour TTL)
│ └── logs/cli.log # CLI-side log (rotates at 1 MiB)
```
## Settings precedence
When the same setting is defined in multiple places, Otto resolves it in this order, with earlier entries overriding later ones:
1. CLI flag passed to `astro otto` (for example, `--model`, `--allowed-tools`, `--no-extension`)
2. Environment variable (for example, `OTTO_DISABLED_EXTENSIONS`)
3. Project file (`.astro/otto/permissions.json`, `.astro/otto/extensions.json`, `.astro/config.yaml`)
4. User file (`~/.astro/otto/settings.json`, `~/.astro/config.yaml`)
5. Built-in default
## Environment variables
The `astro otto` command sets several environment variables automatically based on your `astro login` context and the current project. You don't need to configure these manually.
| Variable | Description |
| -------------------- | ------------------------------------------------------------- |
| `ASTRO_TOKEN` | Bearer token for the Astronomer Gateway |
| `ASTRO_DOMAIN` | Astronomer domain (for example, `astronomer.io`) |
| `ASTRO_ORGANIZATION` | Organization ID for gateway routing |
| `AIRFLOW_API_URL` | Local Airflow REST API URL, auto-discovered from proxy routes |
| `AIRFLOW_USERNAME` | Defaults to `admin` when Airflow is connected |
| `AIRFLOW_PASSWORD` | Defaults to `admin` when Airflow is connected |
The CLI also keeps your Astro access token refreshed in the background for the duration of the session, so long-lived sessions don't hit authentication errors.
You can set the following variables yourself to control Otto behavior:
| Variable | Description |
| -------------------------- | -------------------------------------------------------------------------------- |
| `OTTO_EXTENSIONS` | Comma-separated allowlist of extensions to enable. Disables anything not listed. |
| `OTTO_DISABLED_EXTENSIONS` | Comma-separated denylist of extensions to disable. |
| `OTTO_LOG_LEVEL` | Log verbosity. Useful for debugging. |
## Auto-update
The first time you run `astro otto`, the Astro CLI downloads the Otto binary to `~/.astro/bin/otto`. After that, the CLI checks for new Otto releases once per day in the background and prints a hint to stderr when an update is available. Updates are applied manually with `astro otto update`.
Otto versions independently of the Astro CLI. You don't need to upgrade the Astro CLI to pick up new Otto features or fixes. Check your installed version with `astro otto version`.
To opt out of the daily update check, set `astro config set -g otto.auto_update false`.
## See also
* [Permissions](/docs/astro/otto-permissions) — Allow, ask, and deny rules for tool calls.
* [Extensions](/docs/astro/otto-extensions) — Toggle bundled extensions.
* [Memory](/docs/astro/otto-memory) — Memory tiers and file format.
* [Skills](/docs/astro/otto-skills) — Skill catalog and local skill authoring.
* [`astro otto` CLI reference](/docs/cli/v1.43/astro-otto) — Flags and subcommands.
* [Configure the Astro CLI](/docs/cli/v1.43/configure-cli) — Full Astro CLI config reference.
# Otto skills
Source: https://astronomer.io/docs/astro/otto-skills
Author skills for Otto using the Agent Skills format, and explore the skills Otto ships with for Airflow operations, Dag authoring, dbt, lineage, and more.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Skills are structured workflows Otto loads on demand, following the open [Agent Skills](https://agentskills.io) format. A skill is a folder containing a `SKILL.md` file with YAML frontmatter and Markdown instructions, plus any scripts or supporting files the workflow needs. Skills encode domain knowledge for a specific task such as authoring a Dag, diagnosing a failure, or upgrading Airflow.
Otto's bundled skills come from two sources:
* **Open-source skills** in the [astronomer/agents](https://github.com/astronomer/agents) repository cover Airflow operations, Dag authoring and testing, dbt and Cosmos, lineage and metadata, data discovery, and Airflow extensions.
* **Proprietary skills** are available only through Otto. They cover production failure investigation, Airflow upgrades, and migrations from legacy orchestration systems, and they rely on Astronomer's proprietary compatibility knowledge base.
You can also author your own skills for team-specific workflows. To browse what's loaded in your current session, run `/skills` in an interactive Otto session.
## Author a skill
For comprehensive guidance on skill design, including grounding skills in real expertise, scoping, and writing descriptions that trigger correctly, see [Agent Skills best practices](https://agentskills.io/skill-creation/best-practices).
### Ask Otto to write a skill
The most effective skills are extracted from real work. Complete a task in an Otto session, providing context and corrections as you go, then describe the workflow you want codified:
```text wrap theme={null}
> Write a skill called deploy-to-staging that verifies the current branch is main, runs astro deploy against the staging Deployment, and confirms the deploy succeeded in the Astro UI. Use it whenever I ask to deploy, push, or test against staging.
```
Otto generates a `SKILL.md` under `.astro/otto/skills//` and shows you the draft for review. Edit the file in your editor or ask Otto to revise it before you commit.
### Skill anatomy
Each skill is a folder with a `SKILL.md` file. The frontmatter declares the skill's name and trigger description, and the body holds the workflow Otto follows when the skill fires.
```markdown title="SKILL.md" wrap theme={null}
---
name: deploy-to-staging
description: Deploy the current project to the staging Deployment. Use when the user asks to deploy to staging, push to staging, or test against staging.
---
# Deploy to staging
Follow this workflow to deploy the project:
1. Verify the current branch is `main`.
2. Run `astro deploy --deployment-id `.
3. Confirm the deploy succeeded in the Astro UI.
```
The `description` field is the most important part: it determines when Otto loads the skill. Include one sentence on what the skill does and the phrasing that should trigger it, prefixed with "Use when...".
Skills can also include scripts, templates, or reference docs alongside `SKILL.md`. For example, the [analyzing-data](https://github.com/astronomer/agents/tree/main/skills/analyzing-data) skill ships scripts that run a full Jupyter kernel for data exploration.
Commit `.astro/otto/skills/` to your repository so every engineer on the team picks up the same skills.
### Test and iterate
Run a prompt that should fire the skill and confirm Otto loads it. If the skill doesn't fire, refine the description. If it fires for the wrong prompts, narrow the trigger phrasing. Ask Otto to update the skill the same way you'd refine a prompt: describe what's off, and Otto edits the file for you.
## Where skills live
Otto loads skills from your project repository and your home directory:
* **Project skills** (`.astro/otto/skills/`): Skills committed alongside your Astro project so the whole team picks them up. Otto walks up from the current folder to the git repository root, so skills in any ancestor directory also load.
* **User skills** (`~/.astro/otto/skills/`): Your personal skills, available across every project on this computer. These live in your home directory and stay out of your project repository.
* **Cross-harness skills** (`.agents/skills/` and `~/.agents/skills/`): Skills following the standard Agent Skills layout, available to Otto and any other Agent Skills-compatible tool. Use these when you want the same skills to load across multiple agents.
Otto also recognizes top-level `.md` files in the `.astro/otto/skills/` paths as single-file skills. The `.agents/skills/` paths require a directory with a `SKILL.md` file.
To point Otto at skills from other agent harnesses, such as `~/.claude/skills` or `~/.codex/skills`, list the paths in the `skills` array in `~/.astro/otto/settings.json`. See [Otto settings](/docs/astro/otto-settings).
## How Otto loads skills
When a prompt matches a skill's `description`, Otto loads the skill's `SKILL.md` content and follows the workflow.
You can also invoke a skill directly. Type `/` and start typing the skill name to filter the autocomplete, or run `/skills` to browse the full list.
# Otto tools
Source: https://astronomer.io/docs/astro/otto-tools
Reference for the tools Otto uses, including file and shell operations and the af CLI for managing Airflow.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto uses several tools when working in an Astro project. This page covers what each tool does and how Otto uses it.
Tools are the primitive actions Otto takes, such as reading a file, running a shell command, or querying Airflow. For multi-step workflows that compose these actions into structured playbooks, such as Dag authoring or upgrades, Otto loads [skills](/docs/astro/otto-skills).
## File and shell tools
Otto reads, writes, and edits files in your project, runs shell commands, and searches your codebase:
| Tool | Description |
| ------- | ---------------------------------------------- |
| `read` | Read a file's contents |
| `write` | Create a new file or overwrite an existing one |
| `edit` | Modify an existing file with targeted changes |
| `bash` | Run shell commands |
| `grep` | Search file contents with regular expressions |
| `find` | Locate files by name pattern |
| `ls` | List folder contents |
All file and shell tools are sandboxed to your project folder. Otto won't write or edit files outside the project root.
## af CLI
For Airflow state — Dags, runs, tasks, connections, variables, and health checks — Otto uses the `af` CLI, an open-source command-line wrapper for the Airflow REST API maintained in the [astronomer/agents](https://github.com/astronomer/agents) repository. The `af` CLI supports Airflow 2.x and 3.x with automatic version detection. When Otto is launched from an Astro project with a connected Airflow instance, `AIRFLOW_API_URL` is set automatically.
If no Airflow instance is connected, Otto can still inspect and edit local Dag code, but it doesn't run `af` commands by default. To test against a local Airflow environment, start one with `astro dev start` or ask Otto to start it for you. Once it is detected, `af` commands become available.
Before creating or editing Dags, Otto checks your project's `requirements.txt` and installed Airflow providers so it doesn't suggest operators, hooks, or sensors that aren't available in your environment.
The `af` CLI covers system health, Dag and run management, tasks, assets, connections, variables, instance management, and the provider registry, along with direct API access for endpoints not wrapped by a dedicated subcommand. For the full command reference, see the [`af` CLI documentation](https://github.com/astronomer/agents/blob/main/astro-airflow-mcp/README.md#airflow-cli-tool) in the `astronomer/agents` repository.
## Example workflows
You interact with these tools by asking Otto questions in natural language. Otto selects and runs the appropriate `af` commands automatically.
### Debug a failed Dag run
> "The `etl_orders` Dag failed last night. What happened?"
Otto checks system health, looks for import errors, finds the failed run, reads task logs, and identifies the root cause. If the fix is a code change, Otto proposes the edit and validates it.
### Explore an unfamiliar Dag
> "Walk me through the `customer_pipeline` Dag — what does it do and how has it been running?"
Otto reads the Dag source, inspects its tasks and dependencies, checks recent run history, and summarizes the connections it uses.
### Check upgrade readiness
> "Which of my Dags would break if I upgrade to Airflow 3?"
Otto evaluates your Dags against Astronomer's compatibility knowledge base and produces a prioritized list of changes needed, grouped by risk level. Available to Team, Business, and Enterprise tier customers.
### Trigger and monitor
> "Trigger the `daily_etl` Dag with config `{'env': 'staging'}` and tell me when it finishes."
Otto triggers the run and monitors it until completion, reporting the outcome.
## Automatic Dag validation
After Otto edits or creates a Dag file, it runs `af dags errors` to check for import errors when an Airflow instance is connected. If errors are found, Otto attempts to fix them in the same turn. If no Airflow instance is connected, Otto can still edit Dag files, but it can't verify imports until you connect an environment or start a local one with `astro dev start`.
## Astro CLI
Otto can use the [Astro CLI](/docs/cli/v1.43/overview) through the `bash` tool for project-level operations. For example, Otto can run `astro dev pytest` to execute the tests in your project's `tests/` folder against your local Airflow environment. Any Astro CLI command available in your shell is available to Otto.
# Upgrade Airflow with Otto
Source: https://astronomer.io/docs/astro/otto-upgrades
Use Otto to evaluate Airflow version upgrades, provider package upgrades, and Astro Runtime upgrades against Astronomer's proprietary compatibility knowledge base.
**Labs**
This feature is in [Labs](/docs/astro/feature-previews).
Otto upgrades Airflow projects against a proprietary compatibility knowledge base maintained by Astronomer. The knowledge base captures which upgrade paths are safe, which changes break Dags in practice, and which provider versions are compatible with which Airflow releases. Every finding traces back to a real Apache Airflow GitHub issue, provider changelog, or production incident, so Otto's evaluations are grounded in evidence rather than generic LLM inference.
Airflow 2 to 3 alone introduced over 121 breaking changes, and the 80+ provider packages each ship on independent release cadences. The compatibility knowledge base is what makes evaluating a specific upgrade path tractable.
## Upgrade compatibility coverage
### Airflow core versions
Otto evaluates:
* 2.x minor upgrades within the 2.5+ range, including 2.5 to 2.10.
* The 2.x to 3.0 migration, which introduces the largest set of breaking changes in Airflow's history.
* 3.x point releases, individually tracked from 3.0.1 through 3.2.1.
For each transition, Otto identifies removed and renamed APIs (operators, hooks, context variables), silent behavior changes that compile but produce different results, configuration default changes, and plugin, timetable, and executor interface breaks.
### Provider packages
The knowledge base covers 16 providers, prioritized by support volume and usage: Google, Amazon, Kubernetes, Snowflake, FAB, Slack, Databricks, Standard, Azure, Common SQL, SMTP, HTTP, SSH, Celery, Postgres, and MySQL.
For each provider, Otto tracks breaking changes at the parameter level: deprecated parameters, removed operators, base-class swaps, behavior changes within a version range, and the minimum Airflow version required.
### Astro Runtime
Otto coordinates Runtime upgrades with the corresponding Airflow core and bundled provider versions, and detects Runtime-specific issues such as namespace package precedence on Astro Runtime images and registry changes that pure Airflow analysis would miss.
### Cross-package compatibility
Beyond per-version analysis, Otto flags known incompatible package combinations: dependency diamond conflicts, version locks between core and providers, and pinning requirements that surface only at install time.
## What Otto catches
The knowledge base goes beyond what static linters and Airflow's own migration tooling detect:
* **Cross-package dependency conflicts**: combinations that fail to resolve or crash at runtime.
* **Silent behavior changes**: code that compiles but executes differently after the upgrade.
* **Custom plugin, timetable, and callback breaks**: interface changes in plugin and serialization APIs.
* **Provider-level breaking changes**: deprecated parameters, removed classes, and signature changes across the 16 covered providers.
* **Astro Runtime-specific issues**: Runtime image changes that Airflow core analysis alone misses.
## How findings are scored
Every finding carries a severity (critical, high, medium, or low) and a confidence label:
* **Verified**: backed by production incident data, a referenced GitHub issue, or a provider changelog. The fix is known to work.
* **AI-suggested**: inferred from documented patterns when the knowledge base lacks an exact match. Review before applying.
Each finding includes the file and line, the specific change, and a source reference such as a GitHub issue, provider changelog entry, or migration guide section.
## Where the knowledge base comes from
Astronomer curates the compatibility knowledge base from sources tied to real production behavior: public Apache Airflow development history, provider release artifacts, internal migration experience, and the patterns surfaced through Astronomer's years of support and engineering work. Every entry traces back to a concrete source rather than generic LLM inference.
## Run an upgrade with Otto
Ask Otto to evaluate your project in natural language. Examples:
> "Which of my Dags would break if I upgrade to Airflow 3?"
> "Assess my project for an Airflow 2.7 to 2.10 upgrade."
> "The Snowflake provider has a new release I want. Is my project ready for it?"
> "Walk me from Runtime 11 to Runtime 13."
Otto detects your current Airflow core version, Runtime version, and installed providers, then analyzes the project against the subset of the knowledge base relevant to your transition. The output is a prioritized findings list with file locations, severity, confidence, and proposed fixes.
Otto can apply mechanical fixes directly, including import rewrites, parameter renames, and version bumps. For semantic rewrites such as moving direct ORM access to Task SDK methods, Otto walks through the change with you. Before any patched dependencies are written, Otto verifies that the new dependency set resolves cleanly.
## Related
* [Skills](/docs/astro/otto-skills): The full skill catalog, including the upgrade skill.
# Astro Documentation
Source: https://astronomer.io/docs/astro/overview
Astro is a fully managed Apache Airflow® service for building, running, and observing data pipelines in the cloud.
Astro is a cloud solution that helps you focus on your data pipelines and spend less time managing Apache Airflow®, with capabilities enabling you to build, run, and observe data all in one place.
## Run on the cloud
A Deployment is an instance of Apache Airflow hosted on Astro.
Get your dags up and running on Astro.
Push code to Astro using templates for popular CI/CD tools.
## Get started
Use tutorials and concepts to learn everything you need to know about running Airflow.
Learn how to create an Astro project and run it locally with the Astro command-line interface (CLI).
## More Astro Tools
Develop applications and scripts for Astro components with a standard REST API.
Browse Airflow providers, modules, and plugins.
Build Apache Airflow® workflows using YAML files.
Automate, scale, and manage your Astro infrastructure with Terraform.
Orchestrate your dbt projects in Airflow.
# Autoscale Remote Execution Agent workers on queue depth
Source: https://astronomer.io/docs/astro/remote-agents-autoscale-workers
Scale Remote Execution Agent worker Pods on the number of queued tasks, so that I/O-bound tasks do not exhaust the task slots on each worker.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Each Remote Execution Agent worker Pod runs a fixed number of concurrent tasks. The `syncSlots` value sets that number, and each concurrent task uses one slot. A worker that has no free slot does not accept more tasks, and the extra tasks stay in the queue.
Tasks that wait on an external system, such as a warehouse query or an API call, use very little CPU and memory. These tasks fill every slot on a worker while CPU utilization stays low. A Horizontal Pod Autoscaler (HPA) that scales on CPU or memory does not add replicas in this state, so the queue grows and task latency increases.
This document shows how to scale worker Pods on queue depth instead. Queue depth is the number of tasks in the `queued` and `running` states, which each agent worker reports in the `astro_agent_client_queue_stats` metric. It covers two setups: [prometheus-adapter](#scale-with-prometheus-adapter) with the HPA that the Helm chart creates, and [KEDA](#scale-with-keda) for clusters that do not run prometheus-adapter.
## Slot capacity and queue depth
The task capacity of a worker Deployment is `syncSlots` multiplied by the number of replicas. A Deployment with `syncSlots: 20` and two replicas runs 40 tasks at the same time.
Use this capacity to size the autoscaler:
* Set `maxReplicaCount` to your peak number of concurrent tasks divided by `syncSlots`, rounded up. For a peak of 200 concurrent tasks and `syncSlots: 20`, set `maxReplicaCount: 10`.
* Set the metric target to `syncSlots`. The autoscaler then adds one replica for each `syncSlots` tasks of work in the queue.
* Set `minReplicaCount` to the capacity you want available before the autoscaler reacts. Each scaling decision takes at least one metric interval, and a new worker Pod takes time to start.
Raising `syncSlots` is the other way to add capacity for I/O-bound tasks. A slot holds a task process, so more slots need more memory on the worker Pod. Test a higher value against your own tasks before you use it in production.
## Prerequisites
* A Remote Execution Agent that runs Agent Client version `1.7.0` or later, which exposes the `/metrics` endpoint. See [Register and configure agents](/docs/astro/remote-execution-configure-agents).
* A Prometheus instance that scrapes the agent worker Pods. See [Scrape metrics from Remote Execution Agents](/docs/astro/remote-agents-metrics).
* Permission to install cluster components and to run `helm upgrade` against the agent release.
* One of the following:
* prometheus-adapter, which serves the metric through the Kubernetes custom metrics API.
* KEDA, which reads Prometheus directly and creates its own HPA.
## Choose a scaling method
| Method | How it works | Choose it when |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| prometheus-adapter | An adapter publishes the queue metric on the Kubernetes custom metrics API. The Helm chart creates the HPA from `workers[].hpa`. | Your platform runs prometheus-adapter, or you can install it. All autoscaling configuration stays in `values.yaml`. |
| KEDA | A `ScaledObject` queries Prometheus directly. KEDA creates and owns the HPA. | Your platform has no custom metrics API, or another component already occupies it. Only one adapter can serve `custom.metrics.k8s.io` in a cluster. |
Do not use both methods for the same worker Deployment. Two autoscalers that target one Deployment overwrite each other's decisions.
## Scale with prometheus-adapter
The adapter rule in the next step maps the `job` label to a Kubernetes Deployment, so `job` must hold the name of the worker Deployment. The Helm chart creates one Service for each worker, labeled `deploymentName: -worker-`, which a `ServiceMonitor` can copy into `job`:
```yaml title="worker-servicemonitor.yaml" wrap theme={null}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: astro-agent-workers
namespace: re
spec:
jobLabel: deploymentName
selector:
matchLabels:
app: astro-agent
component: worker
endpoints:
- port: http
path: /metrics
```
If you use a standalone Prometheus with static scrape configs, relabel the target so that `job` holds the same value.
Add the following rule to your prometheus-adapter configuration:
```yaml title="prometheus-adapter-values.yaml" wrap theme={null}
rules:
- seriesQuery: '{__name__="astro_agent_client_queue_stats",container!="POD",namespace!="",pod!=""}'
resources:
overrides:
job:
resource: deployment
namespace:
resource: namespace
metricsQuery: sum by (job) (max by (job, queue, state) (<<.Series>>{state=~"queued|running", <<.LabelMatchers>>}))
name:
matches: ".*astro_agent_client_queue_stats.*"
as: "astro_agent_client_queued_or_running_tasks"
```
The counts come from the Astro orchestration plane in the worker heartbeat response, so every Pod of a worker Deployment reports the same values. `max by (job, queue, state)` removes the duplicate series, and `sum by (job)` adds the `queued` and `running` series together into one queue-depth value for each worker Deployment.
Query the custom metrics API for the worker Deployment. Replace `re` with your namespace and `astro-worker-default-worker` with your Deployment name:
```bash wrap theme={null}
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/re/deployments.apps/astro-worker-default-worker/astro_agent_client_queued_or_running_tasks"
```
The response contains a `value` field with the current queue depth. An error means that the adapter rule or the `job` label does not match. Fix this before you enable the HPA.
Configure the worker in `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
queues: "default"
syncSlots: 20
hpa:
enabled: true
minReplicaCount: 2
maxReplicaCount: 10
metric:
enabled: true
name: astro_agent_client_queued_or_running_tasks
target:
type: AverageValue
averageValue: "20"
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Pods
value: 1
periodSeconds: 60
scaleDown:
stabilizationWindowSeconds: 300
terminationGracePeriodSeconds: 600
```
The `averageValue` target of `20` matches `syncSlots: 20`, so the HPA runs one replica for each 20 tasks in the queue. See [Metric target types](#metric-target-types) for why queue depth needs an `AverageValue` target.
The chart ignores `replicas` when `hpa.enabled` is `true`.
```bash wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
kubectl get hpa -n re
```
The `TARGETS` column shows the current queue depth against the target. If it shows ``, run `kubectl describe hpa -n re` to see which metric the HPA cannot read.
## Scale with KEDA
KEDA queries Prometheus directly, so the cluster needs no custom metrics adapter. KEDA creates the HPA for the worker Deployment and owns it.
Set `hpa.enabled: false` for the worker, so that the chart and KEDA do not create two autoscalers for one Deployment:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
queues: "default"
syncSlots: 20
replicas: 2
hpa:
enabled: false
```
Keep `replicas` equal to the `minReplicaCount` you set in the next step. Each `helm upgrade` writes `replicas` back to the Deployment, and KEDA restores the scaled count at its next poll.
```yaml title="worker-scaledobject.yaml" wrap theme={null}
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: astro-worker-default-worker
namespace: re
spec:
scaleTargetRef:
name: astro-worker-default-worker
minReplicaCount: 2
maxReplicaCount: 10
pollingInterval: 30
advanced:
horizontalPodAutoscalerConfig:
behavior:
scaleDown:
stabilizationWindowSeconds: 300
triggers:
- type: prometheus
metricType: AverageValue
metadata:
serverAddress: http://prometheus-operated.monitoring.svc.cluster.local:9090
threshold: "20"
query: |-
sum(max by (queue, state) (astro_agent_client_queue_stats{namespace="re",job="astro-worker-default-worker",state=~"queued|running"}))
```
`scaleTargetRef.name` is the name of the worker Deployment, which the chart builds as `-worker-`.
`threshold` matches `syncSlots`, and the default `AverageValue` metric type divides the query result by the threshold. KEDA therefore runs one replica for each 20 tasks in the queue.
The query must return a single value. Adjust the label matchers to your own scrape configuration, and add a matcher for the worker Deployment when one Prometheus instance scrapes several of them. Read the labels from a worker's `/metrics` endpoint before you write the query.
```bash wrap theme={null}
kubectl apply -f worker-scaledobject.yaml
kubectl get scaledobject -n re
kubectl get hpa -n re
```
The `READY` and `ACTIVE` columns of the `ScaledObject` report whether KEDA can read the metric. KEDA names the HPA that it creates `keda-hpa-`.
Do not set `minReplicaCount: 0` for an agent worker. The queue metric comes from the worker Pods, so a Deployment that scales to zero exposes no metric and never scales back up.
### Other KEDA scalers
The `prometheus` trigger fits any platform that keeps the agent metrics in Prometheus or in a Prometheus-compatible service, such as Amazon Managed Service for Prometheus, Azure Monitor managed service for Prometheus, or Google Cloud Managed Service for Prometheus.
If your queue depth lives in another system, KEDA can read it with an `external` trigger, which calls a gRPC service that you run. The arithmetic stays the same: report the number of queued and running tasks, and set the threshold to `syncSlots`. For the list of triggers, see the [KEDA scalers reference](https://keda.sh/docs/latest/scalers/).
## Metric target types
Kubernetes computes the replica count differently for each target type. Use `AverageValue` for queue depth.
| Target type | Replica count | Use it for |
| -------------- | ------------------------------------------------ | ----------------------------------------------------------------------- |
| `AverageValue` | `metric / target`, rounded up | A metric that counts work for the whole Deployment, such as queue depth |
| `Value` | `metric / target × current replicas`, rounded up | A metric that already describes a single replica |
A `Value` target multiplies the ratio by the current replica count. With a queue-depth metric, the replica count therefore multiplies again in each scaling cycle for as long as the queue stays above the target, until the HPA reaches `maxReplicaCount`. For the full algorithm, see the [Kubernetes HPA documentation](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details).
## Combine queue depth with resource metrics
Queue depth measures outstanding work, not the load on a Pod. Tasks that use a lot of memory can still exhaust a worker before its slots are full. Add resource metrics with `hpa.extraMetrics`, which takes Kubernetes HPA metric objects:
```yaml title="values.yaml" wrap theme={null}
hpa:
enabled: true
minReplicaCount: 2
maxReplicaCount: 10
metric:
enabled: true
name: astro_agent_client_queued_or_running_tasks
target:
type: AverageValue
averageValue: "20"
extraMetrics:
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
```
The HPA evaluates every metric and uses the highest replica count that any of them recommends. Resource metrics need `resources.requests` on the worker, because the HPA calculates utilization against the request.
With KEDA, add a second trigger of type `memory` or `cpu` to the same `ScaledObject`.
## Scale down without task failures
A worker that stops during a task fails that task. Two settings protect running work:
* `terminationGracePeriodSeconds` on the worker gives a Pod time to finish its tasks before Kubernetes stops it. The default is `600`. Set it higher than your longest task if your tasks run for more than 10 minutes.
* `behavior.scaleDown.stabilizationWindowSeconds` makes the autoscaler wait before it removes replicas. The examples on this page use `300`.
A queue of short tasks therefore makes the value dip and recover between scaling cycles. `scaleDown.stabilizationWindowSeconds` makes the HPA use the highest replica count it recommended over the trailing window, so a brief dip does not remove a worker.
## Related documentation
* [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference)
* [Scrape metrics from Remote Execution Agents](/docs/astro/remote-agents-metrics)
* [Register and configure agents](/docs/astro/remote-execution-configure-agents)
* [Remote Execution Agent failure scenarios](/docs/astro/remote-agents-failure-scenarios)
# Configure AWS PrivateLink for Remote Execution Agents
Source: https://astronomer.io/docs/astro/remote-agents-aws-privatelink
Configure private connectivity between Remote Execution Agents and the Astro orchestration plane using AWS PrivateLink.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
AWS PrivateLink enables private connectivity between your Remote Execution Agents and the Astro orchestration plane without exposing traffic to the public internet. This guide explains how to set up a VPC Endpoint in your AWS environment to establish secure communication with Astro.
## Overview
By default, Remote Execution Agents communicate with the Astro orchestration plane over the public internet. With AWS PrivateLink, you can route this traffic through a private connection within AWS, which provides enhanced security and can simplify network configurations for organizations with strict security requirements.
The setup involves creating a VPC Endpoint in your AWS account that connects to Astronomer's VPC Endpoint Service. Once configured, your Remote Execution Agents can communicate with Astro through this private connection.
## Prerequisites
* An Astro Deployment configured for Remote Execution.
* Remote Execution Agents installed in an AWS environment.
* Access to the AWS Console with permissions to create VPC Endpoints and modify Route53 configurations.
## Astro-side configuration
Before you can create a VPC Endpoint, Astronomer must configure the VPC Endpoint Service on the Astro side. Contact [Astronomer Support](https://support.astronomer.io) with the following information:
* Your Astro Cluster ID.
* The AWS Account ID where your Remote Execution Agents are running.
* The AWS Region where your Remote Execution Agents are running.
Astronomer Support will provide you with the **VPC Endpoint Service name**, **Service region**, and supported **Availability Zones** required to create your VPC Endpoint.
If your Remote Execution Agents run in a different AWS region than the Astro orchestration plane, inform Astronomer Support. Additional configuration may be required on the Astro side, such as adding your region to the VPC Endpoint Service cross-region configuration or adding your AWS account to the allowed principals list.
## Create a VPC Endpoint
After receiving the VPC Endpoint Service name from Astronomer Support, create a VPC Endpoint in your AWS account.
In the AWS Console, go to **VPC** > **Endpoints**.
Click **Create endpoint** to begin the configuration.
Set the following values:
* **Name tag**: Enter a descriptive name, such as `astro-privatelink`.
* **Type**: Select **Endpoint services that use NLBs and GWLBs**.
* **Service name**: Enter the VPC Endpoint Service name provided by Astronomer Support, and click **Verify service** to confirm the service name is valid.
* **Cross-Region**: Enable if required (optional).
* **VPC**: Select the VPC where your Remote Execution Agents are running.
* **Subnets**: Select at least one subnet. For high availability, select subnets in multiple Availability Zones.
* **Security group**: Select or create a security group that allows inbound traffic on HTTPS port 443.
Subnet selection shows your subnets in the Availability zones supported by the VPCe Service. If there is a mismatch, you must create subnet(s) in the zones provided by Astronomer Support.
## Configure DNS resolution
After creating the VPC Endpoint, configure DNS so that your Remote Execution Agents resolve the Astro orchestration plane hostname to the private endpoint IP addresses.
### Configure Route53 private hosted zone
1. In the AWS Console, go to **Route 53** > **Hosted zones**.
2. Click **Create hosted zone**.
3. Enter `external.astronomer.run` as the domain name.
4. Select **Private hosted zone**.
5. Associate the hosted zone with the VPC where your VPC Endpoint was created.
1. In the hosted zone, click **Create record**.
2. For **Record name**, enter your Astro Cluster ID.
3. Select **Alias**.
4. For **Route traffic to**, select **Alias to VPC endpoint**.
5. Select your region and the VPC Endpoint you created.
6. Click **Create records**.
## Verify the connection
After completing the configuration, verify that your Remote Execution Agents can communicate with Astro through the private endpoint. Validate in the Astro UI that the agents are heart beating and reporting a **Healthy** status. You can also verify from within your network using the below instructions.
1. Connect to a host within your VPC that has network access to the VPC Endpoint.
2. Run a DNS lookup to confirm the hostname resolves to a private IP address:
```sh wrap theme={null}
nslookup .external.astronomer.run
```
The response should show the private IP addresses assigned to your VPC Endpoint rather than public IP addresses.
3. Test connectivity to the endpoint:
```sh wrap theme={null}
curl -v https://.external.astronomer.run
```
The expected response is `404 page not found`. If the connection is successful, your Remote Execution Agents will use the private endpoint for all communication with the Astro orchestration plane.
## Multiple Remote Execution Agents
If you have multiple Remote Execution Agents across different VPCs, you can either create a VPC Endpoint in each VPC, or use a single VPC Endpoint and configure network routing between VPCs.
The following table summarizes the actions required based on your configuration:
| Configuration | Yes | No |
| --------------------- | --------------------- | --------------------------------------------- |
| Same AWS region | No additional actions | Attach VPC to the Route53 private hosted zone |
| Different AWS region | No additional actions | Contact Astronomer Support |
| Different AWS account | No additional actions | Contact Astronomer Support |
If you previously created a Route53 private hosted zone, you can associate additional VPCs with the same hosted zone rather than creating new zones for each VPC.
## Restrict traffic to the private endpoint
After verifying that the private endpoint works correctly, you can optionally configure your Remote Execution API (Orchestration plane) to only allow traffic originating from your VPC Endpoint. This ensures that all communication with Astro uses the private connection.
To restrict traffic:
1. Take note of your Astro Cluster VPC Subnet Range, under **Settings** > **Clusters** > **Cluster details** (in the legacy UI, **Organization Settings** > **Clusters** > **Cluster details**).
2. In the Astro UI, navigate to your Deployment and go to **Settings**.
3. In your Deployment Advanced settings, add the cluster CIDR range to the **Allowed IP address ranges** list.
This configuration ensures that only traffic coming through the VPC Endpoint Service can reach the Deployment.
## Troubleshooting
### VPC Endpoint shows "pending acceptance"
The VPC Endpoint Service may require manual acceptance of endpoint connections, if still in pending state after 5 minutes. Contact Astronomer Support to approve your endpoint connection request.
### DNS resolution returns public IP addresses
Verify that your Route53 private hosted zone is correctly configured and associated with the VPC where you are testing.
### Connection timeouts
Check that the security group attached to the VPC Endpoint allows inbound traffic on port 443 from the subnets where your Remote Execution Agents are running.
# Configure Azure Private Link for Remote Execution Agents
Source: https://astronomer.io/docs/astro/remote-agents-azure-privatelink
Configure private connectivity between Remote Execution Agents and the Astro orchestration plane using Azure Private Link.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Azure Private Link enables private connectivity between your Remote Execution Agents and the Astro orchestration plane without exposing traffic to the public internet. This guide explains how to set up a Private Endpoint in your Azure environment to establish secure communication with Astro.
## Overview
By default, Remote Execution Agents communicate with the Astro orchestration plane over the public internet. With Azure Private Link, you can route this traffic through a private connection within Azure, which provides enhanced security and can simplify network configurations for organizations with strict security requirements.
The setup involves creating a Private Endpoint in your Azure subscription that connects to Astronomer's Private Link Service. Once configured, your Remote Execution Agents can communicate with Astro through this private connection.
## Prerequisites
* An Astro Deployment configured for Remote Execution.
* Remote Execution Agents installed in an Azure environment (Azure Kubernetes Service (AKS)).
* Access to the Azure portal with permissions to create Private Endpoints, Private DNS zones, and modify networking configurations.
## Astro-side configuration
Before you can create a Private Endpoint, Astronomer must configure the Private Link Service on the Astro side. Contact [Astronomer support](https://support.astronomer.io) with the following information:
* Your Astro Cluster ID.
Astronomer support will provide you with the **Private Link Service alias** required to create your Private Endpoint.
## Create a Private Endpoint
After receiving the Private Link Service alias from Astronomer Support, create a Private Endpoint in your Azure subscription.
Before starting, collect the following:
* The Private Link Service alias provided by Astronomer support.
* The Remote Execution API URL for your Deployment, which you can find in the Deployment details in the Astro UI.
In the Azure portal, go to **Private Link Overview** > **Private endpoints**.
Click **Create** to begin the configuration.
Set the following values:
* **Resource group**: Select the resource group where your AKS cluster with Remote Execution Agents is deployed.
* **Name**: Enter a descriptive name, such as `astro-privatelink`.
* **Network Interface Name**: Accept the default or enter a custom name.
* **Region**: Select the region where your Remote Execution Agents are running.
Set the following values:
* **Connection method**: Select **Connect to an Azure resource by resource ID or alias**.
* **Resource ID or alias**: Enter the Private Link Service alias provided by Astronomer support.
Set the following values:
* **Virtual Network**: Select the VNet where your AKS cluster with Remote Execution Agents is deployed.
* **Subnet**: Select the appropriate subnet based on your internal network preferences.
Review your configuration and click **Create**.
After creating the Private Endpoint, contact Astronomer support to approve your endpoint connection request. You can proceed with the DNS configuration while waiting for approval.
## Configure DNS resolution
After creating the Private Endpoint, configure DNS so that your Remote Execution Agents resolve the Astro orchestration plane hostname to the Private Endpoint IP address.
### Create a private DNS zone
In the Azure portal, go to **Private DNS zones**.
1. Click **Create**.
2. Enter `external.astronomer.run` as the zone name.
3. Select the resource group and click **Create**.
1. In the newly created DNS zone, go to **Virtual network links**.
2. Click **Add**.
3. Enter a link name and select the VNet where your AKS cluster is deployed.
4. Click **OK**.
1. In the DNS zone, click **Record set**.
2. For **Name**, enter the first subdomain from your Remote Execution API URL. For example, if your API URL is `clxxxxxxxxx.external.astronomer.run`, enter `clxxxxxxxxx`.
3. For **Type**, select **A**.
4. For **IP address**, enter the Private Endpoint IP address. You can find this in the Private Endpoint's **Network interface** settings in the Azure portal.
5. Click **OK**.
## Verify the connection
After Astronomer support approves your endpoint connection, verify that your Remote Execution Agents can communicate with Astro through the Private Endpoint. Validate in the Astro UI that the agents are heartbeating and reporting a **Healthy** status. You can also verify from within your network using the following instructions.
1. Connect to a host within your VNet that has network access to the Private Endpoint.
2. Run a DNS lookup to confirm the hostname resolves to a private IP address:
```sh wrap theme={null}
nslookup .external.astronomer.run
```
The response should show the private IP address assigned to your Private Endpoint rather than a public IP address.
3. Test connectivity to the endpoint:
```sh wrap theme={null}
curl -v https://.external.astronomer.run
```
The expected response is `404 page not found`. If the connection is successful, your Remote Execution Agents will use the Private Endpoint for all communication with the Astro orchestration plane.
## Multiple Remote Execution Agents
Only one Private Link Service is required per Astro cluster. If you have multiple Remote Execution Agents across different VNets, you can either create a Private Endpoint in each VNet (the Private Link Service alias remains unchanged) or use a single Private Endpoint across your network.
If you previously created a private DNS zone, you can associate additional VNets with the same zone rather than creating new zones for each VNet.
## Restrict traffic to the Private Endpoint
After verifying that the Private Endpoint works correctly, you can optionally configure your Remote Execution Agents to only allow traffic through the Private Endpoint. This ensures that all communication with Astro uses the private connection.
To restrict traffic:
1. Take note of your Astro Cluster VPC Subnet Range, under **Settings** > **Clusters** > **Cluster details** (in the legacy UI, **Organization Settings** > **Clusters** > **Cluster details**).
2. In the Astro UI, navigate to your Deployment and go to **Settings**.
3. In your Deployment Advanced settings, add the cluster CIDR range to the **Allowed IP address ranges** list.
This configuration ensures that only traffic coming through the Private Link Service can reach the Deployment.
## Troubleshooting
### Private Endpoint shows "pending" connection state
The Private Link Service requires manual acceptance of endpoint connections. Contact Astronomer support to approve your endpoint connection request.
### DNS resolution returns public IP addresses
Verify that your private DNS zone is correctly configured and linked to the VNet where you are testing. Ensure the A record points to the correct Private Endpoint IP address.
### Connection timeouts
Check that your network security group (NSG) rules allow outbound traffic on port 443 from the subnets where your Remote Execution Agents are running to the Private Endpoint.
# Remote Execution Agent failure and recovery scenarios
Source: https://astronomer.io/docs/astro/remote-agents-failure-scenarios
Understand how Astro handles Remote Execution Agent and API server failures and task recovery.
When the heartbeat between the API server and a Remote Execution Agent is disrupted, the Astro executor prevents task duplication by marking queued tasks from that agent as `failed`. This makes tasks eligible for reassignment to healthy agents. To ensure safe task execution, an agent must receive explicit confirmation from the API server before starting any task. If an agent loses connectivity with the API server, the agent continues executing any tasks that the API server already confirmed and marked as `running`, but the agent will not start new tasks until heartbeat communication is restored.
### Agent failure
The API Server marks an agent as failed if the API server misses three consecutive heartbeat intervals. When that happens, the API server checks whether the Agent has any "queued" tasks, or tasks the agent already picked up and started running, but has not yet reported as complete. If a worker agent fails, the API server marks those tasks as failed and makes them available for reassignment. If a triggerer Agent fails, the API server immediately reassigns the tasks, since triggerer tasks are short-lived and idempotent.
#### Dag scheduling and retention during Agent disconnection
The Airflow scheduler retains all dags that were most recently parsed and sent by the dag processor agent. If the dag processor agent or any Remote Execution Agent disconnects or fails, the scheduler continues to use these previously parsed dags. The scheduler will keep creating dag runs on schedule or in response to events, such as dataset updates, for all retained dags.
* New or updated dags are not detected until a healthy dag processor Agent reconnects and provides an updated set of dags.
* All tasks and dag runs remain pending until a healthy Remote Execution Agent, worker or triggerer, is available for execution.
If no healthy Remote Execution Agents are connected, the scheduler continues to create dag runs for known dags but those tasks remain in queued state and will not execute until an agent becomes available.
If a task stays in queued state for more than 600 seconds (default) or the value set via the [`AIRFLOW__SCHEDULER__TASK_QUEUED_TIMEOUT`](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#task-queued-timeout) environment variable on your Astro deployment, it will be marked as failed.
### API Server failure
If an agent's heartbeats can't reach the API server, the agent assumes that the API server and other agents remain healthy. In this case:
* A **worker** continues running any tasks that the API server already marked as `running`, but the worker doesn't start new tasks until it reconnects with the API server. This prevents two agents from running the same task.
* A **triggerer** stops processing tasks entirely until it restores connectivity. Since triggerer workloads are designed to be reassigned immediately when disconnected, trigger execution stops during the partition.
This behavior preserves task safety and prevents duplication for both workers and triggerers, even during partial failures or network partitions.
# Helm chart configuration reference
Source: https://astronomer.io/docs/astro/remote-agents-helm-reference
Reference for required and optional Helm chart values used to install the Remote Execution Agent.
This reference describes configuration values for the Remote Execution Agent Helm chart. For complete configuration options, see the `values.yaml` file downloaded from the Astro UI.
For a history of chart changes, see [Helm chart release notes](/docs/astro/agent-helm-chart-release-notes). For which chart versions are compatible with which Astro Agent versions, see the [Helm chart to Astro agent compatibility matrix](/docs/astro/agent-maintenance-policy#helm-chart-to-astro-agent-compatibility-matrix).
## Required configuration values
The following values must be configured before installing the Helm chart:
### Agent authentication
**agentToken** / **agentTokenSecretName** / **agentTokenFile**
You must specify exactly one of these to provide the agent token generated in the Astro UI.
* **agentToken**: Token value as plain text in `values.yaml` (not recommended for production)
* **agentTokenSecretName**: Name of existing Kubernetes secret containing the token
* **agentTokenFile**: Path to file containing the token (agent reads at runtime)
See [Agent token configuration](/docs/astro/remote-execution-configure-agents#agent-token-configuration) for detailed instructions.
### Image registry access
**imagePullSecretName** / **imagePullSecretData**
You must specify exactly one of these to allow agents to pull images from the registry.
* **imagePullSecretName**: Name of existing Kubernetes secret with Docker credentials
* **imagePullSecretData**: Docker config JSON as string (Helm creates secret named `image-pull-secret`)
See [Image pull secret configuration](/docs/astro/remote-execution-configure-agents#image-pull-secret-configuration) for detailed instructions.
### Kubernetes namespace
**namespace**
Kubernetes namespace where the agent will be deployed.
* If `createNamespace: true`, Helm creates the namespace
* If `createNamespace: false`, namespace must exist before installation
If using `agentTokenSecretName` and `imagePullSecretName`, set `createNamespace: false` and create the namespace manually with secrets already present.
See [Install in restricted Kubernetes namespace](/docs/astro/remote-agents-restricted-kubernetes) for restricted namespace configuration.
### Resource name prefix
**resourceNamePrefix**
Name prefix for all Kubernetes resources (Deployments, ConfigMaps, Secrets) created by the Helm chart.
### Secrets backend
**secretBackend**
Airflow secrets backend class for accessing connections and variables. Required for agent operation.
Supported backends:
* `airflow.providers.amazon.aws.secrets.secrets_manager.SecretsManagerBackend`
* `airflow.providers.microsoft.azure.secrets.key_vault.AzureKeyVaultBackend`
* `airflow.providers.google.cloud.secrets.secret_manager.CloudSecretManagerBackend`
* `airflow.providers.hashicorp.secrets.vault.VaultBackend`
* `airflow.secrets.local_filesystem.LocalFilesystemBackend` (not recommended for production)
See [Configure secrets backend](/docs/astro/secrets-backend) for detailed configuration instructions.
### XCom backend
**xcomBackend**
Airflow XCom backend class for passing data between tasks. Required for agent operation.
Typically set to: `airflow.providers.common.io.xcom.backend.XComObjectStorageBackend`
See [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend) for detailed configuration instructions.
### State store backend
**stateStoreBackend**
Airflow worker-side state store backend class for persisting task and asset state on Astro Runtime 3.3 and later. Available in Helm chart 2.3.0 and later.
Defaults to `airflow.providers.common.io.state_store.backend.StateStoreObjectStorageBackend` with a local file path. For production, point the path at shared object storage.
See [Configure state store backend](/docs/astro/remote-execution-configure-state-store-backend) for detailed configuration instructions.
### DAG bundles
**dagBundleConfigList**
JSON string defining how agents access dag code. Required for running dags.
See [Configure DAG sources](/docs/astro/remote-execution-configure-dag-sources) for detailed configuration instructions.
## Common environment variables
**commonEnv**
Environment variables applied to all agent components (worker, DAG processor, triggerer). Used to configure secrets backend parameters, XCom paths, logging settings, and other Airflow configuration.
Example:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__SECRETS__BACKEND_KWARGS
value: '{"connections_prefix": "airflow/connections", "variables_prefix": "airflow/variables"}'
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_PATH
value: "s3://bucket/xcom"
```
## Worker resource configuration
**workers**
Workers are configured as a list in `values.yaml`. Each entry defines a worker Deployment with its own name, resource allocation, replica count, and optional queue assignment.
| Parameter | Description | Default |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------- | ---------------- |
| `name` | Unique identifier for the worker Deployment. Used in Kubernetes resource names. | `default-worker` |
| `replicas` | Number of worker Pod replicas. Ignored when `hpa.enabled` is `true`. | `1` |
| `queues` | Comma-separated list of Airflow queues this worker listens on. | `default` |
| `syncSlots` | Number of tasks the worker Pod runs at the same time. Each concurrent task uses one slot. | `20` |
| `resources.requests.cpu` | Minimum CPU allocated to the worker Pod. | — |
| `resources.requests.memory` | Minimum memory allocated to the worker Pod. | — |
| `resources.limits.cpu` | Maximum CPU the worker Pod can use. | — |
| `resources.limits.memory` | Maximum memory the worker Pod can use. | — |
| `env` | List of environment variables specific to this worker. | `[]` |
| `volumes` | Additional volumes to mount on the worker Pod. | `[]` |
| `volumeMounts` | Mount paths for the additional volumes. | `[]` |
| `nodeSelector` | Kubernetes node selector for scheduling worker Pods. | `{}` |
| `tolerations` | Kubernetes tolerations for scheduling worker Pods. | `[]` |
| `serviceAccount.name` | Custom service account name. Overrides the default `{{ resourceNamePrefix }}-worker-{{ worker.name }}`. | — |
| `serviceAccount.create` | Whether the Helm chart creates the service account. Set to `false` when using a pre-existing service account. | `true` |
| `terminationGracePeriodSeconds` | The grace period for the worker Pod to finish existing tasks before terminating. | `600` |
Example with two workers:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
replicas: 2
queues: "default"
resources:
requests:
cpu: "500m"
memory: "1Gi"
limits:
cpu: "2"
memory: "4Gi"
- name: high-memory-worker
replicas: 1
queues: "high-memory"
resources:
requests:
cpu: "1"
memory: "4Gi"
limits:
cpu: "4"
memory: "16Gi"
```
When you configure multiple workers, each worker creates a separate Kubernetes Deployment. The service account name for each worker defaults to `{{ resourceNamePrefix }}-worker-{{ worker.name }}`. If you use IRSA (AWS), Workload Identity (GCP), or managed identity (Azure), annotate each worker's service account.
## Horizontal Pod Autoscaler
**workers\[].hpa**
Each worker supports a Horizontal Pod Autoscaler (HPA) configuration to automatically scale the number of worker Pod replicas based on resource utilization or custom metrics.
When `hpa.enabled` is `true`, the Helm chart creates a `HorizontalPodAutoscaler` resource named `{{ resourceNamePrefix }}-worker-{{ worker.name }}-hpa` for the worker Deployment. The `replicas` value is ignored because the HPA controls replica count.
| Parameter | Description | Default |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| `hpa.enabled` | Enable the Horizontal Pod Autoscaler for this worker. | `false` |
| `hpa.minReplicaCount` | Minimum number of worker Pod replicas. Required when `hpa.enabled` is `true`. | `1` |
| `hpa.maxReplicaCount` | Maximum number of worker Pod replicas. Required when `hpa.enabled` is `true`. | `1` |
| `hpa.metric.enabled` | Add a metric that describes the worker Deployment object to the HPA. Set it to `false` to scale on `hpa.extraMetrics` only. | `true` |
| `hpa.metric.name` | Name of the metric in the Kubernetes custom metrics API. | `astro_agent_client_queued_or_running_tasks` |
| `hpa.metric.target` | Target for `hpa.metric.name`. Follows the Kubernetes [HPA metrics spec](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/). | `{type: Value, value: 20}` |
| `hpa.extraMetrics` | Additional Kubernetes HPA metric objects, such as CPU or memory targets. | `[]` |
| `hpa.behavior` | Kubernetes HPA scaling behavior, which controls how fast replicas are added and removed. | See below\* |
\* The chart's default `hpa.behavior` is:
```yaml theme={null}
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Pods
value: 1
periodSeconds: 60
scaleDown:
stabilizationWindowSeconds: 300
```
The `hpa.metric` block is required when `hpa.enabled` is `true`. Because `workers` is a list, Helm replaces your whole worker entry and applies none of the defaults in this table. If you enable the HPA without a `metric` block, the command fails with `nil pointer evaluating interface {}.enabled`.
Example with CPU-based autoscaling:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
queues: "default"
resources:
requests:
cpu: "500m"
memory: "1Gi"
limits:
cpu: "2"
memory: "4Gi"
hpa:
enabled: true
minReplicaCount: 1
maxReplicaCount: 5
metric:
enabled: false
extraMetrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80
```
You must set `resources.requests` for the metrics you use in HPA targets. For example, CPU-based autoscaling requires `resources.requests.cpu` to be set. Without resource requests, the HPA cannot calculate utilization percentages.
You can combine multiple metrics to define more sophisticated scaling behavior. The HPA evaluates all specified metrics and scales to the highest recommended replica count.
Example with CPU and memory metrics:
```yaml wrap theme={null}
hpa:
enabled: true
minReplicaCount: 2
maxReplicaCount: 10
metric:
enabled: false
extraMetrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 75
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
```
CPU and memory targets under-scale workers that run I/O-bound tasks. Such tasks fill every slot on a worker while CPU utilization stays low, so the HPA adds no replicas and tasks stay queued. To scale on the number of queued tasks instead, see [Autoscale Remote Execution Agent workers on queue depth](/docs/astro/remote-agents-autoscale-workers).
## Triggerer resource configuration
**triggerer**
The triggerer runs deferred tasks asynchronously. Configure the triggerer to control replica count, async capacity, resource allocation, and Pod-level settings.
| Parameter | Description | Default |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| `replicas` | Number of triggerer Pod replicas. | `1` |
| `asyncSlots` | Number of concurrent triggers the triggerer Pod can compute. | `1000` |
| `image` | Docker image for the triggerer. Defaults to the top-level `image` if not set. | — |
| `imagePullPolicy` | Image pull policy for the triggerer. Defaults to the top-level `imagePullPolicy` if not set. | — |
| `resources.limits.cpu` | Maximum CPU the triggerer Pod can use. | `1` |
| `resources.limits.ephemeral-storage` | Maximum ephemeral storage the triggerer Pod can use. | `1Gi` |
| `resources.limits.memory` | Maximum memory the triggerer Pod can use. | `2Gi` |
| `resources.requests.cpu` | Minimum CPU allocated to the triggerer Pod. | `1` |
| `resources.requests.ephemeral-storage` | Minimum ephemeral storage allocated to the triggerer Pod. | `1Gi` |
| `resources.requests.memory` | Minimum memory allocated to the triggerer Pod. | `2Gi` |
| `env` | List of environment variables specific to the triggerer. | `[]` |
| `livenessProbe` | Liveness probe configuration for the triggerer Pod. | See following example |
| `readinessProbe` | Readiness probe configuration for the triggerer Pod. | See following example |
| `podSecurityContext` | Pod security context for the triggerer Pod. By default, the agent runs as a non-root user with UID 50000 and group ID 50000. | `~` |
| `containerSecurityContext` | Security context for the triggerer container. | `{}` |
| `initContainers` | Init containers to add to the triggerer Pod. | `[]` |
| `extraContainers` | Sidecar containers to add to the triggerer Pod. | `[]` |
| `volumes` | Additional volumes to mount on the triggerer Pod. | `[]` |
| `volumeMounts` | Mount paths for the additional volumes. | `[]` |
| `nodeSelector` | Kubernetes node selector for scheduling triggerer Pods. | `~` |
| `affinity` | Affinity rules for the triggerer Pod. | `{}` |
| `tolerations` | Kubernetes tolerations for scheduling triggerer Pods. | `[]` |
Example:
```yaml title="values.yaml" expandable wrap theme={null}
triggerer:
replicas: 2
asyncSlots: 500
resources:
limits:
cpu: "1"
ephemeral-storage: "1Gi"
memory: "2Gi"
requests:
cpu: "1"
ephemeral-storage: "1Gi"
memory: "2Gi"
livenessProbe:
httpGet:
path: healthz
port: 39091
initialDelaySeconds: 30
periodSeconds: 5
failureThreshold: 3
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
httpGet:
path: healthz
port: 39091
initialDelaySeconds: 30
periodSeconds: 5
failureThreshold: 3
successThreshold: 1
timeoutSeconds: 5
podSecurityContext:
runAsUser: 50000
fsGroup: 50000
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
containerSecurityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
initContainers:
- name: vault-agent
image: vault:1.13.0
command: ["vault", "agent", "-config=/etc/vault/config.hcl"]
volumeMounts:
- name: vault-config
mountPath: /etc/vault
env:
- name: VAULT_ADDR
value: "https://vault.example.com"
- name: VAULT_TOKEN
valueFrom:
secretKeyRef:
key: token
name: vault-token
extraContainers:
- name: logging-sidecar
image: timberio/vector:0.45.0-debian
env:
- name: VECTOR_CONFIG
value: /etc/vector/vector.yaml
volumeMounts:
- name: vector-config
mountPath: /etc/vector
resources:
limits:
cpu: "0.5"
memory: "256Mi"
requests:
cpu: "0.5"
memory: "256Mi"
volumes:
- name: task-logs
emptyDir: {}
- name: vector-config
configMap:
name: vector-config
volumeMounts:
- name: task-logs
mountPath: /var/log/airflow
readOnly: true
nodeSelector:
node.kubernetes.io/instance-type: c5.large
```
To run multiple triggerers, increase `replicas`. The configured number of replicas runs continuously. For restricted namespaces with Pod security standards set to restricted, configure `podSecurityContext` and `containerSecurityContext` to meet your cluster's requirements.
## Optional configuration
### Logging sidecar
**loggingSidecar**
Optional sidecar for exporting task logs to external platforms or viewing logs in the Airflow UI before task completion.
See [Configure logging sidecar](/docs/astro/remote-agents-logging-sidecar) for configuration instructions.
### OpenLineage
**openLineage**
Optional configuration for data lineage collection.
You must configure OpenLineage to use [Astro Observe](/docs/astro/astro-observe) with Remote Execution Deployments.
See [Configure OpenLineage](/docs/astro/remote-execution-configure-openlineage) for configuration instructions.
### Sentinel monitoring
**sentinel**
Monitoring service for agent health reporting (agent version 1.2.0+). Astronomer recommends enabling Sentinel for all deployments.
See [Sentinel for Remote Execution Agents](/docs/astro/remote-agents-sentinel) for configuration instructions.
### Cloud provider annotations
**annotations** and **labels**
Kubernetes annotations and labels to configure Pods to run using a specific IAM role (AWS), workload identity (GCP) or managed identity (Azure).
## Helm commands
After the Remote Execution Agent is installed, any updates to the agent use the `helm upgrade` command.
### Install agent
```sh wrap theme={null}
helm repo add astronomer https://helm.astronomer.io
helm repo update
helm install astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
### Update agent
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
### View current configuration
```sh wrap theme={null}
helm get values astro-agent
```
# Configure LoggingSidecar in a Remote Execution Agent
Source: https://astronomer.io/docs/astro/remote-agents-logging-sidecar
Ship Airflow task logs from a Remote Execution Agent to external systems using a logging sidecar.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Airflow task logs are generated when tasks execute in the Worker and Triggerer components. The logging sidecar is a container that runs alongside these components to collect and ship task logs to external systems like Splunk, Elasticsearch, AWS CloudWatch, or other log aggregation services.
The following procedure describes how to configure your Remote Execution Agent to use the logging sidecar. This process configures the `loggingSidecar` section in your `values.yaml` file, which controls the deployment of a sidecar container that collects and forwards task logs.
## Prerequisites
* You must have permissions for `deployment create` or `pod create` in the kubernetes Namespace where your Remote Execution Agent is installed.
## Enable the Logging Sidecar
1. Configure volumes in your Agent Worker and Agent Triggerer components of your `values.yaml` file to collect task logs:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
volumes:
- name: task-logs
emptyDir: {}
volumeMounts:
- name: task-logs
mountPath: /usr/local/airflow/logs
triggerer:
volumes:
- name: task-logs
emptyDir: {}
volumeMounts:
- name: task-logs
mountPath: /usr/local/airflow/logs
```
2. To enable the logging sidecar, set `enabled` to `true` in your Remote Execution Agent's `values.yaml` file, and define the name of your logging sidecar and the image you want to use. Astronomer recommends using [Vector](https://vector.dev/docs/) for exporting task logs and the following example uses the [Timber](https://hub.docker.com/r/timberio/vector) docker image for it.
```yaml title="values.yaml" wrap theme={null}
loggingSidecar:
enabled: true
name: vector-logging-sidecar
image: timberio/vector:0.45.0-debian
```
3. Allocate resources for your sidecar container in the `values.yaml` file:
```yaml title="values.yaml" wrap theme={null}
loggingSidecar:
resources:
limits:
cpu: "0.5"
memory: "1Gi"
requests:
cpu: "0.5"
memory: "1Gi"
```
## Example logging sidecar configuration
The following YAML file shows a full configuration example for a logging sidecar that uses Vector to export task log data to the [Splunk Cloud Platform](https://docs.splunk.com/Documentation/SplunkCloud).
```yaml title="values.yaml" wrap expandable theme={null}
loggingSidecar:
enabled: true
name: vector-logging-sidecar
image: timberio/vector:0.45.0-debian
# Mount the task logs directory to access log files
volumeMounts:
- name: task-logs
mountPath: /etc/vector/task_logs
# Resource allocation for the sidecar container
resources:
limits:
cpu: "0.5"
memory: "1Gi"
requests:
cpu: "0.5"
memory: "1Gi"
# Vector configuration
config: |
data_dir: /etc/vector/task_logs
# Define log sources
sources:
task_logs:
type: file
include:
- /etc/vector/task_logs/**/*.log
transforms:
parse_task_log_file:
type: remap
inputs:
- task_logs
source: |
parsed = parse_regex!(.file, r'/dag_id=(?P[0-9a-z-_]+)/run_id=(?P[^/]+)/task_id=(?P[0-9a-z-_]+)/(?:map_index=(?P-?[0-9]+)/)?attempt=(?P[0-9]+)/(?P[0-9a-z-]+)(?:\.log\.trigger\.[0-9]+)?\.log$')
.tiID = parsed.tiID
.attempt = parsed.attempt
.taskID = parsed.taskID
.runID = parsed.runID
.dagID = parsed.dagID
.mapIndex = parsed.mapIndex ?? -1
sinks:
splunk:
type: splunk_hec_logs
inputs:
- parse_task_log_file
endpoint: https://.splunkcloud.com
default_token:
index:
indexed_fields:
- tiID
- attempt
- taskID
- runID
- dagID
encoding:
codec: "text"
workers:
- name: default-worker
volumes:
- name: task-logs
emptyDir: {}
volumeMounts:
- name: task-logs
mountPath: /usr/local/airflow/logs
triggerer:
volumes:
- name: task-logs
emptyDir: {}
volumeMounts:
- name: task-logs
mountPath: /usr/local/airflow/logs
```
# Scrape metrics from Remote Execution Agents
Source: https://astronomer.io/docs/astro/remote-agents-metrics
Scrape metrics from Astro Remote Execution Agents.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
This guide lists available metrics when running Astro's Remote Execution Agents and explains how to scrape metrics using OpenTelemetry and Prometheus.
## What you can monitor
A self-managed Prometheus instance can collect the following classes of metrics from agent components:
* **Agent client metrics** that each agent component exposes on its own `/metrics` endpoint, including a `component_health` gauge and heartbeat, agent proxy, and Python runtime metrics. The Dag processor also exposes parsing-pipeline metrics. See [Agent client metrics](#agent-client-metrics) for the full list.
* **Airflow application metrics** that Airflow emits in StatsD format from the worker, Dag processor, and triggerer. Examples include scheduler heartbeats, task instance state counts, and Dag parse times.
* **Kubernetes infrastructure metrics** for the agent Pods, such as CPU, memory, and Pod status. These come from `kube-state-metrics`, `cAdvisor`, and `node-exporter` on your cluster.
* **Sentinel runtime metrics** Sentinel reports agent and integration health back to Astro, and you can scrape its Pod for local observability. Requires [Sentinel to be enabled](/docs/astro/remote-agents-sentinel).
For metrics that Astro generates outside your cluster, such as orchestration plane scheduler activity, see [Export metrics from Astro](/docs/astro/export-metrics).
## Prerequisites
* A Remote Execution Agent (running Agent Client version `1.7.0` and above) installed in your Kubernetes cluster. See [Register and configure agents](/docs/astro/remote-execution-configure-agents).
* A running Prometheus deployment in the same cluster, or one that can reach the agent namespace over the network. The Prometheus Operator with `PodMonitor` or `ServiceMonitor` resources is supported, and so is a standalone Prometheus that uses static scrape configs.
* Cluster-level access to deploy Helm chart updates and, if you use the Prometheus Operator, to create custom resources.
* `kube-state-metrics` and `cAdvisor` available in your cluster, if you want to collect Kubernetes infrastructure metrics.
## Monitor Airflow application metrics
Airflow can expose metrics to [OpenTelemetry](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#setup-opentelemetry) or [StatsD](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#setup-statsd).
This guide covers a minimal monitoring example using OpenTelemetry. Features such as Kubernetes namespace isolation are out of scope for this guide. Code examples assume the components are deployed in a Kubernetes namespace named `re`.
See additional configuration here:
* [Airflow StatsD metrics example](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#setup-statsd)
* [OpenTelemetry Collector configuration](https://opentelemetry.io/docs/collector/configuration)
### Step 1: Install OpenTelemetry Dependency
Add `apache-airflow[otel]` to `requirements-client.txt` and deploy the Remote Execution agents (using `astro remote deploy`).
### Step 2: Install OpenTelemetry
This step installs an OpenTelemetry Collector on your Kubernetes cluster using a Helm chart. If you already have OpenTelemetry running, you can skip this step.
From your terminal, add the `open-telemetry` Helm repository and download the latest metadata:
```sh wrap theme={null}
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update
```
Create a YAML file named for example `otel-values.yaml` for OpenTelemetry configuration:
```yaml title="otel-values.yaml" expandable wrap theme={null}
mode: deployment
image:
repository: otel/opentelemetry-collector-contrib
command:
name: otelcol-contrib
config:
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
exporters:
debug:
verbosity: detailed
prometheus:
endpoint: 0.0.0.0:8889
service:
pipelines:
metrics:
receivers: [otlp]
exporters: [debug, prometheus]
ports:
otlp-http:
enabled: true
containerPort: 4318
servicePort: 4318
protocol: TCP
prometheus:
enabled: true
containerPort: 8889
servicePort: 8889
protocol: TCP
```
Install the OpenTelemetry Collector:
```sh wrap theme={null}
helm install otel-collector open-telemetry/opentelemetry-collector -n re -f otel-values.yaml
```
### Step 3: Configure Airflow to ship metrics to OpenTelemetry
Configure these environment variables in your Remote Execution `values.yaml` under `commonEnv`:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__METRICS__OTEL_ON
value: "True"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector-opentelemetry-collector.re.svc.cluster.local:4318
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: http/protobuf
```
This ensures Airflow services push metrics to the OTLP endpoint.
Upgrade your Remote Execution Helm chart:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent --values values.yaml
```
### Step 4: Verify metrics
At this stage, Airflow application metrics should arrive in the OTLP collector. You can verify this by port forwarding the otel-collector:
```sh wrap theme={null}
kubectl port-forward -n re deploy/otel-collector-opentelemetry-collector 8889:8889
```
Browse to [http://localhost:8889/metrics](http://localhost:8889/metrics) and check if you observe any metrics. Note that you might need to run some Airflow tasks for more metrics to show. Here’s an example of metrics that you might observe:
```text wrap expandable theme={null}
# HELP airflow_airflow_io_load_filesystems
# TYPE airflow_airflow_io_load_filesystems gauge
airflow_airflow_io_load_filesystems{job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version=""} 209.85527300035756
# HELP airflow_dag_example_astronauts_get_astronauts_duration
# TYPE airflow_dag_example_astronauts_get_astronauts_duration gauge
airflow_dag_example_astronauts_get_astronauts_duration{job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version=""} 3903.361
# HELP airflow_operator_successes_pythondecoratedoperator_total
# TYPE airflow_operator_successes_pythondecoratedoperator_total counter
airflow_operator_successes_pythondecoratedoperator_total{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 1
# HELP airflow_operator_successes_total
# TYPE airflow_operator_successes_total counter
airflow_operator_successes_total{dag_id="example_astronauts",job="airflow",operator="_PythonDecoratedOperator",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 1
# HELP airflow_serde_load_serializers
# TYPE airflow_serde_load_serializers gauge
airflow_serde_load_serializers{job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version=""} 0.8434970004600473
# HELP airflow_task_duration
# TYPE airflow_task_duration gauge
airflow_task_duration{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 3903.361
# HELP airflow_ti_finish_example_astronauts_get_astronauts_success_total
# TYPE airflow_ti_finish_example_astronauts_get_astronauts_success_total counter
airflow_ti_finish_example_astronauts_get_astronauts_success_total{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 1
# HELP airflow_ti_finish_total
# TYPE airflow_ti_finish_total counter
airflow_ti_finish_total{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",state="success",task_id="get_astronauts"} 1
# HELP airflow_ti_start_example_astronauts_get_astronauts_total
# TYPE airflow_ti_start_example_astronauts_get_astronauts_total counter
airflow_ti_start_example_astronauts_get_astronauts_total{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 1
# HELP airflow_ti_start_total
# TYPE airflow_ti_start_total counter
airflow_ti_start_total{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 1
# HELP airflow_ti_successes_total
# TYPE airflow_ti_successes_total counter
airflow_ti_successes_total{dag_id="example_astronauts",job="airflow",otel_scope_name="airflow.sdk._shared.observability.metrics.otel_logger",otel_scope_schema_url="",otel_scope_version="",task_id="get_astronauts"} 1
```
If you see metrics similar to the above, your setup is successful.
From here, you can configure your metrics backend such as Prometheus to scrape the metrics from `otel-collector:8889`. A common metrics/monitoring setup is Prometheus as the metrics backend, plus Grafana for visualization.
## Agent client metrics
Each agent component (worker, Dag processor, and triggerer) runs an internal HTTP server that exposes Prometheus-format metrics directly on a `/metrics` endpoint, on port `39091` by default (configurable through the setting `http_server.port`, or using the environment variable `ASTRO_AGENT_CLIENT_HTTP_SERVER__PORT`). These metrics describe the agent client's own runtime, including its health, its heartbeat traffic with the Astro orchestration plane, and the Python process it runs in. Agent client metrics are independent of the Airflow application metrics described in [Monitor Airflow application metrics](#monitor-airflow-application-metrics), and you can scrape both endpoints from the same Prometheus instance.
The most important health signal is the `component_health` gauge. Each internal subsystem reports `1` when healthy and `0` when unhealthy, for example:
```text wrap theme={null}
component_health{component="TriggererHeartbeater"} 1.0
component_health{component="TriggererProc"} 1.0
component_health{component="Server"} 1.0
```
The `component` label values vary by agent client. For example, the worker reports its own set of subsystems, and the Dag processor reports subsystems for the parsing pipeline. Alert when any `component_health` series drops to `0`.
If you are using Prometheus to scrape the metrics of your Agent clients, you can configure the Helm chart's `annotations` with the following annotations to ensure that your metrics get collected:
```yaml title="values.yaml" wrap theme={null}
# inside your values.yaml file
# make sure to update the port annotation if you changed the default value
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/scheme: "http"
prometheus.io/port: "39091"
```
### Generic metrics
All three agent clients ship a common set of metrics that cover Python runtime, process resources, heartbeat traffic with the API server, queue state, and the agent proxy.
| Metric | Type | Description |
| ------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `component_health` | Gauge | Health status of agent subsystems. `1` is healthy and `0` is unhealthy. |
| `heartbeat_requests_total` | Counter | Total heartbeat attempts, with `component` and `outcome` labels (`success`, `timeout`, `error`). |
| `heartbeat_duration_seconds` | Histogram | Time from the start of a heartbeat request to the receipt of the provider response. |
| `heartbeat_payload_bytes` | Histogram | Size in bytes of the serialized heartbeat request body before it is sent. |
| `heartbeat_requests_received_total` | Counter | Total heartbeat requests received from tasks. |
| `heartbeat_requests_sent_total` | Counter | Total heartbeat requests sent to the API server. |
| `heartbeat_requests_error_total` | Counter | Total heartbeat requests that failed to be sent to the API server. |
| `matched_proxy_errors_total` | Counter | Total proxy failures for matched routes, with `route` and `error_type` labels. |
| `astro_agent_client_queue_stats` | Gauge | Number of tasks in each state in each queue. Use it to scale workers on queue depth. See [Autoscale Remote Execution Agent workers on queue depth](/docs/astro/remote-agents-autoscale-workers). |
| `astro_agent_proxy_http_requests_total` | Counter | Total agent proxy requests, with `method`, `status`, and `handler` labels. |
| `astro_agent_proxy_http_request_duration_seconds` | Histogram | Agent proxy request latency, with `handler` and `method` labels. Use this when aggregation by handler matters. |
| `astro_agent_proxy_http_request_duration_highr_seconds` | Histogram | High-resolution agent proxy request latency for accurate percentile calculations. |
| `astro_agent_proxy_http_request_size_bytes` | Summary | Content length of incoming agent proxy requests, by `handler`. |
| `astro_agent_proxy_http_response_size_bytes` | Summary | Content length of outgoing agent proxy responses, by `handler`. |
| `python_info` | Gauge | Python platform information, including the interpreter implementation and version labels. |
| `python_gc_objects_collected_total` | Counter | Objects collected during garbage collection, by `generation`. |
| `python_gc_objects_uncollectable_total` | Counter | Uncollectable objects found during garbage collection, by `generation`. |
| `python_gc_collections_total` | Counter | Number of times each generation was collected. |
| `process_cpu_seconds_total` | Counter | Total user and system CPU time, in seconds. |
| `process_virtual_memory_bytes` | Gauge | Virtual memory size, in bytes. |
| `process_resident_memory_bytes` | Gauge | Resident memory size, in bytes. |
| `process_start_time_seconds` | Gauge | Start time of the process since the Unix epoch, in seconds. |
| `process_open_fds` | Gauge | Number of open file descriptors. |
| `process_max_fds` | Gauge | Maximum number of open file descriptors. |
### Dag processor metrics
In addition to the generic metrics, the Dag processor exposes parsing-pipeline metrics.
| Metric | Type | Description |
| ----------------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| `dag_processor_heartbeat_dags_sent_total` | Counter | Total Dags included in heartbeat requests. |
| `dag_processor_results_queue_depth` | Gauge | Number of parsed Dag results waiting in the coordinator queue. Use it as a back-pressure indicator. |
| `dag_processor_cache_hits_total` | Counter | Total Dags skipped because their `dag_hash` matched the cached value. |
| `dag_processor_cache_misses_total` | Counter | Total Dags processed because they were new, changed, or cold in the cache. |
| `dag_processor_cache_size` | Gauge | Number of entries in the Dag processor `dag_hashes` cache. |
**Note** that the `heartbeat_*` metrics described earlier in the `Generic Metrics` section are also available for the Dag Processor component, and can be filtered by `component=dag_processor`.
## Related documentation
* [Sentinel for Remote Execution Agents](/docs/astro/remote-agents-sentinel)
* [Autoscale Remote Execution Agent workers on queue depth](/docs/astro/remote-agents-autoscale-workers)
* [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference)
* [Export metrics from Astro](/docs/astro/export-metrics)
* [Register and configure agents](/docs/astro/remote-execution-configure-agents)
# Install Remote Execution Agents in a restricted kubernetes namespace
Source: https://astronomer.io/docs/astro/remote-agents-restricted-kubernetes
Install a Remote Execution Agent in a Kubernetes namespace with restricted Pod security standards.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
You can install the Remote Execution Agent in a Kubernetes namespace with restricted pod security standards. Your organization might have different security standards for infrastructure supporting internal-only sandboxes compared to production environments.
Kubernetes Pod Security Standards define different security levels for Pods:
* **Privileged**: No restrictions (least secure)
* **Baseline**: Prevents known privilege escalations
* **Restricted**: Highly-constrained settings following security best practices (most secure)
The **Restricted** profile enforces the following limitations:
* Runs containers as non-root users
* Prevents privilege escalation
* Drops all Linux capabilities
* Uses read-only root filesystems when possible
* Requires a runtime default seccomp profile
However, because of these limitations, you need to complete the following additional Remote Execution Agent configuration set up.
## Step 1: Create a restricted namespace
Create a Namespace in your Kubernetes manifest with the following `restricted` Pod security standards:
```yaml title="namespace.yaml" wrap theme={null}
apiVersion: v1
kind: Namespace
metadata:
name: astro-agent-restricted
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
```
## Step 2: Configure Global Security Settings
Modify your Agent's `values.yaml` file to set global security context settings that apply to all Agent components' Pods and containers:
```yaml title="values.yaml" wrap theme={null}
# Global pod security context for all components
podSecurityContext:
seccompProfile:
type: RuntimeDefault
runAsUser: 50000
fsGroup: 50000
runAsNonRoot: true
# Global container security context for all components
containerSecurityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
```
## Step 3: Configure component-specific settings
When using the Agent in a restricted namespace, you must configure volume mounts because:
1. The container security context sets `readOnlyRootFilesystem: true`
2. These directories need write access during runtime
3. Using `emptyDir` volumes provides isolated, writable storage that meets security requirements
### Worker configuration
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
# Other worker settings...
# Required volumes for filesystem access
volumes:
- name: tmp
emptyDir: {}
- name: task-logs
emptyDir: {}
volumeMounts:
- name: tmp
mountPath: /tmp # This folder is used by the Astro Agent to maintain the socket file
- name: task-logs
mountPath: /usr/local/airflow/logs # Or the configured folder that holds the task logs
```
### Dag processor configuration
```yaml title="values.yaml" wrap theme={null}
dagProcessor:
# Other Dag processor settings...
# Required volumes for filesystem access
volumes:
- name: tmp
emptyDir: {}
volumeMounts:
- name: tmp
mountPath: /tmp # This folder is used by the Astro Agent to maintain the socket file
```
### Triggerer configuration
```yaml title="values.yaml" wrap theme={null}
triggerer:
# Other triggerer settings...
# Required volumes for filesystem access
volumes:
- name: tmp
emptyDir: {}
- name: task-logs
emptyDir: {}
volumeMounts:
- name: tmp
mountPath: /tmp # This folder is used by the Astro Agent to maintain the socket file
- name: task-logs
mountPath: /usr/local/airflow/logs # Or the configured folder that holds the task logs
```
## Step 4: (Optional) Add logging sidecar configuration
```yaml title="values.yaml" wrap theme={null}
loggingSidecar:
# Other logging sidecar settings...
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
volumeMounts:
- name: task-logs
mountPath: /etc/airflow/logs # Or the configured folder that holds the task logs
```
# Sentinel for Remote Execution Agents
Source: https://astronomer.io/docs/astro/remote-agents-sentinel
Overview of the Sentinel service for Astro Remote Execution Agents.
## Overview
The **Sentinel** service provides real-time monitoring and operational visibility for Astro Remote Execution Agents running in your Kubernetes cluster. Sentinel automates health checks and reports agent status back to the Astro orchestration plane. This enables Astronomer support to provide proactive support and improved triage for support issues.
Sentinel is available as part of the Remote Execution Agent Helm chart starting in version **1.2.0**.
Sentinel is included in the Remote Execution Agent Helm chart starting in version 1.2.0. Astronomer recommends enabling Sentinel for all Remote Execution deployments.
Sentinel provides the following key benefits:
* Detects Pod and component issues before they impact task execution.
* Monitors essential integrations such as XCom and secrets backends.
## How Sentinel works
Sentinel runs as a Pod alongside your agent components in Kubernetes. It:
* Watches for issues with agent Pods in its namespace.
* Checks the health of key integrations and reports status.
* Sends regular "heartbeat" reports to Astro's API, where Deployment health can be reviewed.
* Only monitors agent-managed Pods, default is Pods labeled `app=astro-agent`. No user workload data, dag code, or unrelated Pod information leaves your environment.
## Set up
To enable Sentinel, set the following in your Helm chart configuration:
```yaml title="values.yaml" wrap theme={null}
sentinel:
enabled: true
```
Astronomer recommends that you host the Sentinel image in your organization's registry and update the image reference in your Helm chart configuration.
To customize which agent pods Sentinel observes, you can change the `agent_component_app_label` in the Helm chart values. By default, Sentinel only monitors pods labeled `app=astro-agent`, but you can restrict or broaden this scope as needed.
## Security and scope
* Sentinel only observes Pods with a specific label in its namespace.
* All status data flows outbound to Astro. No inbound connectivity is required.
* No dag, task logs, or business data is transmitted.
# Register and configure agents
Source: https://astronomer.io/docs/astro/remote-execution-configure-agents
Register Remote Execution Agents with an Astro Deployment and install the Helm chart.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Remote Execution Agents execute Airflow tasks in your Kubernetes infrastructure. This guide covers registering agents with your Astro Deployment and installing the Helm chart.
## Prerequisites
* Astro Deployment configured for Remote Execution mode. See [Create a Deployment](/docs/astro/create-deployment).
* Kubernetes 1.30 or later
**Recommended Kubernetes configuration**
Configure `singleProcessOOMKill: true` in your kubelet configuration. With this setting,
Kubernetes kills only the process that runs out of memory instead of the entire Pod. Without it, one task's
out-of-memory error kills all tasks on the worker and loses all task logs.
See [Kubernetes documentation](https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/) for details.
* Helm 3 or later
* [Deployment API token](/docs/astro/deployment-api-tokens) with Deployment Admin role to pull the base Astro Remote Execution Agent Image
## Step 1: Create agent token
The agent token authenticates your agent to the Astro orchestration plane. Create this token before installing the Helm chart.
Save the token value in a secure location immediately after creation. You cannot retrieve it again. The limit is 50 agent tokens per Deployment.
In the Astro UI, click **Deployments**, then select your Remote Execution Deployment (in the legacy UI, select a Workspace first).
Select the **Remote Agents** tab and toggle to the **Tokens** view.
1. Click **+Agent Token**
2. Enter a **Name** and **Expiration** period
3. Optionally add a **Description**
4. Click **Create**
Copy the agent token and save it securely. You will use this token in the Helm chart configuration.
Retrieve your [Deployment API token](/docs/astro/deployment-api-tokens). This authenticates API requests.
Make a GET request to the organizations endpoint:
```sh wrap theme={null}
curl https://api.astronomer.io/platform/v1beta1/organizations \
-H "Authorization: Bearer "
```
Locate the `id` field in the response.
Make a GET request to the deployments endpoint using your organization ID:
```sh wrap theme={null}
curl https://api.astronomer.io/platform/v1beta1/organizations//deployments \
-H "Authorization: Bearer "
```
Locate the `id` field for your Remote Execution Deployment in the response.
Make a POST request to create the token. Replace the `organizationId`, `deploymentId`, and `your-API-Deployment-token` placeholders with your own values. You can optionally set a description and expiration period for the token.This example sets a 30-day expiration:
```sh wrap theme={null}
curl -X POST https://api.astronomer.io/iam/v1beta1/organizations//deployments//agent-tokens \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"description": "Production agent token",
"name": "prod-agent",
"tokenExpiryPeriodInDays": 30
}'
```
Copy the `token` field from the response and save it securely.
## Step 2: Install Helm chart
Astronomer recommends pulling both the Remote Execution Agent image and the Sentinel image and storing them in your private registry. Sentinel provides advanced monitoring and reporting for Remote Execution Agents, starting from version 1.2.0. The Agent base images are minimal, so you might need to add packages for your pipelines to function properly. Use either an [Organization API token](/docs/astro/organization-api-tokens) with the `Org Owner` role or a [Deployment API token](/docs/astro/deployment-api-tokens) with the `Deployment Admin` role to authenticate.
1. In the Astro UI, go to the **Remote Agents** tab
2. Toggle to the **Agents** view
3. Click **Register a Remote Agent**
4. Click **Download** to get the `values.yaml` file
Update the following values in `values.yaml`. All other values have working defaults.
You must configure these values before installing the Helm chart:
* `agentToken`, `agentTokenSecretName`, or `agentTokenFile` - See [Agent token configuration](#agent-token-configuration)
* `imagePullSecretName` or `imagePullSecretData` - See [Image pull secret configuration](#image-pull-secret-configuration)
* `namespace` - Kubernetes namespace for agent deployment
* `resourceNamePrefix` - Name prefix for Kubernetes resources
* `secretBackend` - Must be configured before agents can execute tasks. See [Configure secrets backend](/docs/astro/remote-execution-configure-secrets-backend)
* `xcomBackend` - Must be configured before agents can execute tasks. See [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend)
* `stateStoreBackend` - Required on Astro Runtime 3.3 and later, where agents don't start without it. Helm chart 2.3.0 and later set a working default that isn't suitable for production. See [Configure state store backend](/docs/astro/remote-execution-configure-state-store-backend)
See the Helm chart comments and [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference) for descriptions of values.
If self-hosting the image, log in to the image registry with your Deployment API token:
```sh wrap theme={null}
docker login images.astronomer.cloud -u cli -p
```
**Sentinel image available with 1.2.0 and later**
Starting with Remote Execution Agent 1.2.0, a Sentinel image is published alongside the agent images to provide monitoring for Remote Execution Agents. The Sentinel image must be pulled separately. Astronomer recommends enabling Sentinel for all deployments. To enable Sentinel, configure the service in your `values.yaml` file. See [Sentinel for Remote Execution Agents](/docs/astro/remote-agents-sentinel).
After you log in, you can pull the Remote Execution Agent and Sentinel images directly. To find the latest version and image path, refer to the [Remote Execution Agent release notes](/docs/astro/agent-release-notes) for all currently hosted images and [Remote Execution Agent image reference](/docs/astro/agent-images) for their full URLs. For example:
```sh wrap theme={null}
docker pull images.astronomer.cloud/baseimages/astro-remote-execution-agent:3.1-3-python-3.12-astro-agent-1.2.0
```
```sh wrap theme={null}
docker pull images.astronomer.cloud/baseimages/astro-remote-execution-sentinel:1.2.0
```
**Configure scope for registry proxies**
If you use JFrog Artifactory or a similar registry management tool to mirror or proxy `images.astronomer.cloud`, you need to configure specific include patterns instead of using the default `**/*` pattern.
The Deployment API token has limited scope and cannot fetch manifests for all repositories. Configure your remote registry to include only these specific paths:
* `baseimages/astro-remote-execution-agent`
* `baseimages/astro-remote-execution-sentinel`
Without these specific patterns, you might encounter `403 Forbidden` errors when JFrog attempts to crawl all repositories in the registry.
Pull the Remote Execution Agent image, apply customizations that your dags require, and push it to your private registry. Then update the `values.yaml` file to reference your customized image.
You must configure `secretBackend` in your `values.yaml` before running the Helm install. The installation fails if `secretBackend` has no value. See [Configure secrets backend](/docs/astro/remote-execution-configure-secrets-backend).
Run the following commands to install the agent:
```sh wrap theme={null}
helm repo add astronomer https://helm.astronomer.io
helm repo update
helm install astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
## Step 3: Optionally set allowed IP ranges
Restrict Deployment access to specific IP address ranges for additional security or network isolation between environments.
In the Astro UI, click the options menu for your Deployment and select **Edit**.
1. In the **Advanced** section, click **+Add IP**.
2. Enter an IP address range in CIDR format.
3. Click **Add**.
4. Repeat to add multiple ranges.
## Step 4: Verify agent heartbeat
Confirm the agent is connected and healthy.
In the Astro UI, go to the **Remote Agents** tab. A healthy agent shows:
* Health status: **Healthy**
* Last heartbeat: Within the past minute
You can also verify locally that all agent client deployment Pods are running with `kubectl get pods -n `. For more in-depth validation, check pod logs for heartbeat activity.
To verify that your agents can communicate with your Astro Orchestration plane:
1. Connect to a host or Pod within your VPC that has your Remote Execution Agent running.
2. Run a DNS lookup to confirm the hostname resolves successfully:
```sh wrap theme={null}
nslookup .external.astronomer.run
```
The response should show the Astro cluster's public load balancer's public IP addresses, or the private IP addresses assigned to your VPC Endpoint if you configured [AWS PrivateLink](/docs/astro/remote-agents-aws-privatelink).
3. Test connectivity to the endpoint:
```sh wrap theme={null}
curl -v https://.external.astronomer.run
```
The expected response is `404 page not found`. A successful connection confirms your Remote Execution Agents are able to communicate with the Astro orchestration plane over a public connection or via your private VPC endpoint.
Temporarily remove any configured [allowed IP ranges](#step-3-optionally-set-allowed-ip-ranges) if the agent is not starting up and reporting Healthy. If connecting using a public connection, your network team may need to allowlist the Astro cluster's public load balancer's public IP addresses (step 2) for outbound access from your VPC.
After verifying agent health, configure how agents access DAG code. See [Configure DAG sources](/docs/astro/remote-execution-configure-dag-sources).
Trigger a test DAG run to verify the agent executes tasks successfully.
If you expect tasks to run longer than the default grace period of 10 minutes, update the `terminationGracePeriodSeconds` parameter for your workers in `values.yaml`. This ensures that worker Pods have enough time to finish existing tasks before terminating. See [Worker resource configuration](/docs/astro/remote-agents-helm-reference#worker-resource-configuration).
**HTTP/HTTPS proxy server support**
Starting with Remote Execution Agent 1.3.2, the agents support running behind an HTTP(S) proxy server. Configure proxy settings using the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variables.
For Remote Execution Agent versions earlier than 1.3.2, proxy servers are not supported. If your Kubernetes environment automatically adds a proxy configuration to Pods, the agents will fail to establish an outbound connection to the orchestration plane. You might see errors similar to these in worker logs:
* `"exc_type":"ReadError","exc_value":"[Errno 104] Connection reset by peer"`
* `"exc_type":"HTTPStatusError","exc_value":"Client error '400 Bad Request' for url ...`
**Workaround:** Remove the proxy configuration from the agent Pods, or upgrade to Agent 1.3.2 or later.
## Agent token configuration
Provide the agent token using one of these methods:
### agentToken
Store the token directly in `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
agentToken: ""
```
Storing tokens directly in values files exposes them in version control. Use `agentTokenSecretName` or `agentTokenFile` for better security.
### agentTokenSecretName
Reference an existing Kubernetes secret containing the token:
```sh wrap theme={null}
kubectl -n create secret generic agent-token \
--from-file=token=token.txt
```
In `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
agentTokenSecretName: "agent-token"
```
### agentTokenFile
Mount a file containing the token. The agent reads the token at runtime:
```yaml title="values.yaml" wrap theme={null}
agentTokenFile: "/path/to/token/file"
```
## Image pull secret configuration
Configure image pull secrets to authenticate with your container registry. The configuration differs depending on whether you pull images directly from Astronomer's registry or from a self-hosted registry.
The image pull secret requires an **Astro API token**, not an agent token. Use either an [Organization API token](/docs/astro/organization-api-tokens) with the `Org Owner` role or a [Deployment API token](/docs/astro/deployment-api-tokens) with the `Deployment Admin` role. The agent token created in Step 1 authenticates the agent to the Astro orchestration plane and cannot be used for pulling images.
Use this configuration when pulling images directly from `images.astronomer.cloud`.
### imagePullSecretName (Astronomer registry)
Reference an existing Kubernetes secret in your namespace:
```sh wrap theme={null}
kubectl create secret docker-registry -n \
--docker-server=images.astronomer.cloud \
--docker-username=cli \
--docker-password=
```
In `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
imagePullSecretName: ""
```
### imagePullSecretData (Astronomer registry)
Alternatively, provide Docker config JSON directly. The Helm chart creates a secret named `image-pull-secret`:
```yaml title="values.yaml" wrap theme={null}
imagePullSecretData: |
{
"auths": {
"images.astronomer.cloud": {
"auth": "",
"email": ""
}
}
}
```
Use this configuration when pulling images from a self-hosted registry, proxy, or mirror.
If you use a proxy or mirror for `images.astronomer.cloud`, you still need an Astro API token to authenticate with the upstream Astronomer registry. Configure this in your proxy settings. See [Pull agent image for private registries](#image-pull-secret-configuration).
### imagePullSecretName (self-hosted registry)
Reference an existing Kubernetes secret in your namespace:
```sh wrap theme={null}
kubectl create secret docker-registry -n \
--docker-server= \
--docker-username= \
--docker-password=
```
In `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
imagePullSecretName: ""
```
### imagePullSecretData (self-hosted registry)
Alternatively, provide Docker config JSON directly. The Helm chart creates a secret named `image-pull-secret`:
```yaml title="values.yaml" wrap theme={null}
imagePullSecretData: |
{
"auths": {
"": {
"auth": "",
"email": ""
}
}
}
```
## Manage Remote Execution Agents
You can take the following actions on your registered Remote Execution Agents:
* **Cordon:** Cordoning a Remote Execution Agent marks it as unavailable for scheduling new tasks, while allowing it to continue running and complete any tasks already in progress.
This allows you to gracefully remove the Agent from service without interrupting current workloads. For example, you can cordon an Agent to delete or perform maintenance, such as an upgrade, on the Agent or underlying infrastructure.
A cordoned Agent will not receive new work, but it remains active until all running tasks have finished. Once ready to reintroduce the Agent to the task pool, it can be uncordoned to resume normal operation.
* **Uncordon:** Uncordoning a Remote Execution Agent re-enables it to receive new tasks and resume normal scheduling.
* **Delete:** Deletes the Remote Execution Agent from the Deployment.
## Remote Execution Agent maintenance policy
Each Remote Execution Agent minor version is maintained for **6 months** from the release month.
See [Agent maintenance policy](/docs/astro/agent-maintenance-policy) for more details about versioning, support, and upgrade recommendations.
## Next steps
After registering agents, configure the required components:
* [Configure secrets backend](/docs/astro/remote-execution-configure-secrets-backend) - Required for agent operation
* [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend) - Required for passing data between tasks
* [Configure DAG sources](/docs/astro/remote-execution-configure-dag-sources) - Required for accessing DAG code
## Related documentation
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [Remote Execution Agent failure scenarios](/docs/astro/remote-agents-failure-scenarios)
* [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference)
* [Install agents in restricted Kubernetes namespaces](/docs/astro/remote-agents-restricted-kubernetes)
# Configure DAG sources
Source: https://astronomer.io/docs/astro/remote-execution-configure-dag-sources
Configure GitDagBundle or LocalDagBundle as the dag source for Remote Execution Agents.
Remote Execution Agents require configuration to access your DAG code. This guide covers configuring DAG bundles, which are collections of DAG files and supporting code introduced in Airflow 3.
This feature requires Airflow 3.x Deployments. Configuring multiple DAG bundles in a single Deployment is only supported in Remote Execution mode.
## DAG bundle types
Choose between two types of DAG bundles:
* **GitDagBundle**: Dags stored in a Git repository (recommended for production)
* **LocalDagBundle**: Dags stored in the container image or persistent volume (default)
### When to use each bundle type
**Use GitDagBundle when**:
* Running production deployments
* Tracking DAG versions with full rerun capabilities
* Storing dags in version control systems
* Managing multiple teams or DAG repositories
**Use LocalDagBundle when**:
* Running development or testing environments
* Building dags into container images
* Using existing PVC-based DAG management
* Preferring simpler configuration
See [GitDagBundle compared to LocalDagBundle](#gitdagbundle-compared-to-localdagbundle) for functional differences.
## Dag hashing
The Dag processor computes a hash of each Dag and caches it. On each processing cycle, the Dag processor compares the current hash of a Dag against the cached value:
* If the hash matches, the Dag is unchanged, so the Dag processor skips it instead of re-sending it to the Astro orchestration plane.
* If the Dag is new, changed, or not yet in the cache, the Dag processor processes it and updates the cache.
Because the Dag processor skips unchanged Dags, Dag hashing lowers memory utilization and network bandwidth, and speeds up Dag updates in Deployments with many Dags.
To monitor cache behavior, use the `dag_processor_cache_hits_total`, `dag_processor_cache_misses_total`, and `dag_processor_cache_size` metrics. See [Dag processor metrics](/docs/astro/remote-agents-metrics#dag-processor-metrics).
Dag hashing functionality is enabled by default, starting on Astro Agent client release `1.8.0` and later. You can disable that feature at any time with the following environment variable: `ASTRO_AGENT_CLIENT_DAG_PROCESSOR__ENABLE_DAG_CACHING=False`.
## Configure GitDagBundle
GitDagBundle fetches dags from Git repositories and provides automatic versioning capabilities.
GitDagBundle is recommended for production Remote Execution deployments.
### Supported authentication methods
GitDagBundle supports the following authentication methods:
* Access tokens (personal access tokens, OAuth tokens)
* SSH keys
* SSH agent
Choose the method that aligns with your security requirements and infrastructure.
### Required token permissions by provider
When you create an access token, grant the minimum permissions required to read repository contents:
| Provider | Token type | Required permissions |
| --------- | ---------------- | ----------------------------------------------------------------------------------------------- |
| GitHub | Fine-grained PAT | `Contents: Read-only` on the target repository. `Metadata: Read-only` is included automatically |
| GitHub | Classic PAT | `repo` scope for private repositories. Public repositories require no scope |
| GitLab | PAT | `read_repository` |
| Bitbucket | App password | `Repositories: Read` |
### Configure public repository
For public repositories, no authentication configuration is required. Configure only the repository URL and tracking reference:
```yaml title="values.yaml" wrap theme={null}
dagBundleConfigList: '[{"name": "public-dags", "classpath": "airflow.providers.git.bundles.git.GitDagBundle", "kwargs": {"repo_url": "https://github.com/your-org/public-dags", "tracking_ref": "main", "subdir": "dags"}}]'
```
### Configure private repository
For private repositories, configure both the DAG bundle and an Airflow connection for authentication.
Add an Airflow connection environment variable in `values.yaml`. The connection name suffix must match the `git_conn_id` value in your DAG bundle configuration.
Use this method with a Personal Access Token (PAT) or OAuth token. Set `login` to your Git username and `password` to the token value.
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW_CONN_GIT_REPO
value: >-
{
"conn_type": "git",
"login": "",
"password": "",
"host": "github.com",
"schema": "https",
"extra": {
"repo": "/",
"branch": "main"
}
}
```
See [Required token permissions by provider](#required-token-permissions-by-provider) for the minimum permissions each provider requires.
Use this method with an SSH deploy key. Set `login` to `git` and provide the private key in the `extra` field.
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW_CONN_GIT_REPO
value: >-
{
"conn_type": "git",
"login": "git",
"host": "",
"schema": "ssh",
"extra": {
"private_key": ""
}
}
```
The connection name `AIRFLOW_CONN_GIT_REPO` creates a connection with ID `git_repo`. This ID must match the `git_conn_id` value in your DAG bundle configuration.
For production environments, store connection credentials in a [secrets backend](/docs/astro/remote-execution-configure-secrets-backend) instead of `values.yaml`. See [Use a secrets backend for Git credentials](#use-a-secrets-backend-for-git-credentials) for an example using Azure Key Vault.
Configure the DAG bundle with matching `git_conn_id`:
```yaml title="values.yaml" wrap theme={null}
dagBundleConfigList: '[{"name": "private-dags", "classpath": "airflow.providers.git.bundles.git.GitDagBundle", "kwargs": {"tracking_ref": "main", "subdir": "dags", "repo_url": "https://github.com//.git", "git_conn_id": "git_repo"}}]'
```
Note that `git_conn_id: "git_repo"` matches the connection ID from the `AIRFLOW_CONN_GIT_REPO` environment variable.
Apply the configuration:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
### Configure refresh interval
Control how frequently agents check for repository updates using the `refresh_interval` parameter:
```yaml title="values.yaml" wrap theme={null}
dagBundleConfigList: '[{"name": "private-dags", "classpath": "airflow.providers.git.bundles.git.GitDagBundle", "kwargs": {"repo_url": "https://github.com/your-org/private-dags", "tracking_ref": "main", "subdir": "dags", "git_conn_id": "git_repo", "refresh_interval": 300}}]'
```
The default refresh interval is 300 seconds. Reducing this value across many bundles may increase the risk of hitting Git provider rate limits.
### Use a secrets backend for Git credentials
For production environments, use a secrets backend to store Git connection credentials instead of hardcoding them in `values.yaml`. The following example shows how to configure Azure Key Vault with workload identity authentication on Azure AKS.
Add the secrets backend configuration to your `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
secretBackend: airflow.providers.microsoft.azure.secrets.key_vault.AzureKeyVaultBackend
commonEnv:
- name: AIRFLOW__SECRETS__BACKEND_KWARGS
value: '{"connections_prefix": "airflow-connection", "variables_prefix": "airflow-variable", "vault_url": "", "workload_identity_tenant_id": "", "managed_identity_client_id": ""}'
```
This configuration uses Azure workload identity for authentication, which is the recommended approach for Azure AKS environments. For other authentication methods, see [Azure Key Vault secrets backend](/docs/astro/secrets-backend/azure-key-vault).
Create secrets in Azure Key Vault for each Git connection. The secret name must follow the pattern `-`. For example, to create a connection with ID `git-repo1-conn`:
1. In Azure Key Vault, create a secret named `airflow-connection-git-repo1-conn`.
2. Set the secret value to a JSON connection string:
```json wrap theme={null}
{
"conn_type": "git",
"login": "",
"password": "",
"host": "github.com",
"schema": "https",
"extra": {
"repo": "/",
"branch": "main"
}
}
```
Repeat this process for each Git repository connection you need.
Configure your DAG bundles to reference the connections stored in Azure Key Vault:
```yaml title="values.yaml" wrap theme={null}
dagBundleConfigList: '[
{
"name": "dags-folder",
"classpath": "airflow.providers.git.bundles.git.GitDagBundle",
"kwargs": {
"repo_url": "https://github.com//.git",
"tracking_ref": "main",
"subdir": "dags",
"refresh_interval": 120,
"git_conn_id": "git-repo1-conn"
}
},
{
"name": "dags-folder2",
"classpath": "airflow.providers.git.bundles.git.GitDagBundle",
"kwargs": {
"repo_url": "https://github.com//.git",
"tracking_ref": "main",
"subdir": "dags",
"refresh_interval": 120,
"git_conn_id": "git-repo2-conn"
}
}
]'
```
The `git_conn_id` values must match the connection IDs you created in Azure Key Vault (without the `airflow-connection-` prefix).
Apply the configuration:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
## Configure LocalDagBundle
LocalDagBundle reads dags from the local filesystem. This is the default dag bundle type.
### DAG storage options
Choose one of two methods to provide dags to agents:
**Option 1: Include dags in container image**
Build a custom agent image that includes your DAG files. Copy dags into the `/dags` folder during image build.
**Option 2: Mount Persistent Volume Claim**
Create a PVC containing your dags and mount it into all agent components (Dag Processor, Worker, and Triggerer) at the same path.
### Configure DAG path
LocalDagBundle looks for dags in `/dags` by default. Specify a different path using the `path` parameter:
```yaml title="values.yaml" wrap theme={null}
dagBundleConfigList: '[{"name": "local-dags", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": {"path": "/opt/airflow/dags"}}]'
```
### Configure with container image
Create a Dockerfile extending the base agent image:
```dockerfile title="Dockerfile" wrap theme={null}
FROM images.astronomer.cloud/baseimages/astro-remote-execution-agent:3.1-3-python-3.12-astro-agent-1.2.0
# Copy dags into the image
COPY dags/ /dags/
# Install additional dependencies if needed
COPY requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt
```
Reference your custom image in `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
image: your-registry.example.com/custom-agent:1.0.0
dagProcessor:
image: your-registry.example.com/custom-agent:1.0.0
triggerer:
image: your-registry.example.com/custom-agent:1.0.0
dagBundleConfigList: '[{"name": "local-dags", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": {"path": "/dags"}}]'
```
Apply the configuration:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
### Configure with Persistent Volume Claim
Create a PersistentVolumeClaim in your Kubernetes namespace:
```yaml title="pvc.yaml" wrap theme={null}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dags-pvc
namespace:
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 20Gi
storageClassName:
```
Apply the PVC:
```sh wrap theme={null}
kubectl apply -f pvc.yaml
```
Update `values.yaml` to mount the PVC into all components:
```yaml title="values.yaml" expandable wrap theme={null}
workers:
- name: default-worker
volumes:
- name: dags-volume
persistentVolumeClaim:
claimName: dags-pvc
volumeMounts:
- name: dags-volume
mountPath: /opt/airflow/dags
readOnly: true
dagProcessor:
volumes:
- name: dags-volume
persistentVolumeClaim:
claimName: dags-pvc
volumeMounts:
- name: dags-volume
mountPath: /opt/airflow/dags
readOnly: true
triggerer:
volumes:
- name: dags-volume
persistentVolumeClaim:
claimName: dags-pvc
volumeMounts:
- name: dags-volume
mountPath: /opt/airflow/dags
readOnly: true
dagBundleConfigList: '[{"name": "local-dags", "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle", "kwargs": {"path": "/opt/airflow/dags"}}]'
```
Apply the configuration:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
## GitDagBundle compared to LocalDagBundle
Both bundle types support DAG versioning in the Airflow UI, but GitDagBundle provides additional capabilities:
| Scenario | LocalDagBundle | GitDagBundle |
| ------------------------------------ | ----------------------------------------------- | ----------------------------------------------------- |
| **Viewing previous DAG runs** | Displays DAG as it existed at run time | Displays DAG as it existed at run time |
| **Creating new DAG runs** | Uses current DAG code | Uses current DAG code |
| **Rerunning whole previous DAG run** | Uses current DAG code | Uses DAG version from original run time |
| **Rerunning individual tasks** | Uses latest version for rerun tasks | Uses task code from original run time |
| **Code changes during DAG run** | Uses current DAG code at task start time | Completes using bundle version from run start |
| **Running backfills** | Uses current DAG code | Uses latest bundle version |
| **Version creation** | Every structural DAG change creates new version | Every committed structural change creates new version |
## DAG versioning
Airflow 3 automatically tracks DAG versions when you use DAG bundles. Each DAG run associates with a specific DAG version visible in the Airflow UI.
Key behaviors:
* New versions are created for structural changes (tasks, dependencies, schedules)
* The scheduler uses the latest DAG version to create new runs
* You can view code for any previous DAG version in the UI
* GitDagBundle allows rerunning tasks with their original code version
See [Airflow DAG versioning](/docs/learn/airflow-dag-versioning) for detailed information about versioning behavior.
## Next steps
After configuring DAG sources:
* [Deploy Remote Execution project](/docs/astro/deploy-project-remote-execution) - Build and deploy your Airflow project
* [Configure logging](/docs/astro/remote-execution-logging-overview) - Set up task log collection
* [Configure OpenLineage](/docs/astro/remote-execution-configure-openlineage) - Enable data lineage tracking
## Related documentation
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [DAG versioning documentation](/docs/astro/dag-versioning)
* [Secrets backend configuration](/docs/astro/remote-execution-configure-secrets-backend)
# Configure OpenLineage for a Remote Execution Agent
Source: https://astronomer.io/docs/astro/remote-execution-configure-openlineage
Configure an OpenLineage API key on your Remote Execution Agent so that lineage events flow to Astro Observe and Astro Alerts.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
OpenLineage enables you to access data lineage and provenance across your Airflow workflows for your Remote Execution Agent. Features like [Observe](/docs/astro/astro-observe) and [Astro Alerts](/docs/astro/alerts) require that you enable OpenLineage for your data pipelines.
When you create your Remote Execution Agent, Astro automatically generates a Helm `values.yaml` file with OpenLineage configurations pre-filled. To set up OpenLineage, you need to configure an access credential for OpenLineage. This can be an [Astro Deployment API token](/docs/astro/deployment-api-tokens) used as your OpenLineage API key. There are three methods you can use to add your API key to your Helm values:
* Method 1 - Configure the API key as plain text. This stores your API key in your `values.yaml` file as plaintext, which is the simplest but least secure option. It's appropriate for development or testing environments.
* Method 2 - Use a pre-created Kubernetes secret. This procedure stores your API key separately from your `values.yaml` file, which provides more security than storing as plaintext. This option provides security with standard Kubernetes features.
* Method 3 - Inject your API key with a secrets manager. This approach uses an init container to inject the Agent token into the Remote Execution Agent component Pods. This example uses the [HashiCorp Vault](https://developer.hashicorp.com/vault) Agent, but you can use your own secrets manager. This option provides enhanced security with the potential for secret rotation.
## Prerequisites
* A Kubernetes cluster
* [Helm](https://helm.sh/docs/helm/helm_install/)
* The `values.yaml` file downloaded from the Remote Execution Agent registration modal in the [Astro UI](https://cloud.astronomer.io)
* A [Deployment API Token](/docs/astro/deployment-api-tokens) that uses a [Custom Deployment role](/docs/astro/customize-deployment-roles) with **Observe Ingest** permissions
## Setup
### Step 1: Retrieve your OpenLineage variables
In the [Astro UI](https://cloud.astronomer.io), go to the **Deployment** page and choose **Agent**. Then click **Register Remote Agent**.
#### Download the values file
Click **Download `values.yaml` file**.
The downloaded Helm values file includes most OpenLineage variables pre-filled, so you only need to configure the OpenLineage API key.
### Step 2: Configure the OpenLineage API key
This method stores an Astro [Deployment API token](/docs/astro/deployment-api-tokens) as your OpenLineage API key in plain text in your `values.yaml` file, so that the Remote Execution Agent Helm chart can use it to create a Kubernetes secret named `openlineage-api-key-secret`. This API key is base64-encoded in the Kubernetes secret.
All Remote Execution Agent components — the worker, Dag processor, and triggerer — use this API key to authenticate with the OpenLineage endpoint.
Add the following OpenLineage configuration to your `values.yaml` file:
```yaml title="values.yaml" wrap theme={null}
openLineage:
# Enable OpenLineage integration
enabled: true
# Set your OpenLineage API key directly in the values file
apiKey: ""
# Do NOT set apiKeySecret when using apiKey
# apiKeySecret: ~
# The following fields are prefilled in the values.yaml downloaded from the Astro UI
url: ""
namespace: ""
endpoint: ""
facetsEnvironmentVariables: ''
```
#### Install the Helm chart
Apply the chart using the `values.yaml` file with the following command:
```sh wrap theme={null}
helm install astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
When you use this method, the Remote Execution Agent Helm chart doesn't create a new secret for the OpenLineage API key. Instead, it configures all Agent components — the worker, Dag processor, and triggerer — to use the existing secret to authenticate with the OpenLineage endpoint.
The secret must have a key named `api-key` containing the OpenLineage API key. You can use an Astro [Deployment API token](/docs/astro/deployment-api-tokens) as your OpenLineage API key.
Create a Kubernetes secret containing your OpenLineage API key:
```sh wrap theme={null}
kubectl create secret generic openlineage-api-key-secret \
--from-literal=api-key= \
--namespace
```
#### Reference the secret from your values file
Configure your `values.yaml` file so that OpenLineage uses your pre-created secret:
```yaml title="values.yaml" wrap theme={null}
openLineage:
# Enable OpenLineage integration
enabled: true
# Do NOT set apiKey when using apiKeySecret
# apiKey: ~
# Reference the pre-created secret you created in the previous step
apiKeySecret: "openlineage-api-key-secret"
# The following fields are prefilled in the values.yaml downloaded from the Astro UI
url: ""
namespace: ""
endpoint: ""
facetsEnvironmentVariables: ''
```
#### Install the Helm chart with the referenced secret
Apply the chart using the `values.yaml` file with the following command:
```sh wrap theme={null}
helm install astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
You can also use a secrets manager to securely store your API keys. The following procedure specifically uses the [HashiCorp Vault Agent](https://developer.hashicorp.com/vault/tutorials/vault-agent).
The Vault Agent init container runs before the main Remote Execution Agent container. The Vault Agent authenticates with Vault to retrieve the OpenLineage API key and then writes the API key to a file in the shared volume. The Remote Execution Agent container can then read the OpenLineage API key from the file using the `OPENLINEAGE_API_KEY` environment variable. Use your Astro [Deployment API token](/docs/astro/deployment-api-tokens) as your OpenLineage API key.
Configure OpenLineage and add init containers for the `dagProcessor`, `workers`, and `triggerer` components:
```yaml title="values.yaml" expandable wrap theme={null}
openLineage:
# Enable OpenLineage integration
enabled: true
# Don't set apiKey or apiKeySecret
# apiKey: ~
# apiKeySecret: ~
# The following fields are prefilled in the values.yaml downloaded from the Astro UI
url: ""
namespace: ""
endpoint: ""
facetsEnvironmentVariables: ''
# Configure each component to use the Vault init container
dagProcessor:
initContainers:
- name: vault-openlineage
image: hashicorp/vault:1.13.1
command: ["/bin/sh", "-c"]
args:
- |
export VAULT_ADDR=https://vault.example.com
vault agent -config=/vault/config/agent.hcl
volumeMounts:
- name: vault-config
mountPath: /vault/config
- name: openlineage-volume
mountPath: /vault/secrets
volumes:
- name: vault-config
configMap:
name: vault-agent-config
- name: openlineage-volume
emptyDir:
medium: Memory
volumeMounts:
- name: openlineage-volume
mountPath: /vault/secrets
env:
- name: OPENLINEAGE_API_KEY
valueFrom:
fileRef:
path: /vault/secrets/openlineage-api-key
triggerer:
initContainers:
- name: vault-openlineage
image: hashicorp/vault:1.13.1
command: ["/bin/sh", "-c"]
args:
- |
export VAULT_ADDR=https://vault.example.com
vault agent -config=/vault/config/agent.hcl
volumeMounts:
- name: vault-config
mountPath: /vault/config
- name: openlineage-volume
mountPath: /vault/secrets
volumes:
- name: vault-config
configMap:
name: vault-agent-config
- name: openlineage-volume
emptyDir:
medium: Memory
volumeMounts:
- name: openlineage-volume
mountPath: /vault/secrets
env:
- name: OPENLINEAGE_API_KEY
valueFrom:
fileRef:
path: /vault/secrets/openlineage-api-key
workers:
initContainers:
- name: vault-openlineage
image: hashicorp/vault:1.13.1
command: ["/bin/sh", "-c"]
args:
- |
export VAULT_ADDR=https://vault.example.com
vault agent -config=/vault/config/agent.hcl
volumeMounts:
- name: vault-config
mountPath: /vault/config
- name: openlineage-volume
mountPath: /vault/secrets
volumes:
- name: vault-config
configMap:
name: vault-agent-config
- name: openlineage-volume
emptyDir:
medium: Memory
volumeMounts:
- name: openlineage-volume
mountPath: /vault/secrets
env:
- name: OPENLINEAGE_API_KEY
valueFrom:
fileRef:
path: /vault/secrets/openlineage-api-key
```
#### Create a ConfigMap for the Vault Agent
```sh wrap theme={null}
cat <
data:
agent.hcl: |
auto_auth {
method "kubernetes" {
mount_path = "auth/kubernetes"
config = {
role = "astro-agent"
}
}
}
template {
destination = "/vault/secrets/openlineage-api-key"
contents = "{{ with secret \"secret/data/openlineage/api-key\" }}{{ .Data.data.key }}{{ end }}"
}
EOF
```
#### Install the Helm chart with the Vault Agent
Apply the chart with the `values.yaml` file:
```sh wrap theme={null}
helm install astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
Read more about [secrets backends on Astro](/docs/astro/secrets-backend).
### Step 3: Set OpenLineage environment variables on the orchestration plane
In the Astro UI, open your Deployment.
#### Open the Environment tab
Click the **Environment** tab.
#### Add the OpenLineage variable
Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet), then click **Add Variable** and add the following environment variable:
```sh wrap theme={null}
OPENLINEAGE_DISABLED=False
```
#### Apply changes
Click **Update Environment Variables** to save your changes.
Setting this variable ensures that all required OpenLineage events, including task and Dag run events, are collected from the scheduler, workers, Dag processor, and triggerer components. This provides complete lineage in Observe and Astro Alerts.
# Configure secrets backend
Source: https://astronomer.io/docs/astro/remote-execution-configure-secrets-backend
Configure AWS, Azure, GCP, or HashiCorp secrets backends for Remote Execution Agents.
Remote Execution Agents require a secrets backend to securely access Airflow connections and variables. A secrets backend stores sensitive information like passwords, API keys, and database credentials outside of your Deployment and agent configuration files.
`secretBackend` is the Airflow secrets backend class to use for the Agent. Each supported integration includes the Remote Execution Agent-specific implementation steps:
* [AWS Secrets Manager](/docs/astro/secrets-backend/aws-secretsmanager#remote-execution)
* [AWS Systems Manager (SSM) Parameter Store](/docs/astro/secrets-backend/aws-paramstore#remote-execution)
* [Azure Key Vault](/docs/astro/secrets-backend/azure-key-vault#remote-execution)
* [Google Cloud Secret Manager](/docs/astro/secrets-backend/gcp-secretsmanager#remote-execution)
* [HashiCorp Vault](/docs/astro/secrets-backend/hashicorp-vault#remote-execution)
It is not recommended for production use cases, but you can also use Airflow’s local filesystem backend as a simpler alternative to an external secrets provider by setting:
```yaml title="values.yaml" wrap theme={null}
secretBackend: "airflow.secrets.local_filesystem.LocalFilesystemBackend"
```
and setting the following environment variable in the Remote Execution Agent's Helm chart:
```yaml title="values.yaml" wrap theme={null}
AIRFLOW__SECRETS__BACKEND_KWARGS: '{"variables_file_path": "/files/var.json", "connections_file_path": "/files/conn.json"}'
```
The rest of the configuration should be passed as environment variables to the Agent components.
# Configure state store backend
Source: https://astronomer.io/docs/astro/remote-execution-configure-state-store-backend
Configure the state store backend that Remote Execution Agents use to store task and asset state on Astro Runtime 3.3 and later.
Starting with Airflow 3.3 (Astro Runtime 3.3), tasks and asset watchers can persist state between runs through the Airflow worker-side state store. Remote Execution Agents store this state in a backend that you control, so it stays in your execution plane. This guide covers the default configuration that the Remote Execution Agent Helm chart applies and how to configure object storage for production.
## Overview
Airflow 3.3 introduces a worker-side state store that tasks and asset watchers use to persist small state values between runs. For example, an asset watcher uses it to track its position in an event stream. By default, Airflow stores this state in the metadata database. With Remote Execution, the metadata database resides in the Astro orchestration plane, so a custom state store backend keeps the data in storage that you control instead. This is the same pattern as the [XCom backend](/docs/astro/remote-execution-configure-xcom-backend).
Agent Client 1.8.0 and later enforce this on Astro Runtime 3.3 and later images: agents don't start until you set the `AIRFLOW__WORKERS__STATE_STORE_BACKEND` environment variable. Runtime versions earlier than 3.3 don't include the state store, and agents apply no state store configuration there.
## Prerequisites
* Remote Execution Agent Helm chart 2.3.0 or later. For earlier chart versions, see [Configure the backend on chart versions earlier than 2.3.0](#configure-the-backend-on-chart-versions-earlier-than-2-3-0).
* For production use, an object storage bucket and workload identity configured for your Kubernetes cluster, as described in [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend).
## Default configuration
Remote Execution Agent Helm chart 2.3.0 and later configure the state store backend automatically. The `stateStoreBackend` value defaults to the object storage backend from the Common IO provider:
```yaml title="values.yaml" wrap theme={null}
stateStoreBackend: airflow.providers.common.io.state_store.backend.StateStoreObjectStorageBackend
```
The chart sets `AIRFLOW__WORKERS__STATE_STORE_BACKEND` to this class on every agent component. If you don't configure a storage path yourself, the chart also applies a local file path default:
```text wrap theme={null}
AIRFLOW__COMMON_IO__STATE_STORE_OBJECTSTORAGE_PATH=file:///usr/local/airflow/state-store
```
**Local path default is for evaluation only**
With the local file path, each agent Pod writes state to its own container filesystem: state isn't shared between Pods and doesn't survive Pod restarts. Configure shared object storage for production deployments.
## Configure object storage for production
Point the state store at shared object storage by setting the storage path in `commonEnv`:
```yaml title="values.yaml" wrap theme={null}
stateStoreBackend: airflow.providers.common.io.state_store.backend.StateStoreObjectStorageBackend
commonEnv:
- name: AIRFLOW__COMMON_IO__STATE_STORE_OBJECTSTORAGE_PATH
value: "s3://@/"
```
The path format and authentication follow the same patterns as the XCom backend, and you can reuse the same bucket and connection with a different path prefix. See [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend) for cloud-specific instructions for AWS S3, Azure Blob Storage, and GCP Cloud Storage, including bucket setup, workload identity, and connection configuration.
After updating your values, apply the configuration:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
## Configure the backend on chart versions earlier than 2.3.0
Helm chart versions earlier than 2.3.0 don't include the `stateStoreBackend` value. Before you move agents to a Runtime 3.3 image, either upgrade to chart 2.3.0 or later, or set the environment variables on all agent components through `commonEnv`:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__WORKERS__STATE_STORE_BACKEND
value: "airflow.providers.common.io.state_store.backend.StateStoreObjectStorageBackend"
- name: AIRFLOW__COMMON_IO__STATE_STORE_OBJECTSTORAGE_PATH
value: "s3://@/"
```
## Custom backend classes
If you use a different state store backend class, set `stateStoreBackend` to your class and configure its settings through `commonEnv`. The chart only applies the local path default for the object storage backend.
## Verify configuration
After applying your configuration:
1. Confirm all agent Pods start successfully. On Runtime 3.3 images, an agent fails to start with a validation error if `AIRFLOW__WORKERS__STATE_STORE_BACKEND` isn't set.
2. Trigger a Dag that uses the state store, for example through an asset watcher.
3. Verify that state objects appear under your configured storage path.
## Next steps
* [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend) - Object storage for passing data between tasks
* [Configure Dag sources](/docs/astro/remote-execution-configure-dag-sources) - Define how agents access Dag code
## Related documentation
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference)
* [Remote Execution Agent release notes](/docs/astro/agent-release-notes)
# Configure XCom backend
Source: https://astronomer.io/docs/astro/remote-execution-configure-xcom-backend
Configure AWS S3, Azure Blob Storage, or GCP Cloud Storage as the XCom backend for Remote Execution.
Remote Execution Agents require a custom XCom backend to pass data between tasks. This guide covers configuring AWS S3, Azure Blob Storage, or GCP Cloud Storage as your XCom backend.
## Overview
XCom (cross-communication) enables data exchange between Airflow tasks. By default, Airflow stores XCom values in the metadata database. With Remote Execution, the metadata database resides in the Astro orchestration plane while agents execute tasks in your infrastructure.
A custom XCom backend stores XCom data in object storage accessible to all agents in your execution plane. This allows tasks running on different agents to share data through a common storage location.
**XCom limitations with callbacks**
In Airflow 3, XCom values are stored externally in storage backends. The database only holds the location of each XCom value, and retrieving the actual XCom data requires a call to the execution API with a valid task token.
Currently, callbacks do not receive a task token, so they cannot retrieve XCom values from external backends. As a result, using XCom in callbacks is not supported at this time when using Remote Execution with custom XCom backends.
**XCom support in triggers**
XCom triggerer support is enabled with Agent Client 1.5.0+. Triggers running on the agent can retrieve and push XCom values when using a compatible client version.
## Prerequisites
* Remote Execution Agent installed and registered
* Object storage bucket in your cloud provider
* Workload identity configured for your Kubernetes cluster (IRSA for AWS, Managed Identity for Azure, Workload Identity for GCP)
* Required Python packages installed in your agent image (see cloud-specific sections below)
## Configure XCom backend
All XCom backend configurations use the `XComObjectStorageBackend` class from the Common IO provider. Choose your cloud provider below for specific configuration instructions.
### Prerequisites (AWS S3)
The Remote Execution Agent image must include these Python packages:
* `apache-airflow-providers-amazon`
* `apache-airflow-providers-common-io`
* `s3fs`
### Create S3 bucket
Create an S3 bucket for XCom storage with the following recommended settings:
* **Versioning**: Enable for data recovery
* **Encryption**: Enable server-side encryption (SSE-S3 or SSE-KMS)
* **Lifecycle policy**: Configure automatic deletion of old XCom objects
### Configure IAM role
Create an IAM role with permissions to read and write to your XCom bucket. Attach this policy to the role:
```json wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::your-xcom-bucket",
"arn:aws:s3:::your-xcom-bucket/*"
]
}
]
}
```
Configure the trust relationship to allow your Kubernetes service accounts to assume the role. See [AWS IRSA documentation](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) for details.
### Update Helm values (AWS S3)
Update your agent's `values.yaml` file with the XCom backend configuration:
```yaml title="values.yaml" wrap theme={null}
xcomBackend: "airflow.providers.common.io.xcom.backend.XComObjectStorageBackend"
commonEnv:
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_PATH
value: "s3://@/"
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_THRESHOLD
value: "0" # Always store XComs in object storage
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_COMPRESSION
value: "zip"
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam:::role/
```
Replace:
* ``: Airflow connection ID for S3 (for example, `aws_xcom`)
* ``: Your S3 bucket name
* ``: Path prefix for XCom objects (for example, `xcom`)
* ``: Your AWS account ID
* ``: IAM role name created above
### Configure the AWS connection
The `` in the XCom path must correspond to a configured Airflow connection. You can define this connection directly in `values.yaml` or through a secrets backend.
Add an `AIRFLOW_CONN_` environment variable to `commonEnv` in your `values.yaml`. The suffix after `AIRFLOW_CONN_` becomes the connection ID. For example, `AIRFLOW_CONN_AWS_XCOM` creates a connection with ID `aws_xcom`:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW_CONN_AWS_XCOM
value: '{"conn_type":"aws"}'
```
Because the agent uses IRSA for authentication, you don't need to specify explicit credentials in the connection. The IAM role annotation on the pod provides access to S3 automatically.
For production environments, store the connection in a [secrets backend](/docs/astro/remote-execution-configure-secrets-backend) instead of `values.yaml`. See [Set up AWS Secrets Manager as your secrets backend](/docs/astro/secrets-backend/aws-secretsmanager#remote-execution) or [Set up AWS Systems Manager Parameter Store as your secrets backend](/docs/astro/secrets-backend/aws-paramstore#remote-execution) for configuration steps.
When using a secrets backend, create a secret that matches your connection ID. For example, if your XCom path uses `aws_xcom` as the connection ID, store the connection under the path corresponding to `aws_xcom` in your secrets backend.
### Apply configuration (AWS S3)
Update your Helm release:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
### Prerequisites (Azure Blob Storage)
The Remote Execution Agent image must include these Python packages:
* `apache-airflow-providers-microsoft-azure`
* `apache-airflow-providers-common-io`
### Create storage account and container
Create an Azure Storage account and container for XCom storage:
1. Create a storage account with these recommended settings:
* **Performance**: Standard
* **Replication**: Locally-redundant storage (LRS) or higher
* **Secure transfer**: Required
2. Create a container named `xcom` (or your preferred name)
3. Note the storage account name
### Configure managed identity
Create a managed identity and grant it access to your storage account:
1. Create a managed identity in Azure
2. Assign the **Storage Blob Data Contributor** role to the managed identity on your storage account
3. Configure workload identity federation to allow your Kubernetes service accounts to use the managed identity
See [Azure Workload Identity documentation](https://learn.microsoft.com/en-us/azure/aks/workload-identity-overview) for details.
### Update Helm values (Azure Blob Storage)
Update your agent's `values.yaml` file with the XCom backend configuration:
```yaml title="values.yaml" wrap theme={null}
xcomBackend: "airflow.providers.common.io.xcom.backend.XComObjectStorageBackend"
commonEnv:
- name: AIRFLOW_CONN_WASB_XCOM
value: '{"conn_type":"azure","login":"","extra":"{\"anon\": false, \"account_name\":\"\",\"managed_identity_client_id\":\"\",\"workload_identity_tenant_id\":\"\"}"}'
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_PATH
value: "abfs://wasb_xcom@/"
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_THRESHOLD
value: "0" # Always store XComs in object storage
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_COMPRESSION
value: "zip"
labels:
azure.workload.identity/use: "true"
annotations:
azure.workload.identity/client-id: ""
```
Replace:
* ``: Your Azure storage account name
* ``: Client ID of your managed identity
* ``: Your Azure tenant ID
* ``: Container name (e.g., `xcom`)
* ``: Path prefix for XCom objects
### Apply configuration (Azure Blob Storage)
Update your Helm release:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
### Prerequisites (GCP Cloud Storage)
The Remote Execution Agent image must include these Python packages:
* `apache-airflow-providers-google`
* `apache-airflow-providers-common-io`
* `gcsfs`
### Create GCS bucket
Create a GCS bucket for XCom storage with the following recommended settings:
* **Location type**: Region or Multi-region based on your requirements
* **Storage class**: Standard
* **Access control**: Uniform (bucket-level permissions)
* **Encryption**: Google-managed or customer-managed encryption keys
### Configure IAM service account
Create a GCP service account and grant it access to your GCS bucket:
1. Create a service account in your GCP project
2. Grant the service account the **Storage Object Admin** role (`roles/storage.objectAdmin`) on your GCS bucket
3. Configure Workload Identity to allow your Kubernetes service accounts to use the GCP service account
To link your Kubernetes service account (KSA) to your GCP service account (GSA):
```sh wrap theme={null}
gcloud iam service-accounts add-iam-policy-binding @.iam.gserviceaccount.com \
--role roles/iam.workloadIdentityUser \
--member "serviceAccount:.svc.id.goog[/]"
```
See [GKE Workload Identity documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) for details.
### Update Helm values (GCP Cloud Storage)
Update your agent's `values.yaml` file with the XCom backend configuration:
```yaml title="values.yaml" wrap theme={null}
xcomBackend: "airflow.providers.common.io.xcom.backend.XComObjectStorageBackend"
commonEnv:
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_PATH
value: "gs:///"
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_THRESHOLD
value: "0" # Always store XComs in object storage
- name: AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_COMPRESSION
value: "zip"
annotations:
iam.gke.io/gcp-service-account: @.iam.gserviceaccount.com
```
Replace:
* ``: Your GCS bucket name
* ``: Path prefix for XCom objects (e.g., `xcom`)
* ``: Your GCP service account name
* ``: Your GCP project ID
### Apply configuration (GCP Cloud Storage)
Update your Helm release:
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
## Configuration options
### XCom path format
The `AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_PATH` parameter defines where XCom objects are stored:
```text wrap theme={null}
://@/
```
* **protocol**: `s3://` for AWS, `abfs://` for Azure, `gs://` for GCP
* **connection-id**: Airflow connection ID for authentication
* **bucket-or-container**: Storage bucket or container name
* **path-prefix**: Optional path prefix for organizing XCom objects
### XCom threshold
The `AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_THRESHOLD` parameter controls when XCom values are stored in object storage:
* `0`: Always store in object storage (recommended for Remote Execution)
* `>0`: Store in object storage only if value size exceeds threshold in bytes
Set this to `0` to ensure all XCom values are accessible to remote agents.
### Compression
The `AIRFLOW__COMMON_IO__XCOM_OBJECTSTORAGE_COMPRESSION` parameter controls compression:
* `zip`: Compress XCom values (recommended)
* `None`: No compression
Compression reduces storage costs and transfer time for large XCom values.
## Verify configuration
After applying your configuration, verify XCom backend functionality:
1. Trigger a test DAG that uses XCom to pass data between tasks
2. Check that tasks complete successfully
3. Verify XCom objects appear in your storage bucket
4. Review agent logs for any XCom-related errors
## Next steps
After configuring XCom backend:
* [Configure secrets backend](/docs/astro/remote-execution-configure-secrets-backend) - Store Airflow connections and variables securely
* [Configure state store backend](/docs/astro/remote-execution-configure-state-store-backend) - Store task and asset state on Astro Runtime 3.3 and later
* [Configure dag sources](/docs/astro/remote-execution-configure-dag-sources) - Define how agents access DAG code
* [Configure logging](/docs/astro/remote-execution-logging-overview) - Export task logs to external platforms
## Related documentation
* [XCom backend strategies](/docs/learn/custom-xcom-backend-strategies)
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference)
# Set up custom timetable support for Remote Execution
Source: https://astronomer.io/docs/astro/remote-execution-custom-timetables
Configure the scheduler to access your secrets backend when using custom timetables on Remote Execution.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
When Dags use custom timetables that connect to external data sources, such as querying Snowflake for scheduling metadata, the scheduler must retrieve connection credentials from your secrets backend at schedule time.
When you [configure Customer Managed Identity](/docs/astro/authorize-deployments-to-your-cloud) for a Remote Execution Deployment, the setup only authorizes the apiserver to access your cloud resources for reading task logs. To support custom timetables, the scheduler also needs authorization to access your secrets backend.
Without this configuration, the scheduler can't retrieve connections from the secrets backend, causing errors like:
```text wrap theme={null}
airflow.exceptions.AirflowNotFoundException: The conn_id `` isn't defined
```
## Prerequisites
* A Remote Execution Deployment with [Customer Managed Identity configured](/docs/astro/authorize-deployments-to-your-cloud).
* A [secrets backend configured](/docs/astro/remote-execution-configure-secrets-backend) for your Remote Execution Agent.
## Authorize the scheduler
Extend your existing Customer Managed Identity configuration to include the scheduler service account. This is the same process used when you first configured workload identity for the apiserver.
No additional configuration is required. The default Customer Managed Identity setup for AWS uses a wildcard pattern in the IAM trust policy that authorizes all service accounts in the Deployment namespace, including the scheduler:
```json wrap theme={null}
":sub": "system:serviceaccount::*"
```
If you specified individual service accounts instead of using a wildcard, add the scheduler service account to your IAM trust policy:
```json wrap theme={null}
":sub": "system:serviceaccount::-scheduler-serviceaccount"
```
The Customer Managed Identity setup for GCP authorizes only the apiserver by default. Run the following command to add the scheduler:
```sh wrap theme={null}
gcloud iam service-accounts add-iam-policy-binding \
--role roles/iam.workloadIdentityUser \
--member "serviceAccount:.svc.id.goog[/-scheduler-serviceaccount]" \
@.iam.gserviceaccount.com \
--project
```
Replace the following values:
* ``: The GCP project ID of the GKE cluster running your Remote Execution Agent
* ``: Your Deployment's Kubernetes namespace
* ``: The GCP service account configured as your Deployment's Customer Managed Identity
* ``: The GCP project containing your service account
Use the same values from the command you ran when configuring Customer Managed Identity for the apiserver.
The Customer Managed Identity setup for Azure creates federated identity credentials only for the apiserver by default. Run the following command to add the scheduler:
```sh wrap theme={null}
az identity federated-credential create \
--name -scheduler \
--identity-name \
--resource-group \
--issuer \
--subject system:serviceaccount::-scheduler-serviceaccount
```
Replace the following values:
* ``: Your Deployment's Kubernetes namespace
* ``: Name of your user-assigned managed identity
* ``: Resource group containing your managed identity
* ``: The OIDC issuer URL for your AKS cluster, available in the **Customer Managed Identity** modal in the Astro UI
Use the same `--identity-name`, `--resource-group`, and `--issuer` values from the command you ran when configuring Customer Managed Identity for the apiserver.
## Verify the configuration
After updating your workload identity configuration, verify that the scheduler can retrieve connections:
1. Check the scheduler logs for authentication errors. Cloud-specific errors such as `AADSTS700213: No matching federated identity record found` (Azure) or `AccessDenied` (AWS/GCP) should no longer appear.
2. Trigger a Dag that uses a custom timetable dependent on a connection from your secrets backend. The Dag should schedule without `AirflowNotFoundException` errors.
## See also
* [Authorize an Astro Deployment to cloud resources using workload identity](/docs/astro/authorize-deployments-to-your-cloud)
* [Configure secrets backend for Remote Execution](/docs/astro/remote-execution-configure-secrets-backend)
# Deploy a dbt project to Remote Execution Agents
Source: https://astronomer.io/docs/astro/remote-execution-deploy-dbt
Learn how to make dbt project files available to Remote Execution Agents so that Cosmos can orchestrate dbt models as Airflow tasks.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Remote Execution Agents run tasks in your own Kubernetes infrastructure. Because Remote Execution mode doesn't support `astro dbt deploy`, you must make your dbt project files available to agents through other methods.
This document covers two approaches for deploying dbt code to Remote Execution Agents, ordered by Astronomer's recommendation.
## Prerequisites
* A [Remote Execution Deployment](/docs/astro/remote-execution-overview) with at least one registered [agent](/docs/astro/remote-execution-configure-agents).
* A [secrets backend](/docs/astro/remote-execution-configure-secrets-backend) and [XCom backend](/docs/astro/remote-execution-configure-xcom-backend) configured for your agents.
* A dbt project in a Git repository.
* [Cosmos](https://astronomer.github.io/astronomer-cosmos/) installed in your agent client image for orchestrating dbt models.
## Option 1: Include the dbt project as a Git submodule (recommended)
Use Git submodules to include an external dbt project repository inside your Dag repository. This approach keeps your dbt and Airflow code in separate repositories while combining them at deploy time.
This is the recommended approach because it:
* Preserves separation of ownership between dbt and Airflow teams.
* Pins the dbt project to a specific commit, giving you control over which version of dbt code runs.
* Works with `GitDagBundle` for automatic Dag versioning.
### How it works
Your Dag repository includes the dbt project as a Git submodule. When agents fetch the Dag bundle from Git, the submodule contents are fetched alongside your Dags. Cosmos then reads the dbt project from the submodule folder to orchestrate dbt models as Airflow tasks.
### Configure the Dag repository
From your Dag repository root, run:
```sh wrap theme={null}
git submodule add dbt/
```
For example, to add a dbt project called `jaffle-shop`:
```sh wrap theme={null}
git submodule add https://github.com/your-org/jaffle-shop dbt/jaffle-shop
```
This creates a `.gitmodules` file and clones the dbt repository into the `dbt/jaffle-shop` folder.
Your Dag repository should look similar to the following:
```text wrap theme={null}
dag-repo/
├── .gitmodules
├── dags/
│ └── dbt_dag.py
└── dbt/
└── jaffle-shop/ # Git submodule
├── models/
├── seeds/
└── dbt_project.yml
```
Create a Dag that uses Cosmos to orchestrate the dbt project. Set the `dbt_project_path` to reference the submodule location within the Dag bundle:
```python title="dags/dbt_dag.py" wrap theme={null}
from cosmos import DbtDag, ProjectConfig, ProfileConfig, ExecutionConfig
from pathlib import Path
from datetime import datetime
dbt_dag = DbtDag(
project_config=ProjectConfig(
dbt_project_path=Path("/usr/local/airflow/dags/dbt/jaffle-shop"),
),
profile_config=ProfileConfig(
profile_name="jaffle_shop",
target_name="dev",
profiles_yml_filepath=Path("/usr/local/airflow/dags/dbt/jaffle-shop/profiles.yml"),
),
execution_config=ExecutionConfig(
dbt_executable_path="/home/astro/dbt_venv/bin/dbt",
),
schedule="@daily",
start_date=datetime(2024, 1, 1),
catchup=False,
dag_id="dbt_jaffle_shop",
)
```
The exact path depends on your `GitDagBundle` configuration. If your bundle uses a `subdir` parameter, adjust the path accordingly.
```sh wrap theme={null}
git add .gitmodules dbt/jaffle-shop dags/dbt_dag.py
git commit -m "Add dbt project as submodule with Cosmos DAG"
git push
```
### Configure agents to fetch submodules
By default, `GitDagBundle` does not recursively fetch Git submodules. You must configure the `git_conn_id` connection to include submodule support and ensure the agent can authenticate to the submodule repository.
If the dbt submodule repository uses the same authentication as the Dag repository, configure the Dag bundle with the same `git_conn_id`. If the submodule is in a public repository, no additional authentication is required.
For private submodule repositories that require separate credentials, configure an additional Git connection in your secrets backend or `values.yaml`.
### Update the dbt submodule
When the dbt team pushes new changes, update the submodule reference in your Dag repository:
```sh wrap theme={null}
git submodule update --remote dbt/jaffle-shop
git add dbt/jaffle-shop
git commit -m "Update jaffle-shop submodule to latest"
git push
```
Agents pick up the change on the next `GitDagBundle` refresh cycle.
For more information about working with Git submodules in an Astro context, see [Use Git submodules with an Astro project](/docs/astro/best-practices/git-submodules).
## Option 2: Include dbt code in the agent client image
Build the dbt project directly into your custom agent client image. This approach works well when dbt code changes infrequently and you want a self-contained image.
Extend the base agent image to include your dbt project and dependencies:
```dockerfile title="Dockerfile.client" wrap theme={null}
FROM images.astronomer.cloud/baseimages/astro-remote-execution-agent:3.1-3-python-3.12-astro-agent-1.2.0
# Install dbt into a virtual environment
RUN python -m venv /home/astro/dbt_venv && \
source /home/astro/dbt_venv/bin/activate && \
pip install --no-cache-dir dbt-postgres && \
deactivate
# Install Cosmos
RUN pip install astronomer-cosmos
# Copy dbt project into the image
COPY dbt/jaffle-shop /usr/local/airflow/dbt/jaffle-shop
```
```sh wrap theme={null}
docker build -f Dockerfile.client -t your-registry.example.com/custom-agent:1.0.0 .
docker push your-registry.example.com/custom-agent:1.0.0
```
Reference the custom image in your `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
workers:
- name: default-worker
image: your-registry.example.com/custom-agent:1.0.0
dagProcessor:
image: your-registry.example.com/custom-agent:1.0.0
triggerer:
image: your-registry.example.com/custom-agent:1.0.0
```
```sh wrap theme={null}
helm upgrade astro-agent astronomer/astro-remote-execution-agent -f values.yaml
```
This approach requires rebuilding and redeploying the agent image every time dbt code changes. For teams that update dbt models frequently, consider Option 1 instead.
## Compare approaches
| Criteria | Git submodule | Agent image |
| --------------------------------------------- | :-----------: | :--------------------: |
| dbt and Airflow code in separate repositories | Yes | Yes |
| Independent dbt deploy cycle | Partial | No |
| Works with `GitDagBundle` versioning | Yes | No |
| Requires image rebuild for dbt changes | No | Yes |
| Additional infrastructure | None | None |
| Best for | Most teams | Infrequent dbt changes |
## Related documentation
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [Configure Dag sources](/docs/astro/remote-execution-configure-dag-sources)
* [Deploy Remote Execution project](/docs/astro/deploy-project-remote-execution)
* [Deploy dbt projects to Astro](/docs/astro/deploy-dbt-project)
* [Use Git submodules with an Astro project](/docs/astro/best-practices/git-submodules)
* [Orchestrate dbt Core jobs with Airflow and Cosmos](/docs/learn/airflow-dbt)
# Get started with Remote Execution
Source: https://astronomer.io/docs/astro/remote-execution-get-started
Set up Remote Execution on Astro with this prerequisite checklist and step-by-step setup guide.
This guide provides everything you need to set up Remote Execution on Astro, including prerequisites, configuration requirements, and a step-by-step checklist.
## What you'll configure
Remote Execution requires both required and optional components. Understand what you need before starting setup.
### Required components
You must configure these components for Remote Execution to function:
| Component | Purpose | When configured |
| --------------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| **Remote Execution Agents** | Execute Airflow tasks in your infrastructure | [Register and configure agents](/docs/astro/remote-execution-configure-agents) |
| **Secrets Backend** | Securely store and access Airflow connections and variables | [Configure secrets backend](/docs/astro/remote-execution-configure-secrets-backend) |
| **XCom Backend** | Pass data between tasks using object storage | [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend) |
| **State Store Backend** | Store task and asset state on Astro Runtime 3.3 and later | [Configure state store backend](/docs/astro/remote-execution-configure-state-store-backend) |
| **Dag sources** | Define how agents access Dag code (Git or local) | [Configure Dag sources](/docs/astro/remote-execution-configure-dag-sources) |
All required components must be configured before agents can successfully execute tasks. The setup checklist below provides the recommended order.
### Recommended components
| Component | Purpose | Documentation |
| ------------ | ----------------------------------------------------------------- | ------------------------------------------------ |
| **Sentinel** | Monitor agent health and report status to the orchestration plane | [Enable Sentinel](/docs/astro/remote-agents-sentinel) |
### Optional components
These components enhance functionality but aren't required for basic operation:
| Component | Purpose | Documentation |
| ---------------------- | -------------------------------------------------------- | ---------------------------------------------------------------------- |
| **Logging** | Export task logs to external platforms or object storage | [Configure logging](/docs/astro/remote-execution-logging-overview) |
| **OpenLineage** | Enable data lineage and observability in Astro Observe | [Configure OpenLineage](/docs/astro/remote-execution-configure-openlineage) |
| **AWS PrivateLink** | Enable private connectivity between agents and Astro | [Configure AWS PrivateLink](/docs/astro/remote-agents-aws-privatelink) |
| **Azure Private Link** | Enable private connectivity between agents and Astro | [Configure Azure Private Link](/docs/astro/remote-agents-azure-privatelink) |
## Setup
Follow these steps in order to set up Remote Execution:
### 1. Meet prerequisites
Before you begin, ensure you have:
* An Astro Deployment configured for Remote Execution mode. See [Create a deployment](/docs/astro/create-deployment).
* Kubernetes 1.30 or later
**Recommended Kubernetes configuration**
Configure `singleProcessOOMKill: true` in your kubelet configuration. With this setting,
Kubernetes kills only the process that runs out of memory instead of the entire Pod. Without it, one task's
out-of-memory error kills all tasks on the worker and loses all task logs.
See [Kubernetes documentation](https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/) for details.
* Helm 3 or later
* Permissions to create Astro agents
* A Deployment API token with Deployment Admin permissions
* Network access from your Kubernetes cluster to Astro. Add `https://.external.astronomer.run/` to your organization's allowlist. To find your cluster ID, go to **Settings** > **Clusters** in the Astro UI.
### 2. Register and configure agents
Install the Remote Execution Agent Helm chart in your Kubernetes cluster:
1. Create an Agent Token in the Astro UI
2. Download and configure the `values.yaml` file
3. Install the Helm chart with your configuration
4. Verify agent heartbeat in the Astro UI
See [Register and configure agents](/docs/astro/remote-execution-configure-agents).
### 3. Configure secrets backend
Configure a secrets backend so agents can access Airflow connections and variables:
* AWS Secrets Manager
* Azure Key Vault
* Google Cloud Secret Manager
* HashiCorp Vault
See [Configure secrets backend](/docs/astro/remote-execution-configure-secrets-backend).
### 4. Configure XCom backend
Configure object storage for passing data between tasks:
* AWS S3
* Azure Blob Storage
* GCP Cloud Storage
See [Configure XCom backend](/docs/astro/remote-execution-configure-xcom-backend).
### 5. Configure Dag sources
Define how agents access your Dag code:
* **GitDagBundle** (recommended): Dags in a Git repository with automatic versioning
* **LocalDagBundle**: Dags in container images or persistent volumes
See [Configure DAG sources](/docs/astro/remote-execution-configure-dag-sources).
### 6. Enable Sentinel
Enable Sentinel to monitor agent health and report status to the orchestration plane. Sentinel detects Pod and component issues and monitors essential integrations such as XCom and secrets backends.
See [Sentinel for Remote Execution Agents](/docs/astro/remote-agents-sentinel).
### 7. Optionally configure logging
Set up task log export to view logs in external platforms or the Airflow UI:
* Export logs with a logging sidecar
* Link Airflow UI to external logging platform
* Show logs in Airflow UI from object storage
See [Configure logging](/docs/astro/remote-execution-logging-overview).
### 8. Deploy your project
Deploy your Airflow project to the Remote Execution deployment:
1. Initialize a Remote Execution project with Astro CLI
2. Build and push the server image (orchestration plane)
3. Build and push client images (execution plane)
4. Update agents to use the new client image
See [Deploy a Remote Execution project](/docs/astro/deploy-project-remote-execution).
### 9. Verify agents are running
Confirm agents are healthy and processing tasks:
1. Check agent heartbeat status in the Astro UI
2. View agent Pods in your Kubernetes cluster
3. Trigger a test Dag run and verify task execution
4. Check task logs to confirm logging configuration
## Next steps
After completing setup:
* [Configure OpenLineage](/docs/astro/remote-execution-configure-openlineage) to enable data lineage and Astro Observe features
## Related documentation
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [Execution modes](/docs/astro/execution-mode)
* [Helm chart configuration reference](/docs/astro/remote-agents-helm-reference)
# Configure logging
Source: https://astronomer.io/docs/astro/remote-execution-logging-overview
Compare logging options for Remote Execution Agents, including sidecars and object storage.
Remote Execution Agents generate task logs in your Kubernetes cluster. By default, these logs remain in agent Pods and are lost when Pods terminate. Configure logging to preserve and access these logs.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
## Logging approaches
### External logging provider (recommended)
Export logs to your logging platform (Splunk, Elasticsearch, CloudWatch, etc.) using a logging sidecar. Configure the Airflow UI to display links to external logs.
* See [Configure logging sidecar](/docs/astro/remote-agents-logging-sidecar)
* See [Export logs to external platforms](/docs/astro/remote-task-logs-external)
### Object storage (Airflow UI display)
Store logs in object storage (S3, GCS, Azure Blob) and configure the Astro API server to fetch and display them in the Airflow UI. Logs appear after task completion.
* See [Display logs in Airflow UI](/docs/astro/remote-task-logs-af-ui)
### Real-time streaming to object storage
Extend object storage logging with a Vector sidecar to stream partial logs while tasks run. Provides real-time log visibility in the Airflow UI.
* See [Display logs in Airflow UI](/docs/astro/remote-task-logs-af-ui#display-task-logs-during-task-execution)
## Comparison
| Feature | External Logging | Object Storage | Real-Time Streaming |
| -------------------- | ------------------------- | ----------------------- | ------------------------- |
| **Data location** | Your logging platform | Your object storage | Your object storage |
| **UI experience** | Link to external platform | View in Airflow UI | View in Airflow UI (live) |
| **Log availability** | Near real-time | After task completion | During task execution |
| **Setup complexity** | Medium | Medium | High |
| **Storage costs** | Platform-dependent | Standard object storage | Higher (many small files) |
## Prerequisites
* Remote Execution Agent installed and registered
* Workload identity configured for your Kubernetes cluster
* One of the following:
* **External logging**: Logging platform endpoint
* **Object storage**: S3, GCS, or Azure Blob container
* **Real-time streaming**: Object storage + Vector configuration
## Next steps
* [Configure logging sidecar](/docs/astro/remote-agents-logging-sidecar)
* [Export logs to external platforms](/docs/astro/remote-task-logs-external)
* [Display logs in Airflow UI](/docs/astro/remote-task-logs-af-ui)
# Remote Execution overview
Source: https://astronomer.io/docs/astro/remote-execution-overview
Run Airflow tasks in your own Kubernetes infrastructure while Astro manages orchestration.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
Remote Execution is an execution mode on Astro that separates task execution from orchestration. With Remote Execution, you run Airflow tasks in your own Kubernetes infrastructure while Astro manages the orchestration components in the cloud. Use Remote Execution to keep your data and code within your own infrastructure for security or compliance requirements.
## How Remote Execution works
Remote Execution uses a decoupled architecture with two planes:
**Orchestration plane (Astro-managed)**
The orchestration plane runs in Astro's cloud infrastructure and includes:
* **Scheduler**: Determines when dags and tasks should run
* **Web Server/API Server**: Provides the Airflow UI and REST API
* **Metadata Database**: Stores Dag and task metadata
* **Remote Execution API**: Manages agent communication and task distribution
The orchestration plane assigns tasks to agents, monitors their health via heartbeats, and provides visibility through logging and observability features.
**Execution plane (Customer-managed)**
The execution plane runs in your Kubernetes cluster and includes:
* **Remote Execution Agents**: Deployed via Helm charts, each agent includes:
* **DAG Processor**: Parses and serializes Dag code
* **Triggerer**: Manages deferrable tasks
* **Worker**: Executes Airflow tasks
* **Sentinel**: Monitors agent health and reports status to the orchestration plane
Agents pull tasks from the orchestration plane via secure HTTPS connections, execute them locally, and report status back. Agents maintain frequent heartbeats with the API Server. If an agent loses its heartbeat, the orchestration plane automatically reroutes tasks to healthy agents. See [Remote Execution Agent failure scenarios](/docs/astro/remote-agents-failure-scenarios) for more information.
## Key concepts
### Remote Execution Agents
Agents are the core component of Remote Execution. Each agent is a collection of Airflow components (Worker, Dag Processor, Triggerer) deployed as a single unit in your Kubernetes cluster. You can deploy multiple agents with unique configurations across different clusters, regions, or node types to meet your workload requirements.
Agents communicate with Astro using:
* **Agent tokens**: Authenticate agents to the orchestration plane
* **Outbound-only connections**: Enable communication from your infrastructure to Astro without requiring inbound traffic
* **Heartbeat mechanism**: Monitor agent health with regular status checks
### Dag bundles
Dag bundles are collections of Dag files and supporting code. Remote Execution supports two types:
* **GitDagBundle**: Dags stored in a Git repository (recommended for production)
* **LocalDagBundle**: Dags stored in the container image or persistent volume
GitDagBundle provides automatic Dag versioning, allowing you to track changes and view different versions in the Airflow UI.
### XCom backend
XCom (cross-communication) allows Airflow tasks to share data. With Remote Execution, you must configure an object storage backend (AWS S3, Azure Blob Storage, or GCP Cloud Storage) to pass XCom data between tasks running on different agents.
### Secrets backend
Remote Execution Agents must be configured with a secrets backend to securely access Airflow connections and variables. This can be AWS Secrets Manager, Azure Key Vault, Google Cloud Secret Manager, or HashiCorp Vault.
### State store backend
Starting with Airflow 3.3 (Astro Runtime 3.3), tasks and asset watchers can persist state between runs through the Airflow worker-side state store. With Remote Execution, agents store this state in your execution plane instead of the Astro-hosted metadata database. The Remote Execution Agent Helm chart (2.3.0 and later) sets a working default, and you can point it at object storage for production.
## What you need to configure
Configure the following required and optional components for Remote Execution.
### Required components
* [**Remote Execution Agents**](/docs/astro/remote-execution-configure-agents): Deployed via Helm in your Kubernetes cluster
* [**Secrets Backend**](/docs/astro/remote-execution-configure-secrets-backend): To securely store and access Airflow connections and variables
* [**XCom Backend**](/docs/astro/remote-execution-configure-xcom-backend): Object storage for passing data between tasks
* [**State Store Backend**](/docs/astro/remote-execution-configure-state-store-backend): Storage for task and asset state on Astro Runtime 3.3 and later. The Helm chart (2.3.0 and later) sets a working default
* [**Dag Sources**](/docs/astro/remote-execution-configure-dag-sources): Configure how agents access your dag code (Git or local)
### Recommended components
* [**Sentinel**](/docs/astro/remote-agents-sentinel): Monitor agent health and report status to the orchestration plane. Astronomer recommends enabling Sentinel for all production deployments.
### Optional components
* [**Logging**](/docs/astro/remote-execution-logging-overview): Export task logs to external logging platforms or object storage
* [**OpenLineage**](/docs/astro/remote-execution-configure-openlineage): Enable data lineage and observability features
## Next steps
* [Get started with Remote Execution](/docs/astro/remote-execution-get-started) - Set up prerequisites and follow the setup checklist
* [Register and configure agents](/docs/astro/remote-execution-configure-agents) - Install and register your first agent
## Related documentation
* [Execution modes](/docs/astro/execution-mode)
* [Deployment settings](/docs/astro/deployment-settings)
* [Remote Execution Agent release notes](/docs/astro/agent-release-notes)
# Remote Execution shared responsibility model
Source: https://astronomer.io/docs/astro/remote-execution-shared-responsibility
Remote Execution uses a decoupled architecture where Astronomer manages the orchestration plane and the customer manages the execution plane. This document defines the responsibilities for each party.
For the general Astro shared responsibility model, see [Shared responsibility model](/docs/astro/shared-responsibility-model).
## Astronomer responsibilities
Astronomer is responsible for managing the orchestration plane and supporting the Remote Execution platform, including:
### Orchestration plane
* Operating and maintaining the Airflow scheduler, API server, web server, and metadata database in Astro's cloud infrastructure.
* Managing the Remote Execution API that coordinates task distribution between the orchestration plane and customer-managed agents, and performs task lifecycle management.
* Monitoring agent heartbeats and automatically rerouting tasks to healthy agents when an agent becomes unavailable.
* Providing the Astro UI and Astro API for Deployment management, agent registration, and token creation.
* Securing authentication and authorization for all orchestration plane interfaces, including the Astro UI, API, and CLI.
* Maintaining data encryption at rest and in transit for all orchestration plane components.
* In case of a Disaster Recovery failover, Astronomer is responsible for handling infrastructure operations necessary to migrate the Airflow Orchestration Plane over to the secondary site (the `Disaster Recovery` feature needs to be enabled on the Astronomer cluster).
### Agent software and support
* Publishing and maintaining Remote Execution Agent images.
* Publishing and maintaining the Remote Execution Agent Helm chart.
* Providing [Astronomer support](https://support.astronomer.io) for Remote Execution configuration and troubleshooting.
## Customer responsibilities
The customer is responsible for managing the execution plane and the infrastructure that Remote Execution Agents run on, including:
### Disaster Recovery
* Triggering a failover on the Astronomer-managed Kubernetes Cluster if the situation requires it.
### Kubernetes infrastructure
* Provisioning and maintaining Kubernetes clusters where agents run (and possible Disaster Recovery sites).
* Managing cluster capacity, node pools, and autoscaling to support agent workloads.
* Applying Kubernetes and node OS security patches and version upgrades.
* Configuring network policies, firewalls, and access controls within the cluster.
* Ensuring network connectivity from agent clusters to the Astro orchestration plane. See [Allowlist Astro domains](/docs/astro/allowlist-domains).
### Agent deployment and operations
* [Installing and configuring](/docs/astro/remote-execution-configure-agents) Remote Execution Agents using the Helm chart.
* Creating and managing [agent tokens](/docs/astro/remote-execution-configure-agents#step-1-create-agent-token) for authenticating agents to the orchestration plane.
* Pulling agent images from the Astronomer registry and storing them in a private registry when required.
* Building and maintaining custom agent images with additional Python packages and OS-level dependencies required by Dag code.
* [Upgrading agents](/docs/astro/agent-maintenance-policy#remote-execution-agent-image-upgrade-process) to latest (recommended) or other supported versions within the maintenance window.
* Monitoring agent Pod health and resource utilization in Kubernetes.
### Secrets and credentials
* [Configuring a secrets backend](/docs/astro/remote-execution-configure-secrets-backend) (AWS Secrets Manager, Azure Key Vault, Google Cloud Secret Manager, or HashiCorp Vault) for Airflow connections and variables.
* Managing and rotating credentials stored in the secrets backend.
* Configuring workload identity or service account permissions for agents to access the secrets backend.
### Data storage
* [Configuring an XCom backend](/docs/astro/remote-execution-configure-xcom-backend) (AWS S3, Azure Blob Storage, or GCP Cloud Storage).
* [Configuring a state store backend](/docs/astro/remote-execution-configure-state-store-backend) for task and asset state on Astro Runtime 3.3 and later.
* Provisioning and managing object storage buckets or containers used for XCom, the state store, and logging.
* Configuring IAM roles, managed identities, or service accounts for agent access to storage resources.
* Managing storage lifecycle policies, encryption, and access controls.
### Dag code and sources
* Developing and maintaining Dag code with security and quality coding practices.
* [Configuring Dag sources](/docs/astro/remote-execution-configure-dag-sources) (GitDagBundle or LocalDagBundle) for agent access to Dag code.
* Managing Git repository authentication credentials for GitDagBundle configurations.
* Building and deploying [Remote Execution project images](/docs/astro/deploy-project-remote-execution) for both the orchestration and execution planes.
### Logging and observability
* [Configuring task logging](/docs/astro/remote-execution-logging-overview) to preserve logs from agent Pods.
* Provisioning and managing external logging platforms or object storage for log export.
* It is recommended to enable [Sentinel](/docs/astro/remote-agents-sentinel) for agent health monitoring.
* Optionally configuring [OpenLineage](/docs/astro/remote-execution-configure-openlineage) for data lineage tracking.
### Security
* Managing user roles, permissions, and authentication assets (tokens, connections, environment variables).
* Integrating with identity providers for secure SSO/MFA.
* Managing customer-owned credentials.
* Securing outbound network connections from agent clusters to the Astro orchestration plane.
* Configuring private connectivity ([AWS PrivateLink](/docs/astro/remote-agents-aws-privatelink) or [Azure Private Link](/docs/astro/remote-agents-azure-privatelink)) when required.
* Securing network communications between agents and data resources in the execution plane, including secrets backends, object storage, and data sources.
* Managing IP allowlists and firewall rules for agent clusters.
* Implementing and maintaining secure, high-quality data pipelines, including dependency and vulnerability management.
## Related documentation
* [Shared responsibility model](/docs/astro/shared-responsibility-model)
* [Remote Execution overview](/docs/astro/remote-execution-overview)
* [Security in Astro](/docs/astro/security)
* [Remote Execution Agent maintenance policy](/docs/astro/agent-maintenance-policy)
# Show Remote Execution Agent task logs in Airflow UI
Source: https://astronomer.io/docs/astro/remote-task-logs-af-ui
Configure a Remote Execution Agent to upload task logs to object storage so they display in the Airflow UI after task completion or in real time.
You can display task logs in the Airflow UI by exporting logs to object storage and configuring the Astro API Server to retrieve them. Start by enabling log display after task completion, then optionally extend the setup to stream logs in real time as tasks run.
This guide explains configuring post-task log display and expanding that configuration to support real-time log streaming.
## Display task logs after task completion
Set up log uploading so logs are visible in the Airflow UI after task completion. This requires:
* Remote Execution Agent configuration (`values.yaml`)
* Astro UI Deployment configuration
* Workload identities: write access for the Remote Execution Agent, read access for the Astro API Server
The `commonEnv` block in the following procedures applies environment variables to all Airflow components in the Remote Execution Agent. These variables configure Airflow's [remote logging](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/logging-tasks.html#serving-logs-from-remote-location) so that workers and the triggerer upload completed task logs to object storage:
* `AIRFLOW__LOGGING__REMOTE_LOGGING`: Turns on Airflow's remote log upload.
* `AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID`: Names the Airflow connection used to authenticate with object storage.
* `AIRFLOW_CONN_`: Defines that connection inline, so no separate connection record is required. A URI with no credentials (for example, `s3://`) causes the underlying cloud SDK to use its default credential chain, which picks up the workload identity attached to the Pod.
* `AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER`: Sets the bucket and path prefix that Airflow writes task logs to. Use a Deployment-scoped path so logs from different Deployments don't collide.
* `AIRFLOW__LOGGING__LOGGING_CONFIG_CLASS`: Replaces Airflow's default logging configuration with the Astronomer Runtime configuration, which installs the task log handler used to write logs to and read logs from object storage.
* `ASTRONOMER_ENVIRONMENT`: Set to `cloud` for Astro Deployments. Astronomer Runtime reads this value to select Astro-specific logging defaults.
The Astro Orchestration Plane provides secure private connectivity with a pre-configured S3 Gateway Endpoint.
1. Configure the following environment variables in the Helm chart's `values.yaml`, and replace the path for the `AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER` value with your information:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__LOGGING__REMOTE_LOGGING
value: "True"
- name: AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID
value: "astro_aws_logging"
- name: AIRFLOW_CONN_ASTRO_AWS_LOGGING
value: "s3://"
- name: AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER
value: "s3:///"
- name: AIRFLOW__LOGGING__LOGGING_CONFIG_CLASS
value: "astronomer.runtime.logging.logging_config"
- name: ASTRONOMER_ENVIRONMENT
value: "cloud"
```
**Mounting credentials manually**
If you don't use workload identity and instead want to manually mount a credential, you must also add the following environment variable defining the location of a token file to your Remote Agent's `values.yaml` file. You can customize the file path, `/tmp/logging-token`, to the name of your logging token file.
```yaml title="values.yaml" wrap theme={null}
- name: ASTRO_LOGGING_AWS_WEB_IDENTITY_TOKEN_FILE
value: "/tmp/logging-token"
```
2. Run `helm upgrade` to apply the change to your Agents.
3. In the Astro UI, navigate to your Deployment and click the **Details** tab. Click **Edit** in the **Advanced** section to access your logging configurations.
4. Select **Bucket Storage** in the **Task Logs** field and fill in the **Bucket URL** as `s3:///`. Or, use the path that you configured for `AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER` in your Remote Agent's Helm chart's `values.yaml`.
5. In the **Workload Identity for Bucket Storage** section, select **Customer Managed Identity** and follow the instructions to set up your Customer Managed Identity so that the identity you create has read access to the specified bucket and path. The Customer Managed Identity must have `s3:GetObject` and `s3:ListBucket` permissions on the S3 bucket. Additionally, ensure that no ACLs on the bucket restrict those actions.
**Default Identity** isn't currently supported for Task Logs Bucket Storage on AWS. You must use **Customer Managed Identity**.
6. If your log bucket is in a different region from your Astro Deployment, you need to define the AWS region in the `AIRFLOW__ASTRONOMER_PROVIDERS_LOGGING__AWS_REGION` environment variable for Astronomer-managed components. In the Astro UI, navigate to your Deployment and click the **Environment** tab. Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet), then click **Add Variable** to add the following environment variables to your Deployment:
* `AIRFLOW__ASTRONOMER_PROVIDERS_LOGGING__AWS_REGION `
The Astro Orchestration Plane provides secure private connectivity with a pre-configured Private Service Connect endpoint to GCP Cloud Storage.
1. Configure the following environment variables in the Helm chart's `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__LOGGING__REMOTE_LOGGING
value: "True"
- name: AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID
value: "astro_gcs_logging"
- name: AIRFLOW_CONN_ASTRO_GCS_LOGGING
value: "gcs://"
- name: AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER
value: "gs:///"
- name: AIRFLOW__LOGGING__LOGGING_CONFIG_CLASS
value: "astronomer.runtime.logging.logging_config"
- name: ASTRONOMER_ENVIRONMENT
value: "cloud"
```
The path for the `AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER` value is configurable. This is only an example format.
2. Do a `helm upgrade` to apply the change to your Agents.
3. In the Astro UI, navigate to your Deployment and click the **Details** tab. Click **Edit** in the **Advanced** section.
4. In the **Task Logs** field, select **Bucket Storage** and fill in the **Bucket URL** as `gs:///`. Or, use the path that you configured for `AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER` in your Remote Agent's Helm chart's `values.yaml`.
5. In the **Workload Identity for Bucket Storage** section, select **Customer Managed Identity** and follow the instructions to set up your Customer Managed Identity so that the identity you create has read access to the specified bucket and path.
On GCP, you can authorize your Deployment to cloud resources using workload identity with the alternative methods described [here](/docs/astro/authorize-deployments-to-your-cloud?tab=gcp#setup).
You must configure a connection from your Astro Orchestration Plane to your storage account for the Astro API server to read task logs. You can use either a private connection or a public connection.
* **Private Connectivity**: Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) to establish a Private Link connection.
* **Public Connectivity**: Enable **Enabled from all networks** in the networking settings of your storage account. Azure doesn't support IP network rules for restricting access from resources deployed in the same region as the storage account. See [Restrictions for IP network rules](https://learn.microsoft.com/en-us/azure/storage/common/storage-network-security-limitations#restrictions-for-ip-network-rules).
For security, Astronomer recommends you assign the **Storage Blob Data Reader** role to the workload identity used by the API server and apply the following settings for your storage account:
* **Secure transfer required**: Enabled
* **Allow Blob anonymous access**: Disabled
* **Minimum TLS version**: TLS 1.2 or higher
1. Authenticate to your storage account with an Azure Managed Identity, or the alternative method that uses a Storage Account Access Key.
If you write task logs using an Azure Managed Identity, configure the following environment variables in the Helm chart's `values.yaml`:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__LOGGING__REMOTE_LOGGING
value: "True"
- name: AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID
value: "astro_azure_logs_override"
- name: AIRFLOW_CONN_ASTRO_AZURE_LOGS_OVERRIDE
value: "wasb://@.blob.core.windows.net"
- name: AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER
value: "wasb-"
- name: AIRFLOW__AZURE_REMOTE_LOGGING__REMOTE_WASB_LOG_CONTAINER
value: ""
- name: AIRFLOW__LOGGING__LOGGING_CONFIG_CLASS
value: "astronomer.runtime.logging.logging_config"
- name: ASTRONOMER_ENVIRONMENT
value: "cloud"
labels:
azure.workload.identity/use: "true"
annotations:
azure.workload.identity/client-id: ""
```
The `AIRFLOW__AZURE_REMOTE_LOGGING__REMOTE_WASB_LOG_CONTAINER` variable sets the Azure Blob Storage container that Airflow writes logs to. The `labels` and `annotations` blocks enable [Azure Workload Identity](https://azure.github.io/azure-workload-identity/docs/) on the Agent Pods so Airflow can authenticate to Azure without static credentials.
If writing task logs using an Storage Account Access Key, it isn't necessary to configure the `labels` and `annotations` in your Helm chart's `values.yaml`. It is **required** to configure the `AIRFLOW_CONN_ASTRO_AZURE_LOGS_OVERRIDE` environmental variable with the format `value: wasb://:@.blob.core.windows.net`.
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__LOGGING__REMOTE_LOGGING
value: "True"
- name: AIRFLOW__LOGGING__REMOTE_LOG_CONN_ID
value: "astro_azure_logs_override"
- name: AIRFLOW_CONN_ASTRO_AZURE_LOGS_OVERRIDE
value: "wasb://:@.blob.core.windows.net"
- name: AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER
value: "wasb-"
- name: AIRFLOW__AZURE_REMOTE_LOGGING__REMOTE_WASB_LOG_CONTAINER
value: ""
- name: AIRFLOW__LOGGING__LOGGING_CONFIG_CLASS
value: "astronomer.runtime.logging.logging_config"
- name: ASTRONOMER_ENVIRONMENT
value: "cloud"
```
2. Run `helm upgrade` to apply the change to your Agents.
3. In the Astro UI, navigate to your Deployment and click the **Details** tab. Click **Edit** in the **Advanced** section.
4. Select **Bucket Storage** in the **Task Logs** field and add the **Bucket URL** as `wasb://@.blob.core.windows.net/wasb-`.
5. In the **Workload Identity for Bucket Storage** section, select **Customer Managed Identity** and follow the instructions to set up your Customer Managed Identity so that the identity you create has read access to the specified bucket and path.
6. In the Astro UI, navigate to your Deployment and click the **Environment** tab. Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet), then click **Add Variable** to add the following environment variables to your Deployment:
* `ASTRO_LOGGING_AZURE_CLIENT_ID: `
* `ASTRO_LOGGING_AZURE_TENANT_ID: `
## Display task logs during task execution
Once you have post-completion log visibility, you can enable real-time log display. Remote Execution prevents the Airflow API server from reading logs directly from workers until they reach object storage. Use [Vector](https://vector.dev), included in the Remote Execution Agent Helm chart, to upload partial logs while tasks are running.
### Prerequisites
Before you configure Vector, ensure that your Remote Execution Deployment is already set up to [upload task logs to object storage after task completion](#display-task-logs-after-task-completion).
### Enable Vector sidecar
Use Vector to watch for log file changes and upload updates to object storage during task execution.
In your Helm `values.yaml`:
* Set `loggingSidecar.enabled` to `true` to inject the Vector container into each worker and triggerer Pod:
```yaml title="values.yaml" wrap theme={null}
loggingSidecar:
enabled: true
```
* Configure `loggingSidecar.volumeMounts` to give Vector read access to the Airflow task log files and a writable location for its on-disk checkpoint state:
```yaml title="values.yaml" wrap theme={null}
loggingSidecar:
volumeMounts:
- name: task-logs
mountPath: /var/log/airflow/task_logs
readOnly: true
- name: vector-data
mountPath: /var/lib/vector
```
The `task-logs` mount is the directory Vector reads from. The `vector-data` mount stores Vector's file checkpoints so it can resume uploads after a restart without re-sending lines.
### Configure log upload for your cloud provider
The `loggingSidecar.config` block is the Vector pipeline definition. Each cloud-specific config uses the same three-stage structure:
* `sources.airflow_task_logs`: Tails the local task log files written by Airflow workers and the triggerer. `read_from: beginning` ensures Vector starts at the top of each file so partial logs aren't missed.
* `transforms.strip_path_prefix`: Removes the local mount path from each event's `file` field and writes the result to `log_path`. This produces an object key that matches the layout Airflow uses when it uploads the complete log after task completion, so the Astro API Server can read both the partial and final logs from the same location.
* `sinks.`: Uploads the transformed events to object storage. `key_prefix` (or `blob_prefix` on Azure) uses the `log_path` field from the transform to place each log under the right object key. `batch.max_bytes` and `batch.timeout_secs` control how often Vector flushes — smaller values stream logs to the UI faster but produce more small objects in storage. See [Small file problem](#small-file-problem).
Configure `loggingSidecar.config`:
```yaml title="values.yaml" expandable wrap theme={null}
loggingSidecar:
config: |
# Vector configuration for Astronomer Remote Execution agents for uploading Airflow task logs to AWS S3
sources:
airflow_task_logs:
type: file
include:
- /var/log/airflow/task_logs/**/*.log
read_from: beginning
transforms:
strip_path_prefix:
type: remap
inputs: [airflow_task_logs]
source: |
.log_path, err = replace(.file, "/var/log/airflow/task_logs/", "")
if err != null {
abort
}
sinks:
s3:
# For more Vector AWS S3 configuration options, see https://vector.dev/docs/reference/configuration/sinks/aws_s3
type: aws_s3
inputs: [strip_path_prefix]
bucket: # set bucket name e.g. airflow_logs
region: # set AWS region e.g. us-east-2
compression: none
encoding:
codec: text
key_prefix: '{{ "{{" }} log_path {{ "}}" }}.'
filename_time_format: "%Y-%m-%dT%H-%M-%S"
filename_append_uuid: false
batch:
max_bytes: 1000000 # configure based on your storage costs and log frequency requirements - see Caveats section below
timeout_secs: 10 # configure based on your storage costs and log frequency requirements - see Caveats section below
```
**AWS authentication with Vector**
Above Vector config assumes a managed identity is set up for authentication, as described in [Display task logs after task completion](#display-task-logs-after-task-completion).
If you require a different way to authenticate with AWS, such as static keys, see [https://vector.dev/docs/reference/configuration/sinks/`aws_s3`/#auth](https://vector.dev/docs/reference/configuration/sinks/aws_s3/#auth) for all available options.
Configure `loggingSidecar.config`:
```yaml title="values.yaml" expandable wrap theme={null}
loggingSidecar:
config: |
# Vector configuration for Astronomer Remote Execution agents for uploading Airflow task logs to GCS
sources:
airflow_task_logs:
type: file
include:
- /var/log/airflow/task_logs/**/*.log
read_from: beginning
transforms:
strip_path_prefix:
type: remap
inputs: [airflow_task_logs]
source: |
.log_path, err = replace(.file, "/var/log/airflow/task_logs/", "")
if err != null {
abort
}
sinks:
gcs:
# For more Vector GCP Cloud Storage configuration options, see https://vector.dev/docs/reference/configuration/sinks/gcp_cloud_storage/
type: gcp_cloud_storage
inputs: [strip_path_prefix]
bucket: # set to GCS bucket name
compression: none
encoding:
codec: text
key_prefix: '{{ "{{" }} log_path {{ "}}" }}.' # If you place logs at a specific prefix, prepend that prefix here like 'logs/{{ "{{" }} log_path {{ "}}" }}.'
filename_time_format: "%Y-%m-%dT%H-%M-%S"
filename_append_uuid: false
batch:
max_bytes: 1000000 # configure based on your storage costs and log frequency requirements - see Caveats section below
timeout_secs: 10 # configure based on your storage costs and log frequency requirements - see Caveats section below
```
**GCP authentication with Vector**
Above Vector config assumes Workload Identity is set up for authentication, as described in [Display task logs after task completion](#display-task-logs-after-task-completion).
If you require a different way to authenticate with GCP, such as service account keys, see [https://vector.dev/docs/reference/configuration/sinks/`gcp_cloud_storage`/#auth](https://vector.dev/docs/reference/configuration/sinks/gcp_cloud_storage/#auth) for all available options.
Configure `loggingSidecar.env` to provide your Azure Storage connection string as a Kubernetes secret:
```yaml title="values.yaml" wrap theme={null}
loggingSidecar:
env:
- name: AZURE_STORAGE_CONNECTION_STRING
valueFrom:
secretKeyRef:
name: azure-blob-logs
key: AZURE_STORAGE_CONNECTION_STRING
```
Configure `loggingSidecar.config`:
```yaml title="values.yaml" expandable wrap theme={null}
loggingSidecar:
config: |
# Vector configuration for Astronomer Remote Execution agents for uploading Airflow task logs to Azure Blob Storage
sources:
airflow_task_logs:
type: file
include:
- /var/log/airflow/task_logs/**/*.log
read_from: beginning
transforms:
strip_path_prefix:
type: remap
inputs: [airflow_task_logs]
source: |
.log_path, err = replace(.file, "/var/log/airflow/task_logs/", "")
if err != null {
abort
}
sinks:
azure_blob:
# For more Vector Azure Blob Storage configuration options, see https://vector.dev/docs/reference/configuration/sinks/azure_blob/
type: azure_blob
inputs: [strip_path_prefix]
container_name: # set to Azure Blob Storage container name
connection_string: "${AZURE_STORAGE_CONNECTION_STRING}"
compression: none
encoding:
codec: text
blob_prefix: '{{ "{{" }} log_path {{ "}}" }}.' # If you configured a specific log path prefix, prepend that prefix here like 'wasb-/{{ "{{" }} log_path {{ "}}" }}.'
blob_time_format: "%Y-%m-%dT%H-%M-%S"
blob_append_uuid: false
batch:
max_bytes: 1000000 # configure based on your storage costs and log frequency requirements - see Caveats section below
timeout_secs: 10 # configure based on your storage costs and log frequency requirements - see Caveats section below
```
Vector doesn't currently support Azure Managed Identity for the Azure Blob sink. You must authenticate using a Storage Account connection string. See the [Vector Azure Blob sink documentation](https://vector.dev/docs/reference/configuration/sinks/azure_blob/) for all available authentication options.
**Developing Vector Remap Language (VRL)**
Vector expressions are written in Vector Remap Language (VRL). If you want to edit an expression in the Vector config, this [online VRL playground](https://playground.vrl.dev) is a useful debugging tool.
**Debugging Vector**
If you're having issues uploading logs, you can enable debug logging for the Vector sidecar by adding this to the sink configuration (so you'll have 2 sinks, e.g. an `s3` sink, and a `debug` sink):
```yaml title="values.yaml" wrap theme={null}
debug:
type: console
inputs: [strip_path_prefix]
encoding:
codec: json
```
With this second sink, Vector will display debug logs on the console, accessible with `kubectl logs [worker pod] -c vector-logging-sidecar`.
The following volume configuration creates the shared `emptyDir` volumes that the Vector sidecar and the Airflow worker or triggerer container both mount. `task-logs` is the directory Airflow writes logs into and Vector reads from. `vector-data` holds Vector's checkpoint state. The worker and triggerer mount `task-logs` at `/usr/local/airflow/logs`, which is where Airflow writes by default, while the Vector sidecar mounts the same volume at `/var/log/airflow/task_logs` to match its `sources.airflow_task_logs.include` glob.
* Configure `workers[*].volumes`:
```yaml title="values.yaml" wrap theme={null}
volumes:
- name: task-logs
emptyDir: {}
- name: vector-data
emptyDir: {}
```
* Configure `workers[*].volumeMounts`:
```yaml title="values.yaml" wrap theme={null}
volumeMounts:
- name: task-logs
mountPath: /usr/local/airflow/logs
```
* Configure `triggerer.volumes`:
```yaml title="values.yaml" wrap theme={null}
volumes:
- name: task-logs
emptyDir: {}
- name: vector-data
emptyDir: {}
```
* Configure `triggerer.volumeMounts`:
```yaml title="values.yaml" wrap theme={null}
volumeMounts:
- name: task-logs
mountPath: /usr/local/airflow/logs
```
* Set `AIRFLOW__LOGGING__DELETE_LOCAL_LOGS` in `commonEnv` so Airflow removes the local log file after it uploads the complete log to object storage. This keeps the shared `task-logs` volume from filling up on long-running Pods:
```yaml title="values.yaml" wrap theme={null}
commonEnv:
- name: AIRFLOW__LOGGING__DELETE_LOCAL_LOGS
value: "True"
```
### Log upload process
Partial logs are uploaded and displayed as follows:
1. Airflow worker or triggerer writes local task log files, as set by `AIRFLOW__LOGGING__LOG_FILENAME_TEMPLATE`.
2. Vector watches `/var/log/airflow/task_logs/**/*.log` and uploads log changes in chunks while the task runs.
3. Vector appends a timestamp to the file name before uploading each chunk.
4. Airflow scans object storage for log chunks when displaying the UI log view.
5. The UI displays all log content to the user.
**Version compatibility**
Using Vector to upload logs assumes Airflow’s logging format is compatible. Significant changes to Airflow logging may require reconfiguration.
### Caveats
#### Duplicate log storage
After task completion, Airflow uploads the complete log to object storage and deletes the local copy. This causes duplication:
1. Partial logs from Vector
2. Complete log from Airflow
The Airflow API server deduplicates log lines by timestamp and message. Only storage usage is affected; logs are displayed once.
#### Small file problem
High-frequency, small log file uploads can create many small objects. This may increase storage costs, load on object storage, or trigger rate limits. Adjust file size and upload frequency in your Vector config to balance performance and cost.
* AWS bills object retrieval at a 128KB minimum on certain storage classes ([source](https://aws.amazon.com/blogs/storage/optimizing-storage-costs-and-query-performance-by-compacting-small-objects)).
* A large number of small objects means more object requests (PUTs, GETs, LISTs) and more load on metadata/indexing; this can result in rate limits or latency issues.
Ensure a proper balance between filesize/timeout and log upload frequency in your Vector config.
# Send Remote Execution Agent task logs to external logging provider
Source: https://astronomer.io/docs/astro/remote-task-logs-external
Configure a Remote Execution Deployment to display links to task logs hosted in an external logging provider such as Splunk or Datadog.
For Remote Execution Deployments, the recommended approach for handling task logs is to use a logging shipper that sends logs to your external logging platform. You can configure your Remote Execution Deployment to display links to the external task logs in the Airflow UI, keeping all data within your environment.
To send logs to external logging providers, you must first [configure LoggingSidecar in your Remote Execution Agent](/docs/astro/remote-agents-logging-sidecar).
## Configure external logging provider for Remote Execution Deployments
1. In the Astro UI, navigate to your Deployment and click the **Details** tab. Click **Edit** in the **Advanced** section.
2. Select **External Logging Provider** in the **Task Logs** field.
3. In the **URL Template** field, enter a templated URL that references the [`log_filename_template`](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#log-filename-template) value from your Airflow config. This inserts a dynamic link in the Airflow UI, where logs would normally appear, that points to the corresponding task logs in your external logging provider.
For example, a templated URL for task logs in Splunk might look like:
```text wrap theme={null}
https:///en-US/app//search?q=search%20index%3D%20tiID%3D%22{{ ti.id }}%22&display.page.search.mode=smart&dispatch.sample_ratio=1&earliest=-24h%40h&latest=now
```
# Run your first dag on Astro
Source: https://astronomer.io/docs/astro/run-first-dag
Run your first Apache Airflow dag on Astro using the Astro CLI or GitHub Actions.
Astro is the industry's leading managed service for Apache Airflow.
You can quickly learn how Astro works by running an Apache Airflow dag with either [the Astro CLI](/docs/astro/first-dag-cli) or by using [GitHub Actions](/docs/astro/first-dag-github-actions). Either tutorial takes about 15 minutes. They each showcase different paths available for dag development, CI/CD workflows, and code deployment options.
You'll learn how to:
* Authenticate and log in to Astro.
* Create a Deployment.
* Deploy dags to Astro with either the Astro CLI or GitHub Actions.
* Trigger a run of an example dag.
## Choose a tutorial
If you prefer to develop on your local machine and use command line tools, follow the steps in [Run your first dag with the Astro CLI](/docs/astro/first-dag-cli).
If you can't install additional tools on your current machine or you prefer a no-code workflow, follow the steps in [Run your first dag with GitHub Actions](/docs/astro/first-dag-github-actions), where you can see an example of a CI/CD workflow.
# Subscribe to Astro from the AWS Marketplace
Source: https://astronomer.io/docs/astro/subscribe-aws
Learn how to subscribe to Astro from the AWS marketplace.
[Astro](https://www.astronomer.io/docs/astro) is a managed service for data orchestration that is built for the cloud and powered by Apache Airflow. Your Airflow infrastructure is managed entirely by Astronomer, enabling you to shift your focus from infrastructure to data.
Amazon Web Services (AWS) customers can subscribe to [Astro](https://www.astronomer.io/pricing/) with the AWS Marketplace. This enables you to pay for your Astro usage with your existing AWS billing configuration. You can choose to [subscribe to the Developer or Team plans for monthly, pay-as-you-go billing](https://aws.amazon.com/marketplace/pp/prodview-6lfiiphwtbhz2?trk=8d276e92-b310-40ce-908f-23a198ca7ffc\&sc_channel=el\&source=astronomer) or [work with our team](https://www.astronomer.io/pricing/) on an upfront, annual subscription.
The following steps show you how to subscribe to Astro's pay-as-you-go plans via AWS Marketplace.
## Step 1: Subscribe to Astro in AWS Marketplace
1. Log into your [AWS account](https://aws.amazon.com/console/).
2. Go to the [AWS Marketplace](http://aws.amazon.com/marketplace).
3. Search for **Astro by Astronomer - Pay As You Go**, or go directly to the [product listing](https://aws.amazon.com/marketplace/pp/prodview-6lfiiphwtbhz2?trk=8d276e92-b310-40ce-908f-23a198ca7ffc\&sc_channel=el\&source=astronomer).
Ensure the product name search includes **Pay As You Go**. Other listings from Astronomer are available in AWS Marketplace, but do not include the plans with pay-as-you-go pricing.
3. On the product overview page, click **View purchase options**.
4. Click **Subscribe** to complete your order.
5. Finalize your subscription by clicking **Set up your account** on the subscription confirmation page.
If this button does not immediately appear, wait 1-2 minutes and refresh your page. Alternatively, you can [navigate to your AWS Marketplace subscriptions in the AWS Console](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/marketplace-manage-subscriptions.html) and complete the set-up process by clicking **Set up product** under **Actions**.
6. Fill out the form on the page. Based on your [feature and support needs](https://www.astronomer.io/pricing/), select either the Developer or Team plan. Click **Complete Registration**.
7. After this step, you will be redirected to create your [Astro Organization](/docs/astro/astro-architecture#organization). If you have an existing Astro Organization, associate it to your AWS account using the [form on the Astronomer website](https://www.astronomer.io/aws-marketplace-confirmation/).
Your subscription to Astro is not considered active until you complete *all* of the steps listed above. **If you have questions or experience issues, please contact marketplace \[at] astronomer.io for assistance.**
## Step 2: Start Using Astro
Your new Astro Organization comes pre-loaded with a set amount of credits. You can begin to create Deployments and run Dags using these credits right away.
Within 1 business day of completing the AWS Subscription process, the Astronomer team will configure your Astro Organization to use your AWS Billing account. Astronomer will notify you when this is complete.
You can also verify your AWS Account is linked by going to your Astro Organization’s **Billing Settings** and confirm that the **Payment Type** in the **Payment Method** section shows AWS Marketplace.
See the [Astro Trial Resources](/docs/astro/trial#trial-resources) section for more information about what you can do with your Astro trial and [Run your first dag with the CLI](/docs/astro/first-dag-cli) to get started.
## Canceling your Astro Subscription
You can cancel your Astro subscription in AWS Marketplace. Before you cancel your subscription, please check that you deleted all Deployments and exported any configuration settings for your Deployment that you want to preserve. If you have any active Deployments, you might see an error or any running tasks might abruptly terminate.
After you cancel your subscription in AWS Marketplace, Astronomer hibernates your Deployments for 30 days. After 30 days, your Deployments are permanently deleted. See [Delete a Deployment](/docs/astro/deployment-details#delete-a-deployment).
Navigate to AWS Marketplace and follow the instructions for [canceling your SaaS subscription](https://docs.aws.amazon.com/marketplace/latest/buyerguide/cancel-subscription.html#cancel-saas-subscription).
## Unlink your AWS Billing from Astro
If you no longer want to use your AWS account for your Astro subscription, please contact billing \[аt] astronomer.io for assistance updating your payment settings.
# Start your Astro trial
Source: https://astronomer.io/docs/astro/trial
Start a free 14-day Astro trial directly or through the AWS or Azure marketplace.
Use this guide to get started with Astro, the best place to run Apache Airflow.
## Start a trial
Go to [Try Astro](https://www.astronomer.io/lp/signup/) to activate your free 14-day trial. To create your Astro user account, you'll need to provide a valid email address and create a password.
## Subscribe through a cloud provider marketplace
### Astro with AWS Marketplace
If your company uses AWS, you can subscribe to the Astro pay-as-you-go Developer plan through the AWS Marketplace. After the end of your Astro Trial, the subscription allows you to pay for your monthly Astro use with your existing AWS billing configuration without an upfront, annual subscription. See [Install Astro from the AWS Marketplace](/docs/astro/subscribe-aws).
## Create an Organization and Workspace
After you've created your Astro user account, you'll be asked to create an Organization and your first Workspace.
An *Organization* is the highest management level on Astro. An Organization contains *Workspaces*, which are collections of *Deployments*, or Airflow environments, that are typically owned by a single team. You can manage user roles and permissions both at the Organization and Workspace levels. For more information about Astro's key concepts and components, see [About Astro](/docs/astro/astro-architecture).
To start your trial, Astronomer recommends using the name of your company as the name of your Organization and naming your first Workspace after your data team or initial business use case with Airflow. You can update these names in the Astro UI after you finish activating your trial.
## Next steps
You're now ready to start deploying and running dags on Astro. See [Run your first dag on Astro](/docs/astro/run-first-dag) to choose a detailed quickstart. You'll create a local Astro project, then push that project to your Astro Deployment. The entire process takes about 5 minutes.
You have 14 days and \$20 to spend in credits before your trial ends. See [Manage billing](/docs/astro/manage-billing) to view how much credit you've used over the course of your trial. See [Pricing](https://www.astronomer.io/pricing/) for a breakdown of how much it costs to run Airflow on Astro.
### Trial resources
An Astro trial provides you a level of access to Deployment resources that Astro considers sufficient to run an initial number of Apache Airflow dags and ensure that Astro meets the needs of your Organization.
During a 14-day Astro trial, you can:
* Create one Workspace
* Create one Deployment
* Configure **Worker Count** to a maximum of 5 workers per worker queue
* Use A5, A10, or A20 workers
You cannot use high-availability (HA) mode during an Astro trial. To access additional resources or functionality, add a credit card number or other payment method to your Organization.
To learn more about Deployment resources and features available to Astro customers, see [Configure Deployment resources](/docs/astro/deployment-resources). To learn more about Astro pricing, see [Pricing](https://www.astronomer.io/pricing/).
## After your trial
After your 14-day trial ends, you can no longer access your Workspace from the Astro UI and your Deployments enter [hibernation](/docs/astro/deployment-resources#hibernate-a-development-deployment) for 3 days. You can still access your account and Astronomer support. To regain access to your Deployments and Workspace, you must enter a payment method or contact Astronomer to extend your trial. After you enter a payment method, you can wake your Deployments from hibernation and continue to run Apache Airflow dags.
All Deployment configurations are preserved during hibernation for 3 days from the last day of your Astro trial. After 3 days, your Deployment and all of its metadata are permanently deleted. When your Deployments are deleted, any code that you deployed to Astro will be lost.
If you need additional time to evaluate Astro, or you need to copy your configuration for future use, you can:
* [Add a payment method](/docs/astro/manage-billing#update-billing-details) to maintain your Deployment on one of Astro's pay-as-you-go plans. Choose between Developer or Team. [View pay-as-you-go pricing.](https://astronomer.io/pricing/)
* Contact [sales](https://astronomer.io/contact/) to request a trial extension.
* Run `astro deployment inspect` with the Astro CLI to save your existing Deployment configuration as a JSON or YAML file. See [Astro CLI command reference](/docs/cli/v1.43/astro-deployment-inspect).
# View cluster details
Source: https://astronomer.io/docs/astro/view-cluster-details
Learn how to view a Deployment's cluster details, including your cloud, region, and connection options.
After you configure a Deployment, you can view details about the cluster it runs on in the Astro UI.
## View cluster cloud and region
In the Astro UI, click **Deployments**, then select a Deployment (in the legacy UI, select a Workspace first). The cloud and region for the cluster running your Deployment appears in the **Cluster** section of your Deployment overview page.
## View dedicated cluster information
1. In the Astro UI, click **Deployments**, then select a Deployment (in the legacy UI, select a Workspace first).
2. Click **Details**. Find the dedicated cluster's name under **Name**.
# View Airflow component and task logs for a Deployment
Source: https://astronomer.io/docs/astro/view-logs
View logs for your Deployments both locally and on Astro.
View task and Airflow component logs to troubleshoot your data pipelines and better understand the health of both your tasks and their execution environment.
Airflow has two different log types:
* *Component logs* record the performance of your Airflow components.
* *Task logs* records events emitted by your dag as each task executes.
You can retrieve Deployment logs programmatically with the [Get Deployment logs](/docs/astro/api/v-1/deployment/get-deployment-logs) endpoint in the Astro API. The endpoint supports filtering by log source (`scheduler`, `triggerer`, `worker`, `webserver`, `dag-processor`, or `apiserver`), time range, and free-text search, which makes it useful for building custom log workflows or integrations.
Task logs can additionally be exported to third-party observability platforms. See:
* [Export task logs and metrics to Datadog](/docs/astro/export-datadog)
* [Export task logs to AWS CloudWatch](/docs/astro/export-cloudwatch)
* [Export logs to a Secondary S3 Bucket](/docs/astro/export-secondary-s3-bucket)
* [Export logs to a Secondary WASB Container](/docs/astro/export-secondary-wasb)
## Airflow Component Logs
Airflow has four core components: the scheduler, triggerer, worker, and webserver/API server. Each component records its process in component logs. These logs can be used to monitor overall performance, troubleshoot errors, and optimize resources.
* *Dag processor logs* describe the performance of the Dag processor, a sub-component of the Scheduler. The Dag processor is responsible for parsing dags and turning them into dag objects that contain tasks to be scheduled. These logs can help you understand both the Dag processor and scheduler performance. Dag processor logs are not available for Small Deployments because the Dag processor and scheduler run on the same host. For more information on configuring the scheduler on Astro, see [Scheduler resources](/docs/astro/deployment-resources#scheduler).
* *Scheduler logs* describe the performance of the scheduler, which is responsible for scheduling and queueing task runs. These logs can help you understand scheduler performance and indicate if a task failed due to an issue with the scheduler. For more information on configuring the scheduler on Astro, see [Scheduler resources](/docs/astro/deployment-resources#scheduler).
* *Triggerer logs* describe the performance of the triggerer, the Airflow component responsible for running triggers and signaling tasks to resume when their conditions have been met. The triggerer is used exclusively for tasks that are run with [deferrable operators](/docs/learn/deferrable-operators).
* *Worker logs* are generated by Celery Workers and can help you monitor task execution to optimize performance. This type of log is not available when using the Kubernetes Executor.
* *Webserver logs* relate to the health and performance of [the Airflow UI](/docs/learn/airflow-components). If the Airflow UI at any point does not load, for example, webserver/API server logs might indicate why.
### Airflow component log levels
Logs and messages might also be associated with one of the following *log levels*:
* **Error**: Emitted when a process fails or does not complete. For example, these logs might indicate a missing dag file, an issue with your scheduler's connection to the Airflow database, or an irregularity with your scheduler's heartbeat.
* **Warn**: Emitted when Airflow detects an issue that may or may not be of concern but does not require immediate action. This often includes deprecation notices marked as `DeprecationWarning`. For example, Airflow might recommend that you upgrade your Deployment if there was a change to the Airflow database or task execution logic.
* **Info**: Emitted frequently by Airflow to show that a standard scheduler process, such as dag parsing, has started. These logs are frequent and can contain useful information. If you run dynamically generated dags, for example, these logs will show how many dags were created per dag file and how long it took the scheduler to parse each of them.
### View Airflow component logs in the Astro UI
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
You can access scheduler, triggerer, and task logs in the Astro UI to find the past 24 hours of logs for any Deployment on its **Logs** page.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the **Logs** tab.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Logs** tab.
The maximum number of lines returned is 10,000, with 50 results displayed per page. If there are no logs available for a given Deployment, the following message appears:
```text wrap theme={null}
No matching events have been recorded in the past 24 hours.
```
Typically, this indicates that the Deployment you selected does not currently have any dags running.
#### Filter options
You can use the following options to specify the types of logs or messages that you want to view.
* **String search**: Enter a string, keyword, or phrase to find in your logs. You can also search with suffix wildcards by adding a `*` to your search query. For example, `acti*` returns results that include `action` and `acting`. The string search does not include fuzzy matching, so misspelled strings or incomplete strings without a wildcard, `*`, return zero results.
* **Time range**: Filter the logs displayed based on time.
* **Log type**: Filter based on whether the log message is from a **DAG Processor**, **Scheduler**, **Worker**, **Webserver/API Server**, or **Triggerer**.
### View Airflow component logs locally
To show logs for your Airflow scheduler, webserver, or triggerer locally, run the following Astro CLI command:
```sh wrap theme={null}
astro dev logs
```
After you run this command, the most recent logs for these components appear in your terminal window.
By default, running `astro dev logs` shows logs for all Airflow components. To see logs only for a specific component, add any of the following flags to your command:
* `--scheduler`
* `--webserver`
* `--triggerer`
To continue monitoring logs, run `astro dev logs --follow`. The `--follow` flag ensures that the latest logs continue to appear in your terminal window. For more information about this command, see [CLI Command Reference](/docs/cli/v1.43/astro-dev-logs).
## Airflow task logs
Airflow task logs can help you troubleshoot a specific task instance that failed or retried. Based on your preference, you can choose to use to access task logs in the Astro UI or the Airflow UI. Both provide filters, search, and download options for task logs and share other information about your dag performance on the same page.
Task logs for Astro Deployments are retained for 90 days. The task log retention policy is not currently configurable.
You can also access local Airflow task logs in your local [Airflow UI](/docs/learn/airflow-ui) or [printed to the terminal](/docs/learn/logging#log-locations).
### Airflow task log levels
Similar to the Airflow component log levels, task logs might also be associated with one of the following log levels, that you can search or filter with:
* **Error**
* **Warn**
* **Info**
* **Debug**
* **Critical**
### View task logs in the Airflow UI
1. Access the Airflow UI.
* To access the Airflow UI for a Deployment, open the Deployment in the Astro UI and click **Open Airflow**.
* To access the Airflow UI in a local environment, open a browser and go to `http://localhost:8080`.
2. Click a dag.
3. Click **Graph**.
4. Click a task run.
5. Click **Instance Details**.
6. Click **Log**.
## See also
* [Export task logs and metrics to Datadog](/docs/astro/export-datadog)
* [Export task logs to AWS CloudWatch](/docs/astro/export-cloudwatch)
* [Export task logs to AWS CloudWatch](/docs/astro/export-cloudwatch)
* [Export logs to a Secondary S3 Bucket](/docs/astro/export-secondary-s3-bucket)
* [Export logs to a Secondary WASB Container](/docs/astro/export-secondary-wasb)
# Astronomer Documentation
Source: https://astronomer.io/docs/index
Everything you need to know about Astronomer's modern data orchestration tool for the cloud, powered by Apache Airflow®.
Astronomer Documentation
Everything you need to know about Astronomer's modern data orchestration tool for the cloud, powered by Apache Airflow®.
Explore Astronomer
Build and run your critical data pipelines with Airflow.
Astronomer's data engineering agent, purpose built for Apache Airflow.
Run Apache Airflow® in your environment.
Get started with Apache Airflow and with all Astronomer products.
The distribution of Apache Airflow that powers Astro.
A comprehensive view of your Airflow pipeline data lineage and health.
Tutorials and concepts for everything you need to know about running Airflow 3.
Automate and integrate with Astro using a fully documented REST API.
Get started
Free Airflow courses taught by the Astronomer experts behind the project.
Connect an agent to our MCP server, or read the docs as Markdown and llms.txt.
What's new
# Use these docs with AI
Source: https://astronomer.io/docs/use-docs-with-ai
Connect an AI agent to Astronomer's documentation through an MCP server, raw Markdown pages, or llms.txt.
You can read Astronomer's documentation the way you always have, by browsing the site. If you're working with an AI agent, you have three additional ways to bring this documentation into its context: a hosted MCP server, raw Markdown pages, and `llms.txt` index files.
## MCP server
Astronomer hosts a Model Context Protocol (MCP) server at `https://www.astronomer.io/docs/mcp`. Connect an MCP-compatible client to it and the agent can search this documentation and pull specific pages into its context as it works, instead of relying on what it already knows.
Opening `https://www.astronomer.io/docs/mcp` in a browser returns a large JSON file. That's expected — it's an API endpoint for MCP clients, not a page meant to be viewed directly.
The server exposes three tools:
* **`search_astronomer`** — full-text search across the documentation and API references.
* **`query_docs_filesystem_astronomer`** — read-only, shell-like queries against a virtual filesystem of every documentation page and OpenAPI spec.
* **`submit_feedback`** — report a page that's incorrect, outdated, confusing, or incomplete.
### Connect a client
```bash theme={null}
claude mcp add --transport http astronomer-docs https://www.astronomer.io/docs/mcp
```
Go to **Settings** > **Connectors** > **Add custom connector**, and enter `https://www.astronomer.io/docs/mcp` as the server URL.
Open the command palette with ⌘+Shift+P (or Ctrl+Shift+P on Windows/Linux), run **Open MCP settings**, then **Add custom MCP** and enter `https://www.astronomer.io/docs/mcp` as the server URL.
Add an entry to your MCP configuration:
```json theme={null}
{
"servers": {
"astronomer-docs": {
"url": "https://www.astronomer.io/docs/mcp",
"type": "http"
}
}
}
```
## Markdown pages
Every documentation page is also available as raw Markdown. Append `.md` to any page's URL to fetch its plain-text source instead of the rendered HTML, for example `https://www.astronomer.io/docs/astro/overview.md`.
On the page itself, use the contextual menu in the top right to copy the page as Markdown or open it directly in ChatGPT or Claude.
## llms.txt
The root [llms.txt](/docs/llms.txt) file is an index of pointers to each product's documentation, in the format proposed by the [llms.txt standard](https://llmstxt.org/). Each product has its own nested `llms.txt`, and versioned products like Astro Private Cloud and the Astro CLI nest one level deeper, with a file per version:
```text theme={null}
/llms.txt Index of all products
/astro/llms.txt All Astro pages
/runtime/llms.txt All Astro Runtime pages
/cli/llms.txt Index of CLI versions
/cli/v1.43/llms.txt Astro CLI v1.43 pages
/astro-private-cloud/llms.txt Index of APC versions
/astro-private-cloud/v-2-x/llms.txt Astro Private Cloud v2.x pages
```
These files are generated to cover every supported and archived version of every product, including versions that aren't the default on the site.
# Configure Airflow email notifications on Astro
Source: https://astronomer.io/docs/astro/airflow-email-notifications
Set up email notifications for Airflow task successes and failures.
Incorporating a notification framework is critical to the health of your data pipelines. In addition to [Astro alerts](/docs/astro/alerts), you can configure the following Apache Airflow notification types on Astro:
* Slack notifications
* SLAs
* Email notifications
* Custom callbacks and notifiers
Use this guide to integrate with an SMTP service to have Astro send email notifications whenever a task run fails. To configure Dag alerts for Slack and PagerDuty, see [Astro alerts](/docs/astro/alerts). For best practices and instructions on configuring other notifications in Airflow, including notifiers and custom callbacks, see [Manage Airflow Dag notifications](/docs/learn/error-notifications-in-airflow).
## Configure Airflow email notifications
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
On Astro, setting up email notifications requires configuring an SMTP service for delivering each notification. You can use a single SMTP service for your Organization, but you must configure email notifications for each Deployment.
If your organization isn't using an SMTP service currently, Astronomer recommends one of the following:
* [SendGrid](https://sendgrid.com/)
* [Amazon SES](https://aws.amazon.com/ses/)
The following topics provide setup steps for integrating each of these external SMTP services on Astro, but any external SMTP service can be used.
### Integrate with SendGrid
[SendGrid](https://sendgrid.com/) is an email delivery service that you can use to configure Airflow notifications. A free SendGrid account grants users 40,000 free emails within the first 30 days of an account opening and 100 emails per day after that. This should be enough emails for most notification use cases.
1. [Create a SendGrid account](https://signup.sendgrid.com). Be prepared to disclose some standard information about yourself and your organization.
2. [Verify a Single Sender Identity](https://sendgrid.com/docs/ui/sending-email/sender-verification/). Because you're sending emails for only internal administrative purposes, a single sender identity is sufficient for integrating with Astro. The email address you verify here sends your Airflow notification emails.
3. Create a Sendgrid API key. In SendGrid, go to **Email API** > **Integration Guide**. Follow the steps to generate a new API key using SendGrid's Web API and cURL.
For more information, see [Sendgrid documentation](https://docs.sendgrid.com/ui/account-and-settings/api-keys#creating-an-api-key).
4. Skip the step for exporting your API key to your development environment. Instead, execute the generate cURL code directly in your command line, making sure to replace `$SENDGRID_API_KEY` in the `--header` field with your copied key.
5. Verify your integration in SendGrid to confirm that the key was activated. If you get an error indicating that SendGrid can't find the test email, try rerunning the cURL code in your terminal before retrying the verification.
6. Add the following line to the `requirements.txt` file of your Astro project to install the [SendGrid Airflow provider](https://airflow.apache.org/docs/apache-airflow-providers-sendgrid/stable/index.html):
```text wrap theme={null}
apache-airflow-providers-sendgrid
```
7. In the Astro UI, click **Environment** > **Environment Variables** > **New Environment Variable** to add the following environment variables. Select your workspace from the drop-down, and then add the following variables, one at a time:
| Environment variable key | Environment variable value |
| ------------------------------- | ----------------------------------------------------- |
| `AIRFLOW__EMAIL__EMAIL_BACKEND` | `airflow.providers.sendgrid.utils.emailer.send_email` |
| `AIRFLOW__EMAIL__EMAIL_CONN_ID` | `smtp_default` |
| `SENDGRID_MAIL_FROM` | `` |
For more information about these environment variables, see [Send email using SendGrid](https://airflow.apache.org/docs/apache-airflow/stable/howto/email-config.html#send-email-using-sendgrid).
8. In the Airflow UI, [create an Airflow connection](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html#creating-a-connection-with-the-ui) with the following values:
* **Connection ID**: `smtp_default`
* **Connection Type:**: `Email`
* **Host**: `smtp.sendgrid.net`
* **Login**: `apikey`
* **Password**: ``
* **Port**: `587`
9. Click **Save** to finalize your configuration.
10. To receive email notifications for task failures within a given Dag, configure the following values in the Dag's `default_args`:
```python wrap theme={null}
'email_on_failure': True,
'email': [''],
```
Repeat steps 7-10 for each Deployment where you want to configure Airflow notifications.
1. [Create a SendGrid account](https://signup.sendgrid.com). Be prepared to disclose some standard information about yourself and your organization.
2. [Verify a Single Sender Identity](https://sendgrid.com/docs/ui/sending-email/sender-verification/). Because you're sending emails for only internal administrative purposes, a single sender identity is sufficient for integrating with Astro. The email address you verify here sends your Airflow notification emails.
3. Create a Sendgrid API key. In SendGrid, go to **Email API** > **Integration Guide**. Follow the steps to generate a new API key using SendGrid's Web API and cURL.
For more information, see [Sendgrid documentation](https://docs.sendgrid.com/ui/account-and-settings/api-keys#creating-an-api-key).
4. Skip the step for exporting your API key to your development environment. Instead, execute the generate cURL code directly in your command line, making sure to replace `$SENDGRID_API_KEY` in the `--header` field with your copied key.
5. Verify your integration in SendGrid to confirm that the key was activated. If you get an error indicating that SendGrid can't find the test email, try rerunning the cURL code in your terminal before retrying the verification.
6. Add the following line to the `requirements.txt` file of your Astro project to install the [SendGrid Airflow provider](https://airflow.apache.org/docs/apache-airflow-providers-sendgrid/stable/index.html):
```text wrap theme={null}
apache-airflow-providers-sendgrid
```
7. In the Deployment view of the Astro UI, add the following environment variables
| Environment variable key | Environment variable value |
| ------------------------------- | ----------------------------------------------------- |
| `AIRFLOW__EMAIL__EMAIL_BACKEND` | `airflow.providers.sendgrid.utils.emailer.send_email` |
| `AIRFLOW__EMAIL__EMAIL_CONN_ID` | `smtp_default` |
| `SENDGRID_MAIL_FROM` | `` |
For more information about these environment variables, see [Send email using SendGrid](https://airflow.apache.org/docs/apache-airflow/stable/howto/email-config.html#send-email-using-sendgrid).
8. In the Airflow UI, [create an Airflow connection](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html#creating-a-connection-with-the-ui) with the following values:
* **Connection ID**: `smtp_default`
* **Connection Type:**: `Email`
* **Host**: `smtp.sendgrid.net`
* **Login**: `apikey`
* **Password**: ``
* **Port**: `587`
9. Click **Save** to finalize your configuration.
10. To receive email notifications for task failures within a given Dag, configure the following values in the Dag's `default_args`:
```python wrap theme={null}
'email_on_failure': True,
'email': [''],
```
Repeat steps 7-10 for each Deployment where you want to configure Airflow notifications.
### Integrate with Amazon SES
Use your existing Amazon SES instance to send Airflow notifications by email.
1. Sign in to the AWS Management Console and open the [Amazon SES console](https://console.aws.amazon.com/ses/).
2. Click the menu icon and then click **Verified Identities**.
3. Optional. Complete one of the following tasks:
* To confirm the email account is working and the Amazon SES service can send emails to it, click an email address in the **Identity** column and then click **Send test email**. When the owner of the email address receives the test email, they need to select the validation link in the email.
* To add a new email address, click **Create Identity**, add the email address, and then click **Create Identity**.
For email notifications, Astronomer recommends using one email address as the sender and a second email address as the recipient. All email addresses must be verified.
For more information about configuring Amazon SES, read [Creating an email address identity](https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html#:~:text=of%20those%20Regions.-,Creating%20an%20email%20address%20identity,-Complete%20the%20following) and [Verifying an email address identity](https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html#:~:text=address%20identity.-,Verifying%20an%20email%20address%20identity,-After%20you%E2%80%99ve%20created) in the Amazon documentation.
4. Click **Account dashboard**.
5. In the **Simple Mail Transfer Protocol (SMTP) settings** pane, copy the value displayed below **SMTP endpoint**.
6. Obtain your Amazon SES SMTP credentials:
* Click **Create SMTP credentials** in the **Simple Mail Transfer Protocol (SMTP) settings** pane.
* Enter a name for your SMTP user in the **IAM User Name** field or accept the default value.
* Click **Create** and then **Show User SMTP Security Credentials**.
* Click **Download Credentials** or copy them and store them in a safe place.
* Click **Close Window**.
7. In the Astro UI, click **Environment** > **Environment Variables** > click on the variable you want to edit, and then click **Edit**. Select your workspace from the drop-down, and then add the following variables, one at a time:
| Environment variable key | Environment variable value |
| ------------------------------- | ------------------------------------------- |
| `AIRFLOW__SMTP__SMTP_HOST` | Enter the value you copied in step 5 |
| `AIRFLOW__SMTP__SMTP_STARTTLS` | Enter `True` |
| `AIRFLOW__SMTP__SMTP_SSL` | Enter `False` |
| `AIRFLOW__SMTP__SMTP_USER` | Enter the value you copied in step 6 |
| `AIRFLOW__SMTP__SMTP_PASSWORD` | Enter the value you copied in step 6 |
| `AIRFLOW__SMTP__SMTP_PORT` | Enter `587` |
| `AIRFLOW__SMTP__SMTP_MAIL_FROM` | Enter your from email |
| `AIRFLOW__EMAIL__EMAIL_BACKEND` | Enter `airflow.utils.email.send_email_smtp` |
See [Set environment variables on Astro](/docs/astro/environment-variables).
8. To begin receiving Airflow notifications by email for task failures within a given Dag, configure the following values in the Dag's `default_args`:
```python wrap theme={null}
'email_on_failure': True,
'email': [''],
```
Repeat steps 7-8 for each Deployment in which you want to configure Airflow notifications.
1. Sign in to the AWS Management Console and open the [Amazon SES console](https://console.aws.amazon.com/ses/).
2. Click the menu icon and then click **Verified Identities**.
3. Optional. Complete one of the following tasks:
* To confirm the email account is working and the Amazon SES service can send emails to it, click an email address in the **Identity** column and then click **Send test email**. When the owner of the email address receives the test email, they need to select the validation link in the email.
* To add a new email address, click **Create Identity**, add the email address, and then click **Create Identity**.
For email notifications, Astronomer recommends using one email address as the sender and a second email address as the recipient. All email addresses must be verified.
For more information about configuring Amazon SES, read [Creating an email address identity](https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html#:~:text=of%20those%20Regions.-,Creating%20an%20email%20address%20identity,-Complete%20the%20following) and [Verifying an email address identity](https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html#:~:text=address%20identity.-,Verifying%20an%20email%20address%20identity,-After%20you%E2%80%99ve%20created) in the Amazon documentation.
4. Click **Account dashboard**.
5. In the **Simple Mail Transfer Protocol (SMTP) settings** pane, copy the value displayed below **SMTP endpoint**.
6. Obtain your Amazon SES SMTP credentials:
* Click **Create SMTP credentials** in the **Simple Mail Transfer Protocol (SMTP) settings** pane.
* Enter a name for your SMTP user in the **IAM User Name** field or accept the default value.
* Click **Create** and then **Show User SMTP Security Credentials**.
* Click **Download Credentials** or copy them and store them in a safe place.
* Click **Close Window**.
7. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
8. In the environment variables area, click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet) and add the following environment variables:
| Environment variable key | Environment variable value |
| ------------------------------- | ------------------------------------------- |
| `AIRFLOW__SMTP__SMTP_HOST` | Enter the value you copied in step 5 |
| `AIRFLOW__SMTP__SMTP_STARTTLS` | Enter `True` |
| `AIRFLOW__SMTP__SMTP_SSL` | Enter `False` |
| `AIRFLOW__SMTP__SMTP_USER` | Enter the value you copied in step 6 |
| `AIRFLOW__SMTP__SMTP_PASSWORD` | Enter the value you copied in step 6 |
| `AIRFLOW__SMTP__SMTP_PORT` | Enter `587` |
| `AIRFLOW__SMTP__SMTP_MAIL_FROM` | Enter your from email |
| `AIRFLOW__EMAIL__EMAIL_BACKEND` | Enter `airflow.utils.email.send_email_smtp` |
See [Set environment variables on Astro](/docs/astro/environment-variables).
9. To begin receiving Airflow notifications by email for task failures within a given Dag, configure the following values in the Dag's `default_args`:
```python wrap theme={null}
'email_on_failure': True,
'email': [''],
```
Repeat steps 7-9 for each Deployment in which you want to configure Airflow notifications.
# Set up Astro alerts
Source: https://astronomer.io/docs/astro/alerts
Configure Astro alerts to notify you in Slack, PagerDuty, or email when Dags complete, fail, or exceed expected task durations — without changing Dag code.
Astro alerts provide an additional level of observability to Airflow's notification systems. You can configure an alert to notify you in Slack, PagerDuty, or through email when a Dag completes, if you have a Dag run failure, or if a task duration exceeds a specified time. You can also define whether alerts apply to a specific Deployment or across an entire Workspace or Organization.
Unlike Airflow callbacks and SLAs, Astro alerts don't require changes to Dag code. Follow this guide to set up your Slack, PagerDuty, or email to receive alerts from Astro and then configure your Deployment to send alerts.
For configuring Airflow notifications, see [Airflow email notifications](/docs/astro/airflow-email-notifications) and [Manage Airflow Dag notifications](/docs/learn/error-notifications-in-airflow).
## Alert types
Each Astro alert has a notification channel and a trigger type. The notification channel determines the format and destination of an alert and the trigger type defines what triggers the alert.
### Dag and task alerts
You can trigger an alert to a notification channel using one of the following trigger types:
* **DAG Failure**: The alert triggers whenever the specified Dag fails. From the alert notification, you can open the failed Dag run in the Astro UI to start an Otto investigation. To investigate Dag failures automatically when this alert fires, send it to a **Dag Trigger** notification channel that calls the Otto investigation API. See [Investigate with Otto](/docs/astro/otto-investigate).
* **DAG Success**: The alert triggers whenever the specified Dag completes.
* **DAG Timeliness**: The alert triggers whenever the specified Dag doesn't produce a successful Dag run by the given **Verification Time** including the **Look Back Period**.
* **DAG Duration**: The alert triggers whenever the specified Dag doesn't produce a successful Dag run within the given **Duration**. If the Dag fails before the specified duration is exceeded, the alert is triggered.
* **Task Failure**: The alert triggers whenever the specified task fails.
* **Task Duration**: The alert triggers when a specified task takes longer than expected to complete successfully. If the task fails, the alert is triggered even if it fails before the specified duration is exceeded.
You can only set a task duration alert for an individual task. Alerting on task group duration isn't supported.Timeliness alerts only support Standard Time, as opposed to Daylight Saving Time. If you want Local Time support (for example, for [time zone aware Dags](https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/timezone.html#time-zone-aware-dags)), you must adjust the alert's UTC time when the time changes from Standard Time to Daylight Saving Time or from Daylight Saving Time to Standard Time.
### Deployment health alerts
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Deployment health alerts are customizable Astro Alerts that notify you about [Deployment health incidents](/docs/astro/deployment-health-incidents#deployment-incidents) and suggest specific remediation actions. You can use these alerts to proactively monitor when Deployment health issues arise. For example, you can create an alert for when the Airflow metadata database storage is unusually high. All available Deployment health alerts are enabled by default for new Deployments and can be individually created, deleted, and edited in the **Alerts** tab of existing Deployments. If you don't want Deployment health alerts for a new Deployment, deselect **Deployment Health Alerts** in the **Advanced** section of the Deployment creation page.
Astro enables the following Deployment health alerts by default for new Deployments. You can individually create and customize these alerts for any Deployment:
* **Airflow DB Storage Unusually High**: The alert triggers when the metadata database has tables that are larger than 50GiB (Info) or 75GiB (Warning).
* **Deprecated Runtime Version**: The alert triggers when your Deployment is using a deprecated Astro Runtime version.
* **Job Scheduling Disabled**: The alert triggers when the Airflow scheduler is configured to prevent automatic scheduling of new tasks using Dag schedules.
* **Worker Queue at Capacity**: The alert triggers when at least one worker queue in this Deployment is running the maximum number of tasks and workers.
### Deployment health alert notifications
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
For new Deployments, Astro creates the default [Deployment health alerts](#deployment-health-alerts) with **Email** as the notification channel **Type**. By default, these alerts notify the **Contact Emails** of the Deployment, specified in the **Advanced** section of the Deployment creation page.
If **Contact Emails** is empty, Astro displays the [fallback email(s)](/docs/astro/deployment-details#fallback-emails) that receives alert notifications for the Deployment in the **Advanced** section of Deployment configuration. To change this notification channel, ensure the **Contact Emails** field of your Deployment isn't blank by editing **Deployment Details.**
## Create an alert in the Astro UI
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
### Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project).
* An [Astro Deployment](/docs/astro/create-deployment). Your Deployment must run Astro Runtime 7.1.0 or later to configure Astro alerts and it must have [OpenLineage enabled](/docs/astro/observe-openlineage).
* A configured [notification channel](#configure-and-add-alert-notification-channels).
You can also work with Astro alerts and their notification channels with the [Astro API](/docs/astro/api/v-1-beta-1/platform/alerts/create-an-alert).
Astro alerts requires OpenLineage. By default, every Astro Deployment using Hosted Execution has OpenLineage enabled. If you disabled OpenLineage in your Astro Deployment, you need to enable it to use Astro alerts. See [Disable OpenLineage](/docs/astro/observe-openlineage#disable-openlineage-completely) to find how to disable and re-enable OpenLineage.
If you use [Remote Execution](/docs/astro/execution-mode#remote-execution), you must [enable OpenLineage for Remote Execution Agents](/docs/astro/remote-execution-configure-openlineage) to use Astro Alerts or Observe.
### Step 1: Create your alert
1. In the Astro UI, click **Alerting** > **Alerts**.
If you don't have permissions to add a notification channel or alert at your Workspace or Organization-level, you can add one in the **Alerts** form through the **Deployment settings** page.
1. In the Astro UI, click **Deployments** then select your Deployment.
2. Click the **Alerts** tab.
2. Click **New Alert**.
3. Choose the **Alert Type**.
* **Duration**: Enter the **Duration** for how long a Dag or task should take to run before you send an alert to your notification channels.
* **Timeliness**: Select the **Days of Week** that the alert should observe, the **Verification Time** when it should look for a Dag success, and the **Lookback Period** for how long it should look back for a verification time. For example, if an alert has a **Verification Time** of 3:00 PM UTC and a **Lookback Period** of 60 minutes, it will trigger whenever the given Dag doesn't produce a successful Dag run from 2:00 to 3:00 PM UTC.
**Initial evaluation behavior**
Alerts only evaluate runs that occur after the alert’s creation. If a Dag ran successfully within the **Look Back Period** of a timeliness alert, the alert will still trigger on initial evaluation, since that run occurred before the alert was created.
Timeliness alerts only support Standard Time, as opposed to Daylight Saving Time. If you want Local Time support (for example, for [time zone aware Dags](https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/timezone.html#time-zone-aware-dags)), you must adjust the alert's UTC time when the time changes from Standard Time to Daylight Saving Time or from Daylight Saving Time to Standard Time.
4. Choose the alert **Severity**, either **Info**, **Warning**, or **Critical**.
1. In the Astro UI, click **Alerting** > **Alerts**.
If you don't have permissions to add a notification channel or alert at your Workspace or Organization-level, you can add one in the **Alerts** form through the **Deployment settings** page.
1. In the Astro UI, click **Deployments** then select your Deployment.
2. Click the **Alerts** tab.
2. Click **+ New Alert**.
3. Choose the **Alert Type**
* **Duration**: Enter the **Duration** for how long a Dag or task should take to run before you send an alert to your notification channels.
* **Timeliness**: Select the **Days of Week** that the alert should observe, the **Verification Time** when it should look for a Dag success, and the **Lookback Period** for how long it should look back for a verification time. For example, if an alert has a **Verification Time** of 3:00 PM UTC and a **Lookback Period** of 60 minutes, it will trigger whenever the given Dag doesn't produce a successful Dag run from 2:00 to 3:00 PM UTC.
**Initial evaluation behavior**
Alerts only evaluate runs that occur after the alert’s creation. If a Dag ran successfully within the **Look Back Period** of a timeliness alert, the alert will still trigger on initial evaluation, since that run occurred before the alert was created.
Timeliness alerts only support Standard Time, as opposed to Daylight Saving Time. If you want Local Time support (for example, for [time zone aware Dags](https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/timezone.html#time-zone-aware-dags)), you must adjust the alert's UTC time when the time changes from Standard Time to Daylight Saving Time or from Daylight Saving Time to Standard Time.
4. Choose the alert **Severity**, either **Info**, **Warning**, or **Critical**.
### Step 2: Add alert rules
1. Define the **Workspace** and **Deployment**
The following alert types must be defined at the Deployment level:
* Dag alerts (Dag Duration, Dag Failure, Dag Success, Dag Timeliness)
* Deployment health alerts
* Task alerts (Task Duration, Task Failure)
2. For Dag and Task Alerts, you can further customize the circumstances in which the alert is triggered by defining:
* **Attribute**
* For Dag-level alerts: **DAG ID**
* For Task-level alerts: You can define rules for both the **DAG ID** and **Task ID** attributes.
* **Operator**
* **is one of**: Select specific Dags or tasks the alert should apply to. You can also choose **All dags** to apply the alert to all Dags in the Deployment and **All Tasks** to apply the alert to all tasks in the Dag.
* **contains**: Define a substring that is in the **DAG ID** and/or **Task ID** for the Dags and/or tasks that the alert should apply to.
* **Values**/**Substring**
The following example is a task-level alert for all tasks with a **Task ID** that contains the substring `prod` in all Dags within a Deployment:
### Step 3: Add notification channels for the alert
Select the Notification Channels for the Alert. You can also create a new notification channel by clicking **+Notification Channel**. See [Notification Channels](#configure-and-add-alert-notification-channels) for information on configuring and adding Notification Channels.
### Step 4: (Optional) Change an alert name
After you select a Dag that you want to apply an alert to, Astro automatically generates a name for your alert. However, you can choose to change the name of your alert.
1. Expand the **Change alert names...** section.
2. Edit the **Alert Name**.
3. Click **Create Alert** to save your changes.
### Step 5: (Optional) Test your Dag failure alert
Astro alerts work whether your Dag run is manual or scheduled, so you can test your configured Astro alerts by failing your Dag manually.
1. In the Astro UI, click **DAGs**.
2. Choose the Dag that has your alert configured.
3. Trigger a Dag run.
4. Select **Mark as** and choose **Failed** to trigger an alert for a Dag failure.
5. Check your Slack, PagerDuty, or Email alerts for your Dag failure alert. The alert includes information about the Dag, Workspace, Deployment, and data lineage associated with the failure as well as direct links to the Astro UI.
## Configure and add alert notification channels
You can send Astro alerts, including Deployment Health Alerts, to the following notification channels
* Slack
* PagerDuty
* Email
* Dag trigger
* Opsgenie
For alerts triggered by a specific Dag run, Slack and email notifications include the Airflow Dag run ID. Use it to find the run in the Airflow UI.The **Dag Trigger** notification channel works differently from other notification channel types. Instead of sending a pre-formatted alert message, Astro makes a generic request through the Airflow REST API to trigger a Dag on Astro. You can configure the triggered Dag to complete any action, such as sending a message to your own incident management system or writing data about an incident to a table.
### Notification channels scope
When you create a notification channel, you can define whether it is available to a specific Deployment or available to an entire Workspace or Organization. The type of scope you can use for your notification channels depends on your [user permissions](/docs/astro/user-permissions).
You can view, create, and manage notification channels for your Workspace or Organization in the **Notification Channels** page or when creating a Deployment alert.
### Step 1: Configure your notification channel
To set up alerts in Slack, you need to create a Slack app in your Slack workspace. After you've created your app, you can generate a webhook URL in Slack where Astro will send alerts.
1. Go to [Slack API: Applications](https://api.slack.com/apps/new) to create a new app in your organization's Slack workspace.
2. Click **From scratch** when prompted to choose how you want to create your app.
3. Enter a name for your app, like `astro-alerts`, choose the Slack workspace where you want Astro to send your alerts, and then click **Create App**.
If you don't have permission to install apps into your Slack workspace, you can still create the app, but you will need to request that an administrator from your team completes the installation.
4. Select **Incoming webhooks**.
5. On the **Incoming webhooks** page, click the toggle to turn on **Activate Incoming Webhooks**. See [Sending messages using Incoming Webhooks](https://api.slack.com/messaging/webhooks).
6. In the **Webhook URLs for your Workspace** section, click **Add new Webhook to Workspace**.
If you don't have permission to install apps in your Slack workspace, click **Request to Add New Webhook** to send a request to your organization administrator.
7. Choose the channel where you want to send your Astro alerts and click **Allow**.
8. After your webhook is created, copy the webhook URL from the new entry in the **Webhook URLs for your Workspace** table.
To set up an alert integration with PagerDuty, you need access to your organization's PagerDuty Service. PagerDuty uses the [Events API v2](https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgw-events-api-v2-overview#getting-started) to create a new integration that connects your Service with Astro.
1. Open your PagerDuty service and click the **Integrations** tab.
2. Click **Add an integration**.
3. Select **Events API v2** as the **Integration Type**.
4. On your **Integrations** page, open your new integration and enter an **Integration Name**.
5. Copy the **Integration Key** for your new Astro alert integration.
No external configuration is required for the email integration. Astronomer recommends allowlisting `astronomer.io` with your email provider to ensure that no alerts go to your spam folder. Alerts are sent from `postmaster@astronomer.io`.
The **Dag Trigger** notification channel works differently from other notification channel types. Instead of sending a pre-formatted alert message, Astro makes a generic request through the `DagRuns` endpoint of the [Airflow REST API](https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_dag_run) to trigger any Dag in your Workspace. You can configure the triggered Dag to complete any action, such as sending a message to your own incident management system or writing data about an incident to a table.
The alert payload includes the following parameters:
* `conf`: This parameter holds the alert payload:
* `alertId`: A unique alert ID.
* `alertType`: The type of alert triggered.
* `dagName`: The name of the Dag that the alert condition triggers.
* `message`: The detailed message with the cause of the alert.
* `airflowDagRunId`: The Airflow run ID of the Dag run that caused the alert. For example, `scheduled__2023-11-17T17:30:00+00:00`. This parameter is omitted when no Dag run is associated with the alert.
* `note`: By default, this is `Triggering dag on Airflow `.
The following is an example alert payload that would be passed through the API to trigger the `alert_dag` if `fail_dag` fails:
```json wrap theme={null}
{
"dagName": "alert_dag",
"alertType": "PIPELINE_FAILURE",
"alertId": "d75e7517-88cc-4bab-b40f-660dd79df216",
"airflowDagRunId": "scheduled__2023-11-17T17:30:00+00:00",
"message": "[Astro Alerts] Pipeline failure detected on dag fail_dag. \\nStart time: 2023-11-17 17:32:54 UTC. \\nFailed at: 2023-11-17 17:40:10 UTC. \\nAlert notification time: 2023-11-17 17:40:10 UTC. \\nClick link to investigate in Astro UI: https://cloud.astronomer.io/clkya6zgv000401k8zafabcde/dags/clncyz42l6957401bvfuxn8zyxw/fail_dag/c6fbe201-a3f1-39ad-9c5c-817cbf99d123?utm_source=alert\"\\n"
}
```
These parameters are accessible in the triggered Dag using [Dag params](/docs/learn/airflow-params).
1. Create a Dag that you want to run when the alert is triggered. For example, you can use the following Dag to run arbitrary Python code when the alert is triggered:
```python wrap theme={null}
from datetime import datetime
from typing import Any
from airflow.models.dag import DAG
from airflow.operators.python import PythonOperator
with DAG(
dag_id="register_incident",
start_date=datetime(2023, 1, 1),
schedule=None,
):
def _register_incident(params: dict[str, Any]):
failed_dag = params["dagName"]
print(f"Register an incident in my system for DAG {failed_dag}.")
PythonOperator(task_id="register_incident", python_callable=_register_incident)
```
2. Deploy the Dag to any Deployment in the Workspace where you want to create the alert. The Dag that triggers the alert and the Dag that the alert runs can be in different Deployments, but they must be deployed in the same Workspace.
3. Create a [Deployment API token](/docs/astro/deployment-api-tokens) for the Deployment where you deployed the Dag that the alert will run. Copy the token to use in the next step.
### Step 2: Add a notification channel in the Astro UI
You can add notification channels in the Astro UI.
1. In the Astro UI, click **Alerting** > **Notification Channels**.
2. Click **New Notification Channel**.
3. Enter a name for your notification channel.
4. Choose the Channel Type.
5. Add the notification channel information.
Paste the Webhook URL from your Slack workspace app. If you need to find a URL for an app you've already created, go to your [Slack Apps](https://api.slack.com/apps) page, select your app, and then choose the **Incoming Webhooks** page.
Paste the Integration Key from your PagerDuty Integration and select the **Severity** of the alert.
Enter the email addresses that should receive the alert.
Select the Deployment where your Dag is deployed, then select the Dag. Enter the Deployment API token that you created in Step 1.
6. Choose the scope by defining what you want to make **Notification channel available to:**
7. Click **Create notification channel**.
## Notification History
To view a historical log of all previously triggered Alerts for your Organization, click **Notification History** under the **Alerting** section of the navigation. You can filter the notification log based on:
* **Alert**: Which Alert triggered the notification
* **Time Range**: The time range the notification was triggered in
* **Notification Channel**: The notification channel that is defined for the Alert
* **Status**: Whether the notification was successfully **sent** or **failed**
To view the notification history for a particular Alert, click **Alerts** in the **Alerting** section of the navigation. Here, you can see the number of times an Alert sent a notification (in the "Sent" column) or failed to send a notification (in the "Failed" column). Click the number in the **Sent** column to see notification history for that Alert.
# API authentication and token security
Source: https://astronomer.io/docs/astro/api-authentication
How Astro authenticates API requests, including token types, JWT validation, default and configurable lifetimes, rotation, and revocation.
Astro authenticates programmatic and UI-driven API requests with bearer tokens. This page describes the token types Astro supports, how each is validated, default and configurable lifetimes, rotation and revocation behavior, and current limitations. Use it to evaluate the Astro API authentication model from a security perspective.
For step-by-step instructions on creating each token type, see [Organization API tokens](/docs/astro/organization-api-tokens), [Workspace API tokens](/docs/astro/workspace-api-tokens), [Deployment API tokens](/docs/astro/deployment-api-tokens), and [Authenticate an automation tool to Astro](/docs/astro/automation-authentication).
## Token types
Astro supports two categories of bearer tokens:
* **Customer-created API tokens**. You create these tokens in the Astro UI or with the Astro API to authenticate automation, CI/CD pipelines, and external integrations. Astro scopes each token to an Organization, Workspace, or Deployment.
* **UI-issued short-lived tokens**. The Astro UI requests these tokens from its `/token` endpoint after you sign in. The UI and Astro CLI use them to make authenticated requests on your behalf during an active session.
The following table summarizes each token type:
| Token type | Scope | Issuer | Default lifetime | Configurable lifetime |
| ----------------------- | ------------ | ------ | ---------------- | ---------------------------------------- |
| Organization API token | Organization | Astro | Set at creation | Yes, at creation |
| Workspace API token | Workspace | Astro | Set at creation | Yes, at creation |
| Deployment API token | Deployment | Astro | Set at creation | Yes, at creation |
| UI-issued session token | User session | Auth0 | 8 hours | Up to 30 days through refresh token flow |
## Token validation
All Astro bearer tokens are JSON Web Tokens (JWTs). Astro validates each request by verifying the token's signature, issuer, audience, and expiration (`exp`) claim before authorizing the request.
* Customer-created Organization, Workspace, and Deployment API tokens are JWTs that Astro signs and validates.
* UI-issued session tokens are JWTs that Auth0 signs. Astro validates these tokens through the [Auth0 Identifier First Authentication flow](https://auth0.com/docs/authenticate/login/auth0-universal-login/identifier-first).
Astro rejects tokens with invalid signatures, missing or incorrect claims, or expired `exp` values.
## Token lifetime
You control how long customer-created API tokens remain valid. When you create an Organization, Workspace, or Deployment API token, set the **Expiration** field to the number of days that the token can be used. After the expiration, Astro rejects the token. Astronomer recommends setting the shortest expiration that meets your automation requirements.
UI-issued session tokens have a default lifetime of 8 hours. The Astro UI can extend an active session up to 30 days through a refresh token flow. After this maximum, you must sign in again to obtain a new session token.
## Token rotation and revocation
Astro provides rotation and revocation controls for customer-created API tokens:
* **Rotation**. You can rotate an Organization, Workspace, or Deployment API token from the Astro UI or with the Astro API. Rotation issues a new token value and invalidates the previous value. See [Rotate an Organization API token](/docs/astro/organization-api-tokens#rotate-an-organization-api-token) for an example.
* **Revocation**. Deleting an API token immediately revokes it. Astro rejects any subsequent request that presents the deleted token.
UI-issued session tokens can't be rotated directly. To invalidate an active session, sign out of the Astro UI, which ends the session and invalidates the associated refresh token.
Token rotation replaces the previous token value immediately. The previous value stops working as soon as Astro issues the new value. Plan rotations to minimize the gap between updating the new value in your automation and the previous value becoming invalid.
## Current limitations
The Astro API authentication model has the following current limitations:
* **No Organization-wide maximum-lifetime policy**. Organization Owners can't enforce a maximum expiration across all API tokens created in an Organization. Each token creator sets the expiration at creation time. Astronomer recommends defining and communicating an internal policy for maximum token lifetimes, and auditing existing tokens through the Astro UI.
* **No grace period during rotation**. The public rotation endpoint doesn't allow the previous token value to remain valid alongside the new value for a grace period. To minimize automation downtime, update the new token value in all consumers as soon as you rotate the token.
## See also
* [Organization API tokens](/docs/astro/organization-api-tokens)
* [Workspace API tokens](/docs/astro/workspace-api-tokens)
* [Deployment API tokens](/docs/astro/deployment-api-tokens)
* [Authenticate an automation tool to Astro](/docs/astro/automation-authentication)
* [User permissions reference](/docs/astro/user-permissions)
# Assets overview
Source: https://astronomer.io/docs/astro/assets-overview
About data assets in Astro Observe.
The **Asset Catalog** captures Airflow assets (Dags, tasks, datasets) and data assets (tables) that are automatically emitted during Airflow job runs. Assets in Astro represent the storage and movements of data through Airflow jobs.
Astro Assets are distinct from [Airflow Assets](https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/assets.html), a user-defined logical grouping of data. Astro Assets include but aren't limited to Airflow Assets.
You can find a list of assets in your Organization in the **Asset Catalog** page of Observe.
## Add assets to Observe
After your Dags run at least once, Observe automatically stores information about the tasks, datasets, warehouse tables, and local files you use in your Dags as Assets. You can then find these assets in the **Asset Catalog**.
## View the Asset Catalog
To view the **Asset Catalog**:
In the Astro UI, click **Observe** > **Catalog** (**Asset Catalog** in the legacy UI).
The Asset Catalog displays all assets in your Organization. Each asset shows:
* Asset name and type
* Deployment name
* Dag ID for Airflow assets
* Operator Class for Airflow tasks
* Previous 14 runs status
* Last updated timestamp
* Owner
* Tags
## Search and filter assets
Use the search and filter controls to find specific assets:
* **Search**: Use the search box to filter assets by name.
* **Sort**: Sort assets by last updated time.
* **Asset Type**: Filter by asset type, including:
* Airflow Task
* Airflow Dag
* Airflow Dataset
* OpenLineage Dataset
* Databricks Table
* Snowflake Table
* **Namespaces**: Filter assets by namespace.
* **DAGs**: Filter assets by Dag.
* **Tags**: Filter assets by tag.
* **Dependencies**: Filter by dependency type:
* **Leaf Assets**: Assets that have no downstream dependencies.
* **Root Assets**: Assets that have no upstream dependencies.
## Access asset information
Click an asset from the Asset Catalog to view detailed information about that asset.
After you open a specific asset, you can see detailed information about the Asset and its performance in each tab.
### Details
The **Details** tab includes metadata and information about your asset, organized in the following sections:
* Basic: information about Asset metadata
* Task metadata (Airflow tasks only): Specific task metadata, such as the Dag ID, owner, operator class, and task arguments
* Source: The last accessor of the asset
### Event timeline
The **Event Timeline** tab shows a chronological view of all events associated with the asset, including task successes, failures, SLA breaches, and dataset writes. Use the timeline to track asset activity, troubleshoot issues, and understand historical performance patterns. See [Event timeline](/docs/astro/assets-timeline).
### Lineage
The **Lineage** tab displays an interactive graph showing the upstream and downstream dependencies for the asset. This visualization helps you understand data flow and relationships in your pipelines. See [Asset lineage](/docs/astro/lineage-graph).
### Metrics
The **Metrics** tab displays performance metrics for the asset, including task retries, failures, and duration over time. These metrics help you identify trends and potential issues in your data pipelines.
### Data products
The **Data Products** tab shows which data products include this asset. This helps you understand the business context and impact of the asset across your organization. See [Data products](/docs/astro/create-data-products).
# Event timeline
Source: https://astronomer.io/docs/astro/assets-timeline
View asset event timeline in Astro Observe.
The event timeline provides a chronological view of all events associated with an asset in Astro Observe. Use the event timeline to track asset activity, troubleshoot issues, and understand historical performance patterns.
## View the event timeline
1. In the Astro UI, click **Observe** > **Catalog** (**Asset Catalog** in the legacy UI).
2. Select an asset from the list.
3. Click the **Event Timeline** tab.
The timeline displays a visual bar chart showing events over time, with a detailed event list showing timestamps, event types, and affected entities.
## Filter events
Use the filtering controls to narrow down the events displayed:
* **Run selection**: Choose **All Runs** or select a specific run to view its events.
* **Time period**: Select a time range and specify a date and time to view events before.
* **Event status**: Filter by **Success**, **Neutral**, or **Failure** events. Click a status indicator to toggle that event type on or off.
* **Only final asset events**: Toggle this option to show only events for final assets in your data product, excluding intermediate processing steps.
Click **+ filters** to access additional filtering options:
* **All Event Groups**: Filter events by event group.
* **Filter by namespace**: Filter events by namespace.
* **Filter by DAG**: Filter events by Dag.
* **Filter by Data Product**: Filter events by data product.
* **Filter by Deployment**: Filter events by Deployment.
## View event details
Click any event in the timeline to open a side panel with detailed information about that event, including:
* Event timestamp and metadata: Deployment name, DAG ID, Run ID, Owner
* **Root Cause**: For failure events, view root cause analysis or generate an AI log summary to diagnose the failure. See [Root cause analysis and AI log summaries](/docs/astro/root-cause-analysis).
* **Upstream Dependencies**: View any upstream failures or anomalies that may have contributed to the event
* **Downstream Dependencies**: See assets that depend on this asset, including Asset ID, Asset Name, and Asset Type
## Event types
Events are categorized by status to help you quickly identify issues and track successful operations.
### Success events
Success events indicate normal, expected operations:
* **SLA Success**: An SLA requirement was met
* **Task Success**: An Airflow task completed successfully
* **Task Start**: An Airflow task began execution
### Neutral events
Neutral events represent data operations that don't indicate success or failure:
* **Airflow dataset write**: Data was written to an Airflow dataset
* **OpenLineage dataset write**: Data was written and captured by OpenLineage
### Failure events
Failure events indicate problems that require attention:
* **Alert notification**: An alert was triggered
* **SLA Breach**: An SLA requirement wasn't met
* **Task failure**: An Airflow task failed
## Understand the timeline visualization
The bar chart at the top of the timeline shows event distribution over time:
* **Green bars**: Represent successful events
* **Red bars**: Represent failed events
* **Gray bars**: Represent neutral events
Taller bars indicate multiple events occurring in that time period. Use this visualization to quickly identify patterns, such as recurring failures or periods of high activity.
# Astro executor
Source: https://astronomer.io/docs/astro/astro-executor
Learn how the Astro executor distributes Airflow 3 tasks to agents for improved scaling and reliability.
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
## Overview
The Astro executor is the default for all Airflow 3.x Deployments, and is the only executor you can use for Deployments in remote execution mode. The Astro executor consists of Agents that pull work from an API server. The API server manages the Agent lifecycle and controls task assignment logic, enabling more efficient workload distribution and scaling. This design differs from the Celery executor, where workers fetch tasks directly from a queue, and the Kubernetes executor, where the scheduler launches pods for each task.
By centrally managing both Agent scaling and task assignment, the Astro executor offers increased reliability, improved performance, and cost efficiency compared to other Airflow execution models.
## Remote Execution mode
In a remote execution mode Deployment, the Remote Execution Agents, data sources, code, secrets, and logs are housed in your environment while the API server is hosted in Astro's Orchestration Plane. To configure workers and scaling in Remote Execution mode, see [Remote Execution Agents](/docs/astro/remote-execution-configure-agents).
For more information on Remote versus Hosted execution mode, see [Execution mode](/docs/astro/execution-mode).
## Astro worker autoscaling logic in Hosted execution mode
If your Deployment is in [Hosted execution mode](/docs/astro/execution-mode), the number of Astro workers running per worker queue on your Deployment at a given time is based on two values:
* The total number of tasks in a `queued` or `running` state.
* The worker queue's setting for **Concurrency**.
The calculation is made based on the following expression:
`[Number of workers]= ([Queued tasks]+[Running tasks])/(Concurrency)`
[Kubernetes Event Driven Autoscaling](https://keda.sh/) (KEDA) computes these calculations every ten seconds. When KEDA determines that it can scale down a worker, it waits for five minutes after the last running task on the worker finishes before terminating the worker Pod.
When you push a new image to a Deployment, workers running tasks from before the code push don't shut down until those tasks are complete. To learn more about how changes to a Deployment can affect worker resource allocation, see [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
## Configure the Astro executor in Hosted execution mode
In Hosted execution mode, you can configure Astro executor in the following ways with the Astro UI:
* The type and size of your workers.
* The minimum and maximum number of workers that your Deployment can run at a time.
* The number of tasks that each worker can run at a time.
You can set these configurations per [worker queue](/docs/astro/configure-worker-queues). With the Astro executor, you can configure multiple worker queues for different types of tasks and assign tasks to those queues in your Dag code.
The following document explains basic Astro executor configurations for a single worker queue. For instructions on how to configure multiple worker queues, see [Create a worker queue](/docs/astro/configure-worker-queues#create-a-worker-queue).
If you plan to use only the `KubernetesPodOperator` in your Deployment, set your worker resources to the lowest possible amounts, because the worker is only required for launching your Pods. See [`KubernetesPodOperator`](/docs/astro/kubernetespodoperator) for more information.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Configure Astro worker scaling in Hosted execution mode
For each worker queue on your Deployment, you have to specify certain settings that affect worker scaling behavior. If you're new to Airflow, Astronomer recommends using the defaults in Astro for each of these settings.
1. In the Astro UI, click **Deployments**.
2. Click the Deployment's **More actions** menu (⋯), then click **Edit Deployment**.
3. In the **Execution** section, edit the worker queue and configure the following settings:
* **Worker type**: Choose the amount of resources that each worker will have.
* **Concurrency**: The maximum number of tasks that a single worker can run at a time. If the number of queued and running tasks exceeds this number, a new worker is added to run the remaining tasks. This value is equivalent to the Apache Airflow [worker concurrency](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#worker-concurrency) setting. It is 16 by default.
* **Storage**: Choose the amount of ephemeral storage in GiB that each worker has. This storage volume is transient and allows for temporary storage and processing of data within the worker. The worker is assigned the minimum 10 GiB by default. The maximum quota is 100 GiB. Only ephemeral storage requests that are greater than the default minimum of 10 GiB are chargeable.
* **Worker Count (Min-Max)**: The minimum and maximum number of workers that can run at a time. The number of running workers changes based on **Concurrency** and the current number of tasks in a queued or running state. By default, the minimum number of workers is 1 and the maximum is 10.
The number of running workers might temporarily exceed the max when longer duration tasks delay scaled-down workers from shutting down.
4. Click **Update Deployment**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Details** tab and then click **Edit** in the **Execution** section to edit a worker queue.
3. Configure the following settings:
* **Worker type**: Choose the amount of resources that each worker will have.
* **Concurrency**: The maximum number of tasks that a single worker can run at a time. If the number of queued and running tasks exceeds this number, a new worker is added to run the remaining tasks. This value is equivalent to the Apache Airflow [worker concurrency](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#worker-concurrency) setting. It is 16 by default.
* **Storage**: Choose the amount of ephemeral storage in GiB that each worker has. This storage volume is transient and allows for temporary storage and processing of data within the worker. The worker is assigned the minimum 10 GiB by default. The maximum quota is 100 GiB. Only ephemeral storage requests that are greater than the default minimum of 10 GiB are chargeable.
* **Worker Count (Min-Max)**: The minimum and maximum number of workers that can run at a time. The number of running workers changes based on **Concurrency** and the current number of tasks in a queued or running state. By default, the minimum number of workers is 1 and the maximum is 10.
The number of running workers might temporarily exceed the max when longer duration tasks delay scaled-down workers from shutting down.
4. Click **Update Queue**.
## See also
* [Configure worker queues](/docs/astro/configure-worker-queues).
# Astro Observe overview
Source: https://astronomer.io/docs/astro/astro-observe
Gain insight into the health and performance of your data pipelines and lifecycle.
Astro Observe delivers pipeline-aware data observability purpose-built for Airflow, giving your team visibility into the health, quality, and performance of your business critical data products across the modern data stack.
Using Observe, you can monitor business-critical pipelines as data products, track SLAs, troubleshoot pipeline- or data-level failures, and understand health across your data ecosystem.
If you use [Remote Execution](/docs/astro/execution-mode#remote-execution), you must [enable OpenLineage for Remote Execution Agents](/docs/astro/remote-execution-configure-openlineage) to use Astro Alerts or Observe.
## Health
The **Data Pipelines Health Overview** shows a high-level view of operational and business health across your pipelines and data products.
The dashboard includes pipeline-level run metrics, like failed runs and retries, to identify top silent failures and problematic jobs. The dashboard also shows reliability metrics across the platform, like SLA evaluations and triggered alerts, to help you identify issues at a glance and understand the overall health of your data ecosystem.
## Data products
In Observe, a data product is a composition of assets that deliver a result with business relevance. Observe automatically infers upstream dependencies for the assets that define a data product, like an Airflow dag that populates a dashboard or a Snowflake table powering a recommendation engine.
Data products in Observe can include data assets across Airflow deployments. For example, a set of five dags across different deployments that all populate an executive dashboard with product analytics can be grouped together into a single data product in Observe.
For guidance on identifying data products in your organization, see [how to identify data products in your organization](/docs/learn/data-products#how-to-identify-data-products-in-your-organization).
* Dependencies. A real-time lineage graph displays the relationships between the final assets in a data product and the upstream assets that feed into it.
* SLA evaluations. You can create custom business-level Service Level Agreements for evaluating the on-time delivery of a data product or its freshness. You can also view all SLAs in effect for the data product along with their current statuses at a glance.
* Metrics. You can see key metrics for assets across your data product, like task failures and retries.
See [Create a Data Product](/docs/astro/create-data-products) to refer to steps to create your own data products. Or, to follow a quickstart, see [Get started with Astro Observe](/docs/learn/astro-observe-quickstart).
## Monitors
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Monitors in Astro Observe allow you to automatically track the health of your data products and pipelines. When configured, monitors can trigger alerts for failures or critical events in your data products, enabling rapid detection and resolution of issues.
See [Monitors in Astro Observe](/docs/astro/observe-monitors) for set-up instructions and details.
## Asset Catalog
Assets include information about the attribute details and historical data regarding task runs. In the Astro UI, when you click **Catalog** (in the legacy UI, click **Observe** and then **Asset Catalog** in the Organization menu), you can view and filter the different data assets in your Workspace.
In this view you can see the following information about your Assets, including:
* Name
* Asset type
* Namespace
* Dag ID
* Owner
You can click on any asset to view more detailed information about it, such as historical metrics and metadata. To learn more about using assets and accessing metrics, see [Assets overview](/docs/astro/assets-overview).
# Export Astro audit logs
Source: https://astronomer.io/docs/astro/audit-logs
Export Astro audit logs to track administrative activities and meet compliance requirements.
Astro audit logs record administrative activities and events in your Organization. You can use the audit logs to determine who did what, where, and when. You can also use audit logs to ensure your Organization is meeting its security and regulatory requirements. For example, you can use audit logs to determine when users were added to your Organization or to individual Workspaces.
See [Reference: Astro audit log fields](#audit-logs-reference) for a complete list of available fields in audit logs.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Export audit logs
Audit logs are retained for 90 days. The [Organization Owner](/docs/astro/user-permissions#organization-roles) role is required to export audit logs.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Export…** next to **Audit Logs**.
2. Select the number of days of audit data to export, then click **Export Logs**.
1. Click **Organization Settings** in the Astro UI.
2. In the **Audit Logs** menu, select the number days of audit data to export and then click **Export**.
The extracted audit log data is saved as a [newline delimited JSON (ndjson)](https://github.com/ndjson/ndjson-spec) file with the default filename `-logs--days-.ndjson`.
**CLI**
You can also export logs using the Astro CLI. Run the following command to export audit logs as a GZIP file to your current directory:
```bash wrap theme={null}
astro organization audit-logs export --organization-name=""
```
## Audit logs reference
This section is a reference for all available fields in [Astro audit logs](/docs/astro/audit-logs).
The following categories of event data are available in an audit log:
* **API events**: The data generated by user actions in the Astro UI, Astro CLI, or from internal processing actions in the Astro control plane.
* **Airflow UI access**: The data generated when users access the Airflow UI.
* **Astronomer container registry access**: The data generated when users access the Astronomer container registry with the Astro CLI.
The audit log file is provided as a newline delimited JSON (NDJSON) file. Every entry in the audit log file corresponds to an event, and event attributes provide additional information about each event.
### Common fields
The following table lists the common fields shared by all categories of event data.
#### Table: Common fields in audit logs
| Field | Description |
| ---------------- | --------------------------------------------------------------------------------------------------------------------- |
| `subjectId` | A unique identifier that identifies the initiator of the request. The value can be user ID. |
| `subjectType` | A unique identifier that identifies the subject of the request. The value can be `USER` or `SERVICEKEY`. |
| `organizationId` | A unique identifier that identifies your organization. This is the value displayed in the Astro UI **Settings** page. |
| `timestamp` | The date and time the event occurred. |
| `sourceIp` | The IP address of the originating request. |
| `userAgent` | The application used to make the request. |
To link the user ID back to a user, [Organization Owners](/docs/astro/user-permissions) can use the Astro Access Management UI by clicking **Access Management** in their **Organization Settings**.
### API event fields
Audit log events can be generated from the v1 API or the v2 API. Each API generates different fields for the same actions, and your audit log might include events from both APIs. Audit log event frequency for the v1 API are expected to decline as Astronomer transitions to the v2 API.
#### Table: v1 API event fields
| Field | Description |
| ------------------- | -------------------------------------------------------------------------------- |
| `correlationId` | A unique identifier for the request. |
| `graphqlClientName` | The type of client making the request. The values are `cloud-ui` or `cli`. |
| `operationName` | The name of the API event. For example, `createUserInvite` or `workspaceCreate`. |
| `requestBody` | Raw graphQL for the event. |
| `requestInput` | The input for the API request. |
The following table maps some common `operationName` attributes to their corresponding `requestInput` attributes.
#### Table: `operationName` attribute mappings
| Event | `operationName` attribute | `requestInput` attributes |
| ------------------------------------- | --------------------------- | ------------------------- |
| A new Deployment is created. | `createDeployment` | `label`, `workspaceId` |
| A Deployment is updated. | `updateDeployment` | `deploymentSpec` |
| A Deployment variable is updated. | `updateDeploymentVariables` | `isSecret`, `key` |
| The code for a Deployment is updated. | `ImageCreate` | `deploymentId` |
#### Table: v2 API event fields
| Field | Description |
| ----------------- | ----------------------------------------------- |
| `method` | The HTTP request type sent to REST API. |
| `path` | The path to the invoked REST API. |
| `requestBody` | The parameters passed as input to the API call. |
| `requestId` | A unique identifier for the request. |
| `response status` | The HTTP response status code. |
The following table maps some common `path` attributes to their corresponding `requestBody` attributes.
#### Table: `path` attribute mappings
| Event | `path` attribute | `requestBody` attributes |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| An Organization is created. | `/v1alpha1/organizations` | `metadata`, `name` |
| An Organization is updated. | `/v1alpha1/organizations/{orgShortNameId}` | `billingEmail`, `isScimEnabled`, `metadata`, `name` |
| A managed domain for an Organization is created. | `/v1alpha1/organizations/{orgShortNameId}/domains` | `enforcedLogins` `name` |
| A managed domain for an Organization is updated. | `/v1alpha1/organizations/{orgShortNameId}/domains/{domainId}` | `enforcedLogins` |
| A managed domain for an Organization is deleted. | `/v1alpha1/organizations/{orgShortNameId}/domains/{domainId}` | |
| A managed domain for an Organization is verified. | `/v1alpha1/organizations/{orgShortNameId}/domains/{domainId}/verify` | |
| An SSO Bypass Key for an Organization is created. | `/v1alpha1/organizations/{orgShortNameId}/sso-bypass-key` | |
| An SSO Bypass Key for an Organization is deleted. | `/v1alpha1/organizations/{orgShortNameId}/sso-bypass-key` | |
| An SSO Connection for an Organization is created. | `/v1alpha1/organizations/{orgShortNameId}/sso-connections` | |
| An SSO Connection for an Organization is updated. | `/v1alpha1/organizations/{orgShortNameId}/sso-connections/{connectionId}` | |
| An SSO Connection for an Organization is deleted. | `/v1alpha1/organizations/{orgShortNameId}/sso-connections/{connectionId}` | |
| A new user is invited to an Organization. | `/v1alpha1/organizations/{orgShortNameId}/invites` | `inviteEmail`, `role` |
| A invite to the Organization is updated. | `/v1alpha1/users/self/invites/{inviteId}` | `inviteStatus` |
| A invite to the Organization is deleted. | `/v1alpha1/organizations/{orgShortNameId}/invites/{inviteId}` | |
| A user is deleted from an Organization. | `/v1alpha1/organizations/{orgShortNameId}/users/{userId}` | |
| A user is assigned a new Organization role. | `/v1alpha1/organizations/{orgShortNameId}/users/{userId}/role` | `role` |
| A user's Organization, Workspace, Deployment, or DAG roles are updated. | `/v1alpha1/organizations/{orgShortNameId}/users/{userId}/roles` | `dagRoles`, `deploymentRoles`, `organizationRole`, `workspaceRoles` |
| A user is assigned a new workspace role. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/users/{userId}/role` | `role` |
| A user is removed from a workspace. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/users/{userId}` | |
| A Workspace is created. | `/v1alpha1/organizations/{orgShortNameId}/workspaces` | `apiKeyOnlyDeploymentsDefault`, `description`, `name` |
| A Workspace is updated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}` | `apiKeyOnlyDeploymentsDefault`, `description`, `name` |
| A Workspace is deleted. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}` | |
| A deployment is transferred to another workspace. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/deployments/{deploymentId}` | `workspaceIdTarget` |
| An AWS cluster is created. | `/v1alpha1/organizations/{orgShortNameId}/clusters/aws` | `dbInstanceType`, `k8sTags`, `name`, `nodePools`, `templateVersion` |
| An AWS cluster is updated. | `/v1alpha1/organizations/{orgShortNameId}/clusters/aws/{clusterId}` | `dbInstanceType`, `k8sTags`, `name`, `nodePools`, `templateVersion` |
| An Azure cluster is created. | `/v1alpha1/organizations/{orgShortNameId}/clusters/azure` | `dbInstanceType`, `k8sTags`, `name`, `nodePools`, `providerAccount`, `region`, `templateVersion`, `tenantId`, `type`, `vpcSubnetRange` |
| An Azure cluster is updated. | `/v1alpha1/organizations/{orgShortNameId}/clusters/azure/{clusterId}` | `dbInstanceType`, `k8sTags`, `name`, `nodePools`, `templateVersion`, |
| A GCP cluster is created. | `/v1alpha1/organizations/{orgShortNameId}/clusters/gcp` | `dbInstanceType`, `k8sTags`, `name`, `nodePools`, `podSubnetRange` `providerAccount`, `region`, `servicePeeringRange`, `serviceSubnetRange`, `templateVersion`, `type`, `vpcSubnetRange` |
| A GCP cluster is updated. | `/v1alpha1/organizations/{orgShortNameId}/clusters/gcp/{clusterId}` | `dbInstanceType`, `k8sTags`, `name`, `nodePools`, `templateVersion` |
| A cluster is deleted. | `/v1alpha1/organizations/{orgShortNameId}/clusters/{clusterId}` | |
| An Organization API token is created. | `/v1alpha1/organizations/{orgShortNameId}/api-tokens` | `description`, `name`, `role`, `tokenExpiryPeriodInDays` |
| An Organization API token is updated. | `/v1alpha1/organizations/{orgShortNameId}/api-tokens/{apiTokenId}` | `description`, `name`, `roles` |
| An Organization API token is deleted. | `/v1alpha1/organizations/{orgShortNameId}/api-tokens/{apiTokenId}` | |
| An Organization API token is rotated. | `/v1alpha1/organizations/{orgShortNameId}/api-tokens/{apiTokenId}/rotate` | |
| A Workspace API token is created. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/api-tokens` | `description`, `name`, `role`, `tokenExpiryPeriodInDays` |
| A Workspace API token is updated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/api-tokens/{apiTokenId}` | `description`, `name`, `role` |
| A Workspace API token is deleted. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/api-tokens/{apiTokenId}` | |
| A Workspace API token is rotated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/api-tokens/{apiTokenId}/rotate` | |
| A Team is created. | `/v1alpha1/organizations/{orgShortNameId}/teams` | `description`, `name`, `memberIds` |
| A Team is updated. | `/v1alpha1/organizations/{orgShortNameId}/teams/{teamId}` | `description`, `name` |
| A Team is deleted. | `/v1alpha1/organizations/{orgShortNameId}/teams/{teamId}` | |
| A Team is created via SCIM. | `/scim/v2/{orgShortNameId}/Groups` | `displayName`, `members`, `value`, `display` |
| A Team is updated via SCIM. | `/scim/v2/{orgShortNameId}/Groups/{teamId}` | `displayName`, `members`, `value`, `display` |
| A Team is deleted via SCIM. | `/scim/v2/{orgShortNameId}/Groups/{teamId}` | |
| A User is created via SCIM. | `/scim/v2/{orgShortNameId}/Users` | `userName`, `name`, `emails`, `displayName` |
| A User is updated via SCIM. | `/scim/v2/{orgShortNameId}/Users/{userId}` | `userName`, `name`, `emails`, `displayName` |
| A User is deleted via SCIM. | `/scim/v2/{orgShortNameId}/Users/{userId}` | |
| A user is added to a Team. | `/v1alpha1/organizations/{orgShortNameId}/teams/{teamId}/members` | `memberIds` |
| A user is removed from a Team | `/v1alpha1/organizations/{orgShortNameId}/teams/{teamId}/members` | |
| A Team is removed from a Workspace. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/teams/{teamId}` | |
| A Team's role in a Workspace is updated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/teams/{teamId}/role` | `role` |
| A dag is updated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}` | `isPaused` |
| A dag run is created. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}/runs` | `logicalDate` |
| A dag run has its state updated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}/runs/{pipelineRunId}` | `state` |
| A dag run is cleared. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}/runs/{pipelineRunId}/clear` | `isDryRun` |
| A task instance for a dag run is cleared. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}/clear-task-instances` | `endDate`, `includeDownstream`, `includeFuture`, `includeParentPipelines`, `includePast`, `includeSubPipelines`, `includeUpstream`, `onlyFailed`, `onlyRunning`, `pipelineRunId`, `resetPipelineRuns`, `startDate`, `taskIds` |
| A task instance's state is set. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}/runs/{pipelineRunId}/tasks/{taskId}` | `state` |
| A task instance's state is updated. | `/v1alpha1/organizations/{orgShortNameId}/workspaces/{workspaceId}/runtimes/{runtimeId}/pipelines/{pipelineName}/update-task-instances-state` | `executionDate`, `includeDownstream`, `includeFuture`, `includePast`, `includeUpstream`, `isDryRun`, `pipelineRunId`, `state`, `taskId` |
Use your analytics or audit tool to view additional attribute mapping information.
### Airflow UI access event fields
The following table lists the fields that are unique to Airflow UI access events.
#### Table: Airflow UI access event fields
| Field | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `method` | The HTTP method for the request. |
| `path` | The relative path of the page being accessed. For example, `/dzl9chy4/configuration`. |
| `targetUrl` | The URL for the canonical name record in the Airflow webserver that runs in the Astro data plane. For example, `https://cl8gwrnw601f10tyxhgrhaayw.astronomer.run`. |
The following table lists the fields that are unique to Astronomer container registry access events.
#### Table: Astronomer container registry access event fields
| Field | Description |
| -------------- | ------------------------------------------------------------------------------- |
| `deploymentId` | A unique identifier that identifies the Deployment on which the event occurred. |
| `method` | The HTTP method for the request. |
| `path` | The path to the image in the registry. |
## Astro CLI access event fields
The following table lists the fields that are unique to Astro CLI access events.
#### Table: Astro CLI access event fields
| Field | Description |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `astroClient` | A unique identifier for the API client. `cli` means the request came from the Astro CLI. |
| `astroClientVersion` | A unique identifier for the API client version. |
| `userAgent` | A unique identifier for the API client type and version. `astro-cli/1.15.1` means the request came from version 1.15.1 of the Astro CLI. |
# Authorize an Astro Deployment to cloud resources using workload identity
Source: https://astronomer.io/docs/astro/authorize-deployments-to-your-cloud
Give Astro Deployments access to your cloud resources using a Kubernetes workload identity
When you create an Airflow connection from a Deployment to access cloud resources, Airflow uses your connection details to access those services. You can add credentials to your Airflow connections to authenticate, but it can be risky to add secrets like passwords to your Airflow environment.
To avoid adding secrets to your Airflow connection, you can directly authorize your Astro Deployment to access AWS, GCP, and Azure cloud services using workload identity. Astronomer recommends using a workload identity in most cases to improve security and avoid managing credentials across your Deployments. If you have less strict security requirements, you can still use any of the methods described in [Airflow connection guides](/docs/learn/connections) to manage your connection authorization.
This guide explains how to authorize your Deployment to a cloud using workload identity. For each Deployment, you will:
* Authorize your Deployment to your cloud services.
* Create an Airflow connection to access your cloud services.
Watch the Astro Academy [Customer Workload Managed Identity](https://academy.astronomer.io/learning-bytes-customer-workload-managed-identity) Learning Byte video to learn more about managed identities and how to set up passwordless authentication for GCP.
## Prerequisites
The Astro cluster running your Deployment must be connected to your cloud's network. See [Networking overview](/docs/astro/networking-overview).
## What is workload identity?
A workload identity is a Kubernetes service account that provides an identity to your Deployment. The Deployment can use this identity to authenticate to a cloud's API server, and the cloud can use this identity to authorize the Deployment to access different resources.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Setup
You can also use either the Astro CLI or the Astro API to configure workload identity when you create or update a Deployment by providing the AWS ARN value.
See the following pages for more detail:
* [`astro deployment create`](/docs/cli/v1.43/astro-deployment-create#options-astro) CLI reference
* [`astro deployment update`](/docs/cli/v1.43/astro-deployment-update#options-astro) CLI reference
* [Create Deployment with the Astro API](/docs/astro/api/v-1/deployment/create-a-deployment)
* [Update Deployment with the Astro API](/docs/astro/api/v-1/deployment/update-a-deployment)
### Attach an IAM role to your Deployment
You can attach an AWS IAM role to your Deployment to grant the Deployment all of the role's permissions.
Using IAM roles provides the greatest amount of flexibility for authorizing Deployments to your cloud. For example, you can use existing IAM roles on new Deployments, or your can attach a single IAM role to multiple Deployments that all require the same level of access to your cloud.
#### Prerequisites (AWS)
* Minimum Astro Runtime version:
* 9.15.0
* 10.9.0
* 11.5.0
* A new or existing IAM role in your data sources with the required permissions you want your Deployment to have.
* If using [AWS CloudShell](https://aws.amazon.com/cloudshell/),
the required CLIs are enabled by default.
* If you use a local terminal, the following CLIs are required:
* [AWS CLI](https://aws.amazon.com/cli/)
* [jq](https://jqlang.github.io/jq/)
* [openSSL](https://www.openssl.org/source/)
#### Step 1: Authorize the Deployment to your IAM role (AWS)
To authorize your Deployment, create an IAM role to assign as your Deployment's workload identity:
1. [Create an IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) to delegate permissions to in an AWS service. Grant the role any permission that the Deployment will need in your AWS account. Copy the IAM role ARN to use later in this setup.
2. In the Astro UI, select your Deployment and then click **Details**. In the **Advanced** section, click **Edit**.
3. In the **Workload Identity** menu, select **Customer Managed Identity**.
4. Enter your IAM role ARN when prompted, then copy and run the provided CLI command. Click **Save Configuration** to save the IAM role as a selectable configuration.
**About the AWS CLI command**
The command performs the following actions in your AWS account:
* Creates an [IAM OIDC identity provider](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html) for the Astro cluster's EKS OIDC issuer URL, if one doesn't already exist. You can view existing providers in the AWS console at **IAM** > **Identity providers**.
* Updates the trust policy of the IAM role you specified to allow the Astro cluster's service accounts to assume the role through `sts:AssumeRoleWithWebIdentity`. You can view the updated trust policy in the AWS console at **IAM** > **Roles** > *your role* > **Trust relationships**.
The IAM principal that runs the command needs permissions to create OIDC providers and update IAM role trust policies, such as `iam:CreateOpenIDConnectProvider`, `iam:GetRole`, and `iam:UpdateAssumeRolePolicy`. If the command fails, verify these permissions and check the resources listed previously in the AWS console.
5. Click **Update Deployment** to apply the selected IAM role to the Deployment.
6. (Optional) Repeat these steps for each Astro Deployment that needs to access your AWS resources. Or, you can edit the `` value in `Condition` when setting up the Workload Identity for one of the following scenarios to apply to multiple Deployments.
Available for both Standard and Dedicated clusters. If your organization doesn't allow you to use a wildcards in your IAM Trust Policies, change the `` value in `Condition` to specify the Kubernetes service accounts. The following shows an example:
```json wrap theme={null}
{
"Condition": {
"StringLike": {
":aud": "sts.amazonaws.com",
":sub": [
"system:serviceaccount::-kpo",
"system:serviceaccount::-dag-processor-serviceaccount",
"system:serviceaccount::-scheduler-serviceaccount",
"system:serviceaccount::-triggerer-serviceaccount",
"system:serviceaccount::-apiserver-serviceaccount",
"system:serviceaccount::-worker-serviceaccount"
]
}
}
}
```
For Airflow 2 Deployments, `apiserver-serviceaccount` is named `webserver-serviceaccount`.
If you want to share or re-use the same customer managed identity on static or ephemeral Deployments for dedicated clusters, without having to update your Trust Policy in your AWS account for every net new Deployment, change the `` value in `Condition` to include a wildcard. You should only use a wildcard in dedicated clusters for security purposes. The following shows an example:
```json wrap theme={null}
{
"Condition": {
"StringLike": {
":aud": "sts.amazonaws.com",
":sub": "system:serviceaccount:*:*"
}
}
}
```
#### Step 2: Create an Airflow connection (AWS, IAM role)
Now that your Deployment is authorized, you can connect it to your cloud using an Airflow connection. Create an **Amazon Web Services** connection in either the [Astro UI](/docs/astro/create-and-link-connections) or the Airflow UI for your Deployment and specify the following fields:
* **Connection Id**: Enter a name for the connection.
If you don't see **Amazon Web Services** as a connection type in the Airflow UI, ensure you have installed its provider package in your Astro project's `requirements.txt` file. See **Use Provider** in the [Airflow Registry](https://airflow.apache.org/registry/providers/amazon) for the latest package.
If you use a mix of strategies for managing connections and define the same connection in multiple ways, Airflow uses the following order of precedence:
* Secrets Backend
* Environment Manager
* Environment Variables
* Airflow UI using the Airflow metadata database
### Alternative setup: Authorize your Deployment with AWS IAM roles
#### Step 1: Authorize the Deployment in your cloud (AWS, alternative setup)
To grant a Deployment access to a service that is running in an AWS account not managed by Astronomer, use AWS IAM roles to authorize your Deployment's workload identity. IAM roles on AWS are often used to manage the level of access a specific user, object, or group of users has to a resource, such as Amazon S3 buckets, Redshift instances, and secrets backends.
To authorize your Deployment, create an IAM role that is assumed by the Deployment's workload identity:
1. In the Astro UI, select your Deployment and then click **Details**. Copy the Deployment's **Workload Identity**.
2. In the AWS account that contains your AWS service, create an IAM role. See [Creating a role to delegate permissions to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html).
3. In the AWS Management Console, go to the Identity and Access Management (IAM) dashboard.
4. Click **Roles** and in the **Role name** column, select the role you created in Step 2.
5. Click **Trust relationships**.
6. Click **Edit trust policy** and paste the workload identity you copied from Step 1 in the trust policy. Your policy should look like the following:
```json wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [""]
},
"Action": "sts:AssumeRole"
}
]
}
```
7. Click **Update policy**.
Repeat these steps for each Astro Deployment that needs to access your AWS resources.
#### Step 2: Create an Airflow connection (AWS, alternative setup)
Now that your Deployment is authorized, you can connect it to your cloud using an Airflow connection. Either create an **Amazon Web Services** connection in the [Astro UI](/docs/astro/create-and-link-connections) or the Airflow UI for your Deployment and specify the following fields:
* **Connection Id**: Enter a name for the connection.
* **Extra**:
```json wrap theme={null}
{
"role_arn": "",
"region_name": ""
}
```
If you don't see **Amazon Web Services** as a connection type in the Airflow UI, ensure you have installed its provider package in your Astro project's `requirements.txt` file. See **Use Provider** in the [Airflow Registry](https://airflow.apache.org/registry/providers/amazon) for the latest package.
If you use a mix of strategies for managing connections, if you define the same connection in multiple ways, Airflow uses the following order of precedence:
* Secrets Backend
* Environment Manager
* Environment Variables
* Airflow UI using the Airflow metadata database
You can also use either the Astro CLI or the Astro API to configure workload identity when you create or update a Deployment by providing the GCP service account email.
See the following pages for more detail:
* [`astro deployment create`](/docs/cli/v1.43/astro-deployment-create#options-astro) CLI reference
* [`astro deployment update`](/docs/cli/v1.43/astro-deployment-update#options-astro) CLI reference
* [Create Deployment with the Astro API](/docs/astro/api/v-1/deployment/create-a-deployment)
* [Update Deployment with the Astro API](/docs/astro/api/v-1/deployment/update-a-deployment)
### Attach a service account to your Deployment
You can attach a custom GCP service account to your Deployment to grant the Deployment all of the service account's permissions.
Using service accounts provides the greatest amount of flexibility for authorizing Deployments to your cloud. For example, you can use existing service accounts on new Deployments, or your can attach a single service account to multiple Deployments that all have the same level of access to your cloud.
1. [Create a service account](https://cloud.google.com/iam/docs/service-accounts-create) in the GCP project that you want your Deployment to access. Grant the service account any permissions that the Deployment will need in your GCP project. Copy the service account ID to use later in this setup.
2. In the Astro UI, select your Deployment, then click **Details**. In the **Advanced** section, click **Edit**.
3. In the **Workload Identity** menu, select **Customer Managed Identity**
4. Enter your GCP service account ID when prompted, then copy and run the provided gcloud CLI command.
**About the gcloud CLI command**
The command adds an IAM policy binding to your GCP service account that grants the `roles/iam.workloadIdentityUser` role to each of the Deployment's Kubernetes service accounts (`scheduler`, `triggerer`, `worker`, `apiserver`, `dag-processor`, and `kpo`). This allows those workloads to impersonate your GCP service account through workload identity federation.
You can view the updated bindings in the Google Cloud console at **IAM & Admin** > **Service Accounts** > *your service account* > **Permissions**.
The principal that runs the command needs the `iam.serviceAccountAdmin` role, or equivalent permissions including `iam.serviceAccounts.setIamPolicy`, on the GCP service account. If the command fails, verify these permissions and check the service account's IAM policy in the Google Cloud console.
5. Click **Update Deployment**. The service account is now selectable as a workload identity for the Deployment.
6. Complete one of the following options for your Deployment to access your cloud resources:
* Create a **Google Cloud** connection type in Airflow and configure the following values:
* **Connection Id**: Enter a name for the connection.
* **Impersonation Chain**: Enter the ID of the service account that your Deployment should impersonate.
* To access resources in a secrets backend, run the following command to create an environment variable that grants access to the secrets backend:
```bash wrap theme={null}
astro deployment variable create \
--deployment-id \
'AIRFLOW__SECRETS__BACKEND_KWARGS={"connections_prefix": "airflow-connections", "variables_prefix": "airflow-variables", "project_id": "", "impersonation_chain": ""}'
```
#### Dedicated clusters only: Share or reuse a managed identity using a wildcard
You can only use wildcard `principalSet` bindings with hosted dedicated clusters. Never use wildcard bindings with standard Deployments, which run on shared clusters.
If you want to share or reuse the same customer managed identity across multiple Deployments, for example with ephemeral Deployments, on a dedicated cluster without creating a per-Deployment IAM policy binding, you can use a wildcard `principalSet` binding. This authorizes all service accounts across all namespaces in the cluster to use your GCP service account, so you can specify the same custom workload identity on any Deployment in the cluster, including at Deployment creation time.
You can find the GKE project number and project ID for your cluster. Go to **Settings** > **Clusters** in the Astro UI and click the **Details** tab. You can also use a [GET cluster API call](https://www.astronomer.io/docs/astro/api/v-1/cluster/get-a-cluster) with your cluster ID.
```sh wrap theme={null}
gcloud iam service-accounts add-iam-policy-binding \
--role roles/iam.workloadIdentityUser \
--member "principalSet://iam.googleapis.com/projects//locations/global/workloadIdentityPools/.svc.id.goog/kubernetes.cluster/https://container.googleapis.com/v1/projects//locations//clusters/" \
--project
```
Replace the following values:
* ``: The cluster's region.
* ``: ID of the cluster.
* ``: ID of the serviceAccount or fully qualified identifier for the serviceAccount you want your Deployments to use.
* ``: The GCP project number for the Astro-managed GKE cluster.
* ``: The GCP project ID for the Astro-managed GKE cluster.
* ``: The GCP project that contains your service account.
### Alternative setup: Authorize your Deployment through GCP service account impersonation
If your organization has requirements over how service accounts are managed outside of your cloud, you can manually configure [GCP service account impersonation](https://cloud.google.com/docs/authentication/use-service-account-impersonation) to allow your Deployment's default workload identity to impersonate a service account in your GCP project.
1. [Create a service account](https://cloud.google.com/iam/docs/service-accounts-create) in the GCP project that you want your Deployment to access. Grant the service account any permissions that the Deployment will need in your GCP project. Copy the service account ID to use later in this setup.
2. In the Astro UI, select your Deployment, then click **Details**. Copy the Deployment's **Workload Identity**.
3. In the Google Cloud Console, open the **IAM & Admin > Service Accounts** menu, then open the service account you just created.
4. In the **Actions** column, click **Manage Permissions**, then click **Grant Access**. In the modal that appears, enter your Deployment's workload identity service account in the **Add Principals** field and select the [`Service Account Token Creator`](https://cloud.google.com/iam/docs/understanding-roles#iam.serviceAccountTokenCreator) in the **Assign Roles** field.
5. Complete one of the following options for your Deployment to access your cloud resources:
* Create a **Google Cloud** connection type in Airflow and configure the following values:
* **Connection Id**: Enter a name for the connection.
* **Impersonation Chain**: Enter the ID of the service account that your Deployment should impersonate.
Note that this implementation requires `apache-airflow-providers-google >= 10.8.0`. See [Add Python, OS-level packages, and Airflow providers](/docs/cli/v1.43/add-providers-packages).
* Specify the impersonation chain in code when you instantiate a Google Cloud operator. See [Airflow documentation](https://airflow.apache.org/docs/apache-airflow-providers-google/stable/connections/gcp.html#direct-impersonation-of-a-service-account). Note that if you configure both a connection type and an operator, the operator-level configuration takes precedence.
* To access resources in a secrets backend, run the following command to create an environment variable that grants access to the secrets backend:
```bash wrap theme={null}
astro deployment variable create \
--deployment-id \
'AIRFLOW__SECRETS__BACKEND_KWARGS={"connections_prefix": "airflow-connections", "variables_prefix": "airflow-variables", "project_id": "", "impersonation_chain": ""}'
```
### Alternative setup: Grant an IAM role to your Deployment workload identity
Complete this alternative setup if you don't have an existing Google service account that your Deployment workload identity can impersonate.
#### Step 1: Authorize the Deployment in your cloud (GCP)
To grant a Deployment access to a service that is running in a GCP account not managed by Astronomer, use your Deployment's workload identity. Workload identity is a service account in GCP that's used to manage the level of access for a specific user, object, or group of users to a resource, such as Google BigQuery or a GCS bucket.
To authorize your Deployment, grant the required access to your Deployment's workload identity:
1. In the Astro UI, select your Deployment, then click **Details**. In the **Workload Identity** dropdown menu, select **Default Identity**. Then, copy the workload identity that appears next to the dropdown menu.
2. Grant your Deployment's workload identity an IAM role that has access to your external data service. To do this with the Google Cloud CLI, run:
```bash wrap theme={null}
gcloud projects add-iam-policy-binding $GOOGLE_CLOUD_PROJECT \
--member=serviceAccount: \
--role=
```
To grant your workload identity an IAM role using the Google Cloud console, see [Grant an IAM role](https://cloud.google.com/iam/docs/grant-role-console#grant_an_iam_role).
Repeat these steps for each Deployment that needs to access your GCP resources.
#### Step 2: Create an Airflow connection (GCP)
Now that your Deployment is authorized, you can connect it to your cloud using an Airflow connection. Either create a **Google Cloud** connection in the [Astro UI](/docs/astro/create-and-link-connections) or the Airflow UI for your Deployment and specify the following fields:
* **Connection Id**: Enter a name for the connection.
* **Project Id**: Enter the ID of your Google Cloud Project where your services are running.
If you don't see **Google Cloud** as a connection type in the Airflow UI, ensure you have installed its provider package in your Astro project's `requirements.txt` file. See **Use Provider** in the [Airflow Registry](https://airflow.apache.org/registry/providers/google/) for the latest package.
If you use a mix of strategies for managing connections, if you define the same connection in multiple ways, Airflow uses the following order of precedence:
* Secrets Backend
* Environment Manager
* Environment Variables
* Airflow UI using the Airflow metadata database
In this setup, you'll authorize an existing user-assigned managed identity to a resource on Azure, then give permissions to your Deployment to assume that managed identity.
#### Prerequisites (Azure)
* A [Microsoft Entra ID tenant](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-create-new-tenant) with Global Administrator or Application Administrator privileges.
* A user-assigned managed identity on Azure. See [Azure documentation](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?source=recommendations\&pivots=identity-mi-methods-azp#create-a-user-assigned-managed-identity).
* The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli).
You can only use the same user-assigned managed identity for up to four Deployments. If you need to authorize more than four Deployments to Azure, you need to create more than one user-managed identity. For more information, see [Microsoft Entra documentation](https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-considerations#general-federated-identity-credential-considerations).
#### Step 1: Authorize the managed identity in Azure
1. In your Azure portal, open the resource that your managed identity needs access to. Then, select **Access control (IAM)**.
2. Click **Add** > **Add role assignment**.
3. Select the role for your managed identity, then click **Next**.
4. In the **Assign access to** section, select **Managed identity**. Click **+ Select Members** and choose your managed identity. After you add your managed identity, click **Next**.
5. Review and finalize the assignment.
#### Step 2: Configure your Deployment
1. In your Azure portal, open the **Managed Identities** menu.
2. Search for your managed identity, click **Properties**, then copy its **Name**, **Client ID**, **Tenant ID**, and **Resource group** name.
3. In the Astro UI, select your Deployment, click **Details**, then click **How to Configure...** under **Workload Identity**.
4. In **Managed Identity**, enter the Name of the managed identity you assigned to the resource.
5. In **Resource Group**, enter the **Resource group** name that your managed identity belongs to.
6. Using the Azure CLI, copy and run the provided command in your local terminal.
**About the Azure CLI command**
The command creates [federated identity credentials](https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation) on your user-assigned managed identity, one for each of the Deployment's Kubernetes service accounts (`scheduler`, `triggerer`, `worker`, `apiserver`, `dag-processor`, and `kpo`). Each federated credential trusts the Astro cluster's OIDC issuer and maps a specific Kubernetes service account to your managed identity.
You can view the created credentials in the Azure portal at **Managed Identities** > *your managed identity* > **Settings** > **Federated credentials**.
The principal that runs the command needs the [Contributor](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#contributor) or [Owner](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#owner) role on the managed identity. If the command fails, verify these permissions and check the **Federated credentials** page in the Azure portal.
7. After the command completes, click **Close** on the window in the Astro UI.
8. (Optional) repeat Steps 4 - 8 for any other Deployments that need to be authorized to Azure.
#### Step 3: Create an Airflow connection (Azure)
1. In the Astro UI, go to **Environment** > **Connections**.
2. Click **+ New Connection** to add a new connection for your Workspace.
3. Search for **Azure**, then select the **Managed identity** option.
4. Configure your Airflow connection with the information you copied in the previous steps.
5. Link the connection to the Deployment(s) where you configured your managed identity.
1. In the Astro UI, click **Environment** in the main menu to open the **Connections** page.
2. Click **+ Connection** to add a new connection for your Workspace.
3. Search for **Azure**, then select the **Managed identity** option.
4. Configure your Airflow connection with the information you copied in the previous steps.
5. Link the connection to the Deployment(s) where you configured your managed identity.
Any Dag that uses your connection will now be authorized to Azure through your managed identity.
If you use a mix of strategies for managing connections, if you define the same connection in multiple ways, Airflow uses the following order of precedence:
* Secrets Backend
* Environment Manager
* Environment Variables
* Airflow UI using the Airflow metadata database
## See also
* [Manage Airflow connections and variables](/docs/astro/manage-connections-variables)
* [Deploy code to Astro](/docs/astro/deploy-code)
# Authorize Workspaces to a cluster
Source: https://astronomer.io/docs/astro/authorize-workspaces-to-a-cluster
Learn how to configure a cluster so that only specific Workspaces can use it.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
To provide greater control over your cloud resources, you can set a rule so that only specific Workspaces can use a specific cluster. For example, you can configure a cluster so that only production-level Workspaces can create Deployments in the cluster.
Use this document to learn restrict a cluster so that only authorized Workspaces can use it.
## Prerequisites
* [Organization Owner](/docs/astro/user-permissions#organization-roles) permissions.
* A [dedicated cluster](/docs/astro/create-dedicated-cluster).
## Authorize your workspace
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
1. In the Astro UI, go to **Settings** > **Clusters**, then select a cluster.
2. Go to the **Workspace Authorization** tab and then click **Edit Workspace Authorization**.
3. Click **Restricted** and select the Workspaces that you want to authorize to the cluster.
4. Click **Update**.
1. In the Astro UI's **Organization** section, click **Organization Settings**, then click **Clusters** and then select a cluster.
2. Go to the **Workspace Authorization** tab and then click **Edit Workspace Authorization**.
3. Click **Restricted** and select the Workspaces that you want to authorize to the cluster.
4. Click **Update**.
After you authorize Workspaces to a cluster, Astro treats the cluster as restricted. Restricted clusters do not appear in the dedicated cluster drop-down menu within the **Create Deployment** view of Workspaces that have not been authorized.
A restricted cluster can't host Deployments from an unauthorized Workspace. To restrict a cluster that's currently running Deployments from unauthorized Workspaces, you must transfer the Deployments from these Workspaces to the Workspaces you want to authorize.
Similarly, to unauthorize a Workspace but still keep its Deployments in the cluster, you must transfer your Deployments to a Workspace that is still authorized to the cluster. See [Transfer a Deployment to another Workspace](/docs/astro/transfer-a-deployment).
# Authenticate an automation tool to Astro
Source: https://astronomer.io/docs/astro/automation-authentication
Learn about all possible ways that you can authenticate your automation tool to Astro.
Before you can automate actions on Astro, you must prove to Astro that your automation tool has the correct identity and access to interact with specific Astro resources. Complete the following actions to authenticate to Astro using the Astro CLI and API tokens:
* Create an API token in Astro.
* Install the Astro CLI in your automation environment, such as a GitHub Actions.
* Make the token accessible to the Astro CLI installed in your automation environment.
After you complete this setup, your automation environment is authenticated to Astro. You can then write and run scripts to manage your Deployments through CI/CD.
Astro's authentication process is based on the [Auth0 Identifier First Authentication flow](https://auth0.com/docs/authenticate/login/auth0-universal-login/identifier-first). This process doesn't provide authorization and isn't affected by what a user can do in Astro. To manage authorization in Astro, see [User permissions](/docs/astro/user-permissions).
## Step 1: Create an API token
You can use any of the following credentials to authenticate in an automated process:
* A Deployment API token. See [Deployment API tokens](/docs/astro/deployment-api-tokens).
* A Workspace API token. See [Create a Workspace API token](/docs/astro/workspace-api-tokens).
* An Organization API token. See [Create an Organization API token](/docs/astro/organization-api-tokens).
When you create an API token for your environment, keep the following best practices in mind:
* Always give your API token the minimum permissions required to perform an action. This improves control and security over your Astro components. For example, instead of creating an Organization API token to automate actions across two Workspaces, create a separate Workspace API token for each Workspace.
* Always set an expiration date for your API tokens.
* Always [rotate your API tokens](/docs/astro/workspace-api-tokens#rotate-a-workspace-api-token) for enhanced security.
## Step 2: Install the Astro CLI in your automation tool
To manage your Astro workflows programmatically, you must install the Astro CLI in the environment which will run the workflows. Typically, this requires running `curl -sSL install.astronomer.io | sudo bash -s` or an equivalent installation command before your process starts. See [CI/CD templates](/docs/astro/ci-cd-templates/template-overview) for examples of how to install the Astro CLI in different version management and workflow automation environments.
## Step 3: Add your API token to your environment
To make your API token accessible to the Astro CLI, you need to set specific environment variables in your CI/CD tool or automation environment.
Because these environment variables store sensitive credentials, Astronomer recommends encrypting the variable values before using them in your script. You can do this either directly in your automation tool or in a secrets backend.
To use a Deployment, Workspace, or Organization API token as an authentication credential, set the following environment variable in your script:
```text wrap theme={null}
ASTRO_API_TOKEN=
```
## See also
* [API authentication and token security](/docs/astro/api-authentication)
* [Develop a CI/CD workflow](/docs/astro/set-up-ci-cd)
* [Manage Deployments as code](/docs/astro/manage-deployments-as-code)
# Automate actions on Astro
Source: https://astronomer.io/docs/astro/automation-overview
Learn how you can automate various actions on Astro to quickly build and manage your data ecosystem.
As an administrator or head of your team, you can use the Astro CLI to automate the management of Deployments and Workspaces. Some common actions you can automate include:
* Managing users.
* Deploying code in a CI/CD pipeline.
* Creating Deployments.
Automating actions allows your team to interact with Astro in a predictable way that improves reliability and security. For example, when you automate code deploys with CI/CD, your can have your users deploy from a source where all of their work is tracked and reviewed, such as GitHub.
This section of documentation covers how to automate processes on Astro using Astro CLI. To start automating, you'll first [programmatically authenticate to Astro](/docs/astro/automation-authentication) using an API token. Then, you'll write and run a script to perform your action.
## Common actions to automate
### Deployment actions
* Deploy code to your Deployment using [CI/CD](/docs/astro/set-up-ci-cd).
* Update your Deployment using a [Deployment file](/docs/astro/manage-deployments-as-code).
* Make a request to your Deployment using the [Airflow REST API](/docs/astro/airflow-api).
### Workspace actions
* [Manage users, Teams, and tokens](/docs/cli/v1.43/astro-workspace-list) in your Workspace.
* Create [preview Deployments](/docs/astro/ci-cd-templates/github-actions-deployment-preview) using CI/CD.
* Perform all Deployment-level actions on any Deployment in a Workspace.
### Organization actions
* [Manage Organization users, Teams, and tokens](/docs/cli/v1.43/astro-organization-list).
* Export [audit logs](/docs/astro/audit-logs#export-audit-logs).
# Configure the Celery executor
Source: https://astronomer.io/docs/astro/celery-executor
Configure the Celery executor on Astro by setting worker size, count, and concurrency per queue.
On Astro, you can configure Celery executor in the following ways:
* The type and size of your workers.
* The minimum and maximum number of workers that your Deployment can run at a time.
* The number of tasks that each worker can run at a time.
You can set these configurations per [worker queue](/docs/astro/configure-worker-queues). With the Celery executor, you can configure multiple worker queues for different types of tasks and assign tasks to those queues in your Dag code.
The following document explains basic Celery executor configurations for a single worker queue. For instructions on how to configure multiple worker queues, see [Create a worker queue](/docs/astro/configure-worker-queues#create-a-worker-queue).
If you plan to use only the `KubernetesPodOperator` in your Deployment, set your Celery executor resources to the lowest possible amounts, because the executor is only required for launching your Pods. See [`KubernetesPodOperator`](/docs/astro/kubernetespodoperator) for more information.
## Celery worker autoscaling logic
The number of Celery workers running per worker queue on your Deployment at a given time is based on two values:
* The total number of tasks in a `queued` or `running` state
* The worker queue's setting for **Concurrency**
The calculation is made based on the following expression:
`[Number of workers]= ([Queued tasks]+[Running tasks])/(Concurrency)`
Deployment [parallelism](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#parallelism) is the maximum number of tasks that can run concurrently across worker queues. To ensure that you can always run as many tasks as your worker queues allow, parallelism is calculated with the following expression:
`[Parallelism]= ([The sum of all 'Max Worker Count' values for all worker queues] * [The sum of all 'Concurrency' values for all worker queues])`.
[Kubernetes Event Driven Autoscaling](https://keda.sh/) (KEDA) computes these calculations every ten seconds. When KEDA determines that it can scale down a worker, it waits for five minutes after the last running task on the worker finishes before terminating the worker Pod.
When you push code to a Deployment, workers running tasks from before the code push don't scale down until those tasks is complete. To learn more about how changes to a Deployment can affect worker resource allocation, see [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
## Configure Celery worker scaling
For each worker queue on your Deployment, you have to specify certain settings that affect worker autoscaling behavior. If you're new to Airflow, Astronomer recommends using the defaults in Astro for each of these settings.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Details** tab and then click **Edit** in the **Execution** section to edit a worker queue.
3. Configure the following settings:
* **Worker type**: Choose the amount of resources that each worker will have.
* **Concurrency**: The maximum number of tasks that a single worker can run at a time. If the number of queued and running tasks exceeds this number, a new worker is added to run the remaining tasks. This value is equivalent to the Apache Airflow [worker concurrency](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#worker-concurrency) setting. It is 16 by default.
* **Storage**: Choose the amount of ephemeral storage in GiB that each worker has. This storage volume is transient and allows for temporary storage and processing of data within the worker. The worker is assigned the minimum 10 GiB by default. The maximum quota is 100 GiB. Only ephemeral storage requests that are greater than the default minimum of 10 GiB are chargeable.
* **Worker Count (Min-Max)**: The minimum and maximum number of workers that can run at a time. The number of running workers changes based on **Concurrency** and the current number of tasks in a queued or running state. By default, the minimum number of workers is 1 and the maximum is 10.
The number of running workers might temporarily exceed the max when longer duration tasks delay scaled-down workers from shutting down.
4. Click **Update Queue**.
## See also
* [Configure worker queues](/docs/astro/configure-worker-queues).
* [Airflow Executors explained](/docs/learn/airflow-executors-explained)
# Astro CI/CD templates for AWS CodeBuild
Source: https://astronomer.io/docs/astro/ci-cd-templates/aws-codebuild
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using AWS CodeBuild.
Use the following CI/CD templates to automate deploying Apache Airflow dags from a Git repository to Astro with [AWS CodeBuild](https://aws.amazon.com/codebuild/).
The templates for AWS CodeBuild use [image deploy](/docs/astro/ci-cd-templates/template-overview) templates. If you have one Deployment and one environment on Astro, use the [single branch implementation](#single-branch-implementation). If you have multiple Deployments that support development and production environments, use the [multiple branch implementation](#multiple-branch-implementation).
If you use the [dag-only deploy feature](/docs/astro/deploy-dags) on Astro and are interested in a dag deploy CI/CD template, see [Template overview](/docs/astro/ci-cd-templates/template-overview) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that AWS CodeBuild can access. See [Plan a build in AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/planning.html).
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to AWS CodeBuild. See [Getting started with CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-overview.html).
Each CI/CD template implementation might have additional requirements.
## Single branch implementation
To automate code deploys from a single branch to a single Deployment using AWS CodeBuild, complete the following setup in the Git-based repository that hosts your Astro project:
1. In your AWS CodeBuild pipeline configuration, add the following environment variables:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: The ID for your Deployment.
Be sure to set the value of your API token as secret.
2. At the root of your Git repository, add a [`buildspec.yml`](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-example) file that includes the following script:
```yaml title="buildspec.yml" wrap theme={null}
version: 0.2
phases:
install:
runtime-versions:
python: latest
build:
commands:
- echo "${CODEBUILD_WEBHOOK_HEAD_REF}"
- export ASTRO_API_TOKEN="${ASTRO_API_TOKEN}"
- curl -sSL install.astronomer.io | sudo bash -s
- astro deploy "${ASTRO_DEPLOYMENT_ID}" -f
```
3. In your AWS CodeBuild project, create a [webhook event](https://docs.aws.amazon.com/codebuild/latest/userguide/webhooks.html) for the Git repository where your Astro project is hosted. If you use GitHub, see [GitHub webhook events](https://docs.aws.amazon.com/codebuild/latest/userguide/github-webhook.html). When you configure the webhook, select an event type of `PUSH`.
Your `buildspec.yml` file now triggers a code push to an Astro Deployment every time a commit or pull request is merged to the `main` branch of your repository.
## Multiple branch implementation
To automate code deploys across multiple Deployments using AWS CodeBuild, complete the following setup.
This setup requires two Deployments on Astro and two branches in your Git repository. The example assumes that one Deployment is a development environment, and that the other Deployment is a production environment. To learn more, see [Multiple environments](/docs/astro/set-up-ci-cd#multiple-environments).
1. In your AWS CodeBuild pipeline configuration, add the following environment variables:
* `PROD_ASTRO_API_TOKEN`: The value for your production Workspace or Organization API token.
* `PROD_DEPLOYMENT_ID`: The Deployment ID of your production Deployment.
* `DEV_ASTRO_API_TOKEN`: The value for your development Workspace or Organization API token.
* `DEV_DEPLOYMENT_ID`: The Deployment ID of your development Deployment.
Be sure to set the values for your API tokens as secret.
2. At the root of your Git repository, add a [`buildspec.yml`](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-example) that includes the following script:
```yaml title="buildspec.yml" wrap theme={null}
version: 0.2
phases:
install:
runtime-versions:
python: latest
build:
commands:
- |
if expr "${CODEBUILD_WEBHOOK_HEAD_REF}" : "refs/heads/main" >/dev/null; then
export ASTRO_API_TOKEN="${PROD_ASTRO_API_TOKEN}"
curl -sSL install.astronomer.io | sudo bash -s
astro deploy "${PROD_DEPLOYMENT_ID}" -f
fi
- |
if expr "${CODEBUILD_WEBHOOK_HEAD_REF}" : "refs/heads/dev" >/dev/null; then
export ASTRO_API_TOKEN="${DEV_ASTRO_API_TOKEN}"
curl -sSL install.astronomer.io | sudo bash -s
astro deploy "${DEV_DEPLOYMENT_ID}" -f
fi
```
3. In your AWS CodeBuild project, create a [webhook event](https://docs.aws.amazon.com/codebuild/latest/userguide/webhooks.html) for the Git repository where your Astro project is hosted. If you use GitHub, see [GitHub webhook events](https://docs.aws.amazon.com/codebuild/latest/userguide/github-webhook.html). When you configure the webhook, select an event type of `PUSH`.
Your `buildspec.yml` file now triggers a code push to your development Deployment every time a commit or pull request is merged to the `dev` branch of your repository, and a code push to your production Deployment every time a commit or pull request is merged to the `main` branch of your repository.
# Deploy dags from an AWS S3 bucket to Astro using AWS Lambda
Source: https://astronomer.io/docs/astro/ci-cd-templates/aws-s3
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using AWS S3 and Lambda.
Use the following CI/CD template to automate deploying Apache Airflow dags from an S3 bucket to Astro using AWS Lambda.
## Prerequisites
* An AWS S3 bucket
* An [Astro Deployment](/docs/astro/create-deployment) with [dag-only deploys enabled](/docs/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) containing your project configurations.
### Dag deploy template
This CI/CD template can be used to deploy dags from a single S3 bucket to a single Astro Deployment. When you create or modify a dag in the S3 bucket, a Lambda function triggers and initializes an `astro` project to deploy your dags using Astro CLI.
To deploy any non-dag code changes to Astro, you need to trigger a standard image deploy with your Astro project. When you do this, your Astro project must include the latest version of your dags from your S3 bucket. If your Astro project `dags` folder isn't up to date with your S3 dags bucket when you trigger this deploy, you will revert your dags back to the version hosted in your Astro project.
1. Download the latest Astro CLI binary from [GitHub releases](https://github.com/astronomer/astro-cli/releases), then rename the file to, `astro_cli.tar.gz`. For example, to use Astro CLI version 1.13.0 in your template, download `astro_1.13.0_linux_amd64.tar.gz` and rename it to `astro_cli.tar.gz`.
2. In your S3 bucket, create the following new folders:
* `dags`
* `cli_binary`
3. Add `astro_cli.tar.gz` to `cli_binary`.
4. In the AWS IAM console, [create a new role for AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html#permissions-executionrole-console) with the following permissions. Replace ``, ``, and `` with your values.
```json expandable wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "lambdacreateloggroup",
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "arn:aws:logs:us-east-1::*"
},
{
"Sid": "lambdaputlogevents",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:us-east-1::log-group:/aws/lambda/:*"
]
},
{
"Sid": "bucketpermission",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3::",
"arn:aws:s3::/*"
]
}
]
}
```
5. Author a new AWS Lambda function from scratch with the following configurations:
* **Function name**: Any
* **Runtime**: Python 3.9
* **Architecture**: Any
* **Execution role**: Click **Use an existing role** and enter the role you created.
6. Configure the following [Lambda environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html) for your Lambda function:
* `ASTRO_HOME`: `\tmp`
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: Your Deployment ID.
For production Deployments, Astronomer recommends storing your API credentials in AWS Secrets Manager and referencing them from Lambda. See [https://docs.aws.amazon.com/lambda/latest/dg/configuration-`database.html`](https://docs.aws.amazon.com/lambda/latest/dg/configuration-database.html)
7. Add the following code to `lambda_function.py`. Replace `` with your value.
```python title="lambda_function.py" expandable wrap theme={null}
import os
import subprocess
import tarfile
import boto3
BUCKET = os.environ.get("BUCKET", "")
s3 = boto3.resource('s3')
deploymentId = os.environ.get('ASTRO_DEPLOYMENT_ID')
def untar(filename: str, destination: str) -> None:
with tarfile.open(filename) as file:
file.extractall(destination)
def run_command(cmd: str) -> None:
p = subprocess.Popen("set -x; " + cmd, shell=True)
p.communicate()
def download_to_local(bucket_name: str, s3_folder: str, local_dir: str = None) -> None:
"""
Download the contents of a folder directory
Args:
bucket_name: the name of the s3 bucket
s3_folder: the folder path in the s3 bucket
local_dir: a relative or absolute directory path in the local file system
"""
bucket = s3.Bucket(bucket_name)
for obj in bucket.objects.filter(Prefix=s3_folder):
target = obj.key if local_dir is None \
else os.path.join(local_dir, os.path.relpath(obj.key, s3_folder))
if not os.path.exists(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))
if obj.key[-1] == '/':
continue
bucket.download_file(obj.key, target)
print("downloaded file")
def lambda_handler(event, context) -> None:
"""Triggered by a change to a Cloud Storage bucket.
:param event: Event payload.
:param context: Metadata for the event.
"""
base_dir = '/tmp/astro'
if not os.path.isdir(base_dir):
os.mkdir(base_dir)
download_to_local(BUCKET, 'dags/', f'{base_dir}/dags')
download_to_local(BUCKET, 'cli_binary/', base_dir)
os.chdir(base_dir)
untar('./astro_cli.tar.gz', '.')
run_command('echo y | ./astro dev init')
run_command(f"./astro deploy {deploymentId} --dags")
return {"statusCode": 200}
```
8. [Create a trigger](https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html) for your Lambda function with the following configuration:
* **Source**: Select **S3**.
* **Bucket**: Select the bucket that contains your `dags` directory.
* **Event types**: Select **All object create events**.
* **Prefix**: Enter `dags/`.
* **Suffix**: Enter `.py`.
9. If you haven't already, deploy your complete Astro project to your Deployment. See [Deploy code](/docs/astro/deploy-code).
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.
To avoid this, either push commits individually or configure your repository to **Squash commits** for pull requests that merge multiple commits simultaneously.
10. Add your dags to the `dags` folder in your storage bucket
11. In the Astro UI, click **Deployments**, then select your Deployment. Confirm that your Lambda function worked by checking the Deployment **Dag bundle version**. The version's name should include the time that you added the dags to your S3 bucket.
# Astro CI/CD templates for Azure DevOps
Source: https://astronomer.io/docs/astro/ci-cd-templates/azure-devops
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using Azure DevOps.
Use the following CI/CD templates to automate deploying Apache Airflow Dags from a Git repository to Astro with [Azure DevOps](https://dev.azure.com/).
The template for Azure DevOps is based on the [image deploy template](/docs/astro/ci-cd-templates/template-overview#image-deploy-templates) with a [single branch implementation](#single-branch-implementation), which requires only one Astro Deployment.
If you use the [Dag-only deploy feature](/docs/astro/deploy-dags) on Astro or you're interested in a multiple-branch implementation, see [Template overview](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Azure DevOps can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [Azure DevOps](https://dev.azure.com/).
## Single branch implementation
Complete the following setup in an Azure repository that hosts an Astro project:
1. Set the following environment variable as a [DevOps pipeline variable](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops\&tabs=yaml%2Cbatch):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: The ID for your Deployment.
For production Deployments, ensure that you set the value for your API token as a [secret](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops\&tabs=yaml%2Cbatch#secret-variables).
2. Create a new Azure DevOps pipeline named `astro-devops-cicd.yaml` at the root of the repository that includes the following configuration:
```yaml title="astro-devops-cicd.yaml" wrap theme={null}
trigger:
- main
pr: none
stages:
- stage: deploy
jobs:
- job: deploy_image
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy ${ASTRO_DEPLOYMENT_ID}
env:
ASTRO_API_TOKEN: $(ASTRO_API_TOKEN)
ASTRO_DEPLOYMENT_ID: $(ASTRO_DEPLOYMENT_ID)
```
# Astro CI/CD templates for Bitbucket
Source: https://astronomer.io/docs/astro/ci-cd-templates/bitbucket
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using BitBucket.
Use the following CI/CD templates to automate deploying Apache Airflow dags from a Git repository to Astro with [Bitbucket](https://bitbucket.org/product).
The templates for Bitbucket use the [image deploy](/docs/astro/ci-cd-templates/template-overview) process with a [single branch implementation](#single-branch-implementation), which requires only one Astro Deployment.
If you use the [dag-only deploy feature](/docs/astro/deploy-dags) on Astro or you're interested in a multiple-branch implementation, see [Template overview](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Bitbucket can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [Bitbucket](https://bitbucket.org/product).
## Single branch implementation
To automate code deploys to a Deployment using [Bitbucket](https://bitbucket.org/), complete the following setup in a Git-based repository that hosts an Astro project:
1. Set the following environment variable as a [Bitbucket pipeline variable](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: Your Deployment ID.
For production Deployments, be sure to set the value of your API token as **secured**.
2. Create a new YAML file in `bitbucket-pipelines.yml` at the root of the repository that includes the following configuration:
```yaml title="bitbucket-pipelines.yml" wrap theme={null}
pipelines:
pull-requests: # The branch pattern under pull requests defines the *source* branch.
dev:
- step:
name: Deploy to Production
deployment: Production
script:
- curl -sSL install.astronomer.io | sudo bash -s
- astro deploy ${ASTRO_DEPLOYMENT_ID} -f
services:
- docker
```
# Astro CI/CD templates for CircleCI
Source: https://astronomer.io/docs/astro/ci-cd-templates/circleci
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using CircleCI.
[CircleCI](https://circleci.com/) is a continuous integration and continuous delivery platform that can be used to implement DevOps practices. This document provides sample CI/CD templates to automate deploying Apache Airflow dags from a GitHub repository to Astro using CircleCI.
If you have one Deployment and one environment on Astro, use the [single branch implementation](/docs/astro/ci-cd-templates/template-overview#single-branch-implementation). If you have multiple Deployments that support development and production environments, use the [multiple branch implementation](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation). If your team builds custom Docker images, use the [custom image implementation](/docs/astro/ci-cd-templates/template-overview#custom-image-implementation).
Refer to [Template overview](/docs/astro/ci-cd-templates/template-overview) to see generic templates expressed as simple shell scripts or configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that CircleCI can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* A [CircleCI](https://circleci.com/vcs-authorize/) account.
## Image deploy templates
[Image deploy templates](/docs/astro/ci-cd-templates/template-overview) build a Docker image and push it to Astro whenever you update any file in your Astro project.
To automate code deploys to a Deployment using CircleCI for a single branch implementation, complete the following setup in a Git-based repository that hosts an Astro project:
#### Configuration requirements (Single branch, code deploy)
* You have a `main` branch of an Astro project hosted in a single GitHub repository.
* You have a production Deployment on Astro where you want to deploy your `main` GitHub branch.
* You have a production CircleCI context that stores environment variables for your CI/CD workflows.
#### Implementation (Single branch, code deploy)
1. Set the following environment variables in a [CircleCI context](https://circleci.com/docs/guides/security/contexts/):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: The ID for your Deployment.
2. Create a new YAML file in `.circleci/config.yml` that includes the following configuration:
```yaml title=".circleci/config.yml" expandable wrap theme={null}
# Use the latest CircleCI pipeline process engine version.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
docker: circleci/docker@2.0.1
github-cli: circleci/github-cli@2.0.0
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build_image_and_deploy:
docker:
- image: cimg/base:stable
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- setup_remote_docker:
version: 20.10.11
- checkout
- run:
name: "Deploy to Astro"
command: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy ${ASTRO_DEPLOYMENT_ID} -f
# Invoke jobs with workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
version: 2.1
wf-build-and-deploy:
jobs:
- build_image_and_deploy:
context:
-
filters:
branches:
only:
-
```
The following template can be used to create a multiple branch CI/CD pipeline using CircleCI. A multiple branch pipeline can be used to test dags in a development Deployment and promote them to a production Deployment.
#### Configuration requirements (Multiple branch, code deploy)
* You have both a `dev` and `main` branch of an Astro project hosted in a single GitHub repository.
* You have respective development and production Deployments on Astro where you deploy your GitHub branches to.
* You have respective development and production CircleCI contexts that store environment variables to use in your CI/CD workflows.
#### Implementation (Multiple branch, code deploy)
1. Set the following environment variables in both your production and development [CircleCI contexts](https://circleci.com/docs/guides/security/contexts/):
* `ASTRO_API_TOKEN` = ``
* `ASTRO_DEPLOYMENT_ID` = ``
2. Create a new YAML file in `.circleci/config.yml` that includes the following configuration:
```yaml title=".circleci/config.yml" expandable wrap theme={null}
# Use the latest CircleCI pipeline process engine version.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
docker: circleci/docker@2.0.1
github-cli: circleci/github-cli@2.0.0
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build_image_and_deploy:
docker:
- image: cimg/base:stable
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- setup_remote_docker:
version: 20.10.11
- checkout
- run:
name: "Deploy to Astro"
command: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy ${ASTRO_DEPLOYMENT_ID} -f
# Invoke jobs with workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
version: 2.1
wf_build-and-deploy:
jobs:
- build_image_and_deploy:
context:
-
filters:
branches:
only:
-
jobs:
- build_image_and_deploy:
context:
-
filters:
branches:
only:
-
```
Read more about multiple workflows in the [CircleCI documentation](https://circleci.com/docs/schedule-pipelines-with-multiple-workflows/).
If your Astro project requires additional build-time arguments to build an image, you need to define these build arguments in `docker build` command and then use the `image tag` to deploy to Astro. See [`docker build`](https://docs.docker.com/build/guide/build-args/) for reference.
#### Configuration requirements (Custom Image, code deploy)
* You have a `main` branch of an Astro project hosted in a single GitHub repository.
* You have a production Deployment on Astro where you want to deploy your `main` GitHub branch.
* You have a production CircleCI context where you store environment variables to use in your CI/CD workflows.
#### Implementation (Custom Image, code deploy)
1. Set the following environment variables in a [CircleCI context](https://circleci.com/docs/guides/security/contexts/):
* `ASTRO_API_TOKEN` = ``
* `ASTRO_DEPLOYMENT_ID` = ``
2. Create a new YAML file in `.circleci/config.yml` that includes the following configuration:
```yaml title=".circleci/config.yml" expandable wrap theme={null}
# Use the latest CircleCI pipeline process engine version.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
docker: circleci/docker@2.0.1
github-cli: circleci/github-cli@2.0.0
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build_image_and_deploy:
docker:
- image: cimg/base:stable
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- setup_remote_docker:
version: 20.10.11
- checkout
- run:
name: "Build image and deploy"
command: |
set -e
echo "export image_tag=astro-$(date +%Y%m%d%H%M%S)" >> $BASH_ENV
source "$BASH_ENV"
docker build -t ${image_tag} --build-arg="=" .
curl -sSL install.astronomer.io | sudo bash -s
astro deploy --image-name ${image_tag} ${ASTRO_DEPLOYMENT_ID} -f
# Invoke jobs with workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
version: 2.1
build-and-deploy-prod:
jobs:
- build_image_and_deploy_prod:
context:
-
filters:
branches:
only:
-
```
If you need guidance configuring a CI/CD pipeline for a more complex use case involving custom Runtime images, reach out to [Astronomer support](https://support.astronomer.io/).
## Dag deploy templates
A [dag deploy template](/docs/astro/ci-cd-templates/template-overview#dag-deploy-templates) uses the `--dags` flag in the `astro deploy` command in the Astro CLI to push only dags to your Deployment.
This CI/CD pipeline deploys your dags to Astro when one or more files in your `dags` folder are modified. It deploys the rest of your Astro project as a Docker image when other files or directories are also modified. For more information about the benefits of this workflow, see [Deploy dags only](/docs/astro/deploy-dags).
### Configuration requirements (dag deploy)
For each Deployment that you use with dag deploy templates, you must [enable dag deploys](/docs/astro/deploy-dags).
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.
To avoid this, either push commits individually or configure your repository to **Squash commits** for pull requests that merge multiple commits simultaneously.
### Single branch implementation
To automate code deploys to a Deployment using [CircleCI](https://circleci.com/), complete the following setup in a Git-based repository that hosts an Astro project:
1. Set the following environment variables in a [CircleCI context](https://circleci.com/docs/guides/security/contexts/):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: The ID for your Deployment.
2. In your project repository, create a new YAML file in `.circleci/config.yml` that includes the following configuration:
```yaml title=".circleci/config.yml" expandable wrap theme={null}
# Use the latest CircleCI pipeline process engine version.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
docker: circleci/docker@2.0.1
github-cli: circleci/github-cli@2.0.0
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build_image_and_deploy:
docker:
- image: cimg/base:stable
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- setup_remote_docker:
version: 20.10.11
- checkout
- run:
name: "Build image and deploy"
command: |
curl -sSL install.astronomer.io | sudo bash -s
files=($(git diff-tree HEAD --name-only --no-commit-id))
echo ${files}
find="dags"
if [[ ${files[*]} =~ (^|[[:space:]])"$find"($|[[:space:]]) && ${#files[@]} -eq 1 ]]; then
echo "only deploying dags"
astro deploy ${ASTRO_DEPLOYMENT_ID} --dags -f;
else
echo "image deploy"
astro deploy ${ASTRO_DEPLOYMENT_ID} -f;
fi
# Invoke jobs with workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
version: 2.1
wf-build-and-deploy:
jobs:
- build_image_and_deploy:
context:
-
filters:
branches:
only:
-
```
This script checks the diff between your current commit and the HEAD of your branch to which you are pushing the changes to. If the changes are only in `dags` then it executes a `dag-only` deploy. Otherwise, it executes an image-based deploy. Make sure to customize the script to use your specific branch and context.
You can customize this script to work for multiple branches as shown in the [image-based multi-branch deploy template](/docs/astro/ci-cd-templates/circleci?tab=multibranch#image-deploy-templates) by creating separate `job` and `workflow` for each branch.
# dbt deploy action for deploying dbt code to Astro
Source: https://astronomer.io/docs/astro/ci-cd-templates/dbt-deploy-action
Use pre-built Astronomer CI/CD templates to automate deploying dbt code to Astro using GitHub Actions.
There is a hard limit of 10 dbt bundles per Astro Deployment
If you have a dbt project that you want to use with the deploy action for a GitHub action, you can choose to use either the dbt deploy on its own, or you can create GitHub actions that combine the `infer` action with a dbt deploy.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a GitHub repository.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [GitHub Actions](https://github.com/features/actions).
Each CI/CD template implementation might have additional requirements.
If you use a [self-hosted runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) to execute jobs from GitHub Actions, the Astro CLI's `config.yaml` file, which stores default deploy details, might be shared across your organization and hence multiple CI/CD pipelines. To reduce the risk of accidentally deploying to the wrong Deployment, ensure the following:
* Add `ASTRO_API_TOKEN` to your repository and include a check in your GitHub workflow to verify that it exists.
* Use Deployment API tokens, which are scoped only to one Deployment, instead of Workspace or Organization API tokens.
* Specify `deployment-id` or `deployment-name` in your action. For example, `astro deploy ` or `astro deploy -n `.
* Add the command `astro logout` at the end of your workflow to ensure that your authentication token is cleared from the `config.yaml` file
### Setup
Each template installs the Astro CLI with [`setup-astro-cli`](https://github.com/astronomer/setup-astro-cli) before `deploy-action` runs. Astronomer recommends installing the CLI in a separate step so that you can pin or upgrade the CLI version independently of the action, including with Dependabot, and reuse a single installation across multiple deploy steps. To pin a version, set the `version` input, for example `version: "1.40.1"`. If you omit this step, `deploy-action` installs the latest version of the Astro CLI itself.
#### Prerequisites (Single branch)
* The root folder name for the directory that contains your dbt project.
#### Implementation (Single branch)
To automate code deploys to a single Deployment using [GitHub Actions](https://github.com/features/actions) for a dbt project, complete the following setup in a Git-based repository that hosts an Astro project:
1. Set the following as a [GitHub secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml wrap theme={null}
name: Astronomer CI - Deploy dbt code
on:
push:
branches:
- main
env:
## Sets Deployment API credentials as environment variables
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
deploy-type: dbt
root-folder:
```
3. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow. For example, if you add [`wake-on-deploy`](https://github.com/astronomer/deploy-action/blob/main/README.md#wake-on-deploy) to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using `wake-on-deploy` takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or `config.yaml` file.
The following template can be used to create a multiple branch CI/CD pipeline using GitHub Actions. A multiple branch pipeline can be used to test dags in a development Deployment and promote them to a production Deployment.
#### Configuration requirements
* You have both a `dev` and `main` branch of an Astro project hosted in a single GitHub repository.
* You have respective `dev` and `prod` Deployments on Astro where you deploy your GitHub branches to.
* You have at least one API token with access to both of your Deployments.
* The root folder name for the directory that contains your dbt project.
#### Implementation (Multiple branch)
1. Set the following as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `PROD_ASTRO_API_TOKEN`: The value for your production Workspace or Organization API token.
* `DEV_ASTRO_API_TOKEN`: The value for your development Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Deploy dbt code (Multiple Branches)
on:
push:
branches: [dev]
pull_request:
types:
- closed
branches: [main]
jobs:
dev-push:
if: github.ref == 'refs/heads/dev'
env:
## Sets DEV Deployment API credential as an environment variable
ASTRO_API_TOKEN: ${{ secrets.DEV_ASTRO_API_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
deploy-type: dbt
root-folder:
prod-push:
if: github.event.action == 'closed' && github.event.pull_request.merged == true
env:
## Sets Prod Deployment API credential as an environment variable
ASTRO_API_TOKEN: ${{ secrets.PROD_ASTRO_API_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
deploy-type: dbt
root-folder:
```
3. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow. For example, if you add [`wake-on-deploy`](https://github.com/astronomer/deploy-action/blob/main/README.md#wake-on-deploy) to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using `wake-on-deploy` takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or `config.yaml` file.
In addition to configuring the deploy action to deploy just your dbt changes, you can also configure the action to do a `dbt deploy` and an `infer` deploy.
#### Prerequisites (Combine dbt and Astro project)
* The root folder name for the directory that `contct.ains` your dbt project
#### Implementation (Combine dbt and Astro project)
To automate code deploys to a single Deployment using [GitHub Actions](https://github.com/features/actions) for a dbt project, complete the following setup in a Git-based repository that hosts both an Astro project and a dbt project:
1. Set the following as a [GitHub secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml wrap theme={null}
name: Astronomer CI - Deploy dbt and Astro project code
on:
push:
branches:
- main
env:
## Sets Deployment API credentials as environment variables
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: DBT Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
deploy-type: dbt
root-folder:
- name: DAGs/Image Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
root-folder:
parse: true
```
3. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow. For example, if you add [`wake-on-deploy`](https://github.com/astronomer/deploy-action/blob/main/README.md#wake-on-deploy) to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using `wake-on-deploy` takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or `config.yaml` file.
# Default deploy action for deploying code to Astro
Source: https://astronomer.io/docs/astro/ci-cd-templates/default-deploy-action
Use pre-built Astronomer CI/CD templates to automate deploying code to Astro using GitHub Actions.
By default, the deploy action uses the `infer` deploy type, which enables the action to determine whether to use either a `dags-only` deploy or an `image-and-dags` deploy, depending on the files you change.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a GitHub repository.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [GitHub Actions](https://github.com/features/actions).
Each CI/CD template implementation might have additional requirements.
If you use a [self-hosted runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) to execute jobs from GitHub Actions, the Astro CLI's `config.yaml` file, which stores default deploy details, might be shared across your organization and hence multiple CI/CD pipelines. To reduce the risk of accidentally deploying to the wrong Deployment, ensure the following:
* Add `ASTRO_API_TOKEN` to your repository and include a check in your GitHub workflow to verify that it exists.
* Use Deployment API tokens, which are scoped only to one Deployment, instead of Workspace or Organization API tokens.
* Specify `deployment-id` or `deployment-name` in your action. For example, `astro deploy ` or `astro deploy -n `.
* Add the command `astro logout` at the end of your workflow to ensure that your authentication token is cleared from the `config.yaml` file.
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.
To avoid this, either push commits individually or configure your repository to **Squash commits** for pull requests that merge multiple commits simultaneously.
### Setup
Each template installs the Astro CLI with [`setup-astro-cli`](https://github.com/astronomer/setup-astro-cli) before `deploy-action` runs. Astronomer recommends installing the CLI in a separate step so that you can pin or upgrade the CLI version independently of the action, including with Dependabot, and reuse a single installation across multiple deploy steps. To pin a version, set the `version` input, for example `version: "1.40.1"`. If you omit this step, `deploy-action` installs the latest version of the Astro CLI itself.
To automate code deploys to a single Deployment using [GitHub Actions](https://github.com/features/actions), complete the following setup in a Git-based repository that hosts an Astro project:
1. Set the following as a [GitHub secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml wrap theme={null}
name: Astronomer CI - Deploy code
on:
push:
branches:
- main
env:
## Sets Deployment API credentials as environment variables
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
```
3. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow. For example, if you add [`wake-on-deploy`](https://github.com/astronomer/deploy-action/blob/main/README.md#wake-on-deploy) to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using `wake-on-deploy` takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or `config.yaml` file.
The following template can be used to create a multiple branch CI/CD pipeline using GitHub Actions. A multiple branch pipeline can be used to test dags in a development Deployment and promote them to a production Deployment.
#### Configuration requirements
* You have both a `dev` and `main` branch of an Astro project hosted in a single GitHub repository.
* You have respective `dev` and `prod` Deployments on Astro where you deploy your GitHub branches to.
* You have at least one API token with access to both of your Deployments.
#### Implementation (Multiple branch)
1. Set the following as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `PROD_ASTRO_API_TOKEN`: The value for your production Workspace or Organization API token.
* `DEV_ASTRO_API_TOKEN`: The value for your development Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Deploy code (Multiple Branches)
on:
push:
branches: [dev]
pull_request:
types:
- closed
branches: [main]
jobs:
dev-push:
if: github.ref == 'refs/heads/dev'
env:
## Sets DEV Deployment API credential as an environment variable
ASTRO_API_TOKEN: ${{ secrets.DEV_ASTRO_API_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
prod-push:
if: github.event.action == 'closed' && github.event.pull_request.merged == true
env:
## Sets Prod Deployment API credential as an environment variable
ASTRO_API_TOKEN: ${{ secrets.PROD_ASTRO_API_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
```
3. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow. For example, if you add [`wake-on-deploy`](https://github.com/astronomer/deploy-action/blob/main/README.md#wake-on-deploy) to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using `wake-on-deploy` takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or `config.yaml` file.
If your Astro project requires additional build-time arguments to build an image, you need to define these build arguments using Docker's [`build-push-action`](https://github.com/docker/build-push-action).
#### Prerequisites
* An Astro project that requires additional build-time arguments to build the Runtime image.
#### Implementation (Custom Image)
1. Set the following as a [GitHub secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Additional build-time args
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Create image tag
id: image_tag
run: echo ::set-output name=image_tag::astro-$(date +%Y%m%d%H%M%S)
- name: Build image
uses: docker/build-push-action@v2
with:
deployment-id:
tags: ${{ steps.image_tag.outputs.image_tag }}
load: true
# Define your custom image's build arguments, contexts, and connections here using
# the available GitHub Action settings:
# https://github.com/docker/build-push-action#customizing .
# This example uses `build-args` , but your use case might require configuring
# different values.
build-args: |
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
image-name: ${{ steps.image_tag.outputs.image_tag }}
```
For example, to create a CI/CD pipeline that deploys a project which [installs Python packages from a private GitHub repository](/docs/cli/v1.43/private-python-packages), you would use the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Custom base image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Create image tag
id: image_tag
run: echo ::set-output name=image_tag::astro-$(date +%Y%m%d%H%M%S)
- name: Create SSH Socket
uses: webfactory/ssh-agent@v0.5.4
with:
# GITHUB_SSH_KEY must be defined as a GitHub secret.
ssh-private-key: ${{ secrets.GITHUB_SSH_KEY }}
- name: (Optional) Test SSH Connection - Should print hello message.
run: (ssh git@github.com) || true
- name: Build image
uses: docker/build-push-action@v2
with:
tags: ${{ steps.image_tag.outputs.image_tag }}
load: true
ssh: |
github=${{ env.SSH_AUTH_SOCK }}
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
image-name: ${{ steps.image_tag.outputs.image_tag }}
```
If you need guidance configuring a CI/CD pipeline for a more complex use case involving custom Runtime images, reach out to [Astronomer support](https://support.astronomer.io/).
3. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow. For example, if you add [`wake-on-deploy`](https://github.com/astronomer/deploy-action/blob/main/README.md#wake-on-deploy) to your configuration, the Deploy Action wakes a hibernating Deployment before deploying code to it.
Using `wake-on-deploy` takes precedence over any existing Deployment hibernation overrides that you configured through the Astro UI or `config.yaml` file.
# Astro CI/CD templates for Drone
Source: https://astronomer.io/docs/astro/ci-cd-templates/drone
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using Drone CI.
Use the following CI/CD templates to automate deploying Apache Airflow dags from a Git repository to Astro with [Drone CI](https://www.drone.io/).
The template for DroneCI is based on the [image deploy template](/docs/astro/ci-cd-templates/template-overview) with a [single branch implementation](#single-branch-implementation), which requires only one Astro Deployment.
If you use the [dag-only deploy feature](/docs/astro/deploy-dags) on Astro or you're interested in a multiple-branch implementation, see [Template overview](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Drone can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* A functional Drone [server](https://docs.drone.io/server/overview/).
* A user with admin privileges to your Drone server.
* A [Docker runner](https://docs.drone.io/runner/docker/overview/).
## Single branch implementation
1. Set the following environment variable as a repository-level [secret](https://docs.drone.io/secret/repository/) on Drone:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your Drone server, open your Astro project repository and go to **Settings** > **General**. Under **Project Settings**, turn on the **Trusted** setting.
3. In the top level of your Git repository, create a file called `.drone.yml` that includes the following configuration:
```yaml title=".drone.yml" expandable wrap theme={null}
---
kind: pipeline
type: docker
name: deploy
steps:
- name: install
image: debian
commands:
- apt-get update
- apt-get -y install curl
- curl -sSL install.astronomer.io | sudo bash -s
- name: wait
image: docker:dind
volumes:
- name: dockersock
path: /var/run
commands:
- sleep 5
- name: deploy
image: docker:dind
volumes:
- name: dockersock
path: /var/run
commands:
- astro deploy -f
depends_on:
- wait
environment:
ASTRO_API_TOKEN:
from_secret: ASTRO_API_TOKEN
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
trigger:
branch:
- main
event:
- push
```
# Deploy Dags from Google Cloud Storage to Astro
Source: https://astronomer.io/docs/astro/ci-cd-templates/gcs
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow Dags to Astro using Google Cloud Storage.
## Prerequisites
* A Google Cloud Storage (GCS) bucket.
* An [Astro Deployment](/docs/astro/create-deployment) with [Dag-only deploys enabled](/docs/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) containing your project configurations.
## Dag deploy template
This CI/CD template can be used to deploy Dags from a single GCS bucket to a single Astro Deployment. When you create or modify a Dag in the GCS bucket, a Cloud Function triggers and initializes an Astro project to deploy your Dags using Astro CLI.
To deploy any non-Dag code changes to Astro, you need to trigger a standard image deploy with your Astro project. When you do this, your Astro project must include the latest version of your Dags from your GCS bucket. If your Astro project `dags` folder isn't up to date with your GCS Dags bucket when you trigger this deploy, you revert your Dags back to the version hosted in your Astro project.
1. Download the latest Astro CLI binary from [GitHub releases](https://github.com/astronomer/astro-cli/releases), then rename the file to `astro_cli.tar.gz`. For example, to use Astro CLI version 1.40.0 in your template, download `astro_1.40.0_linux_amd64.tar.gz` and rename it to `astro_cli.tar.gz`.
2. In your GCS bucket, create the following new folders:
* `dags`
* `cli_binary`
3. Add `astro_cli.tar.gz` to `cli_binary`.
4. Create a [Cloud Run Function](https://docs.cloud.google.com/run/docs/quickstarts/functions/deploy-functions-console) with the Python 3.12 runtime in the same region as your storage bucket. Use the inline editor to create your function.
5. Create a [Cloud Storage trigger](https://docs.cloud.google.com/run/docs/triggering/storage-triggers) with the following configuration:
* **Event provider**: Select **Cloud Storage**.
* **Event**: Select **google.cloud.storage.object.v1.finalized**.
* **Bucket**: Select your storage bucket.
* **Service Account**: Ensure the service account you use has the Cloud Run Invoker role.
6. Choose the runtime service account on the **Security** tab of the Cloud Run Functions settings. Ensure that the service account has **Storage Object Viewer** (`storage.objects.list`) access to the Google Cloud Storage bucket.
7. Under the **Containers** settings, set the following [environment variables](https://docs.cloud.google.com/run/docs/configuring/services/environment-variables#setting_runtime_environment_variables) for your Cloud Function:
* `ASTRO_HOME` = `/tmp`
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRO_DEPLOYMENT_ID`: Your Deployment ID.
* `BUCKET`: Your GCS bucket.
For production Deployments, ensure that you store the value for your API token in a secrets backend. See [Secret Manager overview](https://cloud.google.com/secret-manager/docs/overview).
8. When editing the function source, change the function entry point to `astro_deploy`.
9. Add the following code to `main.py`:
```python title="main.py" expandable wrap theme={null}
import os
import shutil
import subprocess
import tarfile
from google.cloud import storage
import functions_framework
BUCKET = os.environ.get("BUCKET", "missing-bucket")
deploymentId = os.environ.get("ASTRO_DEPLOYMENT_ID", "missing-deployment-id")
def clear_dir(path: str) -> None:
if os.path.exists(path):
print(f"Clearing directory: {path}")
shutil.rmtree(path)
os.makedirs(path, exist_ok=True)
print(f"Re-created directory: {path}")
def untar(filename: str, destination: str) -> None:
with tarfile.open(filename) as file:
file.extractall(destination)
def run_command(cmd: str) -> None:
print(f'running command: {cmd}')
p = subprocess.Popen("set -x; " + cmd, shell=True)
p.communicate()
def download_to_local(bucket_name: str, gcs_folder: str, local_dir: str = None) -> None:
"""Download the contents of a folder directory
:param bucket_name: the name of the gcs bucket
:param gcs_folder: the folder path in the gcs bucket
:param local_dir: a relative or absolute directory path in the local file system
"""
## create a storage client to access GCS objects
storage_client = storage.Client()
source_bucket = storage_client.bucket(bucket_name)
## get a list of all the files in the bucket folder
blobs = source_bucket.list_blobs(prefix=gcs_folder)
## download each of the dag to local
for blob in blobs:
if blob.name.endswith('/'):
continue
target = blob.name if local_dir is None \
else os.path.join(local_dir, os.path.relpath(blob.name, gcs_folder))
print(target)
if not os.path.exists(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))
blob.download_to_filename(target)
print("downloaded file")
@functions_framework.cloud_event
def astro_deploy(cloud_event) -> None:
base_dir = '/tmp/astro'
dags_dir = f'{base_dir}/dags'
clear_dir(dags_dir)
# --- Download DAGs ---
print('downloading dags')
download_to_local(BUCKET, 'dags/', f'{base_dir}/dags') # NOTE: use "dags/" prefix
# --- Download CLI ---
print('downloading cli')
download_to_local(BUCKET, 'cli_binary/', base_dir)
# --- Initialize project ---
os.chdir(base_dir)
untar('./astro_cli.tar.gz', '.')
run_command('echo y | ./astro dev init')
# --- Remove generated example DAG(s) ---
example_paths = [
"dags/example_dag.py",
"dags/exampledag.py",
]
for path in example_paths:
full_path = os.path.join(base_dir, path)
if os.path.exists(full_path):
print(f"Removing generated example DAG: {full_path}")
os.remove(full_path)
else:
print(f"Example DAG not found: {full_path}")
# --- Deploy ----
run_command(f'./astro deploy {deploymentId} --dags')
```
10. Add the dependency `google-cloud-storage` to the `requirements.txt` file for your Cloud Function. See [Specifying Dependencies in Python](https://docs.cloud.google.com/run/docs/runtimes/python-dependencies).
11. (Optional) If you want the function to trigger when Dags are deleted as well as created/modified, create another [Cloud Storage trigger](https://docs.cloud.google.com/run/docs/triggering/storage-triggers) with the following configuration:
* **Event provider**: Select **Cloud Storage**.
* **Event**: Select **google.cloud.storage.object.v1.deleted**.
* **Bucket**: Select your storage bucket.
* **Service Account**: Ensure the service account you use has the Cloud Run Invoker role.
12. If you haven't already, deploy your complete Astro project to your Deployment. See [Deploy code](/docs/astro/deploy-code).
13. Add your Dags to the `dags` folder in your storage bucket.
14. In the Astro UI, click **Deployments**, then select your Deployment. Confirm that your deploy worked by checking the Deployment **Dag bundle version**. The version's name should include the time that you added the Dags to your GCS bucket.
# GitHub Actions templates for deploying code to preview Deployments on Astro
Source: https://astronomer.io/docs/astro/ci-cd-templates/github-actions-deployment-preview
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to a preview Deployment using GitHub Actions.
The Astro GitHub integration can automatically deploy code from a GitHub repository to Astro without you needing to configure a GitHub action. In addition, the Astro UI shows Git metadata for each deploy on your Deployment information screen. See [Deploy code with the Astro GitHub integration](/docs/astro/deploy-github-integration) for setup steps.
The Astronomer [deploy action](https://github.com/astronomer/deploy-action/blob/main/README.md#deployment-preview-templates) includes several sub-actions that can be used together to create a complete [Deployment preview](/docs/astro/ci-cd-templates/preview-deployments) pipeline, a configuration that allows you to test your code changes in an ephemeral development Deployment before promoting your changes to a production Astro Deployment.
The Deployment preview templates use GitHub secrets to manage the credentials needed for GitHub to authenticate to Astro. You can specify the credentials for your [secrets backend](/docs/astro/secrets-backend) so that preview Deployments have access to secret Airflow variables or connections during tests. See [Deployment preview template with secrets backend implementation](#deployment-preview-template-with-secrets-backend-implementation).
Deployment preview templates use Astronomer's [`deploy-action`](/docs/astro/ci-cd-templates/template-overview) to automates the deploy process, meaning it can selectively deploy parts of your project based on which files you changed. See [Standard deploy templates](/docs/astro/ci-cd-templates/template-overview) for more information about the `deploy-action`.
Each template installs the Astro CLI with [`setup-astro-cli`](https://github.com/astronomer/setup-astro-cli) before `deploy-action` runs. Astronomer recommends installing the CLI in a separate step so that you can pin or upgrade the CLI version independently of the action, including with Dependabot, and reuse a single installation across multiple deploy steps. To pin a version, set the `version` input, for example `version: "1.40.1"`. If you omit this step, `deploy-action` installs the latest version of the Astro CLI itself.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a GitHub repository.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Workspace API token](/docs/astro/workspace-api-tokens) or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [GitHub Actions](https://github.com/features/actions).
Specific templates might have additional requirements.
Creating preview Deployments for Deployments that use a private image registry is currently unsupported.
If you use a [self-hosted runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) to execute jobs from GitHub Actions, the Astro CLI's `config.yaml` file, which stores default deploy details, might be shared across your organization and hence multiple CI/CD pipelines. To reduce the risk of accidentally deploying to the wrong Deployment, ensure the following:
* Add `ASTRO_API_TOKEN` to your repository and include a check in your GitHub workflow to verify that it exists.
* Specify `deployment-id` or `deployment-name` in your action. For example, `astro deploy ` or `astro deploy -n `.
* Add the command `astro logout` at the end of your workflow to ensure that your authentication token is cleared from the `config.yaml` file.
## Deployment preview template
The standard Deployment preview template uses GitHub secrets and an Astro Workspace or Organization API token to create a preview Deployment whenever you create a new feature branch off of your main branch.
### Setup
1. Copy and save the Deployment ID for your Astro Deployment.
Replace `` with this Deployment ID in all the scripts created in the following steps. Even though some scripts take action on the preview Deployment, the `` should be same for each script.
2. Set the following [GitHub secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) in the repository hosting your Astro project:
* Key: `ASTRO_API_TOKEN`
* Secret: ``
3. In your project repository, create a new YAML file in `.github/workflows` named `deploy-to-preview.yml` that includes the following configuration:
```yaml title="deploy-to-preview.yml" wrap theme={null}
name: Astronomer CI - Deploy code to preview
on:
pull_request:
branches:
- main
env:
## Set your API token as a GitHub secret
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Create preview Deployment
uses: astronomer/deploy-action@v0.14.0
continue-on-error: true # Create action fails if deploy preview already exist, which is expected for subsequent commits in the PR
with:
action: create-deployment-preview
deployment-id:
wait-time: 10m # Max wait time for the preview deployment to be completed by the deploy action. The workflow will fail if the deployment fails to create within give time period.
- name: Deploy code to preview
uses: astronomer/deploy-action@v0.14.0
with:
action: deploy-deployment-preview
deployment-id:
```
4. In the same folder, create a new YAML file named `delete-preview-deployment.yml` that includes the following configuration:
```yaml title="delete-preview-deployment.yml" wrap theme={null}
name: Astronomer CI - Delete Preview Deployment
on:
delete:
branches:
- "**"
env:
## Set your API token as a GitHub secret
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Delete preview Deployment
uses: astronomer/deploy-action@v0.14.0
with:
action: delete-deployment-preview
deployment-id:
```
5. In the same folder, create a new YAML file named `deploy-to-main-deployment.yml` that includes the following configuration:
```yaml title="deploy-to-main-deployment.yml" wrap theme={null}
name: Astronomer CI - Deploy code to main Deployment
on:
push:
branches:
- main
env:
## Set your API token as a GitHub secret
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy code to main Deployment
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
```
6. (Optional) You can add [optional configurations](https://github.com/astronomer/deploy-action/blob/main/README.md#configuration-options) to customize your workflow.
All three workflow files must have the same Deployment ID specified. The actions use this Deployment ID to create and delete preview Deployments based on your main Deployment.
## Deployment preview template with secrets backend implementation
If you use a [secrets backend](/docs/astro/secrets-backend) to manage Airflow objects such as variables and connections, you can configure your action to grant preview Deployments access to your secrets backend. This means that dags in the preview Deployment can access your secret Airflow objects for testing purposes.
This template makes use of the `AIRFLOW__SECRETS__BACKEND_KWARGS` environment variable to store information and credentials for your secrets backend.
### Prerequisites
* A [secrets backend](/docs/astro/secrets-backend), such as Hashicorp Vault.
### Setup
1. Copy and save the Deployment ID for your Astro deployment.
Replace `` with this Deployment ID in all the scripts created in the following steps. Even though some scripts take action on the preview Deployment, the `` should be same for each script.
2. Set the following [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) in the repository hosting your Astro project. This includes your Astro API Token, so that GitHub has permissions to deploy code to your Deployments or Workspaces, and your secrets backend information stored in `AIRFLOW__SECRETS__BACKEND_KWARGS`. See [Configure a secrets backend](/docs/astro/secrets-backend) for more information about configuring your secrets backend as an environment variable.
* **Key 1**: `ASTRO_API_TOKEN`
* **Secret 1**: ``
* **Key 2**: `AIRFLOW__SECRETS__BACKEND_KWARGS`
* **Secret 2**: ``
3. In your project repository, create a new YAML file in `.github/workflows` named `create-deployment-preview.yml` that includes the following configuration.
```yaml title="create-deployment-preview.yml" wrap theme={null}
name: Astronomer CI - Create preview Deployment with Secrets Backend
on:
create:
branches:
- "**"
env:
## Sets Deployment API token credentials as environment variables
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Create Deployment Preview
uses: astronomer/deploy-action@v0.14.0
id: create-dep-prev
with:
action: create-deployment-preview
deployment-name: "test"
- name: Create Secret Variables
run: |
astro deployment variable update --deployment-id ${{ steps.create-dep-prev.outputs.preview-id }} AIRFLOW__SECRETS__BACKEND_KWARGS=${{ secrets.AIRFLOW__SECRETS__BACKEND_KWARGS }} --secret
```
4. In the same folder, create a new YAML file named `deploy-to-preview.yml` that includes the following configuration:
```yaml title="deploy-to-preview.yml" wrap theme={null}
name: Astronomer CI - Deploy code to preview
on:
pull_request:
branches:
- main
env:
## Set your API token as a GitHub secret
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy code to preview
uses: astronomer/deploy-action@v0.14.0
with:
action: deploy-deployment-preview
deployment-id:
```
5. In the same folder, create a new YAML file named `delete-preview-deployment.yml` that includes the following configuration:
```yaml title="delete-preview-deployment.yml" wrap theme={null}
name: Astronomer CI - Delete Preview Deployment
on:
delete:
branches:
- "**"
env:
## Set your API token as a GitHub secret
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Delete preview Deployment
uses: astronomer/deploy-action@v0.14.0
with:
action: delete-deployment-preview
deployment-id:
```
6. In the same folder, create a new YAML file named `deploy-to-main-deployment.yml` that includes the following configuration:
```yaml title="deploy-to-main-deployment.yml" wrap theme={null}
name: Astronomer CI - Deploy code to main Deployment
on:
push:
branches:
- main
env:
## Set your API token as a GitHub secret
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy code to main Deployment
uses: astronomer/deploy-action@v0.14.0
with:
deployment-id:
```
All four workflow files must have the same Deployment ID specified. The actions use this Deployment ID to create and delete preview Deployments based on your main Deployment.
# GitHub Actions templates for deploying to Astro from private networks
Source: https://astronomer.io/docs/astro/ci-cd-templates/github-actions-private-network
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro on private networks using GitHub Actions.
The Astro GitHub integration can automatically deploy code from a GitHub repository to Astro without you needing to configure a GitHub action. In addition, the Astro UI shows Git metadata for each deploy on your Deployment information screen. See [Deploy code with the Astro GitHub integration](/docs/astro/deploy-github-integration) for setup steps.
If you don't have access to the Astronomer [deploy action](https://github.com/astronomer/deploy-action) because you can't access the public internet from your GitHub repository, use one of the following private network templates to deploy to Astro.
Read the following sections to choose the right template for your use case. If you have one Deployment and one environment on Astro, use the [single branch implementation](/docs/astro/ci-cd-templates/template-overview#single-branch-implementation). If you have multiple Deployments that support development and production environments, use the [multiple branch implementation](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation). If your team builds custom Docker images, use the [custom image implementation](/docs/astro/ci-cd-templates/template-overview#custom-image-implementation). If you want to deploy a prebuilt image from an artifact registry without rebuilding, use the [prebuilt image implementation](/docs/astro/deploy-project-image#deploy-a-prebuilt-docker-image).
You can configure your CI/CD pipelines to deploy a full project image or your `dags` directory. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
If you use a [self-hosted runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) to execute jobs from GitHub Actions, the Astro CLI's `config.yaml` file, which stores default deploy details, might be shared across your organization and hence multiple CI/CD pipelines. To reduce the risk of accidentally deploying to the wrong Deployment, ensure the following:
* Add `ASTRO_API_TOKEN` to your repository and include a check in your GitHub workflow to verify that it exists.
* Use Deployment API tokens, which are scoped only to one Deployment, instead of Workspace or Organization API tokens.
* Specify `deployment-id` or `deployment-name` in your action. For example, `astro deploy ` or `astro deploy -n `.
* Add the command `astro logout` at the end of your workflow to ensure that your authentication token is cleared from the `config.yaml` file.
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a GitHub repository.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [GitHub Actions](https://github.com/features/actions).
## Setup
To automate code deploys to a Deployment using [GitHub Actions](https://github.com/features/actions), complete the following setup in a Git-based repository that hosts an Astro project:
1. Set the following as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration. When you make a commit to a specified branch, this workflow sets your Deployment API credentials as environment variables, installs the latest version of the Astro CLI, checks to see if your `dags` folder has changes, and then either completes a full code deploy or a dag-only code deploy.
```yaml expandable wrap theme={null}
name: Astronomer CI - Deploy code
on:
push:
branches:
- main
env:
## Sets Deployment API credentials as environment variables
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
jobs:
build:
runs-on: ubuntu-latest # add the appropriate image
steps:
# Install the Astro CLI (current version)
- name: checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 2
clean: false
- name: Install the CLI
run: curl -sSL install.astronomer.io | sudo bash -s
# Determine if only dag files have changes
- name: Deploy to Astronomer
run: |
files=$(git diff --name-only $(git rev-parse HEAD~1) -- .)
dags_only=1
for file in $files; do
if [[ $file != dags/* ]]; then
echo "$file is not a dag, triggering a full image build"
dags_only=0
break
fi
done
### If only dags changed deploy only the dags in your 'dags' folder to your Deployment
if [ $dags_only == 1 ]
then
astro deploy --dags
fi
### If any other files changed build your Astro project into a Docker image, push the image to your Deployment, and then push and dag changes
if [ $dags_only == 0 ]
then
astro deploy
fi
```
The following setup can be used to create a multiple branch CI/CD pipeline using GitHub Actions to push a [full image deploy](/docs/astro/deploy-project-image) to Astro. A multiple branch pipeline can be used to test dags in a development Deployment and promote them to a production Deployment.
#### Prerequisites (Multiple branch)
* You have both a `dev` and `main` branch of an Astro project hosted in a single GitHub repository.
* You have respective `dev` and `prod` Deployments on Astro where you deploy your GitHub branches to.
* You have at least one API token with access to both of your Deployments.
#### Setup (Multiple branch)
1. Set the following as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `PROD_ASTRO_API_TOKEN`: The value for your production Workspace or Organization API token.
* `DEV_ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Deploy code (Multiple Branches)
on:
push:
branches: [dev]
pull_request:
types:
- closed
branches: [main]
jobs:
dev-push:
if: github.ref == 'refs/heads/dev'
env:
## Sets DEV Deployment API token credential as an environment variable
ASTRO_API_TOKEN: ${{ secrets.DEV_ASTRO_API_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v3
- name: Deploy to Astro
run: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy
prod-push:
if: github.event.action == 'closed' && github.event.pull_request.merged == true
env:
## Sets PROD Deployment API token credential as an environment variable
ASTRO_API_TOKEN: ${{ secrets.PROD_ASTRO_API_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v3
- name: Deploy to Astro
run: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy
```
If your Astro project requires additional build-time arguments to build an image, you need to define these build arguments using Docker's [`build-push-action`](https://github.com/docker/build-push-action). This template always pushes your entire project [as an image](/docs/astro/deploy-project-image) to Astro.
#### Prerequisites (Custom Image)
* An Astro project that requires additional build-time arguments to build the Runtime image.
#### Setup (Custom Image)
1. Set the following as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Additional build-time args
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Create image tag
id: image_tag
run: echo ::set-output name=image_tag::astro-$(date +%Y%m%d%H%M%S)
- name: Build image
uses: docker/build-push-action@v4
with:
tags: ${{ steps.image_tag.outputs.image_tag }}
load: true
# Define your custom image's build arguments, contexts, and connections here using
# the available GitHub Action settings:
# https://github.com/docker/build-push-action#customizing .
# This example uses `build-args` , but your use case might require configuring
# different values.
build-args: |
- name: Deploy to Astro
run: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy --image-name ${{ steps.image_tag.outputs.image_tag }}
```
For example, to create a CI/CD pipeline that deploys a project which [installs Python packages from a private GitHub repository](/docs/cli/v1.43/private-python-packages), you would use the following configuration:
```yaml expandable wrap theme={null}
name: Astronomer CI - Custom base image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Create image tag
id: image_tag
run: echo ::set-output name=image_tag::astro-$(date +%Y%m%d%H%M%S)
- name: Create SSH Socket
uses: webfactory/ssh-agent@v0.5.4
with:
# GITHUB_SSH_KEY must be defined as a GitHub secret.
ssh-private-key: ${{ secrets.GITHUB_SSH_KEY }}
- name: (Optional) Test SSH Connection - Should print hello message.
run: (ssh git@github.com) || true
- name: Build image
uses: docker/build-push-action@v2
with:
tags: ${{ steps.image_tag.outputs.image_tag }}
load: true
ssh: |
github=${{ env.SSH_AUTH_SOCK }}
- name: Deploy to Astro
run: |
curl -sSL install.astronomer.io | sudo bash -s
astro deploy --image-name ${{ steps.image_tag.outputs.image_tag }}
```
If you need guidance configuring a CI/CD pipeline for a more complex use case involving custom Runtime images, reach out to [Astronomer support](https://support.astronomer.io/).
If your organization builds Astro Runtime images in a separate build pipeline and stores them in an artifact registry, use this template to pull and deploy the prebuilt image without rebuilding it. This template skips the build step entirely and deploys the image directly from your registry to Astro.
#### Prerequisites (Prebuilt image)
* A prebuilt Docker image based on Astro Runtime, stored in an artifact registry such as Google Artifact Registry, Amazon ECR, Azure Container Registry, or Docker Hub.
* Registry credentials with pull access to the image.
#### Setup (Prebuilt image)
1. Set the following as [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository):
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* Registry credentials for your artifact registry. See the following tabs for registry-specific secrets.
2. In your project repository, create a new YAML file in `.github/workflows` that includes the following configuration for your registry:
```yaml wrap theme={null}
name: Astronomer CI - Deploy prebuilt image from Google Artifact Registry
on:
push:
branches:
- main
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
REGISTRY: -docker.pkg.dev//
IMAGE_NAME:
IMAGE_TAG:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Configure Docker for Google Artifact Registry
run: gcloud auth configure-docker -docker.pkg.dev --quiet
- name: Pull image from registry
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: Install the Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
run: |
astro deploy --image-name ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
```
Set `GCP_SERVICE_ACCOUNT_KEY` as a GitHub secret containing the JSON key for a Google Cloud service account with read access to the registry.
```yaml expandable wrap theme={null}
name: Astronomer CI - Deploy prebuilt image from Amazon ECR
on:
push:
branches:
- main
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
REGISTRY: .dkr.ecr..amazonaws.com
IMAGE_NAME:
IMAGE_TAG:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region:
- name: Authenticate to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Pull image from registry
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: Install the Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
run: |
astro deploy --image-name ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
```
Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` as GitHub secrets with permissions to pull from the ECR repository.
```yaml wrap theme={null}
name: Astronomer CI - Deploy prebuilt image from Azure Container Registry
on:
push:
branches:
- main
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
REGISTRY: .azurecr.io
IMAGE_NAME:
IMAGE_TAG:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Authenticate to Azure Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Pull image from registry
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: Install the Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
run: |
astro deploy --image-name ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
```
Set `ACR_USERNAME` and `ACR_PASSWORD` as GitHub secrets. You can use a service principal or an admin account with pull access to the registry.
```yaml wrap theme={null}
name: Astronomer CI - Deploy prebuilt image from Docker Hub
on:
push:
branches:
- main
env:
ASTRO_API_TOKEN: ${{ secrets.ASTRO_API_TOKEN }}
IMAGE_NAME: /
IMAGE_TAG:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Authenticate to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull image from registry
run: docker pull ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: Install the Astro CLI
uses: astronomer/setup-astro-cli@v0.0.1
- name: Deploy to Astro
run: |
astro deploy --image-name ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
```
Set `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` as GitHub secrets with pull access to the repository.
These workflows authenticate to the registry, pull the prebuilt image, and deploy it to Astro using `--image-name`. No build step occurs. The image must be based on Astro Runtime.
To learn more about deploying prebuilt images, see [Deploy a prebuilt Docker image](/docs/astro/deploy-project-image#deploy-a-prebuilt-docker-image).
# GitHub Actions templates for deploying code to Astro
Source: https://astronomer.io/docs/astro/ci-cd-templates/github-actions-template
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using GitHub Actions.
The Astro GitHub integration can automatically deploy code from a GitHub repository to Astro without you needing to configure a GitHub action. In addition, the Astro UI shows Git metadata for each deploy on your Deployment information screen. See [Deploy code with the Astro GitHub integration](/docs/astro/deploy-github-integration) for setup steps.
GitHub Action templates use the Astronomer-maintained `deploy-action`, which is available in the [GitHub Marketplace](https://github.com/marketplace/actions/deploy-apache-airflow-dags-to-astro). This action automates the deploy process and includes additional features for more complex automation workflows. Specifically, the action can automatically:
* Choose a deploy type based on the files that were changed in a commit. This allows you to use the same template for dag deploys and image deploys.
* Test dags as part of the deploy process and prevent deploying if any of the tests fail. These tests are defined in the `tests` directory of your Astro project.
* Create a [preview Deployment](/docs/astro/ci-cd-templates/github-actions-deployment-preview) to test your code before deploying to production. A Deployment preview is an Astro Deployment that mirrors the configuration of an existing Deployment.
* Allows you to choose the type of code deploys used by the automation:
* (Default) `infer`
* `image-and-dags`
* `image-only`
* `dags-only`
* `dbt`
If you have one Deployment and one environment on Astro, use the [single branch implementation](/docs/astro/ci-cd-templates/template-overview#single-branch-implementation). If you have multiple Deployments that support development and production environments, use the [multiple branch implementation](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation). If your team builds custom Docker images, use the [custom image implementation](/docs/astro/ci-cd-templates/template-overview#custom-image-implementation). If you don't have access to Astronomer's `deploy-action`, use the [private network templates](/docs/astro/ci-cd-templates/github-actions-private-network).
To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
If you use GitHub Enterprise and cannot access the Astronomer Deploy Action, see [Private network templates](/docs/astro/ci-cd-templates/github-actions-private-network).
## Deploy type
The `deploy-action` includes several deploy types for you to choose a specific type of code deploy for your CI/CD processes.
See the [Deploy Action README](https://github.com/astronomer/deploy-action#readme) to learn more about using and customizing this action, like creating a GitHub action that can support dag and dbt deploys.
### (Default) infer
By default, the `deploy-action` uses `infer`, which allows it to determine the type of code deploy to use based on the types of files changed in a commit: Dag or Astro project. If you committed changes only to dag files, the action triggers a dag deploy. If you committed changes to any other file, the action triggers an image deploy, or `image-and-dags`. This setting does not include `dbt` deploy types. See [default deploy action](/docs/astro/ci-cd-templates/default-deploy-action).
### image-and-dags
The `image-and-dags` option enables the Deploy Action to make a full project deploy, which includes both images and dags. This option will also include code in `includes/`, `plugins/`, or any other directories in the root of the repository. For example, if you have a dbt project in a `dbt/` directory, it will be included when using this Deploy Action.
### image-only
The `image-only` option enables the Deploy Action to deploy only the Docker image of your Astro project without updating existing dags on your Deployment. Use this option when you want to push dependency or configuration changes independently of your dag code. This deploy type skips dag parsing and pytest validation. Requires Astro CLI version 1.21.0 or later.
### dags-only
The `dags-only` deploy option enables the deploy action to deploy only the dags in your Astro project's `dags` directory to your Deployment.
### dbt
The `dbt` deploy option enables the Deploy Action to deploy dbt projects to Astro, when you provide the path to a directory in your GitHub repo that contains your dbt project. See [dbt deploy action](/docs/astro/ci-cd-templates/dbt-deploy-action). This is most commonly used when your dbt code/logic does not live in the same repository as your Astro project.
## Monorepo support
If your Astro project lives in a monorepo, use the following inputs to control how the action checks out your repository and determines whether to trigger a deploy:
* `sparse-checkout`: Limits the GitHub checkout to specific folders, typically the same value as `root-folder`. Use this input to reduce checkout size in large monorepos.
* `image-trigger-paths`: Lists paths outside `root-folder` that also trigger a deploy when changed, for example generated files that get copied into the image at build time. Applies to the `infer`, `image-and-dags`, and `image-only` deploy types.
* `skip-unchanged`: Set to `false` to always run the deploy dictated by `deploy-type`, instead of skipping when no changed files fall under `root-folder` or `image-trigger-paths`. This input replaces the deprecated `deploy-image: true` input.
See [Configuration options](https://github.com/astronomer/deploy-action#configuration-options) in the Deploy Action README for full details and examples.
# Astro CI/CD templates for GitLab
Source: https://astronomer.io/docs/astro/ci-cd-templates/gitlab
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using GitLab.
Use the following CI/CD templates to automate deploys to Astro from a [GitLab](https://gitlab.com/) repository.
Read the following sections to choose the right template for your project. The templates for GitLab include the image deploy templates and dag deploy templates.
If you have one Deployment and one environment on Astro, use the [single branch implementation](#single-branch). If you have multiple Deployments that support development and production environments, use the [multiple branch implementation](#multiple-branch). If you want your CI/CD process to automatically decide which deploy strategy to choose, see [Dag deploy templates](#dag-deploy-templates).
To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a GitLab repository.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
Each CI/CD template implementation might have additional requirements.
## Image deploy templates
Use this template to push code from a GitLab repository to Astro.
1. Set the following [environment variables](https://docs.gitlab.com/ee/ci/variables/#for-a-project) in your GitLab project:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `DEPLOYMENT_ID`: The ID of your Astro Deployment. You can copy the **ID** from your Deployment's home page in the Astro UI.
Astronomer recommends that you always [mask](https://docs.gitlab.com/ee/ci/variables/#mask-a-cicd-variable) your API token to prevent it from being accessible in plain text. You can also set the API token as an [external secret](https://docs.gitlab.com/ee/ci/secrets/index.html) for an extra layer of security.
2. Go to **Build** > **Pipeline Editor** and commit the following:
```yaml title=".gitlab-ci.yml" wrap theme={null}
astro_deploy:
stage: deploy
image: docker:latest
services:
- docker:dind
variables:
ASTRO_API_TOKEN: ${ASTRO_API_TOKEN}
DEPLOYMENT_ID: ${DEPLOYMENT_ID}
before_script:
- apk add --update curl && rm -rf /var/cache/apk/*
- apk add bash
script:
- (curl -sSL install.astronomer.io | bash -s)
- astro deploy -f $DEPLOYMENT_ID
only:
- main
```
Use this template to push code to a development and a production Deployment in Astro based on your GitLab project's branch name.
1. Set the following [environment variables](https://docs.gitlab.com/ee/ci/variables/#for-a-project) in your GitLab project:
* `PROD_ASTRO_API_TOKEN`: The value of your production Workspace or Organization API token.
* `PROD_DEPLOYMENT_ID`: The ID of your Astro Deployment. You can copy the **ID** from your production Deployment's page in the Astro UI.
* `DEV_ASTRO_API_TOKEN`: The value of your development Workspace or Organization API token.
* `DEV_DEPLOYMENT_ID`: The ID of your Astro Deployment. You can copy the **ID** from your development Deployment's page in the Astro UI.
Astronomer recommends that you always [mask](https://docs.gitlab.com/ee/ci/variables/#mask-a-cicd-variable) your API token to prevent it from being accessible in plain text. You can also set the API token as an [external secret](https://docs.gitlab.com/ee/ci/secrets/index.html) for an extra layer of security.
When you create a CI/CD variable that will be used in multiple branches, you might want to [protect the variable](https://docs.gitlab.com/ee/ci/variables/#protect-a-cicd-variable) so that it can only be accessed from the relevant branches.
2. Go to the **Editor** option in your project's CI/CD section and commit the following:
```yaml title=".gitlab-ci.yml" expandable wrap theme={null}
astro_deploy_dev:
stage: deploy
image: docker:latest
services:
- docker:dind
variables:
ASTRO_API_TOKEN: ${DEV_ASTRO_API_TOKEN}
DEPLOYMENT_ID: ${DEV_DEPLOYMENT_ID}
before_script:
- apk add --update curl && rm -rf /var/cache/apk/*
- apk add bash
script:
- (curl -sSL install.astronomer.io | bash -s)
- astro deploy -f $DEPLOYMENT_ID
only:
- dev
astro_deploy_prod:
stage: deploy
image: docker:latest
services:
- docker:dind
variables:
ASTRO_API_TOKEN: ${PROD_ASTRO_API_TOKEN}
DEPLOYMENT_ID: ${PROD_DEPLOYMENT_ID}
before_script:
- apk add --update curl && rm -rf /var/cache/apk/*
- apk add bash
- apk add jq
script:
- (curl -sSL install.astronomer.io | bash -s)
- astro deploy -f $DEPLOYMENT_ID
only:
- main
```
## Dag deploy templates
The dag deploy template uses the `--dags` flag in the Astro CLI to push dag changes to Astro. These CI/CD pipelines deploy your dags only when files in your `dags` folder are modified, and they deploy the rest of your Astro project as a Docker image when other files or directories are modified. For more information about the benefits of this workflow, see [Deploy dags only](/docs/astro/deploy-code).
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.
To avoid this, either push commits individually or configure your repository to **Squash commits** for pull requests that merge multiple commits simultaneously.
### Single branch implementation
Use this template to push code from a GitLab repository to Astro.
1. Set the following [environment variables](https://docs.gitlab.com/ee/ci/variables/#for-a-project) in your GitLab project:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `DEPLOYMENT_ID`: The ID of your Astro Deployment. You can copy the **ID** from your Deployment's page in the Astro UI.
Astronomer recommends that you always [mask](https://docs.gitlab.com/ee/ci/variables/#mask-a-cicd-variable) your API token to prevent it from being accessible in plain text. You can also set the API token as an [external secret](https://docs.gitlab.com/ee/ci/secrets/index.html) for an extra layer of security.
2. Go to the **Editor** option in your project's CI/CD section and commit the following:
```yaml title=".gitlab-ci.yml" expandable wrap theme={null}
astro_smart_deploy:
stage: deploy
image: docker:latest
services:
- docker:dind
variables:
ASTRO_API_TOKEN: ${ASTRO_API_TOKEN}
DAG_FOLDER: "dags"
DEPLOYMENT_ID: ${DEPLOYMENT_ID}
before_script:
- apk add --update curl && rm -rf /var/cache/apk/*
- apk add git
- apk add bash
script:
- (curl -sSL install.astronomer.io | bash -s)
- files=$(git diff --name-only $(git rev-parse HEAD~1) -- .)
- dags_only=1
- echo "$DAG_FOLDER"
- echo "$files"
- for file in $files; do
- echo "$file"
- if [[ "$file" != "$DAG_FOLDER"* ]]; then
- echo "$file is not a dag, triggering a full image build"
- dags_only=0
- break
- else
- echo "just a dag"
- fi
- done
- if [[ $dags_only == 1 ]]; then
- echo "doing dag-only deploy"
- astro deploy --dags $DEPLOYMENT_ID
- elif [[ $dags_only == 0 ]]; then
- echo "doing image deploy"
- astro deploy -f $DEPLOYMENT_ID
- fi
only:
- main
```
# Astro CI/CD templates for Harness
Source: https://astronomer.io/docs/astro/ci-cd-templates/harness
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using Harness.
Use the following CI/CD template to automate a deploy with a [single branch implementation](/docs/astro/ci-cd-templates/template-overview#single-branch-implementation), which requires only one Astro Deployment, from a Git repository to Astro with [Harness](https://harness.org/product).
If you use the [dag-only deploy feature](/docs/astro/deploy-dags) on Astro or you're interested in a multiple-branch implementation, see [Template overview](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Harness can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [Harness](https://www.harness.io/).
## Deploy template
1. [Create a Harness CI pipeline](https://developer.harness.io/docs/continuous-integration/use-ci/prep-ci-pipeline-components/) and configure it as **Remote** with a **Third-party Git provider**.
2. Authenticate to your Git provider.
3. Choose **Cloud** for infrastructure, and **Linux** and **ARM64** for platform. If you want to use other infrastructure, see [Harness’s guide for implementation](https://developer.harness.io/docs/platform/delegates/delegate-concepts/delegate-overview/).
4. Add a step, then choose **Run** as the template type from the step library. Use `sh` for your shell. Only one step is needed to deploy code from your Git repository to Astro, but you can add more if your use case requires.
5. Paste the following code into the command prompt and apply changes.
```bash wrap expandable theme={null}
#!/bin/bash
set -ex
# Prerequisites: Set variables
ORGANIZATION_ID=$ASTRO_ORG_ID
DEPLOYMENT_ID=$ASTRO_DEPLOYMENT_ID
ASTRO_API_TOKEN=$ASTRO_API_TOKEN
ASTRO_PROJECT_PATH=$ASTRO_PROJECT_PATH
# Step 1: Initialize deploy
echo -e "Initiating Deploy Process for deployment $DEPLOYMENT_ID\n"
CREATE_DEPLOY=$(curl --location --request POST "https://api.astronomer.io/platform/v1beta1/organizations/$ORGANIZATION_ID/deployments/$DEPLOYMENT_ID/deploys" \
--header "X-Astro-Client-Identifier: script" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $ASTRO_API_TOKEN" \
--data '{
"type": "IMAGE_AND_DAG"
}' | jq '.')
DEPLOY_ID=$(echo $CREATE_DEPLOY | jq -r '.id')
REPOSITORY=$(echo $CREATE_DEPLOY | jq -r '.imageRepository')
TAG=$(echo $CREATE_DEPLOY | jq -r '.imageTag')
DAGS_UPLOAD_URL=$(echo $CREATE_DEPLOY | jq -r '.dagsUploadUrl')
# Step 2: Log in to Docker
docker login $REPOSITORY -u cli -p $ASTRO_API_TOKEN
echo -e "\nBuilding Docker image $REPOSITORY:$TAG for $DEPLOYMENT_ID from $ASTRO_PROJECT_PATH"
# Step 3: Build image
docker build -t $REPOSITORY:$TAG --platform=linux/amd64 $ASTRO_PROJECT_PATH
# Step 4: Push image
echo -e "\nPushing Docker image $REPOSITORY:$TAG to $DEPLOYMENT_ID"
docker push $REPOSITORY:$TAG
# Step 5: Create tar file wd
echo -e "\nCreating a dags tar file from $ASTRO_PROJECT_PATH/dags and stored in $ASTRO_PROJECT_PATH/dags.tar\n"
cd $ASTRO_PROJECT_PATH
tar -cvf "$ASTRO_PROJECT_PATH/dags.tar" "dags"
# Step 6: Upload dags tar file
echo -e "\nUploading tar file $ASTRO_PROJECT_PATH/dags.tar\n"
VERSION_ID=$(curl -i --request PUT $DAGS_UPLOAD_URL \
--header 'x-ms-blob-type: BlockBlob' \
--header 'Content-Type: application/x-tar' \
--upload-file "$ASTRO_PROJECT_PATH/dags.tar" | grep x-ms-version-id | awk -F': ' '{print $2}')
VERSION_ID=$(echo $VERSION_ID | sed 's/\r//g') # Remove unexpected carriage return characters
echo -e "\nTar file uploaded with version: $VERSION_ID\n"
# Step 7: Finalizing Deploy
FINALIZE_DEPLOY=$(curl --location --request POST "https://api.astronomer.io/platform/v1beta1/organizations/$ORGANIZATION_ID/deployments/$DEPLOYMENT_ID/deploys/$DEPLOY_ID/finalize" \
--header "X-Astro-Client-Identifier: script" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $ASTRO_API_TOKEN" \
--data '{"dagTarballVersion": "'$VERSION_ID'"}')
ID=$(echo $FINALIZE_DEPLOY | jq -r '.id')
if [[ "$ID" != null ]]; then
echo -e "\nDeploy is Finalized. Image and dag changes for deployment $DEPLOYMENT_ID should be live in a few minutes"
echo "Deployed Image tag: $TAG"
echo "Deployed dag Tarball Version: $VERSION_ID"
else
MESSAGE=$(echo $FINALIZE_DEPLOY | jq -r '.message')
if [[ "$MESSAGE" != null ]]; then
echo $MESSAGE
else
echo "Something went wrong. Reach out to astronomer support for assistance"
fi
fi
# Cleanup
echo -e "\nCleaning up the created tar file from $ASTRO_PROJECT_PATH/dags.tar"
rm -rf "$ASTRO_PROJECT_PATH/dags.tar"
```
6. Add the following environment variables in Harness:
`ORGANIZATION_ID`: The ID for your Organization.
`DEPLOYMENT_ID`: The ID for your Deployment.
`ASTRO_API_TOKEN`: The value for your API token as a secret.
`ASTRO_PROJECT_PATH`: The default value is `/harness/` and is followed by the folder name used in the Git provider for Astro, if applicable.
7. Run the pipeline. Harness requires you to save changes before executing. Logs will display any errors.
# Astro CI/CD templates for Jenkins
Source: https://astronomer.io/docs/astro/ci-cd-templates/jenkins
Use pre-built Astronomer CI/CD templates to automate deploying Apache Airflow dags to Astro using Jenkins.
Use the following CI/CD templates to automate deploying Apache Airflow dags from a Git repository to Astro with [Jenkins](https://www.jenkins.io/).
The following templates for Jenkins are available:
* [Image deploy templates](/docs/astro/ci-cd-templates/template-overview#image-deploy-templates)
* [dag deploy templates](/docs/astro/ci-cd-templates/template-overview#dag-deploy-templates)
Each template type supports multiple implementations. If you have one Deployment and one environment on Astro, use the [single branch implementation](/docs/astro/ci-cd-templates/template-overview#single-branch-implementation). If you have multiple Deployments that support development and production environments, use the [multiple branch implementation](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation). If your team builds custom Docker images, use the [custom image implementation](/docs/astro/ci-cd-templates/template-overview#custom-image-implementation).
For more information on each template or to configure your own, see [Template overview](/docs/astro/ci-cd-templates/template-overview). To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Prerequisites
* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Jenkins can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [Jenkins](https://www.jenkins.io/).
Each CI/CD template implementation might have additional requirements.
## Image deploy templates
To automate code deploys to a single Deployment using [Jenkins](https://www.jenkins.io/), complete the following setup in a Git-based repository hosting an Astro project:
1. In your Jenkins pipeline configuration, add the following environment variables:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRONOMER_DEPLOYMENT_ID`: The Deployment ID of your production deployment
To set environment variables in Jenkins, on the Jenkins Dashboard go to **Manage Jenkins** > **Configure System** > **Global Properties** > **Environment Variables** > **Add**. To see Jenkins documentation on environment variables click [here](https://www.jenkins.io/doc/pipeline/tour/environment/)
Be sure to set the value for your API token as secret.
2. At the root of your Astro Git repository, add a [Jenkinsfile](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/) that includes the following script:
```groovy title="Jenkinsfile" wrap theme={null}
pipeline {
agent any
stages {
stage('Deploy to Astronomer') {
when {
expression {
return env.GIT_BRANCH == "origin/main"
}
}
steps {
checkout scm
sh '''
curl -LJO https://github.com/astronomer/astro-cli/releases/download/v1.38.0/astro_1.38.0_linux_amd64.tar.gz
tar -zxvf astro_1.38.0_linux_amd64.tar.gz astro && rm astro_1.38.0_linux_amd64.tar.gz
./astro deploy env.ASTRONOMER_DEPLOYMENT_ID
'''
}
}
}
post {
always {
cleanWs()
}
}
}
```
This `Jenkinsfile` triggers a code push to Astro every time a commit or pull request is merged to the `main` branch of your repository.
To automate code deploys across multiple Deployments using [Jenkins](https://www.jenkins.io/), complete the following setup in a Git-based repository hosting an Astro project:
1. In Jenkins, add the following environment variables:
* `PROD_ASTRO_API_TOKEN`: The value for your production Workspace or Organization API token.
* `PROD_DEPLOYMENT_ID`: The Deployment ID of your production Deployment
* `DEV_ASTRO_API_TOKEN`: The value for your development Workspace or Organization API token.
* `DEV_DEPLOYMENT_ID`: The Deployment ID of your development Deployment
To set environment variables in Jenkins, on the Jenkins Dashboard go to **Manage Jenkins** > **Configure System** > **Global Properties** > **Environment Variables** > **Add**. To see Jenkins documentation on environment variables click [here](https://www.jenkins.io/doc/pipeline/tour/environment/)
Be sure to set the values for your API credentials as secret.
2. At the root of your Git repository, add a [`Jenkinsfile`](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/) that includes the following script:
```groovy title="Jenkinsfile" expandable wrap theme={null}
pipeline {
agent any
stages {
stage('Set Environment Variables') {
steps {
script {
if (env.GIT_BRANCH == 'main') {
echo "The git branch is ${env.GIT_BRANCH}";
env.ASTRO_API_TOKEN = env.PROD_ASTRO_API_TOKEN;
env.ASTRONOMER_DEPLOYMENT_ID = env.PROD_DEPLOYMENT_ID;
} else if (env.GIT_BRANCH == 'dev') {
echo "The git branch is ${env.GIT_BRANCH}";
env.ASTRO_API_TOKEN = env.DEV_ASTRO_API_TOKEN;
env.ASTRONOMER_DEPLOYMENT_ID = env.DEV_DEPLOYMENT_ID;
} else {
echo "This git branch ${env.GIT_BRANCH} is not configured in this pipeline."
}
}
}
}
stage('Deploy to Astronomer') {
steps {
checkout scm
sh '''
curl -LJO https://github.com/astronomer/astro-cli/releases/download/v1.38.0/astro_1.38.0_linux_amd64.tar.gz
tar -zxvf astro_1.38.0_linux_amd64.tar.gz astro && rm astro_1.38.0_linux_amd64.tar.gz
./astro deploy env.ASTRONOMER_DEPLOYMENT_ID
'''
}
}
}
post {
always {
cleanWs()
}
}
}
```
This `Jenkinsfile` triggers a code push to an Astro Deployment every time a commit or pull request is merged to the `dev` or `main` branch of your repository.
If your Astro project requires additional build-time arguments to build an image, you need to define these build arguments using Docker's [`build-push-action`](https://github.com/docker/build-push-action).
#### Configuration requirements
* An Astro project that requires additional build-time arguments to build the Runtime image.
1. In your Jenkins pipeline configuration, add the following environment variables:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRONOMER_DEPLOYMENT_ID`: The Deployment ID of your production deployment
To set environment variables in Jenkins, on the Jenkins Dashboard go to **Manage Jenkins** > **Configure System** > **Global Properties** > **Environment Variables** > **Add**. To see Jenkins documentation on environment variables click [here](https://www.jenkins.io/doc/pipeline/tour/environment/)
Be sure to set the value for your API token as secret.
2. At the root of your Astro Git repository, add a [Jenkinsfile](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/) that includes the following script:
```groovy title="Jenkinsfile" wrap theme={null}
pipeline {
agent any
stages {
stage('Deploy to Astronomer') {
when {
expression {
return env.GIT_BRANCH == "origin/main"
}
}
steps {
checkout scm
sh '''
export astro_id=$(date +%Y%m%d%H%M%S)
docker build -f Dockerfile --progress=plain --build-arg -t $astro_id .
curl -LJO https://github.com/astronomer/astro-cli/releases/download/v1.37.0/astro_1.37.0_linux_amd64.tar.gz
tar -zxvf astro_1.37.0_linux_amd64.tar.gz astro && rm astro_1.37.0_linux_amd64.tar.gz
./astro deploy env.ASTRONOMER_DEPLOYMENT_ID --image-name $astro_id
'''
}
}
}
post {
always {
cleanWs()
}
}
}
```
This `Jenkinsfile` triggers a code push to Astro every time a commit or pull request is merged to the `main` branch of your repository.
## Dag deploy templates
The dag deploy template uses the `--dags` flag in the Astro CLI to push dag changes to Astro. These CI/CD pipelines deploy your dags only when files in your `dags` folder are modified, and they deploy the rest of your Astro project as a Docker image when other files or directories are modified. For more information about the benefits of this workflow, see [Deploy dags only](/docs/astro/deploy-dags).
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.
To avoid this, either push commits individually or configure your repository to **Squash commits** for pull requests that merge multiple commits simultaneously.
### Single branch implementation
Use the following template to implement dag-only deploys to a single Deployment using Jenkins.
1. In your Jenkins pipeline configuration, add the following parameters:
* `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
* `ASTRONOMER_DEPLOYMENT_ID`: The Deployment ID of your production deployment
Be sure to set the values for your API token as secret.
2. At the root of your Git repository, add a [`Jenkinsfile`](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/) that includes the following script:
```groovy title="Jenkinsfile" expandable wrap theme={null}
pipeline {
agent any
stages {
stage('Dag Only Deploy to Astronomer') {
when {
expression {
return env.GIT_BRANCH == "origin/main"
}
}
steps {
checkout scm
sh '''
curl -LJO https://github.com/astronomer/astro-cli/releases/download/v1.38.0/astro_1.38.0_linux_amd64.tar.gz
tar -zxvf astro_1.38.0_linux_amd64.tar.gz astro && rm astro_1.38.0_linux_amd64.tar.gz
files=($(git diff-tree HEAD --name-only --no-commit-id))
find="dags"
if [[ ${files[*]} =~ (^|[[:space:]])"$find"($|[[:space:]]) && ${#files[@]} -eq 1 ]]; then
./astro deploy env.ASTRONOMER_DEPLOYMENT_ID --dags;
else
./astro deploy env.ASTRONOMER_DEPLOYMENT_ID;
fi
'''
}
}
}
post {
always {
cleanWs()
}
}
}
```
# Automate preview Deployments with any CI/CD tool
Source: https://astronomer.io/docs/astro/ci-cd-templates/preview-deployments
Use shell scripts to automate creating, updating, and deleting preview Deployments on Astro with any CI/CD tool.
A *preview Deployment* is an Astro Deployment that a CI/CD workflow automatically creates and deletes based on feature branches in your Git repository. The workflow creates the preview Deployment when you create a temporary feature branch and deletes it when you delete the branch. Astronomer recommends using preview Deployments if you regularly need to test a small set of dags on Astro before promoting those dags to a base, production Deployment. This lowers the infrastructure cost of Deployments that are dedicated to development and testing.
To implement this feature, you need a CI/CD workflow that:
* Creates the preview Deployment when you create a new branch.
* Deploys code changes to Astro when you make updates in the branch.
* Deletes the preview Deployment when you delete the branch.
* Deploys your changes to your base Deployment after you merge your changes into your main branch.
If you use GitHub Actions as your CI/CD tool, you can find preview Deployment templates as part of the [Astronomer GitHub action in the GitHub Marketplace](https://github.com/astronomer/deploy-action?tab=readme-ov-file#deployment-preview-templates). This GitHub action includes sub-actions for each of these four steps. To learn more, see [GitHub Actions templates for preview Deployments](/docs/astro/ci-cd-templates/github-actions-deployment-preview).
To configure your own automated workflow for preview Deployments with another CI/CD tool, use the following scripts. Each of the following four shell scripts is equivalent to the steps required to implement this feature with [GitHub Actions](/docs/astro/ci-cd-templates/github-actions-deployment-preview).
## Create a preview Deployment
In a Deployment preview CI/CD pipeline, you run this script when you create a feature branch off of the main branch of your Astro project.
```bash wrap theme={null}
# Install the Astro CLI
curl -sSL https://install.astronomer.io | sudo bash -s
# Get preview Deployment name
DEPLOYMENT_NAME="$(astro deployment inspect $DEPLOYMENT_ID --key configuration.name)"
BRANCH_DEPLOYMENT_NAME=$BRANCH_NAME_$DEPLOYMENT_NAME
BRANCH_DEPLOYMENT_NAME="$BRANCH_DEPLOYMENT_NAME// /_"
# Create template of Deployment to be copied
astro deployment inspect $DEPLOYMENT_ID --template > deployment-preview-template.yaml # automatically creates deployment-preview-template.yaml file
# Add name to Deployment template file
sed -i "s| name:.*| name: $BRANCH_DEPLOYMENT_NAME}|g" deployment-preview-template.yaml
# Create new preview Deployment based on the Deployment template file
astro deployment create --deployment-file deployment-preview-template.yaml
# Get the ID of the new preview Deployment
PREVIEW_DEPLOYMENT_ID="$(astro deployment inspect -n $BRANCH_DEPLOYMENT_NAME --key metadata.deployment_id)"
# Copy connections, Airflow variables, and pools from the source Deployment
astro deployment connection copy --source-id $DEPLOYMENT_ID --target-id $PREVIEW_DEPLOYMENT_ID
astro deployment airflow-variable copy --source-id $DEPLOYMENT_ID --target-id $PREVIEW_DEPLOYMENT_ID
astro deployment pool copy --source-id $DEPLOYMENT_ID --target-id $PREVIEW_DEPLOYMENT_ID
# Deploy new code to the deployment preview
astro deploy -n $BRANCH_DEPLOYMENT_NAME
```
Creating a Deployment from a template does not copy the connections, Airflow variables, or pools from the source Deployment, so the script copies them separately with `astro deployment connection copy`, `astro deployment airflow-variable copy`, and `astro deployment pool copy`.
The copy commands fail if the source Deployment is hibernating. Resume the source Deployment before you run them.
## Update a preview Deployment
In a Deployment preview CI/CD pipeline, you run this script whenever you make changes in your feature branch.
```bash wrap theme={null}
# Install the Astro CLI
curl -sSL https://install.astronomer.io | sudo bash -s
# Get preview Deployment name
DEPLOYMENT_NAME="$(astro deployment inspect $DEPLOYMENT_ID --key configuration.name)"
BRANCH_DEPLOYMENT_NAME=$BRANCH_NAME_$DEPLOYMENT_NAME
BRANCH_DEPLOYMENT_NAME="$BRANCH_DEPLOYMENT_NAME// /_"
# Deploy new code to the preview Deployment
astro deploy -n $BRANCH_DEPLOYMENT_NAME
```
## Delete a preview Deployment
In a Deployment preview CI/CD pipeline, you run this script when you delete your feature branch.
```bash wrap theme={null}
# Install the Astro CLI
curl -sSL https://install.astronomer.io | sudo bash -s
DEPLOYMENT_NAME="$(astro deployment inspect $DEPLOYMENT_ID --key configuration.name)"
BRANCH_DEPLOYMENT_NAME=$BRANCH_NAME_$DEPLOYMENT_NAME
BRANCH_DEPLOYMENT_NAME="$BRANCH_DEPLOYMENT_NAME// /_"
# Delete preview Deployment
astro deployment delete -n $BRANCH_DEPLOYMENT_NAME -f
```
## Deploy changes from a preview Deployment to a base Deployment
In a Deployment preview CI/CD pipeline, you run this script when you merge your feature branch into your main branch.
```bash wrap theme={null}
# Install the Astro CLI
curl -sSL https://install.astronomer.io | sudo bash -s
# Deploy new code to base Deployment
astro deploy $DEPLOYMENT_ID
```
# Template options
Source: https://astronomer.io/docs/astro/ci-cd-templates/template-overview
Use pre-built templates to get started with automating code deploys
Astronomer CI/CD templates are customizable, pre-built code samples that help you configure automated workflows with popular CI/CD tools, such as GitHub Actions or Jenkins. Use the templates to create a workflow that automates deploying code to Astro according to your team's CI/CD requirements and strategy.
Template types differ based on the deploy method they use and how many branches or environments they require. This document contains information about the following template types:
* *Dag deploy templates* that use the [dag-only deploy feature](/docs/astro/deploy-dags) in Astro and either deploy dags or your entire Astro project depending on the files that you update.
* *dbt deploy templates* that use the [dbt deploy feature](/docs/astro/deploy-dags) in Astro to push dbt code from your specified dbt project directory, by default `/dbt`, to make the code accessible in your Deployment.
* *Image deploy templates* that build a Docker image and push it to Astro whenever you update any file in your Astro project, including your dag directory.
* *Preview Deployment templates* that automatically create and delete Deployments when you create or delete a feature branch from your main Astro project branch.
Astronomer maintains a dedicated guide with templates for select CI/CD tools. Most guides include image based templates for a single-branch implementation. Astronomer recommends reconfiguring the templates to work with your own directory structures, tools, and processes.
If you're interested in documentation for a CI/CD tool or template type that does not exist, configure your own or [contact Astronomer support](https://cloud.astronomer.io/open-support-request). To learn more about single-branch and multiple-branch implementations and decide which template is right for you, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).
## Implementation options
CI/CD templates support different implementations based on how many branches and Astro Deployments your team maintains. Choose the implementation that matches your branching strategy, then apply it with one of the deploy templates described in the following sections. For a detailed comparison of environment and repository strategies, see [Develop a CI/CD workflow](/docs/astro/set-up-ci-cd#choose-a-deploy-strategy).
### Single-branch implementation
A single-branch implementation uses one permanent branch, such as `main`, that deploys to a single Astro Deployment. Use this implementation when you have one Deployment and one environment on Astro. See [Single environment](/docs/astro/set-up-ci-cd#single-environment).
### Multiple-branch implementation
A multiple-branch implementation uses multiple permanent branches that each deploy to a separate Astro Deployment, such as a `dev` branch for development and a `main` branch for production. Use this implementation when you maintain multiple Deployments that support development and production environments. See [Multiple environments](/docs/astro/set-up-ci-cd#multiple-environments).
### Custom image implementation
A custom image implementation builds a custom Docker image and deploys it to Astro. Use this implementation when your team builds custom Docker images, for example to install additional dependencies or apply custom build logic. Build the image for the `linux/amd64` platform. Astro rejects images built for any other platform when you deploy them.
## Dag deploy templates
*Dag deploy templates* check the changes in your Astro project and trigger either a dag deploy or image deploy based on the files changed, allowing for faster deploys. This template deploys your dags when only the files in your `dags` folder are modified, and it deploys the rest of your Astro project as a Docker image when any other files or directories are modified. To learn more about the benefits of this workflow, see [Deploy dags](/docs/astro/deploy-dags).
CI/CD templates that use the dag deploy workflow:
* Require that each Deployment have the dag-only deploy feature enabled. See [Enable/disable dag-only deploys on a Deployment](/docs/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment).
* Use a [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens). This value must be set using the `ASTRO_API_TOKEN` environment variable.
* Install the latest version of the Astro CLI.
* Trigger the following Astro CLI commands depending on which files were updated by the commit:
* If only dag files in the `dags` folder have changed, run `astro deploy --dags`. This pushes your `dags` folder to your Deployment.
* If any file not in the `dags` folder has changed, run `astro deploy`. This triggers two subprocesses. One that creates a Docker image for your Astro project, authenticates to Astro using your Deployment API token, and pushes the image to your Deployment. A second that pushes your `dags` folder to your Deployment.
If you stage multiple commits to dag files and push them all at once to your remote branch, the template only deploys dag code changes from the most recent commit. It will miss any code changes made in previous commits.
To avoid this, either push commits individually or configure your repository to **Squash commits** for pull requests that merge multiple commits simultaneously.
This process is equivalent to the following shell script:
```bash wrap theme={null}
# Set Deployment API token credentials as environment variables
export ASTRO_API_TOKEN=""
export DAG_FOLDER=""
# Install the latest version of Astro CLI
curl -sSL install.astronomer.io | sudo bash -s
# Determine if only dag files have changes
files=$(git diff --name-only $(git rev-parse HEAD~1) -- .)
dags_only=1
for file in $files; do
if [[ $file != "$DAG_FOLDER"* ]]; then
echo "$file is not a dag, triggering a full image build"
dags_only=0
break
fi
done
# If only dags changed deploy only the dags in your 'dags' folder to your Deployment
if [ $dags_only == 1 ]
then
astro deploy --dags
fi
# If any other files changed build your Astro project into a Docker image, push the image to your Deployment, and then push and dag changes
if [ $dags_only == 0 ]
then
astro deploy
fi
```
## Image deploy templates
*Image based templates* build a Docker image and push it to Astro whenever you update any file in your Astro project. This type of template works well for development workflows that include complex Docker customization or logic.
CI/CD templates that use image based workflows:
* Use a [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens) or [Organization API token](/docs/astro/organization-api-tokens). This value must be set using the `ASTRO_API_TOKEN` environment variable.
* Install the latest version of the Astro CLI.
* Run the `astro deploy` command. This creates a Docker image for your Astro project, authenticates to Astro using your Deployment API token, and pushes the image to your Deployment.
This is equivalent to running the following shell script:
```sh wrap theme={null}
# Set Deployment API token credentials as environment variables
export ASTRO_API_TOKEN=""
# Install the latest version of Astro CLI
curl -sSL install.astronomer.io | sudo bash -s
# Build your Astro project into a Docker image and push the image to your Deployment
astro deploy -f
```
## dbt deploy templates
*dbt deploy templates* use [dbt deploy](/docs/cli/v1.43/astro-dbt-deploy) to deploy just your dbt code to your Astro project, allowing for faster deploys. Or, it uses the [Deploy Action with GitHub Actions](/docs/astro/ci-cd-templates/dbt-deploy-action) to deploy dbt code. These templates deploy your dbt code when only the files in your dbt project folder, by default `/dbt`, are modified.
CI/CD templates that use image based workflows:
* Use a [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens) or [Organization API token](/docs/astro/organization-api-tokens). This value must be set using the `ASTRO_API_TOKEN` environment variable.
* Install the latest version of the Astro CLI.
* Run the `astro dbt deploy` command from your dbt project directory. This bundles all files in your dbt project and pushes them to Astro, where they are mounted on your Airflow containers so that your dags can access them.
This is equivalent to running the following shell script from your dbt directory:
```sh wrap theme={null}
# Set Deployment API token credentials as environment variables
export ASTRO_API_TOKEN=""
# Install the latest version of Astro CLI
curl -sSL install.astronomer.io | sudo bash -s
# Push your dbt code to your Deployment
astro dbt deploy -f
```
## Preview Deployment templates
*Preview Deployment* templates automate creating and deleting Deployments based on feature branches in your Git repository. A CI/CD workflow creates a preview Deployment when you create a feature branch and deletes it when you delete the branch. Use preview Deployments to test a small set of dags on Astro before you promote them to a base, production Deployment.
* For GitHub Actions, see [GitHub Actions templates for preview Deployments](/docs/astro/ci-cd-templates/github-actions-deployment-preview).
* For any other CI/CD tool, see [Preview Deployments](/docs/astro/ci-cd-templates/preview-deployments) for equivalent shell scripts.
# Set up authentication and single sign-on for Astro
Source: https://astronomer.io/docs/astro/configure-idp
Configure federated authentication from third-party identity providers on Astro.
This guide provides the steps for integrating identity providers on Astro to enable single sign-on (SSO) for your users. After you complete the integration for your organization:
* Users will automatically be authenticated to Astro if they're already logged in to your identity provider (IdP).
* You no longer have to repeatedly sign in and remember credentials for your account.
* You will have complete ownership over credential configuration and management on Astro.
* You can require multi-factor authentication (MFA) by enforcing SSO and configuring MFA in your IdP.
* You can use services such as [Adaptive Authentication](https://www.okta.com/identity-101/adaptive-authentication/) and [Conditional Access](https://learn.microsoft.com/en-us/azure/active-directory/conditional-access/overview) to create advanced access policies that enforce trusted IP ranges or limit access to authorized devices.
To manage Organization users after you have configured SSO, see [Manage Organization users](/docs/astro/manage-organization-users).
In addition to SSO, users can authenticate to Astro in three ways:
* Basic authentication (username and password)
* Google social login
* GitHub social login
To require users to sign in through your IdP and disable the other methods, see [SSO enforcement](#sso-enforcement).
## Supported SSO identity providers
Single sign-on (SSO) allows users to sign in using their company credentials, managed through an IdP. This provides a streamlined login experience for your Astro users, as they are able to use the same credentials across multiple applications. In addition, this provides improved security and control for organizations to manage access from a single source. Astro supports integrations with the following IdPs:
* [Microsoft Entra ID](https://www.microsoft.com/en-us/security/business/microsoft-entra-pricing)
* [Okta](https://www.okta.com/)
* [OneLogin](https://www.onelogin.com/)
* [Ping Identity](https://www.pingidentity.com/en.html)
You can configure multiple SSO connections for a single Organization. This requires having a unique [verified domain](/docs/astro/manage-domains) for each new SSO connection.
## Configure your SSO identity provider
At a high level, to configure an SSO identity provider (IdP) you will:
1. Create a connection between Astro and your IdP.
2. Map a managed domain to your SSO connection.
3. Invite users to Astro through your IdP.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
This section provides setup steps for setting up Okta as your IdP on Astro. After completing this setup, all users in your organization can use Okta to sign in to Astro.
### Supported Okta features
The Astro integration with Okta supports the following authentication options:
* IdP-initiated SSO
* Service provider (SP)-initiated SSO
* Just-In-Time provisioning
#### Prerequisites (Okta)
* [Organization Owner](/docs/astro/user-permissions) privileges in the Organization you're configuring.
* An [Okta account](https://www.okta.com/) with administrative access.
* At least one [verified domain](/docs/astro/manage-domains).
#### Configure Okta as your identity provider
To set up Okta as your IdP, you will create a Security Assertion Markup Language (SAML) connection to Okta.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Click **+ New SSO Configuration**.
3. Configure the following values for your connection:
* **Connection type**: Select **SAML**.
* **Verified Domains**: Enter the verified domain(s) that you want to map to Okta.
* **Automatic Membership**: Set the default role for users who join your Organization through Okta without an explicit invite from Astro.
4. Copy the **Connection Name** from the pop-out.
5. Open a new tab and go to Okta. In the Okta Admin Console, go to **[Applications](https://help.okta.com/en-us/content/topics/apps/apps_apps_page.htm)** and click **Browse App Catalogue**. Then, search the catalogue, select the **Astro** app integration, and click **Add Integration**. After configuring a label for the integration, the application appears in **Applications**.
When you create your application, Okta automatically maps the following attributes to Astro user account values:
| Attribute | Value |
| --------- | ---------------- |
| email | `user.email` |
| firstName | user.firstName |
| lastName | user.lastName |
| name | user.displayName |
6. Open the Astro application you just configured, click **Sign On**, then click **Edit**. Configure the following values:
* **Connection Name**: Enter the **Connection Name** you copied from the Astro UI.
* **Application username format**: **Email**.
* **Update application username on**: `Create and update`.
7. Copy the values for **Sign-on URL**, **Sign out URL**, and **X.509 Certificate** from the **Metadata Details** section.
8. Assign yourself to the Astro app integration from Okta. See [Assign an app integration to a user](https://help.okta.com/en-us/Content/Topics/Provisioning/lcm/lcm-assign-app-user.htm).
9. Return to the Astro UI. In the configuration screen for your SAML connection, configure the following values:
* **Identity Provider Single Sign-on URL**: Enter your **Single Sign-on URL**.
* **Identity Provider Sign-out URL**: Enter your **Single Sign-out URL**.
* **X.509 Certificate**: Enter your **X.509 Certificate**.
10. Click **Create**. Your Okta integration appears as an entry in **SSO Configuration**.
11. In **SSO Configuration**, click **Activate**. You are redirected to Okta to test your configuration. After you have successfully authenticated, you are redirected to Astro.
12. Click **Activate SSO**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click **Configure SSO**.
3. Configure the following values for your connection:
* **Connection type**: Select **SAML**.
* **SSO Domain(s)**: Enter the verified domain(s) that you want to map to Okta.
* **Automatic Membership**: Set the default role for users who join your Organization through Okta without an explicit invite from Astro.
4. Copy the **Connection Name**.
5. Open a new tab and go to Okta. In the Okta Admin Console, go to **[Applications](https://help.okta.com/en-us/content/topics/apps/apps_apps_page.htm)** and click **Browse App Catalogue**. Then, search the catalogue, select the **Astro** app integration, and click **Add Integration**. After configuring a label for the integration, the application appears in **Applications**.
When you create your application, Okta automatically maps the following attributes to Astro user account values:
| Attribute | Value |
| --------- | ---------------- |
| email | `user.email` |
| firstName | user.firstName |
| lastName | user.lastName |
| name | user.displayName |
6. Open the Astro application you just configured, click **Sign On**, then click **Edit**. Configure the following values:
* **Connection Name**: Enter the **Connection Name** you copied from the Astro UI.
* **Application username format**: **Email**.
* **Update application username on**: `Create and update`.
7. Copy the values for **Sign-on URL**, **Sign out URL**, and **X.509 Certificate** from the **Metadata Details** section.
8. Assign yourself to the Astro app integration from Okta. See [Assign an app integration to a user](https://help.okta.com/en-us/Content/Topics/Provisioning/lcm/lcm-assign-app-user.htm).
9. Return to the Astro UI. In the configuration screen for your SAML connection, configure the following values:
* **Identity Provider Single Sign-on URL**: Enter your **Single Sign-on URL**.
* **Identity Provider Sign-out URL**: Enter your **Single Sign-out URL**.
* **X.509 Certificate**: Enter your **X.509 Certificate**.
10. Click **Create**. Your Okta integration appears as an entry in **SSO Configuration**.
11. In **SSO Configuration**, click **Activate**. You are redirected to Okta to test your configuration. After you have successfully authenticated, you are redirected to Astro.
12. Click **Activate SSO**.
Don't share your single sign-on (SSO) bypass link. With an SSO bypass link, anyone with an email and a password can sign in to Astro. Astronomer recommends periodically regenerating the link from the **Settings** tab in the Astro UI.
An SSO bypass link allows you to authenticate to your Organization without using SSO. This link should be used to access your Organization only when you can't access Astro due to an issue with your identity provider.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. In the **Advanced Settings** section, click **Edit Settings**, turn on **SSO Bypass Link**, then click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
To remove the bypass link, turn off **SSO Bypass Link**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Bypass Link** field, click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
If you don't want to maintain an SSO bypass link, click **Delete**. You can always regenerate a link if you need one in the future.
On the page for your Okta app integration, open the **Assignments** tab. Ensure that all users who will use Astro are assigned to the integration. For more information, see [Assign applications to users](https://help.okta.com/en/prod/Content/Topics/users-groups-profiles/usgp-assign-apps.htm).
SCIM provisioning allows you to manage Astro users from your identity provider platform. See [Set up SCIM provisioning](/docs/astro/set-up-scim-provisioning) for setup steps.
This section provides setup steps for setting up Microsoft Entra ID as your IdP on Astro. After completing this setup, your organization's users can use Microsoft Entra ID to sign in to Astro.
#### Prerequisites (Microsoft Entra ID)
To integrate Azure as your IdP for Astro you must have:
* An Azure subscription.
* [Cloud Application Administrator](https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference#cloud-application-administrator) permissions on Microsoft Entra ID.
* [Organization Owner](/docs/astro/user-permissions) permissions in the Organization you're configuring.
* At least one [verified domain](/docs/astro/manage-domains).
#### Configure Microsoft Entra ID as your identity provider
Follow the [Microsoft documentation](https://learn.microsoft.com/en-us/entra/identity/saas-apps/astro-tutorial#add-astro-from-the-gallery) to add Astro from the gallery to your list of managed SaaS applications.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Click **+ New SSO Configuration**.
3. Configure the following values for your connection:
* **Connection Type**: Select **SAML**. Astro also supports **Azure AD** as a connection type for Microsoft Entra ID. Astronomer recommends **SAML** because Microsoft's [Astro tutorial](https://learn.microsoft.com/en-us/entra/identity/saas-apps/astro-tutorial) only documents the SAML setup path. If you prefer to use the **Azure AD** connection type instead, see [Alternative: Configure SSO using the Azure AD connection type](#alternative-configure-sso-using-the-azure-ad-connection-type).
* **Verified Domains**: Enter the verified domain(s) that you want to map to Microsoft Entra ID.
* **Automatic Membership**: Set the default role for users who join your Organization through Microsoft Entra ID without an explicit invite from Astro.
4. Copy the **Single Sign-On URL** and **Audience URI (SP Entity ID)** for the next step.
5. Keep this configuration window open. You'll return to it later in this procedure.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click **Configure SSO**.
3. Configure the following values for your connection:
* **Connection Type**: Select **SAML**. Astro also supports **Azure AD** as a connection type for Microsoft Entra ID. Astronomer recommends **SAML** because Microsoft's [Astro tutorial](https://learn.microsoft.com/en-us/entra/identity/saas-apps/astro-tutorial) only documents the SAML setup path. If you prefer to use the **Azure AD** connection type instead, see [Alternative: Configure SSO using the Azure AD connection type](#alternative-configure-sso-using-the-azure-ad-connection-type).
* **SSO Domain(s)**: Enter the verified domain(s) that you want to map to Microsoft Entra ID.
* **Automatic Membership**: Set the default role for users who join your Organization through Microsoft Entra ID without an explicit invite from Astro.
4. Copy the **Single Sign-On URL** and **Audience URI (SP Entity ID)** for the next step.
5. Keep this configuration window open. You'll return to it later in this procedure.
In a new tab, open the [Microsoft Entra admin center](https://entra.microsoft.com/) and follow the steps in [Microsoft documentation](https://learn.microsoft.com/en-us/entra/identity/saas-apps/astro-tutorial#configure-microsoft-entra-sso) to configure Microsoft Entra SSO for Astro. In the **Basic SAML Configuration** section of your configuration, set the following values:
* **Identifier (Entity ID)**: Enter the value for **Audience URI (SP Entity ID)** you copied in the previous step.
* **Reply URL (Assertion Consumer Service URL)**: Enter the value for **Single Sign-On URL** you copied in the previous step.
After you complete the configuration, download the PEM certificate from the **SAML Signing Certificate** section for the next step.
1. Return to the Astro UI. In the configuration screen for your SSO connection, configure the following values:
* **X.509 Certificate**: Enter the PEM certificate you downloaded in the previous step.
* **Identity Provider Single Sign-on URL**: Enter the URL you copied in the previous step.
2. Click **Create**. Your Entra ID integration appears as an entry in **SSO Configuration**.
Don't share your single sign-on (SSO) bypass link. With an SSO bypass link, anyone with an email and a password can sign in to Astro. Astronomer recommends periodically regenerating the link from the **Settings** tab in the Astro UI.
An SSO bypass link allows you to authenticate to your Organization without using SSO. This link should be used to access your Organization only when you can't access Astro due to an issue with your identity provider.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. In the **Advanced Settings** section, click **Edit Settings**, turn on **SSO Bypass Link**, then click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
To remove the bypass link, turn off **SSO Bypass Link**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Bypass Link** field, click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
If you don't want to maintain an SSO bypass link, click **Delete**. You can always regenerate a link if you need one in the future.
Follow [Microsoft documentation](https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/assign-user-or-group-access-portal?pivots=portal) to assign users from your organization to your new application.
When a user assigned to the application accesses Astro, they will be brought automatically to Microsoft Entra ID after entering their email in the Astro UI.
#### Alternative: Configure SSO using the Azure AD connection type
Instead of SAML, you can connect Microsoft Entra ID to Astro using the **Azure AD** connection type, which uses OAuth 2.0 / OpenID Connect with an Azure AD app registration. Use this path if your organization prefers OIDC-based SSO over SAML.
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com/) as a Cloud Application Administrator.
2. Follow [Microsoft documentation](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app) to register a new application. When prompted, set the **Redirect URI** type to **Web** and the value to:
```text wrap theme={null}
https://auth.astronomer.io/login/callback
```
3. After the app is created, from the app's **Overview** page, copy the following values for the next step:
* **Application (client) ID**
* **Directory (tenant) ID** (your primary Microsoft Azure AD domain, for example `your-org.onmicrosoft.com`, is also available on the tenant's overview page)
4. In the app, open **Certificates & secrets**, click **New client secret**, and create a secret. Copy the secret **Value** immediately — it's only shown once. Save it for the next step.
5. In the app, open **API permissions** and ensure the default `Microsoft Graph > User.Read` delegated permission is present so users can sign in and read their profile. Grant admin consent if your tenant requires it.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Click **+ New SSO Configuration**.
3. Configure the following values for your connection:
* **Connection Type**: Select **Azure AD**.
* **Verified Domain(s)**: Select the verified domain(s) that you want to map to Microsoft Entra ID. Users with a matching email domain can sign in through SSO.
* **Automatic Membership**: Set the default Organization role for users who sign in through SSO without an explicit invite from Astro.
4. Confirm that the **Redirect URI** shown in the Astro UI matches the redirect URI you configured on the Azure app registration in the previous step:
```text wrap theme={null}
https://auth.astronomer.io/login/callback
```
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click **Configure SSO**.
3. Configure the following values for your connection:
* **Connection Type**: Select **Azure AD**.
* **Verified Domain(s)**: Select the verified domain(s) that you want to map to Microsoft Entra ID. Users with a matching email domain can sign in through SSO.
* **Automatic Membership**: Set the default Organization role for users who sign in through SSO without an explicit invite from Astro.
4. Confirm that the **Redirect URI** shown in the Astro UI matches the redirect URI you configured on the Azure app registration in the previous step:
```text wrap theme={null}
https://auth.astronomer.io/login/callback
```
In the same Astro configuration screen, under **Get the following values from your IdP and input them here**, enter the values you copied from your Azure app registration:
* **Microsoft Azure AD Domain**: Your tenant's primary domain (for example, `your-org.onmicrosoft.com`).
* **Client ID**: The **Application (client) ID** from the app's **Overview** page.
* **Client Secret**: The client secret **Value** you created under **Certificates & secrets**.
Click **Create**. Your Azure AD integration appears as an entry in **SSO Configuration**.
1. In the Microsoft Entra admin center, follow [Microsoft documentation](https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/assign-user-or-group-access-portal?pivots=portal) to assign users or groups from your organization to the Astro app registration.
2. In the Astro UI, activate the new SSO connection and complete the test sign-in flow.
3. Copy your SSO bypass link from the Astro UI **Authentication** page and store it securely in case you ever need to sign in without SSO.
When a user with an email in a verified domain signs in to Astro, they're redirected to Microsoft Entra ID to authenticate.
This section provides setup steps for setting up OneLogin as your IdP on Astro. After completing this setup, your organization's users can use OneLogin to sign in to Astro.
#### Prerequisites (OneLogin)
* A [OneLogin account](https://www.onelogin.com/) with administrative access.
* [Organization Owner](/docs/astro/user-permissions) privileges in the Organization you're configuring.
* At least one [verified domain](/docs/astro/manage-domains).
#### Configure OneLogin as your identity provider
To set up OneLogin as your IdP, you will create a Security Assertion Markup Language (SAML) connection to OneLogin.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Click **+ New SSO Configuration**.
3. Configure the following values for your connection:
* **Connection Type**: Select **SAML**.
* **Verified Domains**: Enter the verified domain(s) that you want to map to OneLogin.
* **Automatic Membership**: Set the default role for users who join your Organization through OneLogin without an explicit invite from Astro.
4. Copy the **Single Sign-On URL** and **Audience URI (SP ENTITY ID)** for use later in this procedure.
5. Open a new tab and go to OneLogin. In the OneLogin administrator dashboard, click **Applications** > **Applications** and then click **Add App**.
6. In the **Search** field, enter **SAML Custom**, and then select **SAML Custom Connector (Advanced)**.
7. In the **Display Name** field, enter **Astro** and then click **Save**.
8. Click **Configuration** in the left menu and complete the following fields:
* **Audience (EntityID)**: ``
* **ACS (Consumer) URL Validator**: ``
* **ACS (Consumer) URL**: ``
9. Select the **Sign SLO Request** and **Sign SLO Response** checkboxes. Then, click **Save**.
10. Click **Parameters** in the left menu, and add the following four parameters, using the same capitalization shown in the **Value** column:
| Field name | Value |
| ---------- | ---------- |
| email | Email |
| firstName | First Name |
| lastName | Last Name |
| name | Name |
Select the **Include in SAML assertion** checkbox for every parameter that you add and then click **Save**.
11. Click **SSO** in the left menu, click **View Details** below the **X.509 Certificate** field and then click **Download**.
12. Select **SHA-256** in the **SAML Signature Algorithm** list.
13. Copy and save the value displayed in the **SAML 2.0 Endpoint (HTTP)** field.
14. Assign yourself to the Astro app integration from OneLogin. See [Assigning apps to users](https://onelogin.service-now.com/kb_view_customer.do?sysparm_article=KB0010387).
15. Return to the Astro UI. In the configuration screen for your SAML connection, configure the following values:
* **Identity Provider Single Sign-on URL**: Enter the value you copied from **SAML 2.0 Endpoint (HTTP)**.
* **X.509 Certificate**: Enter the **X.509 Certificate** that you downloaded.
16. Click **Create**. Your OneLogin integration appears as an entry in **SSO Configuration**.
17. In **SSO Configuration**, click **Activate**. You are redirected to OneLogin to test your configuration. After you have successfully authenticated, you are redirected to Astro. Then, click **Activate SSO**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click **Configure SSO**.
3. Configure the following values for your connection:
* **Connection Type**: Select **SAML**.
* **SSO Domain(s)**: Enter the verified domain(s) that you want to map to OneLogin.
* **Automatic Membership**: Set the default role for users who join your Organization through OneLogin without an explicit invite from Astro.
4. Copy the **Single Sign-On URL** and **Audience URI (SP ENTITY ID)** for use later in this procedure.
5. Open a new tab and go to OneLogin. In the OneLogin administrator dashboard, click **Applications** > **Applications** and then click **Add App**.
6. In the **Search** field, enter **SAML Custom**, and then select **SAML Custom Connector (Advanced)**.
7. In the **Display Name** field, enter **Astro** and then click **Save**.
8. Click **Configuration** in the left menu and complete the following fields:
* **Audience (EntityID)**: ``
* **ACS (Consumer) URL Validator**: ``
* **ACS (Consumer) URL**: ``
9. Select the **Sign SLO Request** and **Sign SLO Response** checkboxes. Then, click **Save**.
10. Click **Parameters** in the left menu, and add the following four parameters, using the same capitalization shown in the **Value** column:
| Field name | Value |
| ---------- | ---------- |
| email | Email |
| firstName | First Name |
| lastName | Last Name |
| name | Name |
Select the **Include in SAML assertion** checkbox for every parameter that you add and then click **Save**.
11. Click **SSO** in the left menu, click **View Details** below the **X.509 Certificate** field and then click **Download**.
12. Select **SHA-256** in the **SAML Signature Algorithm** list.
13. Copy and save the value displayed in the **SAML 2.0 Endpoint (HTTP)** field.
14. Assign yourself to the Astro app integration from OneLogin. See [Assigning apps to users](https://onelogin.service-now.com/kb_view_customer.do?sysparm_article=KB0010387).
15. Return to the Astro UI. In the configuration screen for your SAML connection, configure the following values:
* **Identity Provider Single Sign-on URL**: Enter the value you copied from **SAML 2.0 Endpoint (HTTP)**.
* **X.509 Certificate**: Enter the **X.509 Certificate** that you downloaded.
16. Click **Create**. Your OneLogin integration appears as an entry in **SSO Configuration**.
17. In **SSO Configuration**, click **Activate**. You are redirected to OneLogin to test your configuration. After you have successfully authenticated, you are redirected to Astro. Then, click **Activate SSO**.
Don't share your single sign-on (SSO) bypass link. With an SSO bypass link, anyone with an email and a password can sign in to Astro. Astronomer recommends periodically regenerating the link from the **Settings** tab in the Astro UI.
An SSO bypass link allows you to authenticate to your Organization without using SSO. This link should be used to access your Organization only when you can't access Astro due to an issue with your identity provider.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. In the **Advanced Settings** section, click **Edit Settings**, turn on **SSO Bypass Link**, then click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
To remove the bypass link, turn off **SSO Bypass Link**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Bypass Link** field, click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
If you don't want to maintain an SSO bypass link, click **Delete**. You can always regenerate a link if you need one in the future.
1. In the OneLogin administrator dashboard, click **Applications** > **Applications** and then click **Astro**.
2. Click **Users** in the left menu.
3. Make sure that all users who need to use Astro are assigned to the Astronomer application.
This section provides setup steps for setting up Ping Identity as your IdP on Astro. After completing this setup, your organization's users can use Ping Identity to sign in to Astro.
#### Prerequisites (Ping Identity)
* A [Ping Identity account](https://www.pingidentity.com/) with administrative access.
* [Organization Owner](/docs/astro/user-permissions) privileges in the Organization you're configuring.
* At least one [verified domain](/docs/astro/manage-domains).
#### Configure Ping Identity as your identity provider
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Click **+ New SSO Configuration**.
3. Configure the following values for your connection:
* **Connection type**: Select **SAML**.
* **Verified Domains**: Enter the verified domain(s) that you want to map to Ping Identity.
* **Automatic Membership**: Set the default role for users who join your Organization through Ping Identity without an explicit invite from Astro.
4. Copy the **Single Sign-On URL** and **Audience URI (SP ENTITY ID)** for use later in this procedure.
5. Open a new tab and go to PingIdentity. In the PingIdentity Administrator Console, click **Connections** in the left pane, and then click the **+** icon next to **Applications**.
6. In the **Application Name** field, enter `Astro`. Optionally, add a description and an icon.
7. Click **SAML Application**, and then click **Configure**.
8. Click **Manually Enter** and then complete the following fields:
* **ACS URLs**: ``
* **Entity ID**: ``
9. Click **Save**.
10. Click **Edit** on the **Overview** page, and then enter `` in the **Sign on URL** field. Then, click **Save**.
11. Click the **Configuration** tab, and then click **Edit**.
12. Select **Sign Assertion & Response** and confirm `RSA_SHA256` is selected in the **Signing Algorithm** list. Then, click **Save**.
13. On the **Configuration** page, click **Download Signing Certificate** and select `X509 PEM (.crt)` to download the X.509 certificate for your application.
14. Copy and save the URL in the **Single Sign-on Service** field.
15. Click the **Attribute Mappings** tab, click **Edit**, and add the following attributes, using the capitalization shown in both columns:
| Astronomer | PingOne |
| -------------- | ------------- |
| `saml_subject` | User ID |
| email | Email Address |
| firstName | Given Name |
| lastName | Family Name |
| name | Formatted |
16. Click **Save**.
17. (Optional) If you configured your application on a PingFederate server, enable the **Include the certificate in the signature `` element** setting for your server. See [Ping documentation](https://docs.pingidentity.com/pingfederate/latest/administrators_reference_guide/pf_certificate_key_management.html).
18. Click the toggle in the top right to enable the application.
19. Assign yourself to Astro from Ping Identity. See [Editing a user](https://docs.pingidentity.com/pingone/directory/p1_edituser.html).
20. Return to the Astro UI. In the configuration screen for your SAML connection, configure the following values:
* **Identity Provider Single Sign-on URL**: Enter the value you copied from the **Single Sign-on Service** field.
* **X.509 Certificate**: Enter the X.509 Certificate that you downloaded.
21. Click **Create**. Your Ping Identity integration appears as an entry in **SSO Configuration**.
22. In **SSO Configuration**, click **Activate**. You are redirected to Ping Identity to test your configuration. After you have successfully authenticated, you are redirected to Astro.
23. Click **Activate SSO**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click **Configure SSO**.
3. Configure the following values for your connection:
* **Connection type**: Select **SAML**.
* **SSO Domain(s)**: Enter the verified domain(s) that you want to map to Ping Identity.
* **Automatic Membership**: Set the default role for users who join your Organization through Ping Identity without an explicit invite from Astro.
4. Copy the **Single Sign-On URL** and **Audience URI (SP ENTITY ID)** for use later in this procedure.
5. Open a new tab and go to PingIdentity. In the PingIdentity Administrator Console, click **Connections** in the left pane, and then click the **+** icon next to **Applications**.
6. In the **Application Name** field, enter `Astro`. Optionally, add a description and an icon.
7. Click **SAML Application**, and then click **Configure**.
8. Click **Manually Enter** and then complete the following fields:
* **ACS URLs**: ``
* **Entity ID**: ``
9. Click **Save**.
10. Click **Edit** on the **Overview** page, and then enter `` in the **Sign on URL** field. Then, click **Save**.
11. Click the **Configuration** tab, and then click **Edit**.
12. Select **Sign Assertion & Response** and confirm `RSA_SHA256` is selected in the **Signing Algorithm** list. Then, click **Save**.
13. On the **Configuration** page, click **Download Signing Certificate** and select `X509 PEM (.crt)` to download the X.509 certificate for your application.
14. Copy and save the URL in the **Single Sign-on Service** field.
15. Click the **Attribute Mappings** tab, click **Edit**, and add the following attributes, using the capitalization shown in both columns:
| Astronomer | PingOne |
| -------------- | ------------- |
| `saml_subject` | User ID |
| email | Email Address |
| firstName | Given Name |
| lastName | Family Name |
| name | Formatted |
16. Click **Save**.
17. (Optional) If you configured your application on a PingFederate server, enable the **Include the certificate in the signature `` element** setting for your server. See [Ping documentation](https://docs.pingidentity.com/pingfederate/latest/administrators_reference_guide/pf_certificate_key_management.html).
18. Click the toggle in the top right to enable the application.
19. Assign yourself to Astro from Ping Identity. See [Editing a user](https://docs.pingidentity.com/pingone/directory/p1_edituser.html).
20. Return to the Astro UI. In the configuration screen for your SAML connection, configure the following values:
* **Identity Provider Single Sign-on URL**: Enter the value you copied from the **Single Sign-on Service** field.
* **X.509 Certificate**: Enter the X.509 Certificate that you downloaded.
21. Click **Create**. Your Ping Identity integration appears as an entry in **SSO Configuration**.
22. In **SSO Configuration**, click **Activate**. You are redirected to Ping Identity to test your configuration. After you have successfully authenticated, you are redirected to Astro.
23. Click **Activate SSO**.
Don't share your single sign-on (SSO) bypass link. With an SSO bypass link, anyone with an email and a password can sign in to Astro. Astronomer recommends periodically regenerating the link from the **Settings** tab in the Astro UI.
An SSO bypass link allows you to authenticate to your Organization without using SSO. This link should be used to access your Organization only when you can't access Astro due to an issue with your identity provider.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. In the **Advanced Settings** section, click **Edit Settings**, turn on **SSO Bypass Link**, then click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
To remove the bypass link, turn off **SSO Bypass Link**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Bypass Link** field, click **Copy**. Save this link for when you need to sign in to Astro without using SSO.
If you don't want to maintain an SSO bypass link, click **Delete**. You can always regenerate a link if you need one in the future.
Assign users from your organization to your new application. See [Managing user groups](https://docs.pingidentity.com/pingone/directory/p1_managing_groups.html).
When a user assigned to the application accesses Astro, they are automatically signed in to Ping Identity after entering their email in the Astro UI.
## SSO enforcement
This is feature is only available if you are on the **Business** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
Configuring an SSO connection lets your users sign in through your IdP, but doesn't require them to. By default, users in your verified domains can still sign in with basic authentication, Google, or GitHub. To require them to sign in through your IdP, enforce SSO.
Enforcement:
* Limits sign-in to SSO for users in your verified domains.
* Disables basic authentication, Google, and GitHub for those users.
* Is available on Business plans or higher.
Astro doesn't provide native MFA for basic or social logins. To require MFA for all users, enforce SSO on a Business plan or higher and configure MFA in your IdP — for example, with [Okta Adaptive Authentication](https://www.okta.com/identity-101/adaptive-authentication/) or [Microsoft Conditional Access](https://learn.microsoft.com/en-us/azure/active-directory/conditional-access/overview).
To enforce SSO:
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. In the **Advanced Settings** section, click **Edit Settings**, then select **Allow only Single Sign-On (SSO)** from the **Login Method** list.
You can also restrict sign-in to only Google or only GitHub from the same list.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **Advanced Settings** menu, select **Allow only Single Sign-On (SSO)** from the **Login Methods** list.
You can also restrict sign-in to only Google or only GitHub from the same list.
## Reconfigure SSO to a new identity provider
If your organization needs to switch from one SSO identity provider to another, you can remove the existing SSO connection and configure a new one. This process requires a brief period of downtime during which users can't sign in through the old IdP.
After you delete the old SSO connection, users can't sign in using the old IdP. Schedule this change during a maintenance window to minimize disruption.
### Prerequisites
* [Organization Owner](/docs/astro/user-permissions) permissions in the Organization you're reconfiguring.
* A new IdP account with administrative access.
* At least one [verified domain](/docs/astro/manage-domains).
### Switch to your new identity provider
Before you remove the old SSO connection, complete the initial registration step for your new IdP. This ensures that your new IdP is ready to connect to Astro as soon as the old SSO connection is removed.
Follow the instructions in the relevant tab under [Configure your SSO identity provider](#configure-your-sso-identity-provider) and complete only the first step for your new IdP. For example, if you're switching to Microsoft Entra ID, complete the **Register Astro as an application on Azure** step.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Delete the SSO connection.
3. Confirm the deletion.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click **Delete SSO Connection**.
3. Confirm the deletion.
After you delete the old connection, users can only sign in through an SSO bypass link or other enabled authentication methods until you activate the new SSO connection.
Return to the instructions for your new IdP under [Configure your SSO identity provider](#configure-your-sso-identity-provider) and complete the remaining steps, starting from the step where you configure SSO on Astro.
## Advanced setup
### Configure just-in-time provisioning
Astro supports just-in-time provisioning by default for all single sign-on (SSO) integrations. This means that if someone without an Astro account tries logging into Astro with an email address from a domain that you manage, they are automatically granted a default role in your Organization without needing an invite. Users with emails outside of this domain need to be invited to your Organization to access it.
To enable or disable just-in-time provisioning:
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Edit your SSO connection.
3. In **Automatic Membership**, select the default Organization role for users who sign in to Astro for the first time through your identity provider. To disable just-in-time provisioning, select **Disabled**.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **SSO Configuration** menu, click the pencil icon to edit your SSO connection.
3. In **Automatic Membership**, select the default Organization role for users who sign in to Astro for the first time through your identity provider. To disable just-in-time provisioning, select **Disabled**.
### Regenerate an SSO bypass link
Regenerating your SSO bypass link voids your existing SSO bypass link so that any former users with the existing link can't sign in to Astro.
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**, then in the **Advanced Settings** section, click **Edit Settings**.
2. Click **Regenerate** to create a new bypass link and void the old one.
1. In the Astro UI, click the **Settings** tab.
2. Click **Regenerate** to create a new bypass link and void the old one.
# Configure worker queues
Source: https://astronomer.io/docs/astro/configure-worker-queues
Learn how to create and configure worker queues to create best-fit execution environments for your tasks.
By default, all tasks using the Astro or Celery executor run in a `default` worker queue. You can create additional worker queues to enable multiple worker types or configurations for different groups of tasks, and assign tasks to these queues in your Dag code. For more information about Airflow executors on Astro, see [Manage Airflow executors on Astro](/docs/astro/executors-overview).
Use worker queues to create optimized execution environments for different types of tasks in the same Deployment. You can use worker queues to:
* Separate resource-intensive tasks, such as those that execute machine learning models, from tasks that require minimal resources, such as those that execute SQL queries.
* Separate short-running tasks from long-running tasks.
* Isolate a single task from other tasks in your Deployment.
* Allow some workers to scale to zero but keep a minimum of 1 for other types of workers.
## Benefits
Worker queues can enhance performance, decrease cost, and increase the reliability of task execution in your Deployment. Specifically:
* Executing a task with dedicated hardware that best fits the needs of that task can result in faster performance. In some cases, this can decrease the duration of a Dag by up to 50%.
* Paying for larger workers only for select tasks means that you can lower your infrastructure cost by not paying for that worker when your tasks don't need it.
* Separating tasks that have different characteristics often means they're less likely to result in a failed or zombie state.
## Example
By configuring multiple worker queues and assigning tasks to these queues based on the requirements of the tasks, you can enhance the performance, reliability, and throughput of your Deployment. For example, consider the following scenario:
* You are running Task A and Task B in a Deployment.
* Task A and Task B are dependent on each other, so they need to run in the same Deployment.
* Task A is a long-running task that uses a lot of CPU and memory, while Task B is a short-running task that uses minimal amounts of CPU and memory.
You can assign Task A to a worker queue that is configured to use the A20 worker type, which is optimized for running compute-heavy tasks. Then, you can assign Task B to a worker queue that is configured to use the A5 worker type, which is smaller and optimized for general usage.
## Default worker queue
Each Deployment requires a worker queue named `default` to run tasks. Tasks that aren't assigned to a worker queue in your Dag code are executed by workers in the `default` worker queue.
You can change all settings of the default worker queue except for its name.
## Worker queue settings
You can configure each worker queue on Astro with the following settings:
* **Name:** The name of your worker queue. Use this name to assign tasks to the worker queue in your Dag code. Worker queue names must consist only of lowercase letters and hyphens. For example, `machine-learning-tasks` or `short-running-tasks` or `high-cpu`.
* **Concurrency:** The maximum number of tasks that a single worker can run at a time. If the number of queued and running tasks exceeds this number, a new worker is added to run the remaining tasks. This value is equivalent to [worker concurrency](https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#worker-concurrency) in Apache Airflow. The default for your worker type is suitable for most use cases.
* **Min # Workers / Max # Workers**: The minimum and maximum number of workers that can run at a time. The number of workers autoscales based on **Concurrency** and the current number of tasks in a `queued` or `running` state.
* **Worker Type:** The size of workers in the worker queue, for example A5 or A20. A worker's total available CPU, memory, and storage is defined by its worker size. For more information, see the following section on worker types.
### Hosted Deployment worker types
Each Deployment worker queue has a *worker type* that determines how many resources are available to your Airflow workers for running tasks. A worker type is a virtualized instance of CPU and memory on your cluster that is specific to the Astro platform. The underlying node instance type running your worker can vary based on how Astro optimizes resource usage on your cluster.
Each virtualized instance of your worker type is a *worker*. Astro and Celery workers can run multiple tasks at once, while Kubernetes workers only scale up and down to run a single task at a time.
The following table lists all available worker types on Astro Deployments.
| Worker Type | vCPU | Memory | Ephemeral storage | Default task concurrency | Max task concurrency |
| ----------- | ---- | ------ | ----------------- | ------------------------ | -------------------- |
| A5 | 1 | 2GiB | 10 GiB | 5 | 15 |
| A10 | 2 | 4GiB | 10 GiB | 10 | 30 |
| A20 | 4 | 8GiB | 10 GiB | 20 | 60 |
| A40 | 8 | 16GiB | 10 GiB | 40 | 120 |
| A60 | 12 | 24GiB | 10 GiB | 60 | 180 |
| A120 | 24 | 48GiB | 10 GiB | 120 | 360 |
| A160 | 32 | 64GiB | 10 GiB | 160 | 480 |
All worker types additionally have 10 GiB of ephemeral storage that your tasks can use when storing small amounts of data within the worker.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a worker queue
**CLI**
If you prefer, you can also run the `astro deployment worker-queue create` command in the Astro CLI to create a worker queue. See the [CLI Command Reference](/docs/cli/v1.43/astro-deployment-worker-queue-create).
1. In the Astro UI, click **Deployments**.
2. Click the **More actions** menu (⋯) on the Deployment you want to edit, then click **Edit Deployment**.
3. In the **Execution** section, click **+ Add Queue** to create a new worker queue, and then configure its related attributes. Note that you can't change the name of a worker queue after you create it.
4. When you're done creating your worker queue, click **Update Deployment** to save your changes.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Options** menu of the Deployment you want to update, and select **Edit Deployment**.
3. In the **Execution** section, click **Add Queue** to create a new worker queue, and then configure its related attributes. Note that you can't change the name of a worker queue after you create it.
4. When you're done creating your worker queue, click **Update Deployment** to save your changes.
You can create, update, and delete multiple worker queues at once using a Deployment file. See [Deployments as Code](/docs/astro/manage-deployments-as-code).
## Assign tasks to a worker queue
By default, all tasks run in the default worker queue. To run tasks on a different worker queue, assign the task to the worker queue in your Dag code.
### Step 1: Copy the name of the worker queue
1. In the Astro UI, click **Deployments**, then click the Deployment you want to use.
2. Click the **Details** tab. Under **Execution**, the worker queues are listed.
3. Copy the name of the worker queue you want to assign a task to.
1. In the Astro UI, select a Workspace and select a Deployment.
2. Click the **Details** tab.
3. From the **Execution** section, copy the name of the worker queue you want to assign a task to.
### Step 2: Assign the task in your Dag code
In your Dag code, add a `queue=''` argument to the definition of the task. If a task is assigned to a queue that doesn't exist or isn't referenced properly, the task might remain in a `queued` state and fail to execute. Make sure that the name of the queue in your Dag code matches the name of the queue in the Astro UI.
Astronomer recommends using Apache Airflow's [Taskflow API](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/taskflow.html) to define your task argument. The Taskflow API is feature in Airflow 2 that includes a task [decorator](/docs/learn/airflow-decorators) and makes Dags easier to write. In the following examples, all instances of the task will run in the `machine-learning-tasks` queue. Choose an example based on whether or not you use the Taskflow API.
```python wrap theme={null}
train_model = PythonOperator(
task_id="train_model",
python_callable=train_model_flights,
queue="machine-learning-tasks",
)
```
```python wrap theme={null}
@task(task_id="train_model", queue="machine-learning-tasks")
def train_model_flights(x_train, y_train):
import xgboost
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
xgbclf = xgboost.XGBClassifier()
pipe = Pipeline([
("scaler", StandardScaler(with_mean=False)),
("xgbclf", xgbclf),
])
pipe.fit(x_train, y_train)
return pipe
```
## Update a worker queue
**CLI**
If you prefer, you can run the `astro deployment worker-queue update` command in the Astro CLI to update a worker queue. See the [CLI Command Reference](/docs/cli/v1.43/astro-deployment-worker-queue-update).
You can update worker queue configurations at any time. The worker queue name can't be changed.
If you need to change the worker type of an existing worker queue, Astronomer recommends making the change at a time when it won't affect production pipelines. After you've changed a worker type, Astronomer recommends waiting a minimum of five minutes before pushing new code to your Deployment.
1. In the Astro UI, click **Deployments**.
2. Click the **More actions** menu (⋯) on the Deployment you want to edit, then click **Edit Deployment**.
3. Expand the **Execution** section if it isn't already expanded.
4. Update the worker queue settings, and then click **Update Deployment**.
The Airflow components of your Deployment automatically restart to apply the updated resource allocations. This action is equivalent to deploying code to your Deployment and doesn't impact running tasks that have 24 hours to complete before running workers are terminated. See [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Options** menu of the Deployment you want to update, and select **Edit Deployment**.
3. Expand the **Execution** section if it isn't already expanded.
4. Update the worker queue settings, and then click **Update Deployment**.
The Airflow components of your Deployment automatically restart to apply the updated resource allocations. This action is equivalent to deploying code to your Deployment and doesn't impact running tasks that have 24 hours to complete before running workers are terminated. See [What happens during a code deploy](/docs/astro/deploy-project-image#what-happens-during-a-project-deploy).
**Update Airflow Pool**
If you see tasks getting stuck, it might be because the worker queue configuration doesn't align with the Airflow Pools, a component that allows you to control execution parallelism. Make sure to update your Airflow Pools to match the changes in potential maximum task parallelism caused by changes to the worker queue.
For more information on limited parallelism, see [Airflow Pools](/docs/learn/airflow-pools).
## Delete a worker queue
**CLI**
If you prefer, you can also run the `astro deployment worker-queue delete` command in the Astro CLI to delete a worker queue. See the [CLI Command Reference](/docs/cli/v1.43/astro-deployment-worker-queue-delete).
All scheduled tasks that are assigned to a worker queue after the worker queue is deleted remain in a `queued` state indefinitely and won't execute. To avoid stalled task runs, ensure that you reassign all tasks from a worker queue before deleting it. You can either remove the worker queue argument or assign the task to a different queue.
1. In the Astro UI, click **Deployments**.
2. Click the **More actions** menu (⋯) on the Deployment you want to edit, then click **Edit Deployment**.
3. Expand the **Execution** section if it isn't already expanded.
4. Click the trash can icon next to the worker queue you want to remove, then click **Update Deployment**.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Options** menu of the Deployment you want to update, and select **Edit Deployment**.
3. Expand the **Execution** section if it isn't already expanded.
4. Click **Remove queue** to delete the worker queue, and then click **Update Deployment**.
# Create a network connection between Astro and AWS
Source: https://astronomer.io/docs/astro/connect-aws
Create a network connection to AWS.
You can grant Astro cluster and its Deployments access to your external AWS resources.
Publicly accessible endpoints allow you to quickly connect your Astro clusters or Deployments to AWS through an Airflow connection. If your cloud restricts IP addresses, you can add the external IPs of your Deployment or cluster to an AWS resource's allowlist. See [Connect to a public AWS endpoint](/docs/astro/connect-aws-public)
If you have stricter security requirements, you can create a private connection to AWS in a few different ways. See [Private networking connections](#private-networking-connections) for more information.
After you create a connection from your cluster to AWS, you might also need to individually authorize Deployments to access specific resources. See [Authorize your Deployment using workload identity](/docs/astro/authorize-deployments-to-your-cloud).
## Standard and dedicated cluster support for AWS networking
Standard clusters have different connection options than dedicated clusters.
Standard clusters can connect to AWS in the following ways:
* Using [static external IP addresses](/docs/astro/connect-aws-public#allowlist-a-deployment’s-external-ip-addresses-on-aws)
* Using PrivateLink to connect with the following endpoints:
* [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html) - Gateway Endpoint
* [Amazon Simple Queue Service (SQS)](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-internetwork-traffic-privacy.html#sqs-vpc-endpoints) - Interface Endpoint - [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/vpc-endpoints.html) - Interface Endpoints for ECR API and Docker Registry API
* [Elastic Load Balancing (ELB)](https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/load-balancer-vpc-endpoints.html) - Interface Endpoint
* [AWS Security Token Service (AWS STS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_sts_vpce.html) - Interface Endpoint
### Private networking connections
Dedicated clusters can connect to AWS in the same ways as standard clusters. Additionally, they support a number of private connectivity options including:
* [VPC peering](/docs/astro/connect-aws-vpc-peering)
* [Transit Gateways](/docs/astro/connect-aws-transit-gateways)
* [AWS PrivateLink](/docs/astro/connect-aws-privatelink)
* [VPN](/docs/astro/connect-aws-VPN)
* [Hostname resolution options](/docs/astro/connect-aws-hostname-resolution)
If you require a private connection between Astro and AWS, Astronomer recommends configuring a dedicated cluster. See [Create a dedicated cluster](/docs/astro/create-dedicated-cluster). Transitive connectivity to on-premise networks is also possible through your managed VPCs. However, architectures with a demarcation point between Astro and your on-premise network are not supported.
## See Also
* [Manage Airflow connections and variables](/docs/astro/manage-connections-variables)
* [Authorize your Deployment using workload identity](/docs/astro/authorize-deployments-to-your-cloud)
# AWS Networking: VPN
Source: https://astronomer.io/docs/astro/connect-aws-VPN
Create a VPN connection to AWS.
This connection option is only available for dedicated Astro clusters.
Use this connectivity type to access on-premises resources or resources in other cloud providers.
## Prerequisites
* An Astro Deployment with a dedicated cluster.
* Configured gateway device or application with Public IP address. You need 2 addresses for an HA setup.
Contact your internal network team or engineer and ask for the following information:
* Public IP addresses for the tunnels configuration.
* IKE pre-shared key, if your team wants to use a particular key.
* Preferable settings for phase 1 and phase 2 (BGP only) IKE negotiations.
* ASN for BGP or IP prefixes for static configuration.
* (Optional) A size /30 IPv4 CIDR block from the 169.254.0.0/16 range for the inside tunnel IPv4 addresses.
## Contact Astronomer support for VPN configuration on Astro side
Submit all collected details to [Astronomer support](https://cloud.astronomer.io/open-support-request). The Astronomer CRE team will proceed with the required steps. The CRE team will contact you using your support ticket to ask follow-up questions, request clarification, or let you know about connectivity tests.
# AWS Networking: Hostname resolution options
Source: https://astronomer.io/docs/astro/connect-aws-hostname-resolution
Hostname resolution options for AWS.
Securely connect Astro to resources running in other VPCs or on-premises through a resolving service.
Using Route 53 requires sharing a resolver rule with your Astro account. If this is a security concern, Astronomer recommends using Domain Name System (DNS) forwarding. If you have a small number of records and immutable IP addresses, the Astronomer support team can create a Private zone with DNS records, pointed to your resources.
Use Route 53 Resolver rules to allow Astro to resolve DNS queries for resources running in other VPCs or on-premises.
**Prerequisites**
* An Amazon Route 53 Resolver rule. See [Managing forwarding rules](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-rules-managing.html).
* Permission to share resources using the AWS Resource Access Manager (RAM)
To allow Astro to access a private hosted zone, you need to share your Amazon Route 53 Resolver rule with your Astro AWS account.
1. In the Route 53 Dashboard, click **Rules** below **Resolver** in the navigation menu.
2. Select a Resolver rule and then click **Details**.
3. Click **Share** and enter `Astro` in the **Name** field.
4. In the **Resources - optional** section, select **Resolver Rules** in the **Select resource type** list and then select one or more rules.
5. On the **Associate permissions** page, accept the default settings and then click **Next**.
6. On the **Grant access to principals** page, select **Allow sharing only within your organization**, and then enter your Astro AWS account ID for your organization in the **Enter an AWS account ID** field.
To get the Astro AWS account ID, In the Astro UI, click **Organization Settings**. From the **General** page, copy the **AWS External ID**.
7. Click **Create resource share**.
To verify that the Amazon Route 53 Resolver rule was shared correctly, submit a request to [Astronomer support](https://cloud.astronomer.io/open-support-request). With your request, include the Amazon Route 53 Resolver rule ID. To locate the Resolver rule ID, open the Route 53 Dashboard, and in the left menu click **Rules** below **Resolver**. Copy the value in the Resolver **ID** column.
Use Domain Name System (DNS) forwarding to allow Astro to resolve DNS queries for resources running in other VPCs or on-premises. Unlike Route 53, you don't need to share sensitive configuration data with your Astro account. To learn more about DNS forwarding, see [Forwarding outbound DNS queries to your network](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-forwarding-outbound-queries.html).
To use this solution, make sure Astro can connect to the DNS server using a VPC peering or transit gateway connection and then submit a request to [Astronomer support](https://cloud.astronomer.io/open-support-request). With your request, include the following information:
* The domain name for forwarding requests
* The IP address of the DNS server where requests are forwarded
Astronomer support can create Private hosted zones for reflecting particular DNS records in your environment without any changes or additional configurations. Private zones work well when the number of zones and records is small and stable. Otherwise, name resolution accuracy and connectivity in general can be affected.
To use this solution, submit a request to [Astronomer support](https://cloud.astronomer.io/open-support-request). With your request, include the following information:
* List of DNS records for the Private zone
* IP addresses that have to be assigned to each DNS record
### (Optional) Create an Airflow connection to confirm connectivity
After Astronomer support confirms that DNS forwarding was successfully set up, you can confirm that it works by creating an Airflow connection to a resource running in a VPC or on-premises. See [Managing Connections](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html).
# AWS Networking: AWS PrivateLink
Source: https://astronomer.io/docs/astro/connect-aws-privatelink
Create a PrivateLink connection to AWS.
On Astro standard clusters, only the following AWS PrivateLink endpoints are supported:
* [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html) - Gateway Endpoint
* [Amazon Elastic Compute Cloud (Amazon EC2) Autoscaling](https://docs.aws.amazon.com/general/latest/gr/as.html) - Interface Endpoint
* [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/vpc-endpoints.html) - Interface Endpoints for ECR API and Docker Registry API
* [Elastic Load Balancing (ELB)](https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/load-balancer-vpc-endpoints.html) - Interface Endpoint
* [AWS Security Token Service (AWS STS)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_sts_vpce.html) - Interface Endpoint
Astro automatically supports cross-region connectivity for dedicated clusters that use AWS PrivateLink connections. Standard cross-region data transfer charges apply.
Use AWS PrivateLink to create private connections from Astro to your AWS services without exposing your data to the public internet.
All Astro clusters are pre-configured with the following AWS PrivateLink endpoints:
* Amazon S3 - Gateway Endpoint
* Amazon Elastic Compute Cloud (Amazon EC2) Autoscaling - Interface Endpoint
* Amazon Elastic Container Registry (ECR) - Interface Endpoints for ECR API and Docker Registry API
* Elastic Load Balancing (ELB) - Interface Endpoint
* AWS Security Token Service (AWS STS) - Interface Endpoint
To enable PrivateLink connectivity between the Astronomer VPC and your VPC, you must open a support ticket with [Astronomer support](https://cloud.astronomer.io/open-support-request). PrivateLink isn't self-service.
To request additional endpoints, or assistance connecting to other AWS services, complete the following steps:
* Prepare a list of your AWS Services that require Endpoints, such as SQS, Lambda, or DynamoDB.
* Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) and provide this information for next steps.
By default, Astronomer support activates the **Enable DNS Name** option on supported AWS PrivateLink endpoint services. With this option enabled, you can make requests to the default public DNS service name instead of the public DNS name that is automatically generated by the VPC endpoint service. For example, `*.notebook.us-east-1.sagemaker.aws` instead of `vpce-xxx.notebook.us-east-1.vpce.sagemaker.aws`. For more information about AWS DNS hostnames, see [DNS hostnames](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#:~:text=recursive%20DNS%20queries.-,DNS%20hostnames,-When%20you%20launch).
* To retrieve your cluster's AWS account ID on Astro, contact [Astronomer support](https://cloud.astronomer.io/open-support-request).
* Go to your VPCe Service configuration and add `arn:aws:iam:::role/astronomer-remote-management` into a list of the Allowed principals.
* Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) and provide a VPCe Service name for the custom Service.
* (Optional) If Route53 alias is required for the proper connectivity by your service such as Snowflake or EKS, add a preferable DNS name for the Endpoint to your request. Otherwise, you can skip this step.
You'll incur additional AWS infrastructure costs for every AWS PrivateLink endpoint service that you use. See [AWS PrivateLink pricing](https://aws.amazon.com/privatelink/pricing/).
# Connect to a public AWS Endpoint
Source: https://astronomer.io/docs/astro/connect-aws-public
Create a network connection to a public AWS endpoint.
All Astro clusters include a set of external IP addresses that persist for the lifetime of the cluster. When you create a Deployment in your workspace, Astro assigns the external IP addresses to it. To facilitate communication between Astro and your cloud, you can allowlist these external IPs in your cloud. If you have no other security restrictions, this means that any cluster with an allowlisted external IP address can access your AWS resources through a valid Airflow connection.
## Allowlist a Deployment's external IP addresses on AWS
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Select the **Details** tab.
3. In the **Other** section, you can find the **External IPs** associated with the Deployment.
Add the IP addresses to the allowlist of any external services that you want your Deployment to access.
When you use publicly accessible endpoints to connect to AWS, traffic moves directly between your Astro cluster and the AWS API endpoint. Data in this traffic never reaches the Astronomer managed control plane. Note that you still might also need to authorize your Deployment to some resources before it can access them. For example, you can [Authorize deployments to your cloud with workload identity](/docs/astro/authorize-deployments-to-your-cloud) so that you can avoid adding passwords or other access credentials to your Airflow connections.
If you use Dedicated clusters and want to allowlist external IP addresses at the cluster level instead of at the Deployment level, you can find the list of cluster-level external IP addresses in the **Clusters** page of the Astro UI.
1. In the **Organization** section of the Astro UI, click **Organization Settings**, then click **Clusters**, then select a cluster.
2. In the Details page, copy the IP addresses listed under **External IPs**.
Add the IP addresses to the allowlist of any external services that you want your cluster to access. You can also access these IP addresses from the **Details** page of any Deployment in the cluster.
After you allowlist a cluster's IP addresses, all Deployments in that cluster have network connectivity to AWS.
# AWS Networking: Transit Gateways
Source: https://astronomer.io/docs/astro/connect-aws-transit-gateways
Create a Transit Gateway connection to AWS.
This connection option is only available for dedicated Astro clusters.
Use AWS Transit Gateway to connect one or more Astro clusters to other VPCs, AWS accounts, and on-premises networks supported by your organization.
AWS Transit Gateway is an alternative to VPC Peering on AWS. Instead of having to establish a direct connection between two VPCs, you can attach over 5,000 networks to a central transit gateway that has a single VPN connection to your corporate network.
While it can be more costly, AWS Transit Gateway requires less configuration and is often recommended for organizations connecting a larger number of VPCs. For more information, see [AWS Transit Gateway](https://aws.amazon.com/transit-gateway/).
AWS Transit Gateway doesn't provide built-in support for DNS resolution. If you need DNS integration, Astronomer recommends that you use the Route 53 Resolver service. For assistance integrating the Route 53 Resolver service with your Astronomer VPC, contact [Astronomer support](https://cloud.astronomer.io/open-support-request).
If your transit gateway is in a different region than your Astro cluster, contact [Astronomer support](https://cloud.astronomer.io/open-support-request). Astronomer support can create a new transit gateway in your AWS account for Astro and set up [a cross-region peering attachment](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-peering.html) with your existing transit gateway.
If Astronomer creates a new transit gateway in your AWS account for Astro, keep in mind that your organization will incur additional AWS charges for the new transit gateway as well as the inter-region transfer costs.
## Prerequisites
* A [dedicated Astro cluster](/docs/astro/create-dedicated-cluster). Transit Gateway connections are not available for standard clusters.
* An existing transit gateway in the same region as your Astro cluster.
* Permission to share resources using AWS Resource Access Manager (RAM).
## Setup
1. To retrieve your cluster's AWS account ID on Astro, contact [Astronomer support](https://cloud.astronomer.io/open-support-request).
2. In your AWS console, copy the ID of your existing transit gateway (TGW).
3. [Create a resource share in AWS RAM](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-create.html) and [share the TGW with your cluster's Astro AWS account](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-transit-gateways.html#tgw-sharing).
4. Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) and provide the following information:
* Your Astro cluster **ID**.
* Your TGW ID from Step 2.
* The CIDR block for the external VPC or on-premises network that you want to connect your Astro cluster with.
Astronomer support approves the resource sharing request, attaches the Astro private subnets to your transit gateway, and creates routes in the Astro route tables to your transit gateway for each of the CIDR provided. Astronomer support notifies you about the process completion and provides you with the Astro CIDRs.
5. After you receive the confirmation from Astronomer support, use the Astro CIDRs to [create back routes](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-peering.html#tgw-peering-add-route) from your transit gateway to the Astro VPC.
6. Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) to confirm that you have created the static route. Astronomer support then tests the connection and confirm.
7. (Optional) Repeat the steps for each Astro cluster that you want to connect to your transit gateway.
# AWS Networking: VPC Peering
Source: https://astronomer.io/docs/astro/connect-aws-vpc-peering
Create a VPC peering network connection to AWS.
Choose one of the following setups based on the security requirements of your company and your existing infrastructure.
This connection option is only available for dedicated Astro clusters.
### Prerequisites
* An external VPC on AWS
* A CIDR block for your external VPC in the RFC 1918 range
* [Organization Owner](/docs/astro/user-permissions#organization-roles) permissions
### Setup
To set up a private connection between an Astro VPC and an AWS VPC, you can create a VPC peering connection. VPC peering ensures private and secure connectivity, reduces network transit costs, and simplifies network layouts.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
1. Open the AWS console of the AWS account with the external VPC and copy the following:
* AWS account ID
* AWS region
* VPC ID of the external VPC
* CIDR block of the external VPC
2. In the Astro UI, go to **Settings** > **Clusters**, select your cluster, click **VPC Peering Connections**, then click **+ New VPC Peering Connection**.
3. Configure the following values for your VPC peering connection using the information you copied in Step 1:
* **Peering Name**: Provide a name for the VPC peering connection.
* **AWS account ID**: Enter the account ID of the external VPC.
* **Destination VPC ID**: Enter the VPC ID.
* **Destination VPC region**: Enter the region of the external VPC.
* **Destination VPC CIDR block**: Enter the CIDR block of the external VPC.
4. Click **Create Connection**. The connection appears as **Pending**.
5. Wait a few minutes for the **Complete Activation** button to appear, then click **Complete Activation**.
6. In the modal that appears, follow the instructions to accept the connection from your external VPC and create routes from the external VPC to Astro.
1. Open the AWS console of the AWS account with the external VPC and copy the following:
* AWS account ID
* AWS region
* VPC ID of the external VPC
* CIDR block of the external VPC
2. In the Astro UI, click **Organization Settings**, then click **Clusters**, select your cluster, click **VPC Peering Connections**, then click **+ VPC Peering Connection**.
3. Configure the following values for your VPC peering connection using the information you copied in Step 1:
* **Peering Name**: Provide a name for the VPC peering connection.
* **AWS account ID**: Enter the account ID of the external VPC.
* **Destination VPC ID**: Enter the VPC ID.
* **Destination VPC region**: Enter the region of the external VPC.
* **Destination VPC CIDR block**: Enter the CIDR block of the external VPC.
4. Click **Create Connection**. The connection appears as **Pending**.
5. Wait a few minutes for the **Complete Activation** button to appear, then click **Complete Activation**.
6. In the modal that appears, follow the instructions to accept the connection from your external VPC and create routes from the external VPC to Astro.
A few minutes after you complete the instructions in the modal, the connection status changes from **Pending** to **Active**. A new default route appears in **Routes** with your configured CIDR block.
**Troubleshooting VPC connection statuses**
Astro might show additional information in your connection status if it has an issue when it creates the connection. The following are all possible connection statuses.
* **Pending** (Without **Complete Activation**): Astro is sending the peering request to the external VPC. Wait 1-2 minutes for request to be created and sent.
* **Pending** (With **Complete Activation**): The peering connection request has been created and sent. Click **Complete Activation** to finish the setup.
* **Active**: The peering connection was successfully created and accepted.
* **Failed**: The peering connection request was rejected. Delete the failed connection and retry using a new connection configuration. If you don't delete the failed connection, Astro will retry creating the peering request whenever you create a new VPC connection.
* **Not Found**: Astro failed to create the peering request. Wait 5 minutes for Astro to retry. If the status hasn't changed after 5 minutes, delete the connection and retry using a new connection configuration.
Note that a VPC connection can be listed as **Active** even when it has an incorrectly configured CIDR block. To reconfigure your CIDR block without deleting your connection, delete the route that was generated when you configured the connection and create a new route with the correct CIDR block.
### Configure additional routes for a VPC connection
Your initial VPC connection connects Astro to your external VPC through a primary CIDR block. To connect Astro to other data services or systems within the external VPC, you can create additional routes to secondary CIDR blocks or subnets within the primary CIDR block. You can also complete this setup if you recently configured a new service in your external VPC and want to connect it with Astro without updating your base VPC connection.
1. Open the **Routes** tab, then click **+ New Route**.
2. Configure the following details for your route:
* **Route ID**: Provide a name for the route.
* **Destination**: Enter the subnet of the service in the external VPC.
* **Target**: Select the VPC peering connection you configured.
3. Click **Create Route**, then wait a few minutes for the route to be created.
1. Open the **Routes** tab, then click **+ Route**.
2. Configure the following details for your route:
* **Route ID**: Provide a name for the route.
* **Destination**: Enter the subnet of the service in the external VPC.
* **Target**: Select the VPC peering connection you configured.
3. Click **Create Route**, then wait a few minutes for the route to be created.
#### DNS considerations for VPC peering
If your external VPC resolves DNS hostnames using **DNS Hostnames** and **DNS Resolution**, you must also enable the **Accepter DNS Resolution** setting on AWS. This allows Astro clusters and Deployments to resolve the public DNS hostnames of the external VPC to its private IP addresses. To configure this option, see [AWS Documentation](https://docs.aws.amazon.com/vpc/latest/peering/modify-peering-connections.html).
If your external VPC resolves DNS hostnames using [private hosted zones](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html), then you must associate your Route53 private hosted zone with the Astro VPC using instructions provided in [AWS Documentation](https://aws.amazon.com/premiumsupport/knowledge-center/route53-private-hosted-zone/).
To retrieve the ID of any Astro VPC, contact [Astronomer support](https://cloud.astronomer.io/open-support-request). If you have more than one Astro cluster, request the VPC ID of each cluster.
# Create a network connection between Astro and Azure
Source: https://astronomer.io/docs/astro/connect-azure
Create a network connection to Microsoft Azure.
Use this document to learn how you can grant an Astro cluster and its Deployments access to your external Azure resources.
Publicly accessible endpoints allow you to quickly connect your Astro clusters or Deployments to Azure through an Airflow connection. See [Create a connection to a public Azure endpoint](/docs/astro/connect-azure-public). If your cloud restricts IP addresses, you can add the external IPs of your Deployment or cluster to an Azure resource's allowlist.
If you have stricter security requirements, you can [create a private connection](#create-a-private-connection-between-astro-and-azure) to Azure in a few different ways.
After you create a connection from your cluster to Azure, you might also need to individually authorize Deployments to access specific resources. See [Authorize your Deployment using workload identity](/docs/astro/authorize-deployments-to-your-cloud).
## Standard and dedicated cluster support for Azure networking
Standard clusters have different connection options than dedicated clusters.
Standard clusters can connect to Azure in the following ways:
* Using [static external IP addresses](/docs/astro/connect-azure-public#allowlist-a-deployment’s-external-ip-addresses-on-azure).
### Create a private connection between Astro and Azure
Dedicated clusters can also connect to Azure using static IP addresses. Additionally, they support a number of private connectivity options including:
* [VNet peering](/docs/astro/connect-azure-vnet-peering)
* [VHub peering](/docs/astro/connect-azure-vhub-peering)
* [VPN](/docs/astro/connect-azure-vpn)
* [Azure Private Link](/docs/astro/connect-azure-private-link)
* [Hostname resolution options](/docs/astro/connect-azure-hostname-resolution)
If you require a private connection between Astro and Azure, Astronomer recommends configuring a dedicated cluster. See [Create a dedicated cluster](/docs/astro/create-dedicated-cluster).
## See Also
* [Manage Airflow connections and variables](/docs/astro/manage-connections-variables)
# Azure Networking: Hostname resolution options
Source: https://astronomer.io/docs/astro/connect-azure-hostname-resolution
Hostname resolution options for Azure.
Securely connect Astro to resources running in other VNets or on-premises through a resolving service.
Astronomer recommends using Domain Name System (DNS) forwarding as the most flexible and reliable solution. If you have a small number of records and immutable IP addresses, the Astronomer support team can create a Private zone with DNS records, pointed to your resources.
Use Domain Name System (DNS) forwarding to allow Astro to resolve DNS queries for resources running in other VPCs or on-premises. You have access to internal resources through private names. All changes in zone will be available for Astro environment immediately.
To use this solution, make sure Astro can connect to the DNS server using a VNet or VHub peering connection and then submit a request to [Astronomer support](https://cloud.astronomer.io/open-support-request). With your request, include the following information:
* The domain name for forwarding requests
* The IP address of the DNS server where requests are forwarded
Astronomer support can create Private hosted zones for reflecting particular DNS records in your environment without any changes or additional configurations. Private zones work well when the number of zones and records is small and stable. Otherwise, name resolution accuracy and connectivity in general can be affected.
To use this solution, submit a request to [Astronomer support](https://cloud.astronomer.io/open-support-request). With your request, include the following information:
* List of DNS records for the Private zone
* IP addresses that have to be assigned respectively
#### (Optional) Create an Airflow connection to confirm connectivity
After Astronomer support confirms that DNS forwarding was successfully set up, you can confirm that it works by creating an Airflow connection to a resource running in a VPC or on-premises. See [Managing Connections](https://airflow.apache.org/docs/apache-airflow/stable/howto/connection.html).
# Azure Networking: Azure PrivateLink
Source: https://astronomer.io/docs/astro/connect-azure-private-link
Create a PrivateLink connection to Azure.
This connection option is only available for dedicated Astro clusters.
Use Azure Private Link to create private connections from Astro to your Azure services without exposing your data to the public internet.
Astro clusters are pre-configured with the Azure blob private endpoint.
To request additional endpoints, or assistance connecting to other Azure services, provide [Astronomer support](https://cloud.astronomer.io/open-support-request) with the following information for the resource you want to connect to using Private Link:
* Resource name
* Resource ID
* [Group ID](https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/private-link/private-endpoint-overview.md#private-link-resource)
For example, to connect with Azure Container Registry:
1. Follow the [Azure documentation](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal?tabs=azure-cli) to create the [container registry](https://portal.azure.com/#create/Microsoft.ContainerRegistry). Copy the name of container registry.
2. Follow the [Azure documentation](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-private-link#create-a-private-endpoint---new-registry) to create a private endpoint for your container registry. Then, copy the name of the **Data endpoint**.
3. Then, from the left panel, go to **Overview** menu, and click on JSON view in **Essentials**, to copy the resource ID. You can also run Azure CLI command `az acr show -n myRegistry` to get the resource ID.
4. Contact [Astronomer Support](https://cloud.astronomer.io/open-support-request) with your request to connect. Provide the resource name, data endpoint name, and resource ID.
5. When Astronomer support adds an Azure private endpoint, corresponding private DNS zone and Canonical Name (CNAME) records are created to allow you to address the service by its private link name. Astronomer support will send the connection request in Azure Portal's [Private Link Center](https://portal.azure.com/#view/Microsoft_Azure_Network/PrivateLinkCenterBlade/~/pendingconnections).
6. Approve the connection requests from your Azure portal, then confirm that you've completed this in your support ticket. Astronomer support will then test whether the DNS resolves the endpoint correctly.
After Astronomer configures the connection, you can create Airflow connections to your resource. In some circumstances, you might need to modify your dags to address the service by its private link name (For example, `StorageAccountA.privatelink.blob.core.windows.net` instead of `StorageAccountA.blob.core.windows.net`).
Note that you'll incur additional Azure infrastructure costs for every Azure private endpoint that you use. See [Azure Private Link pricing](https://azure.microsoft.com/en-us/pricing/details/private-link/).
# Create a connection between Astro and Azure public endpoint
Source: https://astronomer.io/docs/astro/connect-azure-public
Create a network connection to a public endpoint on Microsoft Azure.
All Astro clusters include a set of external IP addresses that persist for the lifetime of the cluster. When you create a Deployment in your workspace, Astro assigns it one of these external IP addresses. To facilitate communication between Astro and your cloud, you can allowlist these external IPs in your cloud. If you have no other security restrictions, this means that any cluster with an allowlisted external IP address can access your Azure resources through a valid Airflow connection.
## Allowlist a Deployment's external IP addresses on Azure
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Select the **Details** tab.
3. In the **Other** section, you can find the **External IPs** associated with the Deployment.
Add the IP addresses to the allowlist of any external services that you want your Deployment to access.
When you use publicly accessible endpoints to connect to Azure, traffic moves directly between your Astro cluster and the Azure API endpoint. Data in this traffic never reaches the Astronomer managed control plane. Note that you still might also need to authorize your Deployment to some resources before it can access them. For example, you can [Authorize deployments to your cloud with workload identity](/docs/astro/authorize-deployments-to-your-cloud) so that you can avoid adding passwords or other access credentials to your Airflow connections.
If you use Dedicated clusters and want to allowlist external IP addresses at the cluster level instead of at the Deployment level, you can find the list of cluster-level external IP addresses in your Organization's **Clusters**.
1. In the **Organization** section of the Astro UI, click **Organization Settings**, then click **Clusters**, then select a cluster.
2. In the Details page, copy the IP addresses listed under **External IPs**.
Add the IP addresses to the allowlist of any external services that you want your cluster to access. You can also access these IP addresses from the **Details** page of any Deployment in the cluster.
After you allowlist a cluster's IP addresses, all Deployments in that cluster have network connectivity to Azure.
# Azure Networking: VHub Peering
Source: https://astronomer.io/docs/astro/connect-azure-vhub-peering
Create a VHub peering network connection to Azure.
This connection option is only available for dedicated Astro clusters.
To set up a private connection between an Astro Virtual Network (VNet) and an Azure VHub, you can create a VHub peering connection. VHub peering ensures private and secure connectivity, reduces network transit costs, and attaches the Astro environment to a centralized managed network.
1. Retrieve the following information from the target Azure environment that you want to connect with:
* Azure Tenant ID and Subscription ID.
* VHub name.
* Resource Group name.
* Optional. Firewall IP address if you use any on the VHub side.
2. Prepare a `astro-vhub-peering-creator-role.json` JSON file with the following permissions. Replace `{customer-subscription-id}` with your value:
```json title="astro-vhub-peering-creator-role.json" wrap theme={null}
{
"Name": "Astro VHub Peering Contributor",
"IsCustom": true,
"Description": "Can create VNET peering with Astro.",
"Actions": [
"Microsoft.Resources/subscriptions/resourceGroups/read",
"Microsoft.Resources/subscriptions/read",
"Microsoft.Network/virtualHubs/hubVirtualNetworkConnections/write",
"Microsoft.Network/virtualHubs/read",
"Microsoft.Network/virtualWans/virtualHubs/read",
"Microsoft.Network/virtualHubs/hubVirtualNetworkConnections/read"
],
"NotActions": [
],
"AssignableScopes": [
"/subscriptions/{customer-subscription-id}"
]
}
```
3. Run the following Azure CLI commands to give Astronomer Support temporary permissions to establish a VHub peering connection:
```sh wrap theme={null}
# Add Astronomer Service Principal
az ad sp create --id a67e6057-7138-4f78-bbaf-fd9db7b8aab0
# Create a Custom role with permissions prepared in previous step
az role definition create --role-definition ~/astro-vhub-peering-creator-role.json
# Assign Custom role to the Astronomer Service Principal ({customer-subscription-id} has to be replaced with your value)
az role assignment create \
--assignee a67e6057-7138-4f78-bbaf-fd9db7b8aab0 \
--role "Astro VHub Peering Contributor" \
--scope "/subscriptions/{customer-subscription-id}"
# Verify an assignment
az role assignment list --assignee a67e6057-7138-4f78-bbaf-fd9db7b8aab0 --all -o table
```
4. Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) to tell them that you granted them permissions to the Astronomer Service Principal. In addition, provide the following details in your request:
* Astro Cluster ID
* Azure Tenant ID and Subscription ID with a VHub
* Resource group name
* VHub name and preferable name for the peering
* (Optional) Firewall IP address if you use any on the VHub side.
After receiving your request, Astronomer support creates a VHub peering connection to Astro VNet. No other actions are required from you. Astronomer support will notify you when the connection is ready to use.
When the network connection is confirmed, you can delete the temporary roles you created using the following command. Replace `{customer-subscription-id}` with your value:
```sh wrap theme={null}
az role assignment delete --assignee a67e6057-7138-4f78-bbaf-fd9db7b8aab0 --role "Astro VHub Peering Contributor" --scope "/subscriptions/{customer-subscription-id}"
```
# Azure Networking: VNet Peering
Source: https://astronomer.io/docs/astro/connect-azure-vnet-peering
Create a VNet peering network connection to Azure.
To set up a private connection between an Astro Virtual Network (VNet) and an Azure VNet, you can create a VNet peering connection. VNet peering ensures private and secure connectivity, reduces network transit costs, and simplifies network layouts.
## Prerequisites
* A dedicated Astro cluster
* Global Admin permissions in Azure to add the Astronomer Service Principal
## Set up VNet peering
1. Retrieve the following information from the target Azure environment that you want to connect with:
* Azure Tenant ID and Subscription ID.
* VNet name.
* Resource Group name.
2. Prepare the `astro-vnet-peering-creator-role.json` JSON file with the following permissions. Replace `{customer-subscription-id}` with your value:
```json title="astro-vnet-peering-creator-role.json" wrap theme={null}
{
"Name": "Astro VNET Peering Contributor",
"IsCustom": true,
"Description": "Can create VNET peering with Astro.",
"Actions": [
"Microsoft.Resources/subscriptions/resourceGroups/read",
"Microsoft.Resources/subscriptions/read",
"Microsoft.Network/virtualNetworks/read",
"Microsoft.Network/virtualNetworks/write",
"Microsoft.Network/virtualNetworks/peer/action",
"Microsoft.Network/virtualNetworks/virtualNetworkPeerings/write",
"Microsoft.Network/virtualNetworks/virtualNetworkPeerings/read"
],
"NotActions": [
],
"AssignableScopes": [
"/subscriptions/{customer-subscription-id}"
]
}
```
3. Run the following Azure CLI commands to give Astronomer support temporary permissions to establish a VNet peering connection:
```sh wrap theme={null}
# Add Astronomer Service Principal
az ad sp create --id a67e6057-7138-4f78-bbaf-fd9db7b8aab0
# Create a Custom role with permissions prepared in previous step
az role definition create --role-definition ~/astro-vnet-peering-creator-role.json
# Assign Custom role to the Astronomer Service Principal ({customer-subscription-id} has to be replaced with your value)
az role assignment create \
--assignee a67e6057-7138-4f78-bbaf-fd9db7b8aab0 \
--role "Astro VNET Peering Contributor" \
--scope "/subscriptions/{customer-subscription-id}"
# Verify an assignment
az role assignment list --assignee a67e6057-7138-4f78-bbaf-fd9db7b8aab0 --all -o table
```
4. Contact [Astronomer support](https://cloud.astronomer.io/open-support-request) to tell them that you granted permissions to the Astronomer Service Principal. In addition, provide the following details in your request:
* Astro Cluster ID
* Azure Tenant ID and Subscription ID of the target VNet
* Resource group name
* VNet Name and preferred name for peering
After receiving your request, Astronomer support creates a VNet peering connection between the two VNets. No other actions are required from you. Astronomer support will notify you when the connection is ready to use.
When the network connection is confirmed, you can delete the temporary roles you created using the following command. Replace `{customer-subscription-id}` with your value:
```sh wrap theme={null}
az role assignment delete --assignee a67e6057-7138-4f78-bbaf-fd9db7b8aab0 --role "Astro VNET Peering Contributor" --scope "/subscriptions/{customer-subscription-id}"
```
# Azure Networking: VPN
Source: https://astronomer.io/docs/astro/connect-azure-vpn
Create a VPN connection to Azure.
This connection option is only available for dedicated Astro clusters.
Use this connectivity type to access on-premises resources or resources in other cloud providers.
## Prerequisites
Retrieve the following information about your VPN device or application:
* Public IP address
* Subnet CIDR range, multiple if needed, for your side of the connection
* Preferences regarding shared key and BGP usage
* IKE settings for the tunnel
## Contact Astronomer support for VPN configuration on Astro side
Submit all collected details to [Astronomer support](https://cloud.astronomer.io/open-support-request). The Astronomer CRE team will proceed with the required steps. The CRE team will contact you using your support ticket to ask follow-up questions, request clarification, or let you know about connectivity tests.
# Create and use data products with Astro Observe
Source: https://astronomer.io/docs/astro/create-data-products
Create observability tools on Astro to gain insight into the health and performance of your data pipelines and lifecycle.
In Observe, a data product is a composition of assets that deliver a result with business relevance. Observe automatically infers upstream dependencies for the assets that define a data product, like an Airflow dag that populates a dashboard or a Snowflake table powering a recommendation engine.
For guidance on identifying data products in your organization, see [how to identify data products in your organization](/docs/learn/data-products#how-to-identify-data-products-in-your-organization).
The **Data Products** landing page provides an overview of all your data products and their SLA statuses. You can see at a glance which data products are late or stale, who owns them, and when they were last updated to see a snapshot of data product health.
The following procedures describe how to create data products and leverage them to gain insight across pipelines and deployments. After you create a data product, then you can [view data product details](#view-your-data-product-details).
You can follow a comprehensive walkthrough of setting up a Data Product and testing an alert in the [Get started with Observe](/docs/learn/data-products) quickstart.
## Prerequisites
See [Observe prerequisites](/docs/astro/observe-get-started#prerequisites)
## Create a data product
* In the sidebar, go to **Observe** > **Catalog** (**Asset Catalog** in the legacy UI).
* Click **+ Create Data Product**.
* In the sidebar, go to **Observe** > **Data Products**.
* Click **+ Data Product**.
* In the asset selection panel, use filters to find and select the final downstream assets for your data product.
* As you select assets from the left panel, they will appear in the right preview area.
* Click **Continue** after selecting one or more assets.
* Enter a **Name** and optionally a **Description** for your data product.
* Choose a **Data Product Owner**: Select either **User** or **Team**, then specify the responsible user or team.
* Review your selected assets and inspect the automatically generated asset lineage graph on the right side. You can still add assets to the data product after it is created.
* Click **Create Data Product** to proceed.
See [Create a data product monitor](/docs/astro/observe-monitors#data-product-monitors) for information on monitoring data products.
After completing these steps, your new data product will be available to view and manage under **Data Products**.
## View your data product details
After you create a data product, you can view in-depth details about the performance of your assets by selecting your data product for a closer look.
1. Click **Observe** in the Astro UI, and then click **Data Products**.
2. Choose the data product that you want to view details about.
When you see information about a specific data product, you can see summary performance data. This includes general statistics, like the average SLA success rate and information about when the data product was created and last updated. Additional details can be found in the following tabs.
### Overview
The overview tab provides summary information about the assets in your data product and the rates of overall SLA success rates, consolidated into daily, weekly, and monthly overall rates. This view allows you to quickly identify trends in historical data for your business-critical pipelines.
### Event timeline
Each Data Product in Observe has an Event Timeline that reflects activity from the assets, like dag and task completion, and key issues, like breached SLAs and triggered alerts, in that data product. The event timeline supports filtering by event status along with more fine-grained filters. Selecting any particular event displays metadata about the event, including the notification history of a triggered alert.
The event timeline view allows you to see a record of events associated with your data product. These are categorized into **Success**, **Neutral**, and **Failure** events.
#### Success events
* SLA Success
* Task Success
* Task Start
#### Neutral events
* Airflow dataset write
* OpenLineage dataset write
#### Failure events
* Alert notification
* SLA Breach
* Task failure
For more information about diagnosing failures, see [Root cause analysis and AI log summaries](/docs/astro/root-cause-analysis).
### Assets
The **Assets** tab shows the assets included in the specific data product.
If you select an asset from the list to examine in-depth, you can see additional asset-specific details. See [Assets](/docs/astro/assets-overview) for descriptions.
### Metrics
Data products that include Airflow task assets report the following metrics by default:
* Task retries
* Task failures
* Task duration
### Alerts
The **Alerts** tab consolidates all alerts and SLAs that are specific to your selected data product. From this page you can [Add an alert](/docs/astro/observe-slas#create-an-alert), find an existing alert, and view the notification history for an alert.
# Create a dedicated Astro cluster
Source: https://astronomer.io/docs/astro/create-dedicated-cluster
Create a dedicated, single-tenant Astro cluster with custom regions, networking, and security controls for your Organization's Deployments.
This is feature is only available if you are on the **Team** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
A *dedicated cluster* exclusively runs Deployments from your Organization within a single-tenant environment on Astronomer's cloud. Dedicated clusters provide more configuration options for regions, connectivity, and security than standard clusters. You might want to create a dedicated cluster if:
* You need to connect to data services using private networking.
* You want more options for the region your cluster is hosted in.
* You otherwise want to keep your Deployments as isolated as possible.
Dedicated clusters offer the self-service convenience of a fully managed service while respecting the need to keep data private, secure, and within a single-tenant environment. If you don't need the aforementioned features, you can use one of the standard clusters when you [Create a Deployment](/docs/astro/create-deployment).
Each cloud provider has specific requirements for CIDR size, based on underlying infrastructure behavior and observations from customer deployments. Astro doesn't accept values smaller than these minimums.
Astronomer can't provide an exact match between network settings and workload size or the number of Deployments, because many factors influence address space utilization. Astronomer engineers provide specific recommendations and guidance after reviewing your use case requirements.
Organization Owners can require all new Deployments to use a dedicated cluster by enabling the **Enforce Dedicated Clusters** policy. See [Enforce dedicated clusters for new Deployments](/docs/astro/organization-settings#enforce-dedicated-clusters-for-new-deployments).
## Setup
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
1. In the Astro UI, go to **Settings** > **Clusters**.
2. Click **+ New Cluster**.
3. Configure the following details about your cluster:
* **Cloud Provider**: Select **AWS**.
* **Name**: The name for your cluster.
* **Region**: Select the region that you want your cluster to run in.
* **VPC Subnet Range**: Provide a subnet range for Astro to connect to your existing AWS resources through VPC peering. The default is `172.20.0.0/20`, and the minimum size you can use is `/22`.
4. (Optional) Expand **Advanced Configuration** to further define Kubernetes Pod Networking:
Astro allocates a secondary VPC CIDR range specifically for Kubernetes Pod IPs within your cluster. Pods use source network address translation (SNAT) for connections outside the VPC, so your data sources see connections from the primary VPC subnet, not the Pod CIDR. Only traffic internal to the VPC, such as to RDS databases, appears from Pod IPs in the secondary CIDR.
* **Pod CIDR Range**: Specify the range for Pod IP addresses. This range must not overlap with your VPC Subnet Range or any connected networks.
The Pod CIDR range isolates Pod networking and mitigates Pod IP exhaustion. SNAT ensures that all external connections use the main VPC subnet, simplifying integration with external services.
5. (Optional) In the **Disaster Recovery** section, configure cross-region disaster recovery:
Cross-region disaster recovery requires the Enterprise Business Critical tier.
* **Cross-Region Disaster Recovery**: Enable to create a secondary DR cluster in a different AWS region.
* **Failover Region**: Select the AWS region for the secondary cluster.
* **DR VPC Subnet Range**: Specify a different VPC subnet range for the secondary cluster, or leave blank to use the same range as the primary cluster.
* **DR Pod CIDR Range**: Specify a different Pod CIDR range for the secondary cluster, or leave blank to use the same range as the primary cluster.
* **Task Logs Replication SLA**: Enable to guarantee a 15-minute recovery point objective (RPO) for task logs. Additional charges apply.
See [Disaster recovery](/docs/astro/disaster-recovery) for details on how these options affect your DR configuration.
6. Click **Create Cluster**. After Astro finishes creating the cluster, users in your Organization can select the cluster when they [create a Deployment](/docs/astro/create-deployment).
1. In the Astro UI, click **Organization Settings**, then click **Clusters**.
2. Click **+ Cluster**.
3. Configure the following details about your cluster:
* **Cloud Provider**: Select **AWS**.
* **Name**: The name for your cluster. You can change this name after creation.
* **Region**: Select the region that you want your cluster to run in.
* **VPC Subnet Range**: Provide a subnet range for Astro to connect to your existing AWS resources through VPC peering. The default is `172.20.0.0/20`, and the minimum size you can use is `/22`.
4. (Optional) Expand **Advanced Configuration** to further define Kubernetes Pod Networking:
Astro allocates a secondary VPC CIDR range specifically for Kubernetes Pod IPs within your cluster. Pods use source network address translation (SNAT) for connections outside the VPC, so your data sources see connections from the primary VPC subnet, not the Pod CIDR. Only traffic internal to the VPC, such as to RDS databases, appears from Pod IPs in the secondary CIDR.
* **Pod CIDR Range**: Specify the range for Pod IP addresses. This range must not overlap with your VPC Subnet Range or any connected networks.
The Pod CIDR range isolates Pod networking and mitigates Pod IP exhaustion. SNAT ensures that all external connections use the main VPC subnet, simplifying integration with external services.
5. (Optional) In the **Disaster Recovery** section, configure cross-region disaster recovery:
Cross-region disaster recovery requires the Enterprise Business Critical tier.
* **Cross-Region Disaster Recovery**: Enable to create a secondary DR cluster in a different AWS region.
* **Failover Region**: Select the AWS region for the secondary cluster.
* **DR VPC Subnet Range**: Specify a different VPC subnet range for the secondary cluster, or leave blank to use the same range as the primary cluster.
* **DR Pod CIDR Range**: Specify a different Pod CIDR range for the secondary cluster, or leave blank to use the same range as the primary cluster.
* **Task Logs Replication SLA**: Enable to guarantee a 15-minute recovery point objective (RPO) for task logs. Additional charges apply.
See [Disaster recovery](/docs/astro/disaster-recovery) for details on how these options affect your DR configuration.
6. Click **Create cluster**. After Astro finishes creating the cluster, users in your Organization can select the cluster when they [create a Deployment](/docs/astro/create-deployment).
1. In the Astro UI, go to **Settings** > **Clusters**.
2. Click **+ New Cluster**.
3. Configure the following details about your cluster:
* **Cloud Provider**: Select **GCP**.
* **Name**: The name for your cluster.
* **Region**: Select the region that your cluster runs in.
* **VPC Subnet Range**: Specify the range used by nodes in your GKE cluster (Default: `172.20.0.0/22`). Astro uses this range to make private connections to your target data sources. The minimum size you can use is `/24`.
4. (Optional) Configure the following **Advanced Configuration** details about your cluster for Private Networking.
Astro uses source network address translation (SNAT) that performs many-to-one IP address translations for connections to your data sources and defaults secondary ranges to RFC 6598 address space (non-standard Private IP addresses), to minimize the risk and concern with IP overlap and exhaustion. When using private networking, like VPN or VPC Peering, between Astro and your target data sources, your target data sources see connections from the default **VPC Subnet Range**. If you're using private connections, confirm that the following **Advanced Configuration** network ranges don't overlap with your target data source networks.
* **Pod Subnet Range**: Specify the range used by GKE Pods (Default: `100.64.0.0/16`).
* **Service Subnet Range**: Specify the range used by Services in your GKE cluster (Default: `100.65.0.0/22`).
* **Service Peering Range**: Specify the range used by Private Service connections (Default: `100.66.0.0/21`)
If there is an overlap between the Advanced Configurations and your target data source networks, you can use the following alternative ranges:
* **RFC 1918**:
* 10.0.0.0/8, 10.0.0.0 – 10.255.255.255
* 172.16.0.0/12, 172.16.0.0 – 172.31.255.255
* 192.168.0.0/16, 192.168.0.0 – 192.168.255.255
* **RFC 6598**: 100.64.0.0/10, specifically IP addresses from 100.64.0.0 to 100.127.255.255
5. (Optional) In the **Disaster Recovery** section, configure cross-region disaster recovery:
Cross-region disaster recovery requires the Enterprise Business Critical tier.
* **Cross-Region Disaster Recovery**: Enable to create a secondary DR cluster in a different GCP region.
* **Failover Region**: Select the GCP region for the secondary cluster. Only regions compatible with your primary region appear, based on [supported GCP dual-region pairings](https://docs.cloud.google.com/storage/docs/locations#location-dr). For example, `us-east5` pairs only with `us-central1` or `us-east1`.
* **DR VPC Subnet Range**: Specify the VPC subnet range for the secondary cluster. This range is required and must not overlap with the primary **VPC Subnet Range**.
* **DR Pod CIDR Range**: Specify the Pod range for the secondary cluster. This range is required and must not overlap with the primary **Pod Subnet Range**.
* **DR Service Subnet Range**: Specify the Service range for the secondary cluster. This range is required and must not overlap with the primary **Service Subnet Range**.
* **DR Service Peering Range**: Specify the Private Service connection range for the secondary cluster. This range is required and must not overlap with the primary **Service Peering Range**.
* **Task Logs Replication SLA**: Enable to guarantee a 15-minute recovery point objective (RPO) for task logs. Additional charges apply.
See [Disaster recovery](/docs/astro/disaster-recovery) for details on how these options affect your DR configuration.
6. Click **Create Cluster**. After Astro finishes creating the cluster, users in your Organization can select the cluster when they [create a Deployment](/docs/astro/create-deployment).
1. In the Astro UI, click **Organization Settings**, then click **Clusters**.
2. Click **+ Cluster**.
3. Configure the following details about your cluster:
* **Cloud Provider**: Select **GCP**.
* **Name**: The name for your cluster. You can change this name after creation.
* **Region**: Select the region that your cluster runs in.
* **VPC Subnet Range**: Specify the range used by nodes in your GKE cluster (Default: `172.20.0.0/22`). Astro uses this range to make private connections to your target data sources. The minimum size you can use is `/24`.
4. (Optional) Configure the following **Advanced Configuration** details about your cluster for Private Networking.
Astro uses source network address translation (SNAT) that performs many-to-one IP address translations for connections to your data sources and defaults secondary ranges to RFC 6598 address space (non-standard Private IP addresses), to minimize the risk and concern with IP overlap and exhaustion. When using private networking, like VPN or VPC Peering, between Astro and your target data sources, your target data sources see connections from the default **VPC Subnet Range**. If you're using private connections, confirm that the following **Advanced Configuration** network ranges don't overlap with your target data source networks.
* **Pod Subnet Range**: Specify the range used by GKE Pods (Default: `100.64.0.0/16`).
* **Service Subnet Range**: Specify the range used by Services in your GKE cluster (Default: `100.65.0.0/22`).
* **Service Peering Range**: Specify the range used by Private Service connections (Default: `100.66.0.0/21`)
If there is an overlap between the Advanced Configurations and your target data source networks, you can use the following alternative ranges:
* **RFC 1918**:
* 10.0.0.0/8, 10.0.0.0 – 10.255.255.255
* 172.16.0.0/12, 172.16.0.0 – 172.31.255.255
* 192.168.0.0/16, 192.168.0.0 – 192.168.255.255
* **RFC 6598**: 100.64.0.0/10, specifically IP addresses from 100.64.0.0 to 100.127.255.255
5. (Optional) In the **Disaster Recovery** section, configure cross-region disaster recovery:
Cross-region disaster recovery requires the Enterprise Business Critical tier.
* **Cross-Region Disaster Recovery**: Enable to create a secondary DR cluster in a different GCP region.
* **Failover Region**: Select the GCP region for the secondary cluster. Only regions compatible with your primary region appear, based on [supported GCP dual-region pairings](https://docs.cloud.google.com/storage/docs/locations#location-dr). For example, `us-east5` pairs only with `us-central1` or `us-east1`.
* **DR VPC Subnet Range**: Specify the VPC subnet range for the secondary cluster. This range is required and must not overlap with the primary **VPC Subnet Range**.
* **DR Pod CIDR Range**: Specify the Pod range for the secondary cluster. This range is required and must not overlap with the primary **Pod Subnet Range**.
* **DR Service Subnet Range**: Specify the Service range for the secondary cluster. This range is required and must not overlap with the primary **Service Subnet Range**.
* **DR Service Peering Range**: Specify the Private Service connection range for the secondary cluster. This range is required and must not overlap with the primary **Service Peering Range**.
* **Task Logs Replication SLA**: Enable to guarantee a 15-minute recovery point objective (RPO) for task logs. Additional charges apply.
See [Disaster recovery](/docs/astro/disaster-recovery) for details on how these options affect your DR configuration.
6. Click **Create cluster**. After Astro finishes creating the cluster, users in your Organization can select the cluster when they [create a Deployment](/docs/astro/create-deployment).
**Configure cluster maintenance windows**
All GCP dedicated clusters are subscribed to the [GKE regular release channel](https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels), meaning that Google automatically upgrades the cluster and its nodes whenever an upgrade is available.
After you create a GCP cluster, you can control when these upgrades happen by requesting a [maintenance window](https://cloud.google.com/kubernetes-engine/docs/how-to/maintenance-windows-and-exclusions#maintenance-window) for the cluster. Maintenance windows determine when and how Google updates your cluster. You can use maintenance windows to ensure that upgrades don't happen while critical Dags are running on your cluster.
To set a maintenance window, first choose a maintenance window time and read through the [maintenance window considerations](https://cloud.google.com/kubernetes-engine/docs/how-to/maintenance-windows-and-exclusions#considerations) to make sure that the time is optimized for your cluster. Then, contact [Astronomer Support](https://cloud.astronomer.io/open-support-request) and provide your cluster ID and desired maintenance window.
1. In the Astro UI, go to **Settings** > **Clusters**.
2. Click **+ New Cluster**.
3. Configure the following details about your cluster:
* **Cloud Provider**: Select **Azure**.
* **Name**: The name for your cluster.
* **Region**: Select the region that you want your cluster to run in.
* **VPC Subnet Range**: Provide a subnet range for Astro to connect to your existing Azure resources through a VNet connection. The default is `172.20.0.0/19`, and the minimum size you can use is `/20`.
4. Click **Create Cluster**. After Astro finishes creating the cluster, users in your Organization can select the cluster when they [create a Deployment](/docs/astro/create-deployment).
1. In the Astro UI, click **Organization Settings**, then click **Clusters**.
2. Click **+ Cluster**.
3. Configure the following details about your cluster:
* **Cloud Provider**: Select **Azure**.
* **Name**: The name for your cluster. You can change this name after creation.
* **Region**: Select the region that you want your cluster to run in.
* **VPC Subnet Range**: Provide a subnet range for Astro to connect to your existing Azure resources through a VNet connection. The default is `172.20.0.0/19`, and the minimum size you can use is `/20`.
4. Click **Create cluster**. After Astro finishes creating the cluster, users in your Organization can select the cluster when they [create a Deployment](/docs/astro/create-deployment).
# Create and assign custom Deployment roles
Source: https://astronomer.io/docs/astro/customize-deployment-roles
Customize your users' permissions for Airflow environments on Astro.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
A user entity's Deployment role determines their level of access to a specific Deployment in a Workspace. User entities with [Workspace Member permissions](/docs/astro/user-permissions#workspace-roles) or higher have some level of access to all Deployments in a Workspace, and these permissions can be increased using Deployment roles.
There are some circumstances where users should have limited access to Deployments in a Workspace. For example, all users might need full access to a development Deployment, but only administrative users need access to a production Deployment.
In situations where you need fine-grained Deployment access, you can create custom Deployment roles and assign them to users with Workspace Accessor or Workspace Member roles. If a user doesn't have a Workspace role when you assign them a Deployment role, Astro automatically gives them Workspace Accessor permissions. When you grant a user a Deployment role, they have a specific level of access to a specific Deployment. Use custom Deployment roles to enable users to collaborate in the same Workspace with only the minimum permissions they require.
Watch the Astro Academy Learning Byte video for [Custom Deployment Roles](https://academy.astronomer.io/learning-bytes-custom-deployment-roles) to review some common use cases and learn more about how Astro implements RBAC.
## Prerequisites
* Organization Owner permissions to create, update, and delete custom roles.
* Workspace Owner permissions or Deployment Admin permissions to assign and change Deployment roles for users.
See the [User permissions reference](/docs/astro/user-permissions) for more information about user roles.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a custom Deployment role
You manage and create custom Deployment roles at the Organization level. After you create a custom Deployment role, you can assign users, teams, and Deployment API tokens the role from any Deployment in the Organization.
Deployment roles are additive, meaning that a user with multiple Deployment roles has all of the permissions of each Deployment role as well as their Workspace role. For example, if a user belongs to a Team with a custom Deployment role that includes permissions to edit Airflow variables, and they also have a personal custom Deployment role that includes permissions to edit connections, then the user has permissions to edit both Airflow variables and connections in the Deployment.
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Roles & Permissions**.
2. Click **Custom**, then click **+ New Custom Role**.
3. In the **New Role** dialog, confirm that the **Scope** dropdown is set to **Deployment**. To create a role scoped to individual Dags instead, select **DAG**. See [Dag-level access control](/docs/astro/dag-level-access-control#create-a-custom-dag-role) for more about Dag-scoped roles.
4. Enter a **Name** and **Description** for the role.
5. In the **Permissions** table, select all permissions that you want the new role to have. See [Custom role permissions reference](/docs/astro/deployment-role-reference) for more information about each available permission.
To base the new role on an existing one, use the **Copy from an existing role or template** dropdown above the table. See [Deployment role templates](#deployment-role-templates) for more information about the available default templates.
**Custom Deployment role permissions**
To deploy with the Astro CLI when using a Deployment API token with a custom Deployment role, the minimum required permissions for the token's Deployment role are [`deployment.get`](/docs/astro/deployment-role-reference#deployment) and [`deployment.deploys.create`](/docs/astro/deployment-role-reference#deployment-deploys).
6. Click **Create Role**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Roles**.
3. Click **Custom** then click **+ Add Role**.
4. In the window that appears, confirm that the **Scope** dropdown is set to **Deployment**. To create a role scoped to individual Dags instead, select **Dag**. See [Dag-level access control](/docs/astro/dag-level-access-control#create-a-custom-dag-role) for more about Dag-scoped roles.
5. Enter a **Name** and **Description** for the role.
6. In the **Permissions** table, check the boxes of all permissions that you want the new role to have. See [Custom role permissions reference](/docs/astro/deployment-role-reference) for more information about each available permission.
Use the dropdown menu above the permissions table to automatically load the permissions of a templated role or an existing custom role as the basis for your new role. See [Deployment role templates](#deployment-role-templates) for more information about the available default templates.
**Custom Deployment role permissions**
To deploy with the Astro CLI when using a Deployment API token with a custom Deployment role, the minimum required permissions for the token's Deployment role are [`deployment.get`](/docs/astro/deployment-role-reference#deployment) and [`deployment.deploys.create`](/docs/astro/deployment-role-reference#deployment-deploys).
7. Click **Create role**.
Your role is now available to assign at the Deployment level. See [Assign users and Teams to Deployments](#assign-users-and-teams-to-deployments) or [Create Deployment API tokens with custom Deployment roles](/docs/astro/deployment-api-tokens#create-a-deployment-api-token) for next steps.
### Deployment role templates
Astro provides a few Deployment role templates that you can use as the basis for custom roles. These roles aren't hard-coded and exist only as templates.
* **Deployment Viewer**: This is similar to the [Airflow Viewer](https://airflow.apache.org/docs/apache-airflow-providers-fab/stable/auth-manager/access-control.html#viewer) role. It grants the user entity view-only permissions for the Airflow UI excluding the **Admin** tab.
* **Deployment Author**: This is similar to the [Airflow User](https://airflow.apache.org/docs/apache-airflow-providers-fab/stable/auth-manager/access-control.html#user) role. It grants the user entity permissions to deploy code and manage Dag and task runs from the Airflow UI.
* **Deployment Operator**: This is similar to the [Airflow Op](https://airflow.apache.org/docs/apache-airflow-providers-fab/stable/auth-manager/access-control.html#op) role. It grants the user entity permissions to update Deployment API tokens and Airflow objects from both the Airflow UI and the Astro UI.
* **Deployment Observe Ingest**: This permission role allows a user entity permissions to ingest OpenLineage events and metrics.
### Example: `MCP_VIEWER` role for the Airflow MCP Plugin
If you use the [Airflow MCP Plugin](/docs/astro/astro-mcp-server#airflow-mcp-plugin) to connect AI tools to your Deployment, create a custom `MCP_VIEWER` role with `deployment.get` and all `deployment.airflow.*.get` permissions. This is the least-privilege role that allows all MCP read tools to work. The MCP protocol requires POST requests, so the built-in `WORKSPACE_MEMBER` role doesn't work. See [Configure authentication](/docs/astro/astro-mcp-server#configure-authentication) for setup instructions.
## Assign users and Teams to Deployments
Using Deployment roles, you can add users and Teams directly to Deployments without first assigning them to a Workspace. If they don't already belong to the Workspace, Astro grants them the *Workspace Accessor* role. A Workspace Accessor only has permissions to access their assigned Deployments within the Workspace. All other Deployments and Workspace settings are hidden.
1. In the Astro UI, open the Deployment where you want to assign the user entity.
2. Click **Access**, then click **Users** or **Teams** depending on what kind of user entity you want to assign to the Deployment.
3. Click **+ User**/ **+ Team**.
4. In the window that appears, select the user entity you want to add, then select the role they will have in the Deployment.
5. Click **Add User**/ **Add Team**.
**Centralized access management for Organization Owners**
Organization Owners can also add or update a user or Team for a Deployment from your Organization's access management settings:
1. In the Astro UI, go to **Settings** > **Access Management**.
2. Select the user or Team.
3. Click the **Deployments** tab, then click **+ Add Deployment** to add them to a Deployment, or **Edit Role** to change their role for an existing Deployment.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Select the user or Team to add or update.
3. Click the **Deployments** tab, then click **+ Deployment** to add them to a Deployment, or open the **More actions** menu (⋯) and select **Edit role** next to an existing Deployment to change their role.
## Restrict a custom Deployment role to specific Workspaces
By default, a custom role is available to use in all Workspaces. After you create a custom Deployment role, you can restrict it so that users can only be assigned the role within specific Workspaces. Use Workspace role restriction when some Workspaces in your Organization have different requirements for how users interact with Deployments.
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Roles & Permissions**.
2. Click **Custom**, then click the name of the custom role you want to restrict.
3. Click the **Restricted Workspaces** tab.
4. In the **Edit Restricted Workspaces** panel, toggle **Workspace Restriction** to **On**.
5. Under **Restricted Workspaces**, select the checkboxes for the Workspaces you want to restrict the role to.
6. Click **Update Restricted Workspaces**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Roles**.
3. Click **Custom**, then select the custom role that you want to restrict.
4. In the menu that appears, click **Restricted Workspaces**, then click **Edit**.
5. Click the **Workspace Restriction** toggle to on, then tick the checkbox for any Workspaces where you want the role to be usable.
6. Click **Update Restricted Workspaces**.
# Dag-level access control
Source: https://astronomer.io/docs/astro/dag-level-access-control
Assign fine-grained, per-Dag roles to users, Teams, and API tokens on Astro.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
**Dag-level access control requires Deployment-based forward auth URLs**
If you use **Dag-level access control**, forward authentication must use the **Deployment-based endpoints**, not the older org-based endpoints.
When you click **Navigate to Airflow** in the Astro UI, the correct Deployment-based URL appears in your browser address bar.
Deployment-based URLs follow this format:
`....`
You only need to reference or configure these endpoints if you are setting up custom ingress, reverse proxies, or other advanced integrations.
Dag-level access control permissions are enforced at the **Deployment level**, and using the older org-based URLs can result in incorrect permission enforcement or authentication failures. Note that you may still be feature-flagged to use the older URI format. Contact your account team to enable the new Deployment-based forward auth URLs to use Dag-level access control.
**Astro Runtime 3.1-12+**
Dag-level access control requires Astro Runtime 3.1-12 or later. Deployments running earlier Runtime versions don't support Dag roles.
Astro supports Dag-level role-based access control (RBAC), which adds a fourth tier to the Astro access control hierarchy: Organization > Workspace > Deployment > Dag. Dag roles grant per-Dag permissions to users, Teams, and API tokens within a specific Deployment, so you can enforce least-privilege security and enable multiple teams to collaborate in a single Deployment without exposing Dags across team boundaries.
When you assign a Dag role, you bind it to Dags using either **Dag tags** or **DAG IDs**:
* **Dag tags (recommended)**: Bind roles to one or more [Dag tags](https://airflow.apache.org/docs/apache-airflow/stable/howto/add-dag-tags.html). Any Dag with a matching tag is automatically included in the role binding. This is the recommended approach because new Dags that share the same tag are automatically covered without needing to update role assignments.
* **DAG IDs**: Bind roles to specific Dag IDs. Dag IDs are unique per Deployment. Use this approach when you need to grant access to a specific Dag that doesn't share tags with other Dags.
Use Dag tags for your role bindings whenever possible. Tag-based bindings scale automatically as you add new Dags, so you won't need to update role assignments every time a new Dag is deployed. For example, tagging all Dags owned by a team with `team:analytics` lets you assign a single Dag role that covers all current and future Dags for that team.
## Prerequisites
* An Astro Deployment running Astro Runtime 3.1-12 or later.
* The user being assigned a Dag role must be an Organization Member. If the user doesn't already have a Workspace role, Astro automatically grants them the Workspace Accessor role when you assign them a Dag role. See [Workspace Accessor](/docs/astro/user-permissions#workspace-roles).
* Organization Owner permissions to create custom Dag roles.
* Workspace Owner or Deployment Admin permissions to assign Dag roles to users, Teams, and API tokens.
## Default Dag roles
Astro provides two default Dag roles that you can assign to users, Teams, and API tokens:
| Role | Description |
| -------------- | ------------------------------------------------------------------ |
| **Dag Viewer** | Read-only access to a specific Dag and its resources. |
| **Dag Author** | Read, edit, and delete access to a specific Dag and its resources. |
To create roles with more granular permissions, see [Create a custom Dag role](#create-a-custom-dag-role).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Assign Dag roles to users
You can also manage Dag roles from a Dag-centric view. See [View and manage Dag access from a Dag](#view-and-manage-dag-access-from-a-dag).
1. In the Astro UI, click **Settings**.
2. Under **Access Management**, click **Users**, then click the user you want to manage.
3. Click the **DAGs** tab.
4. Click **+ Add DAG**.
5. In the **Add User to DAG** slide-out, select a **Deployment**.
6. Under **Target DAG by**, select **DAG Tag** or **DAG ID**. Astronomer recommends using Dag tags so that the role automatically applies to any new Dags with the same tag.
7. Select the Dag tag or Dag ID you want to bind the role to.
8. Select a **DAG Role** and click **Add to DAG**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Users**, then click the user you want to manage.
3. Click the **DAGs** tab.
4. Click **+ Dag**.
5. In the **Add User to DAG** slide-out, select a **Deployment**.
6. Under **Target DAG by**, select **DAG Tag** or **DAG ID**. Astronomer recommends using Dag tags so that the role automatically applies to any new Dags with the same tag.
7. Select the Dag tag or Dag ID you want to bind the role to.
8. Select a **DAG Role** and click **Add to DAG**.
## Assign Dag roles to Teams
You can assign Dag roles to Teams so that all Team members share the same Dag-level permissions.
You can also manage Dag roles from a Dag-centric view. See [View and manage Dag access from a Dag](#view-and-manage-dag-access-from-a-dag).
1. In the Astro UI, click **Settings**.
2. Under **Access Management**, click **Teams**, then click the Team you want to manage.
3. Click the **DAGs** tab, then click **+ Add DAG**.
4. In the slide-out, select a **Deployment**.
5. Under **Target DAG by**, select **DAG Tag** or **DAG ID**. Astronomer recommends using Dag tags so that the role automatically applies to any new Dags with the same tag.
6. Select the Dag tag or Dag ID you want to bind the role to.
7. Select a **DAG Role** and click **Add to DAG**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Teams**, then click the Team you want to manage.
3. Click the **DAGs** tab, then click **+ Dag**.
4. In the slide-out, select a **Deployment**.
5. Under **Target DAG by**, select **DAG Tag** or **DAG ID**. Astronomer recommends using Dag tags so that the role automatically applies to any new Dags with the same tag.
6. Select the Dag tag or Dag ID you want to bind the role to.
7. Select a **DAG Role** and click **Add to DAG**.
## Assign Dag roles to API tokens
You can assign Dag roles to Organization, Workspace, and Deployment API tokens to give them fine-grained access to specific Dags within a Deployment. Direct Access tokens can't be assigned Dag roles.
* **Organization API tokens**: Assign Dag roles from **Organization Settings** > **Access Management** > **API Tokens**. Click the token, then use the **DAGs** tab. See the following steps.
* **Workspace API tokens**: Assign Dag roles from the token's access management page. See [Manage Workspace API token access](/docs/astro/workspace-api-tokens#manage-workspace-api-token-access).
* **Deployment API tokens**: Assign Dag roles from the token's access management page. See [Manage Deployment API token access](/docs/astro/deployment-api-tokens#manage-deployment-api-token-access).
To assign a Dag role to an Organization API token:
1. In the Astro UI, click **Settings**.
2. Under **Access Management**, click **API Tokens**, then click the Organization API token you want to manage.
3. Click the **DAGs** tab, then click **+ Add DAG**.
4. In the slide-out, select a **Deployment**.
5. Under **Target DAG by**, select **DAG Tag** or **DAG ID**. Astronomer recommends using Dag tags so that the role automatically applies to any new Dags with the same tag.
6. Select the Dag tag or Dag ID you want to bind the role to.
7. Select a **DAG Role** and click **Add to DAG**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **API Tokens**, then click the Organization API token you want to manage.
3. Click the **DAGs** tab, then click **+ Dag**.
4. In the slide-out, select a **Deployment**.
5. Under **Target DAG by**, select **DAG Tag** or **DAG ID**. Astronomer recommends using Dag tags so that the role automatically applies to any new Dags with the same tag.
6. Select the Dag tag or Dag ID you want to bind the role to.
7. Select a **DAG Role** and click **Add to DAG**.
You can also manage Dag roles from a Dag-centric view. See [View and manage Dag access from a Dag](#view-and-manage-dag-access-from-a-dag).
## View and edit a user's Dag access
Organization Owners can view and manage all of a user's Dag role assignments from a centralized page.
1. In the Astro UI, click **Settings**.
2. Under **Access Management**, click **Users**, then click the user whose Dag access you want to view.
3. Click the **DAGs** tab.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Users**, then click the user whose Dag access you want to view.
3. Click the **DAGs** tab.
The **DAGs** tab lists explicit Dag role assignments across all Deployments. Users may also have additional access through their Deployment, Workspace, or Organization role, or through a Team membership. The table shows the following columns:
* **DAG ID**: The ID of the Dag the role is bound to.
* **DAG Tag**: The Dag tag the role is bound to.
* **Deployment**: The Deployment the binding belongs to.
* **DAG Role**: The Dag role assigned to the user.
To edit a user's Dag role:
1. Open the **More actions** menu (⋯) next to the Dag entry you want to update and select **Edit role**.
2. In the **Edit Dag Access** slide-out, select a new Dag role. The **DAG ID** and **Deployment** fields are read-only.
3. Click **Save changes**.
To remove a user's access to a Dag, open the **More actions** menu (⋯) and select **Remove**.
## View and manage Dag access from a Dag
Organization Owners can view and manage all role assignments for a specific Dag from the Dag's **Access Management** page. This provides a Dag-centric view of access, showing all users, Teams, and API tokens that have roles on a particular Dag.
1. In the Astro UI, click **DAGs**, then click the Dag you want to manage.
2. Click the **Access** tab, then toggle between **Users**, **Teams**, and **API Tokens**.
1. In the Astro UI, open the **DAGs** page for your Deployment.
2. Open the **More actions** menu (⋯) for the Dag you want to manage and click **Access Management**.
The **Access Management** page shows three tabs:
* **Users**: All users with Dag roles on this Dag.
* **Teams**: All Teams with Dag roles on this Dag.
* **API Tokens**: All API tokens with Dag roles on this Dag.
Roles assigned by **DAG ID** can be added, edited, or removed from this page. Roles assigned by **DAG Tag** are view-only because they are managed through the tag-based binding. To edit a tag-based role, go to **Organization Settings** > **Access Management** and manage the role from the entity's **DAGs** tab.
### Add a Dag role from the Dag Access Management page
1. Click the tab for the entity type you want to add (**Users**, **Teams**, or **API Tokens**).
2. Click **+ User**, **+ Team**, or **+ API Token**, depending on the selected tab.
3. In the slide-out:
* For **Users** and **Teams**: Select the entity and a **DAG Role**, then click **Add**.
* For **API Tokens**: Select a **Scope** (Deployment, Workspace, or Organization) to filter the available tokens. Select an **API Token** and a **DAG Role**, then click **Add**.
Direct Access tokens appear in the token dropdown but aren't selectable.
### Edit or remove a Dag role from the Dag Access Management page
1. Open the **More actions** menu (⋯) next to the entity you want to update.
2. Click **Edit role** to change the Dag role, or click **Remove from Dag** to remove the entity's access to the Dag.
Click an entity's name on the **Access Management** page to navigate to its details page, where you can view and manage all of its role assignments.
## Create a custom Dag role
You can create custom Dag roles with granular permissions at the Organization level. After you create a custom Dag role, you can assign it to users, Teams, and API tokens for any Dag in any Deployment in the Organization.
1. In the Astro UI, click **Settings**.
2. Under **Access Management**, click **Roles & Permissions**.
3. Click **Custom**, then click **+ New Custom Role**.
4. In the slide-out that appears, set the **Scope** dropdown to **Dag**.
5. Enter a **Name** and **Description** for the role.
6. (Optional) Use the **Copy from an existing role** dropdown to load the permissions of a default Dag role or an existing custom role as a starting point.
7. In the **Permissions** table, check the boxes for the permissions you want the role to have. See [Custom role permissions reference](/docs/astro/deployment-role-reference#dag-scope-permissions) for a complete list of available permissions.
8. Click **Create Role**.
1. In the Astro UI, click **Organization Settings**.
2. Go to **Access Management**, then click **Roles**.
3. Click **Custom**, then click **+ Add Role**.
4. In the slide-out that appears, set the **Scope** dropdown to **Dag**.
5. Enter a **Name** and **Description** for the role.
6. (Optional) Use the **Copy from an existing role** dropdown to load the permissions of a default Dag role or an existing custom role as a starting point.
7. In the **Permissions** table, check the boxes for the permissions you want the role to have. See [Custom role permissions reference](/docs/astro/deployment-role-reference#dag-scope-permissions) for a complete list of available permissions.
8. Click **Create Role**.
Your custom Dag role is now available to assign to users, Teams, and API tokens at the Dag level in any Deployment.
### Custom Dag roles vs. custom Deployment roles
Custom Deployment roles and custom Dag roles both use the custom role creation flow in **Organization Settings** > **Access Management** > **Roles**, but they differ in scope:
* **Custom Deployment roles** grant permissions across all Dags and resources in a Deployment. See [Create and assign custom Deployment roles](/docs/astro/customize-deployment-roles).
* **Custom Dag roles** grant permissions to specific Dags within a Deployment, bound by Dag tag or Dag ID.
A user can have both a Deployment role and one or more Dag roles. Permissions are additive, meaning a user with multiple roles has the combined permissions of all their roles.
## Permission dependencies for custom Dag roles
Most Airflow operations require a specific combination of permissions to work. Assigning a resource-specific permission without the required base permission results in access being denied, even when the user appears to have the relevant permission.
Two base permission patterns apply across all resources:
* **Read operations** require `dag.airflow.dag.get` alongside the specific resource read permission. For example, to view Dag runs, a role needs both `dag.airflow.dag.get` and `dag.airflow.dagRun.get`.
* **Write operations** (create, update, delete) require `dag.airflow.dag.update` — not `dag.airflow.dag.get` — alongside the specific resource write permission. For example, to trigger a Dag run, a role needs `dag.airflow.dag.update` and `dag.airflow.dagRun.create`.
Some nested resources also require permissions for all parent resources. For example, viewing task logs requires `dag.airflow.dag.get`, `dag.airflow.dagRun.get`, `dag.airflow.taskInstance.get`, and `dag.airflow.taskLog.get`.
### Common permission sets
The following examples show minimum permission sets for common role types. These are verified against Airflow API behavior but cover a subset of operations. Not all Airflow endpoints are represented here.
View Dags, Dag runs, and task execution details without making changes.
```text wrap theme={null}
dag.airflow.dag.get
dag.airflow.dagRun.get
dag.airflow.taskInstance.get
dag.airflow.taskLog.get
```
Trigger, update, and delete Dag runs.
```text wrap theme={null}
dag.airflow.dag.get
dag.airflow.dag.update
dag.airflow.dagRun.get
dag.airflow.dagRun.create
dag.airflow.dagRun.update
dag.airflow.dagRun.delete
```
View and manage individual task instances.
```text wrap theme={null}
dag.airflow.dag.get
dag.airflow.dag.update
dag.airflow.dagRun.get
dag.airflow.taskInstance.get
dag.airflow.taskInstance.update
dag.airflow.taskInstance.delete
```
Full control over a Dag, including deletion.
```text wrap theme={null}
dag.airflow.dag.get
dag.airflow.dag.update
dag.airflow.dag.delete
dag.airflow.dagRun.get
dag.airflow.dagRun.create
dag.airflow.dagRun.update
dag.airflow.dagRun.delete
```
The [Airflow access control documentation](https://airflow.apache.org/docs/apache-airflow/2.8.3/security/access-control.html) covers a broader set of permissions but isn't consistently maintained and may not reflect actual enforcement behavior. Use it as a general reference and verify requirements in your Deployment.
## See also
* [User permissions reference](/docs/astro/user-permissions)
* [Create and assign custom Deployment roles](/docs/astro/customize-deployment-roles)
* [Custom role permissions reference](/docs/astro/deployment-role-reference)
* [Configure Teams on Astro](/docs/astro/manage-teams)
* [Create and manage Organization API tokens](/docs/astro/organization-api-tokens)
# Create and manage Deployment API tokens
Source: https://astronomer.io/docs/astro/deployment-api-tokens
Use Deployment API tokens to automate code deploys and configuration changes to a Deployment.
A Deployment API token is a credential that you can use to programmatically access a specific Deployment. They are a direct replacement for Deployment API keys, which aren't supported. Using a Deployment API token, you can:
* [Push code](/docs/astro/deploy-code) to a Deployment.
* Update the Deployment's [environment variables](/docs/astro/environment-variables).
* Update a Deployment's configurations. See [Manage Deployments as code](/docs/astro/manage-deployments-as-code).
* Make requests to update your Deployment's Airflow environment using the [Airflow REST API](/docs/astro/airflow-api).
Use this document to learn how to create and manage API tokens. To use your API token in an automated process, see [Authenticate an automation tool](/docs/astro/automation-authentication). For an overview of how Astro authenticates API requests, including JWT validation, token lifetimes, and rotation behavior, see [API authentication and token security](/docs/astro/api-authentication).
## Deployment API token permissions
Unlike Workspace API tokens and Organization API tokens, Deployment API tokens aren't scoped to a specific [user role](/docs/astro/user-permissions). Deployment API tokens have the same permissions as the [Workspace Operator](/docs/astro/user-permissions#workspace-roles) role, but only for Deployment-level operations. For example, an API token can create a Deployment [environment variable](/docs/astro/environment-variables) but, unlike a Workspace Operator, it can't create an [Astro alert](/docs/astro/alerts) because alerts apply to the whole Workspace.
You can manage Dag roles and the Deployment role for a Deployment API token from its access management page. See [Manage Deployment API token access](#manage-deployment-api-token-access).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a Deployment API token
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Access** > **API Tokens**.
3. Click **+ Add API Token** > **New Deployment API Token**.
4. Configure the new Deployment API token:
* **Name**: The name for the API token.
* **Description**: (Optional) The Description for the API token.
* **Type**: **Standard** or **Direct Access**. See [Direct access API tokens](#direct-access-token-api-tokens) for more information.
* **Deployment Role**: (Enterprise plan only) Choose the Deployment-level role and permissions that the API token will have. See [Customize Deployment roles](/docs/astro/customize-deployment-roles).
* **Expiration**: The number of days that the API token can be used before it expires.
5. Click **Add API token**. A confirmation screen showing the token appears.
6. Copy the token and store it in a safe place. You won't be able to retrieve this value from Astro again.
1. In the Astro UI, open your Workspace, then open the Deployment you want to create an API token for.
2. Click **Access**.
3. Click **API Tokens**, then click **+ Deployment API Token**. In the dropdown menu that appears, click **Add Deployment API token**.
4. Configure the new Deployment API token:
* **Name**: The name for the API token.
* **Description**: (Optional) The Description for the API token.
* **Type**: **Standard** or **Direct Access**. See [Direct access API tokens](#direct-access-token-api-tokens) for more information.
* **Deployment Role**: (Enterprise plan only) Choose the Deployment-level role and permissions that the API token will have. See [Customize Deployment roles](/docs/astro/customize-deployment-roles).
* **Expiration**: The number of days that the API token can be used before it expires.
5. Click **Add API token**. A confirmation screen showing the token appears.
6. Copy the token and store it in a safe place. You won't be able to retrieve this value from Astro again.
### Direct access API tokens
A direct access API token grants the ability to bypass the control plane in the event of a system outage. The role assigned to a direct access Deployment API token can't be changed after the token is created.
Only Organization Owners can create direct access Deployment API tokens.
## Assign an Organization or Workspace API token to a Deployment
To centralize API token management, you can add an Organization or Workspace API token to a Deployment instead of creating a dedicated Deployment API token. Deployment-scoped API tokens are useful if you want to manage API tokens from the Organization level on a single screen, or you want to use a single API token for multiple Deployments.
Deployment-scoped API tokens are functionally identical to dedicated Deployment API tokens, except that you can only rotate, update, or delete them within their original scope.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Access** > **API Tokens**.
3. Click **+ Add API Token**, then click **Assign Workspace API Token** or **Assign Organization API Token**.
4. Configure the new Deployment API token:
* **Workspace/ Organization API Token**: Select the API token you want to assign to the Deployment.
* **Deployment Role**: Select the role that the API token has in the Deployment.
5. Click **Update API Token**.
1. In the Astro UI, open your Workspace, then open the Deployment you want to create an API token for.
2. Click **Access**.
3. Click **API Tokens**, then click **+ Deployment API Token**. In the dropdown menu that appears, click either **Assign Workspace API token** or **Assign Organization API token**.
4. Configure the new Deployment API token:
* **Workspace/ Organization API Token**: Select the API token you want to assign to the Deployment.
* **Deployment Role**: Select the role that the API token has in the Deployment.
5. Click **Update API Token**.
## Manage Deployment API token access
You can view and manage the roles for a Deployment API token from its access management page.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Access** > **API Tokens**.
3. Click the row for the API token you want to manage.
1. In the Astro UI, open your Workspace, then open the Deployment that the API token belongs to.
2. Click **Access**.
3. Click **API Tokens**, then click the row for the API token you want to manage.
The token access management page shows the following information and management options:
* **Deployment Role**: View or update the token's Deployment role. Click **Edit** to change the role, then click **Update API Token**.
* **Dag Roles**: View and manage the token's Dag role assignments. Click **+ Dag** to add a Dag role. To edit or remove a Dag role, open the **More actions** menu (⋯) next to the Dag entry. See [Dag-level access control](/docs/astro/dag-level-access-control) for more information about Dag roles.
## Update or delete a Deployment API token
If you delete a Deployment API token, make sure that no existing CI/CD workflows are using it. After it's deleted, an API token can't be recovered. If you unintentionally delete an API token, create a new one and update any CI/CD workflows that used the deleted API token.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Access** > **API Tokens**.
3. Open the **More actions** menu (⋯) next to your API token, then click **Edit Token**.
4. Update the name or description of your token, then click **Update API Token**.
5. (Optional) To delete a Deployment API token, click **Delete API Token**, enter `Delete`, and then click **Yes, Continue**. If you're editing a Deployment-scoped API token, click **Remove API token** instead to unassign the API token from the Deployment.
1. In the Astro UI, open your Workspace, then open the Deployment that the API token belongs to.
2. Click **Edit** next to your API token.
3. Update the name or description of your token, then click **Save Changes**.
4. (Optional) To delete a Deployment API token, click **Delete API Token**, enter `Delete`, and then click **Yes, Continue**. If you're editing a Deployment-scoped API token, click **Remove API token** instead to unassign the API token from the Deployment.
## Rotate a Deployment API token
Rotating a Deployment API token lets you renew a token without needing to reconfigure its name, description, and permissions. You can also rotate a token if you lose your current token value and need it for additional workflows.
When you rotate a Deployment API token, you receive a new valid token from Astro that can be used in your existing workflows. The previous token value becomes invalid and any workflows using those previous values stop working.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click **Access** > **API Tokens**.
3. Open the **More actions** menu (⋯) next to your API token, then click **Rotate Token**. Type in `ROTATE` to confirm, and click **Yes, Continue**. The Astro UI rotates the token and shows the new token value.
4. Copy the new token value and store it in a safe place. You won't be able to retrieve this value from Astro again.
5. In any workflows using the token, replace the old token value with the new value you copied.
1. In the Astro UI, open your Workspace, then open the Deployment that the API token belongs to.
2. Click **Edit** next to your API token.
3. Click **Rotate token**. The Astro UI rotates the token and shows the new token value.
4. Copy the new token value and store it in a safe place. You will not be able to retrieve this value from Astro again.
5. In any workflows using the token, replace the old token value with the new value you copied.
## Use a Deployment API token with the Astro CLI
To use a Deployment API token with Astro CLI, specify the `ASTRO_API_TOKEN` environment variable in the system running the Astro CLI:
```sh wrap theme={null}
export ASTRO_API_TOKEN=
```
After you configure the `ASTRO_API_TOKEN` environment variable, you can run Astro CLI commands related to the Deployment for which the Deployment API token was created. For example, [`astro deployment inspect`](/docs/cli/v1.43/astro-deployment-inspect) or [`astro deployment logs`](/docs/cli/v1.43/astro-deployment-logs).
When using a Deployment API token for automation, Astronomer recommends storing `ASTRO_API_TOKEN` as a secret.
### Use a Deployment API token for CI/CD
You can use Deployment API tokens and the Astro CLI to automate various Deployment management actions in CI/CD.
For all use cases, you must make the following environment variable available to your CI/CD environment:
```text wrap theme={null}
ASTRO_API_TOKEN=
```
After you set this environment variable, you can run Astro CLI commands from CI/CD pipelines without needing to manually authenticate to Astro. For more information and examples, see [Automate code deploys with CI/CD](/docs/astro/set-up-ci-cd).
# Deployment file reference
Source: https://astronomer.io/docs/astro/deployment-file-reference
View all possible values that you can include in a Deployment file when managing Deployments as code.
After you create an Astro Deployment, you can use the Astro CLI to create a Deployment file that contains its unique configurations represented as code. That includes worker queues, environment variables, Astro Runtime version, and more. You can use Deployment files to manage Deployments programmatically on Astro.
When you [inspect a Deployment](/docs/cli/v1.43/astro-deployment-inspect) to generate a Deployment file, its current configuration is generated as a YAML *Deployment file*. The file includes the name, description, and metadata that is unique to the Deployment.
A *Deployment template file* is different from the *Deployment file*. A template file does not have the `metadata` and `environment_variables` section, and the `name` and `description` fields are empty. Deployment template files are used to create new Deployments, while a Deployment file of an existing Deployment can be used to update its configuration. To create a Deployment template file in YAML format, run `astro deployment inspect --template > your-deployment.yaml`.
Use this document as a reference for all fields in both Deployment files and Deployment template files.
## Deployment file example
To see the minimum values required to create a Deployment using a template file, see [Create a Deployment using a template file](/docs/astro/manage-deployments-as-code#create-a-deployment-using-a-template-file).
The following is an example Deployment file for Astro Hosted:
```yaml title="deployment.yaml" expandable wrap theme={null}
deployment:
configuration:
name: test
description: ""
runtime_version: 12.0.0
dag_deploy_enabled: true
ci_cd_enforcement: false
scheduler_size: SMALL
is_high_availability: false
is_development_mode: false
executor: CELERY
scheduler_count: 1
workspace_name: Demo Workspace
deployment_type: STANDARD
cloud_provider: AZURE
region: westus2
default_task_pod_cpu: "0.25"
default_task_pod_memory: 0.5Gi
resource_quota_cpu: "10"
resource_quota_memory: 20Gi
workload_identity: ""
worker_queues:
- name: default
max_worker_count: 10
min_worker_count: 0
worker_concurrency: 5
worker_type: A5
metadata:
deployment_id: cm0cvxk2r000108jt6vdw9sg2
workspace_id: cm0cvy04p000308jt62nze0hc
cluster_id: N/A
release_name: N/A
airflow_version: 2.10.0
current_tag: 12.0.0
status: CREATING
created_at: 2024-08-23T20:00:40.72Z
updated_at: 2024-08-23T20:00:40.72Z
deployment_url: cloud.astronomer.io/cm0cvyx0m000408jt112i7aax/deployments/cm0cvz60c000508jtbgnrese4/overview
webserver_url: org-astro-dev-ex.astronomer.run/cm0cvzely000608jt5v5p27bo
airflow_api_url: org-astro-dev-ex.astronomer.run/cm0cvzowp000708jt2r7662bm/api/v1
alert_emails:
- test-emailclskz4wu5000508jz4gm25q5j@testdomain
hibernation_schedules:
- hibernate_at: 1 * * * *
wake_at: 2 * * * *
description: hibernation schedule 1
enabled: true
```
The following sections describe configuration options for your Deployment file:
### `deployment.environment_variables`
You can create, update, or delete environment variables in the `environment_variables` section of the template file. This is equivalent to configuring environment variables in the Deployment's **Environment Variables** tab in your Deployment's **Environment** settings. Each variable in this section must include a `key` and a `value`.
By default, each variable is created as a non-secret variable. To set any new or existing environment variables as secret, specify `is_secret: true` in the same section as the key and value. For example:
```yaml wrap theme={null}
- is_secret: true
key: PROJECT_NAME
value: test_project
```
When you inspect a Deployment, the value of secret environment variables do not appear in the Deployment file.
To delete an environment variable, remove the lines that contain its key, its value, and other associated fields. Then, reapply the file to the Deployment. Any variables that exist on the Deployment, but are not included in the most recently applied Deployment file, are deleted.
If you commit a template file to a GitHub repository, do not add secret environment variables in the file. Instead, add them manually in the Astro UI. This ensures that you do not commit secret values to a version control tool in plain-text.
When you add environment variables using a Deployment file, you must provide a `value` for your environment variable. Leaving this value blank or as an empty string (`""`) will cause the `astro deployment create` command to fail.
### `deployment.configuration`
The `configuration` section contains all of the basic settings that you can configure from the Deployment **Details** page in the Astro UI. See:
* [Create a Deployment](/docs/astro/create-deployment#create-a-deployment).
* [Update a Deployment name and description](/docs/astro/deployment-details#update-a-deployment-name-and-description).
* [Scheduler](/docs/astro/deployment-resources#scheduler).
### `deployment.worker_queues`
The `worker_queues` section defines the [worker queues](/docs/astro/configure-worker-queues) for Deployments that use the Celery executor. This section is not applicable to Deployments that use Kubernetes executor.
If you don't enter specific values for the `default` worker queue for a Deployment, Astro uses default values based on the worker types available on your cluster. Each additional worker queue must include a `name` and `worker_type`. The Astro CLI uses default values for any other unspecified fields.
### Other fields
* `deployment_type` can be `HOSTED_SHARED` or `HOSTED_DEDICATED` for Astro Hosted depending on your [cluster type](/docs/cli/v1.43/astro-deployment-create#options-astro). Use `HOSTED_SHARED` for standard clusters and `HOSTED_DEDICATED` for dedicated clusters.
* `cluster_name` is the name for the cluster that appears in the Astro UI.
# View and address Deployment health incidents
Source: https://astronomer.io/docs/astro/deployment-health-incidents
A list of all possible Deployment incident types and steps for resolving each one.
Astro monitors your Deployment and displays notifications when issues arise that could affect your Deployment's functionality or performance. Use your Deployment health status to quickly check if your Deployment has any issues that need immediate attention.
## Deployment health
After you create a Deployment, its real-time health status appears at the top of the Deployment information page. Deployment health indicates if the components within your Deployment are running as expected.
The following are possible health statuses your Deployments can have:
* **Creating** (Grey): Astro is still provisioning Deployment resources. It is not yet available to run dags. See [Create a Deployment](/docs/astro/create-deployment).
* **Deploying** (Grey): A code deploy or environment update is in progress. Hover over the status indicator to view specific information about the deploy, including whether it was an image deploy or a dag-only deploy.
* **Healthy** (Green): The Airflow webserver and scheduler are both healthy and running as expected.
* **Unhealthy** (Red): Your Deployment webserver or scheduler are restarting or otherwise not in a healthy, running state.
* **Hibernating** (Grey): Your Deployment is currently hibernating.
* **Unknown** (Grey): The Deployment status can't be determined.
Your Deployment health status will also show a number next to the status if a [Deployment health incident](#deployment-incidents) is currently active. Incidents are classified as **Info**, **Warning** or **Critical** level.
If your Deployment is unhealthy or the status can't be determined, check the status of your tasks and wait for a few minutes. If your Deployment is unhealthy for more than five minutes, review the logs in the [Airflow component logs](/docs/astro/view-logs#view-airflow-component-logs-in-the-astro-ui) in the Astro UI or contact [Astronomer support](https://cloud.astronomer.io/open-support-request).
## Deployment incidents
Astro automatically monitors your Deployments and sends messages when your Deployment isn't running optimally or as expected. These messages are known as *Deployment incidents*. To view information about the incident, hover over the incident and click **View details**.
The following table contains all types of Deployment incidents. An **info** incident indicates that an issue has been identified but it will not impact the execution of dags or tasks. A **warning** incident indicates that specific tasks or dags might fail or that some action that should be taken on the Deployment. A **critical** incident indicates that your entire Deployment might not work as expected.
| Incident name | Severity | Description |
| --------------------------------------- | --------------- | ----------------------------------------------------------------------------------------------------- |
| Scheduler Heartbeat Not Found | Warning | The Airflow scheduler has not sent a heartbeat for longer than 10 minutes. |
| Airflow Database Storage Unusually High | Info or Warning | The metadata database has tables that are larger than 50GiB (Info) or 75GiB (Warning). |
| Deprecated Runtime Version | Warning | Your Deployment is using a deprecated Astro Runtime version. |
| Job Scheduling Disabled | Warning | The Airflow scheduler is configured to prevent automatic scheduling of new tasks using dag schedules. |
| Worker Queue at Capacity | Warning | At least one worker queue in this Deployment is running the maximum number of tasks and workers. |
Use the following topics to address each of these incidents.
**Preview: Deployment Health Alerts**
You can configure alerts for Deployment health incidents so that you are automatically notified via Slack, PagerDuty, or email if certain Deployment health incidents occur. See [Astro Alerts](/docs/astro/alerts) for setup information.
### Scheduler Heartbeat Not Found
The scheduler has not sent a heartbeat for longer than 10 minutes. This could be a sign that the scheduler is down. Tasks will keep running, but new tasks will not be scheduled.
If you receive this incident notification, Astronomer Support has already been notified and no action is required from you. Ensure that you [configured a Deployment contact email](/docs/astro/deployment-details#configure-deployment-contact-emails) so that you can be notified if this issue requires additional follow-ups.
### Airflow Database Storage Unusually High
Your Deployment metadata database is currently storing tables that are larger than 50GiB (Info) or 75GiB (Warning). Click **View details** on the incident to view the affected tables. Even with large tables, Airflow will continue to operate as normal, but tables that are larger than 75GiB might cause degraded scheduler performance. As a result, you may need to clean up the relevant tables in the metadata database to avoid the risk of delayed task runs.
The tables that are currently monitored for size are:
* `dag`
* `dag_run`
* `task_instance`
* `job`
* `log`
* `xcom`
If `xcom` is listed in the affected tables, consider taking one of the following actions:
* Configure an external backend for XCom data, such as AWS S3. See the [Astronomer XCom Backend Tutorial](/docs/learn/custom-xcom-backends-tutorial).
* Implement intermediary data storage for tasks so that Airflow doesn't store large amounts of data when passing data between tasks. See [Intermediary data storage](/docs/learn/airflow-passing-data-between-tasks#intermediary-data-storage).
For additional assistance in cleaning up large tables, submit a request to [Astronomer Support](https://cloud.astronomer.io/open-support-request).
### Deprecated Runtime Version
The Astro Runtime version being used by the Deployment has been deprecated. Airflow will continue to run as normal, but you should upgrade as soon as possible.
To upgrade to a [supported version](/docs/runtime/runtime-version-lifecycle-policy), see [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
### Job Scheduling Disabled
The Airflow scheduler is currently disabled and will not automatically schedule new tasks. To run a new task in this state, you must manually trigger a dag run. To resume all scheduling, remove any overrides to the `AIRFLOW__SCHEDULER__USE_JOB_SCHEDULE` environment variable.
This variable might be configured in the [Astro UI](/docs/astro/manage-env-vars#use-the-astro-ui) or in your [Dockerfile](/docs/astro/manage-env-vars#using-your-dockerfile).
### Worker Queue at Capacity
At least one worker queue in your Deployment is running the maximum possible number of tasks and workers. Tasks will continue to run but new tasks will not be scheduled until worker resources become available. Click **View details** on the incident to view the affected worker queue(s).
To limit this notification for a worker queue, increase its **Max # Workers** setting or choose a larger **Worker Type**. See [Configure worker queues](/docs/astro/configure-worker-queues).
## See also
* [Deployment metrics](/docs/astro/deployment-metrics)
* [Astro alerts](/docs/astro/alerts)
* [Deployment logs](/docs/astro/view-logs)
# View metrics for Astro Deployments
Source: https://astronomer.io/docs/astro/deployment-metrics
Learn how to monitor Deployment performance, health, and total task volume in the Astro UI. These metrics can help you with resource allocation and issue troubleshooting.
The Astro UI exposes a suite of observability metrics that show real-time data related to the performance and health of your Deployments. These metrics are a useful reference as you troubleshoot issues and can inform how you allocate resources. They can also help you estimate the cost of your Deployments. This document explains each available metric and where to find them.
To view information about individual dags, see [dag and task runs](/docs/astro/manage-dags). To track Deployment health and specific incidents, see [Deployment health and incidents](/docs/astro/deployment-health-incidents).
**New Deployment analytics experience**
This feature is in [Preview](/docs/astro/feature-previews) and includes expanded Airflow visibility and improved charting controls. You can switch between the new and previous experience from the **Analytics** page.
## Deployment analytics
The **Analytics** page contains a suite of metrics for a given Deployment. This page includes metrics that give you insight into the performance of both your data pipelines and infrastructure. Because metrics are collected in real time, you can use this page to detect irregularities in your pipelines or infrastructure as they happen.
To view metrics for a Deployment, open the Deployment in the Astro UI, click **Analytics**. The following topics contain information about each available metric.
### Dag and task runs
These metrics contain information about your Deployment's dag runs and task runs over a given period of time.
#### Available metrics
* **Dag/ Task Runs**: This metric graphs the total number of dag/ task runs.
* **Runs per Status**: This metric graphs the number of failed and successful dag/ task runs, plotted based on the dag/ task run start time. Use this metric to see exactly when recent dag/ task runs succeeded or failed.
The dag runs metric does not record dag run timeouts as failed runs. To see timed out dag runs, you must go into the Airflow UI to check on the statuses of each dag run there.
* **P90 Run Duration per Status**: This metric graphs the 90th percentile of execution times for dag/ task runs, plotted based on the dag/ task run start time. In the example above, the P90 Run Duration per Status for successful dag/ task runs at 5:00 was 34 seconds, which means that 90% of those dag/ task runs finished in 34 seconds or less.
This metric can both help you understand how your pipelines are performing overall, as well as identify dag/ task runs that didn't result in a failure but still took longer to run than expected.
* **Ephemeral storage usage (*Kubernetes Executor/KubernetesPodOperator*)**: View how your Kubernetes tasks use your available ephemeral storage as a metric of the percentage used of total ephemeral storage configured. Click on **Dynamic y-axis scaling** to adjust the graph's y-axis to better fit your data or zoom in to view details.
### Airflow workers
These metrics contain infrastructure use information about your workers. Unique worker instances appear on these charts as different colored lines.
Hover over the graph to view a graph legend. If a given worker queue spins a worker down and back up again within a given interval, the newly spun up worker appears as a new color on the graph.
#### Available metrics
* **CPU Usage Per Pod (%)**: This metric graphs the peak CPU usage for all workers as a percentage of your maximum CPU capacity. Different worker Pods appear as differently colored lines on this chart. Hover over a given interval to view the specific number of CPUs being used.
* **Memory Usage Per Pod (MB)**: This metric graphs the peak memory usage for all workers as a percentage of your maximum memory capacity. Different worker Pods will appear as differently colored lines on this chart. This metric should be at or below 50% of your total allowed memory at any given time.
The number of workers per Deployment autoscales based on a combination of worker concurrency and the number of `running` and `queued` tasks. This means that the total available CPU and memory for a single Deployment may change at any time.
* **Network Usage Per Pod (MB)**: This metric graphs each worker/ scheduler Pod's peak network usage over time. Sudden, irregular spikes in this metric should be investigated as a possible error in your project code.
* **Pod Count per Status**: This metric graphs the number of worker and scheduler Pods in a given Kubernetes container state. Because Astro operates on a one-container-per-pod model, the state of the container state is also the Pod state. Use this metric to understand how many workers and schedulers are currently running in your Deployment. This can help you determine the values for **Worker Count (Min-Max)** that best fit your resource use.
**Maximum Worker Count** applies only to workers in the `Running` state. This means that the number of worker Pods in **Pod Count per Status** might be greater than **Maximum Worker Count** at times if Astro scales down these workers at the same time that it creates new workers. For example, let's say that a Deployment has a **Maximum Worker Count** of 20. If you have five workers running tasks for an hour and you deploy code that requires 20 workers, Astro will trigger a scale-down event for the existing five workers and create 20 new workers to run tasks according to your new code. This means that your Deployment temporarily runs 25 workers.
If a pod is stuck in a `Waiting` state, it can indicate that your Deployment did not successfully pull and run your Runtime image. For more information about container states, read the [Kubernetes documentation](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states).
* **Ephemeral storage usage (*Celery workers*)**: View how your Celery worker uses your available ephemeral storage as a metric of the percentage used of total ephemeral storage configured. Click on **Dynamic y-axis scaling** to adjust the graph's y-axis to better fit your data or zoom in to view details.
### Airflow scheduler and Dag processor
These metrics contain infrastructure use information about your scheduler resources. Unique scheduler instances appear on these charts as different colored lines.
Hover over the graph to view a graph legend. If a given Deployment spins a scheduler down and back up again within a given interval, the newly spun up scheduler appears as a new color on the graph. If your Deployment includes a separate Dag processor, that resource also has its own line and appears in the legend.
#### Available metrics
* **CPU Usage Per Pod (%)**: This metric graphs the peak CPU usage for all schedulers as a percentage of your maximum CPU capacity. Different scheduler and Dag processor Pods appear as differently colored lines on this chart. Hover over a given interval to view the specific number of CPUs being used.
* **Memory Usage Per Pod (MB)**: This metric graphs the peak memory usage for all schedulers as a percentage of your maximum memory capacity. Different scheduler Pods appear as differently colored lines on this chart. This metric should be at or below 50% of your total allowed memory at any given time. For scheduler metrics, the maximum allowable memory for each scheduler Pod appears as a dotted red line.
* **Network Usage Per Pod (MB)**: This metric graphs each scheduler Pod's peak network usage over time. Sudden, irregular spikes in this metric should be investigated as a possible error in your project code.
* **Pod Count per Status**: This metric graphs the number of scheduler Pods in a given Kubernetes container state. Because Astro operates on a one-container-per-pod model, the state of the container is also the Pod state. Use this metric to understand how many schedulers and Dag processors are currently running in your Deployment.
If a Pod is stuck in a `Waiting` state, it can indicate that your Deployment did not successfully pull and run your Runtime image. For more information about container states, read the [Kubernetes documentation](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states).
* **Ephemeral storage usage per Pod**: View how your schedulers and Dag processors uses the available ephemeral storage as a metric of the percentage used of total ephemeral storage configured. Click on **Dynamic y-axis scaling** to adjust the graph's y-axis to better fit your data or zoom in to view details.
* **Scheduler Heartbeat**: A scheduler emits a heartbeat at a regular rate to signal that it's healthy to other Airflow components. This metric graphs a scheduler's average heartbeats per minute over a given time.
On average, a scheduler should emit \~11-12 heartbeats per minute. A scheduler is considered "unhealthy" if it has not emitted a heartbeat for over 1 minute. The lack of a scheduler heartbeat is expected during a code push, but erratic restarts or an "Unhealthy" state that persists for a significant amount of time is worth investigating further.
### Airflow triggerer
These metrics provide visibility into the performance and resource use of Airflow triggerer components in your Deployment. The triggerer is responsible for handling deferred tasks and triggers in Airflow, and these metrics help you monitor their health and behavior.
A known bug currently displays `%` as the unit for some Triggerer memory usage metrics. This will be resolved in an upcoming release.
#### Available metrics
* **Pod Count**: See the current number of triggerer Pods. Use this metric to monitor scaling events and ensure expected capacity.
* **CPU Usage Per Triggerer Pod (%)**: Visualize the peak CPU usage for each triggerer Pod as a percentage of your maximum CPU allocation. Both time series and table views of maximum and average are available.
* **Memory Usage Per Triggerer Pod (%)**: Visualize the peak memory usage for each triggerer Pod as a percentage of your maximum memory allocation. Both time series and table views of maximum and average are available.
* **Triggers per Status**: Track the number of triggers in each status over time, helping you understand how triggers progress and where issues may occur.
* **Running Triggerers**: Displays a timeline of running triggers.
You can enable or disable dynamic Y-axis scaling on graphs for clearer visibility into spikes or sustained usage.
Triggerer metrics are available for export with [Universal Metrics Export](/docs/astro/export-metrics).
### Pools
These metrics contain information about your Deployment's configured [Airflow pools](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/pools.html). They can give you insight into how your dags are handling concurrency.
#### Available metrics
* **Status Count for ``**: This metric graphs both the number of open slots in your pool and the number of tasks in each pool state:
* **Open**: The number of available slots in the pool
* **Queued**: The number of task instances which are occupying a pool slot and waiting to be picked up by a worker
* **Running**: The number of tasks instances which are occupying a pool slot and running
* **Starving**: The number of tasks that can't be scheduled when there are 0 available pool slots
A large number of starving tasks could indicate that you should reconfigure your pools to run more tasks in parallel.
## Deployment overview
Each Deployment includes four high-level performance charts about the `default` worker queue which you can view from both the **Deployments** menu and a Deployment's **Overview** page. They include:
* dag runs
* Task Instances
* Worker CPU
* Worker Memory
The data in these four charts is recorded hourly and is displayed in both UTC and your local browser timezone. Each bar across all graphs covers a complete hour while the entire time window for a single graph is 24 hours. For example, a single bar might represent `16:00` to `17:00` while the entire time window of the graph might represent `Nov 1 16:00` to `Nov 2 16:00`.
The data for the most recent hour is for the hour to date. For example, if you are looking at this page at 16:30, then the bar for the `16:00-17:00` hour interval would show data for `16:00-16:30`.
These charts serve as high-level reports for your `default` worker queue that you can investigate further.
The following sections describe each of the 4 available charts.
### Total dag runs
The **Dag Runs** metric records successful and failed dag runs over hour-long intervals. A [dag run](https://airflow.apache.org/docs/apache-airflow/stable/dag-run.html) is defined as an instantiation of a dag at a specific point in time.
You can hover over each bar to see the corresponding hour interval displayed in both UTC and your local timezone. Below that, you can see the number of successful dag runs and the number of failed dag runs. If a bar is partially or fully red, it means that one or more dag runs failed within that hour interval.
The bolded value above the graph denotes the total number of dag runs that have been executed in the last 24 hours.
### Task instances
The **Tasks** chart records successful and failed task instances over hour-long intervals. A [task instance](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/tasks.html#task-instances) is defined as an instantiation of a task at a specific point in time.
You can hover over each bar to see the corresponding hour interval displayed in both UTC and your local timezone. Below that, you can see the number of successful and failed task instances. If a bar is partially or fully red, it means that one or more task instances failed within that hour interval.
The bolded value above the graph denotes the total number of tasks that have run in the last 24 hours.
### Resource usage
The **Worker CPU** and **Worker Memory** charts in the Astro UI provide visibility into the resources being consumed by the workers in your Deployment as measured by CPU and memory consumption.
**Worker CPU** records the peak CPU usage, while **Worker Memory** records the peak memory usage by worker nodes over hour-long intervals. The bolded values above each graph show the maximum CPU/ memory usage by a single worker at any point in time over the last 24 hours.
A known issue with Celery might cause worker memory allocation to increase without a corresponding increase in task count or dag memory use. To correct this issue, redeploy your code without making any changes to restart the Celery worker and reset memory requests. See [Deploy code to Astro](/docs/astro/deploy-code). This issue should not affect your tasks or cause OutOfMemory (OOM) errors. If you experience complications, contact Astronomer Support.
## See also
* [View Organization dashboards](/docs/astro/organization-dashboard)
* [Export task logs and metrics to Datadog](/docs/astro/export-datadog)
* [Export task logs to AWS CloudWatch](/docs/astro/export-cloudwatch)
* [Export logs to a Secondary S3 Bucket](/docs/astro/export-secondary-s3-bucket)
* [Export logs to a Secondary WASB Container](/docs/astro/export-secondary-wasb)
# Environment variables
Source: https://astronomer.io/docs/astro/environment-variables
Overview of environment variables on Astro
On Astro, an *Environment Variable* is a key-value configuration that can be set at the Deployment or Workspace level. You can use environment variables to configure custom environment variables for your Deployments, customize core settings of Airflow and its pre-installed providers, or store Airflow connections and variables.
Some scenarios where you might use environment variables in your Deployment include:
* Adding a token or a URL that is required by your Airflow Dags or tasks.
* Integrating with Datadog or other third-party tooling to [export Deployment metrics](/docs/astro/export-datadog).
* Specifying a tag that's added to all resources created by the Deployment and indicates whether a resource is for development or production.
Some examples of customizing core settings of Airflow or any of its pre-installed providers include:
* Changing the import timeout of DAGBag using `AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT`.
* Setting up an SMTP service to receive [Airflow alerts](/docs/astro/airflow-email-notifications) by email.
You can also use environment variables to store [Airflow connections](/docs/learn/connections#define-connections-with-environment-variables) and [variables](/docs/learn/airflow-variables#using-environment-variables).
Some environment variables on Astro are set globally and can't be overridden for individual Deployments, while others are used by Astro Runtime to enhance your Airflow experience. For more information on these, see [Global environment variables](/docs/astro/platform-variables).
## Choose a strategy
Environment variables can be used in many different contexts on Airflow. To choose the right management and implementation strategy for your specific use case, it's helpful to know how Astro prioritizes and stores environment variables for each available management option.
### Management options
On Astro, you can manage environment variables from three different locations:
* **Workspace Environment Manager**: Create environment variables at the Workspace level and link them to multiple Deployments. This allows you to define common environment variables once and share them across Deployments, with the ability to override values per Deployment. See [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables) for setup steps.
* **Deployment Environment Variables tab**: Set environment variables specific to a single Deployment through your Deployment's **Environment Variables** tab in your Deployment's **Environment** settings in the Astro UI. This is the fastest way to set a Deployment-specific environment variable. See [Using the Astro UI](/docs/astro/manage-env-vars#use-the-astro-ui) for setup steps.
* **Astro project Dockerfile**: Store environment variables in your Dockerfile to manage them as code in a version control tool like GitHub. However, environment variables stored in the Dockerfile don't appear in the Astro UI and might be harder to reference from Dag code. Using the Dockerfile is recommended for more complex production use cases, such as implementing a secrets backend. See [Using your Dockerfile](/docs/astro/manage-env-vars#using-your-dockerfile) for setup steps.
At the local development level, you can use your Astro project `.env` file to set and test environment variables. When you're ready to push these environment variables to a Deployment, you can use the Astro CLI to export and store them in the Astro UI for your Deployment.
### How environment variables are stored in the Astro UI
#### Deployment-level environment variables
When you set a non-secret environment variable in the Deployment UI, Astronomer stores the variable in a database that is hosted and managed by Astronomer.
When you set a secret environment variable in the Deployment UI, the following happens:
1. Astro generates a manifest that defines a Kubernetes secret, named `env-secrets`, that contains your variable's key and value.
2. Astro applies this manifest to your Deployment's namespace.
3. After the manifest is applied, the key and value of your environment variable are stored in a managed [etcd cluster](https://etcd.io/) at rest within Astro.
This process occurs every time you update the environment variable's key or value. The Deployment restarts when Deployment-level environment variables are saved.
#### Workspace-level environment variables
When you create an environment variable in the Workspace Environment Manager, Astro stores the environment variable in an Astronomer-hosted secrets manager and applies it to Deployments as Kubernetes Secrets. See [How environment variables are stored](/docs/astro/create-and-link-environment-variables#how-environment-variables-are-stored) for details.
Environment variables marked as secret are stored securely by Astronomer and are not shown in the Astro UI. However, it's possible for a user in your organization to create or configure a Dag that exposes secret values in Airflow task logs. Airflow task logs are visible to all Workspace members in the Airflow UI and accessible in your Astro cluster's storage.
To avoid exposing secret values in task logs, instruct users to not log environment variables in Dag code.
### Environment variable priority
On Astro, environment variables are applied in the following order of precedence, from highest to lowest:
1. **Deployment-level environment variables** (set in the Deployment's Environment Variables tab in the Astro UI)
2. **Workspace-level environment variables** (set in the Workspace Environment Manager)
3. **Environment variables in your Dockerfile**
For example, if you set `AIRFLOW__CORE__PARALLELISM` with one value in the Deployment UI, another value in the Workspace Environment Manager, and a third value in your `Dockerfile`, the value set in the Deployment UI takes precedence.
When you view environment variables in a Deployment's Environment Variables page, you'll see a unified view of both Deployment and Workspace environment variables, with clear indicators showing the source and any overrides.
Similarly, in local development, environment variables set in your `.env` file take precedence over environment variables set in your Dockerfile.
### Example use cases
For most use cases, Astronomer recommends using the Astro UI to store your environment variables for the following reasons:
* It's easy to use.
* It has built-in security for secret environment variables.
* You can import and export environment variables using the Astro CLI.
There are some scenarios when you might want to use a mix of methods or strategies other than the Astro UI. The following table prescribes specific methods for various common use cases.
| Scenario | Recommended method |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| You are a new Astro user. You just created a Deployment and want to integrate your Hashicorp Vault secrets backend to test Dags. | [Deployment UI](/docs/astro/manage-env-vars#use-the-astro-ui) for ease of use and visibility. |
| Your team has multiple environment types and you use an `ENVIRONMENT_TYPE` environment variable in your Dags to customize the file, bucket, or database schema names. | [Deployment UI](/docs/astro/manage-env-vars#use-the-astro-ui) for visibility. |
| You want to share common environment variables across multiple Deployments in a Workspace, with the ability to override values per Deployment. | [Workspace Environment Manager](/docs/astro/create-and-link-environment-variables) to centrally manage and share environment variables. |
| You want to standardize a core set of environment variables for all new Deployments in a Workspace. | [Workspace Environment Manager](/docs/astro/create-and-link-environment-variables) with auto-linking enabled to apply environment variables to all current and future Deployments. |
| You want to standardize a core set of Airflow environment configurations across multiple environments in your code. | [`Dockerfile`](/docs/astro/manage-env-vars#using-your-dockerfile) to have a file that serves as a source of truth and starting point for all environments. |
| You want to use version control to manage your environment variables from a code repository. | [`Dockerfile`](/docs/astro/manage-env-vars#using-your-dockerfile) to version control your environment configuration. |
| You want to carry over environment variables when you promote code from a development environment to a production environment. | [`Dockerfile`](/docs/astro/manage-env-vars#using-your-dockerfile) to deploy environment variables from project code using CI/CD. |
| You are part of a production support team analyzing Dag failures and want to turn on debugging-related environment variables temporarily. | [Deployment UI](/docs/astro/manage-env-vars#use-the-astro-ui) for ease of use. |
| You're developing locally, and you want to use a secret credential in your Dags. | [Use the `.env` file](/docs/astro/manage-env-vars#manage-environment-variables-locally) locally. This allows you to avoid accidentally sending credentials to your code repository because `.env` is part of `.gitignore`. You can then export the `.env` file to your Deployment using the Astro CLI. |
| You use environment variables to store your Airflow connections and variables, and you have to reconfigure these between Deployments based on the environment type. | [Deployment UI](/docs/astro/manage-env-vars#use-the-astro-ui) for visibility. |
| You want the features of the Astro UI for environment variables, but you also keep track of the non-secret environment variables in your code repository. | Use the [Astro CLI](/docs/astro/manage-env-vars#use-the-astro-ui) and an automation script to add or update the non-secret environment variables in your Deployment from your code repository. |
# Manage Airflow executors on Astro
Source: https://astronomer.io/docs/astro/executors-overview
Compare the Astro, Celery, and Kubernetes executors to choose the right one for your Deployment.
The Airflow executor determines which worker resources run your scheduled tasks.
On Astro, every Deployment requires an executor and you can change the executor at any time. After you choose an executor for an Astro Deployment, you can configure your dags and Deployment resources to maximize the executor's efficiency and performance. Use the information provided in this topic to learn how to configure the Astro, Celery, and Kubernetes executors on Astro.
To learn more about executors in Airflow, see [Airflow executors](/docs/learn/airflow-executors-explained).
## Choose an executor
The difference between executors is based on how tasks are distributed across worker resources. The executor you choose affects the infrastructure cost of a Deployment and how efficiently your tasks execute. Astro currently supports three executors:
* Astro executor
* Celery executor
* Kubernetes executor
Read the following topics to learn about the benefits and limitations of each executor. For information about how to change the executor of an existing Deployment, see [Update the Deployment executor](/docs/astro/deployment-resources#update-the-deployment-executor).
### Astro executor
**Airflow 3**
This feature is only available for Airflow 3.x Deployments.
The [Astro executor](/docs/astro/astro-executor) is the default for all new Airflow 3.x Deployments. The Astro executor consists of agents (workers) that pull work from an API server. The API server manages the agent lifecycle and controls task assignment logic, enabling more efficient workload distribution and scaling. This design differs from the Celery executor, where workers fetch tasks directly from a queue, and the Kubernetes executor, where the scheduler launches pods for each task.
By centrally managing both agent scaling and task assignment, the Astro executor offers increased reliability, improved performance, and cost efficiency compared to other Airflow execution models.
The Astro executor is a good fit for your Deployment if:
* You need more control over agent scaling and task distribution.
* You want a balance between dynamic scaling and efficient task assignment.
* Your workload requires high reliability and performance.
* Cost optimization is a priority for your environment.
### Celery executor
The Celery executor uses a group of workers, each of which can run multiple tasks at a time. Astronomer uses [worker autoscaling logic](/docs/astro/celery-executor#celery-worker-autoscaling-logic) to determine how many workers run on your Deployment at a given time.
The Celery executor is a good option for most use cases. Specifically, the Celery executor is a good fit for your Deployment if:
* You're just getting started with Airflow.
* You want to use different worker types based on the type of task you're running. See [Configure worker queues](/docs/astro/configure-worker-queues).
* You have many short-running tasks.
* Your tasks require the shortest startup latency (often milliseconds).
* You don't require task or dependency isolation.
* You want to direct tasks to run in worker queues with varying resources. This is useful if you want to run a subset of tasks with priority for SLA reasons, or if your tasks have varied resource requirements.
If you find that some tasks consume the resources of other tasks and cause them to fail, Astronomer recommends implementing worker queues or moving to the Kubernetes executor.
See [Manage the Celery executor](/docs/astro/celery-executor) to learn more about how to configure the Celery executor.
### Kubernetes executor
The Kubernetes executor runs each task in an individual Kubernetes Pod that's defined either in your task or Deployment configuration. When a task completes, its Pod is terminated and the resources are returned to your cluster. On Astro, the infrastructure required to run the Kubernetes executor is built into every Deployment and is managed by Astronomer.
You can specify the configuration of a task's Pod, including CPU and memory, as part of your dag definition using the [Kubernetes Python Client](https://github.com/kubernetes-client/python) and the `pod_override` arg. Any task without a `pod_override` runs in a [default Pod](/docs/astro/deployment-resources#configure-kubernetes-pod-resources) as configured on your Deployment.
The Kubernetes executor is a good option for some use cases. Specifically, the Kubernetes executor is a good fit for your Deployment if:
* Your tasks are compute-intensive or you are processing large volumes of data within the task. Kubernetes executor tasks run separately in a dedicated Pod per task.
* Your tasks can tolerate some startup latency (often seconds)
* Your tasks require task or dependency isolation.
* You have had issues running certain tasks reliably with the Celery executor.
If you're running a high task volume or cannot tolerate startup latency, Astronomer recommends the Celery executor. To learn more about using the Kubernetes executor, see [Manage the Kubernetes executor](/docs/astro/kubernetes-executor).
**Running costs for the Kubernetes executor**
For the Kubernetes executor, Astro bills for the number of A5 workers necessary to accommodate the total amount of CPU and Memory, rounded up to the nearest A5. One A5 worker corresponds to 1 CPU and 2 GiB Memory.
In order to ensure reliability, Astro allocates the limit requested by each task. If a task doesn't have [specified limits](/docs/astro/kubernetes-executor#example-set-cpu-or-memory-limits-and-requests), then Astro uses the [Deployment defaults](/docs/astro/deployment-resources#configure-kubernetes-pod-resources).
The Kubernetes executor is primarily used for resource optimization. If you want more control over the environment and dependencies that your tasks run with, consider using the [`KubernetesPodOperator`](/docs/astro/kubernetespodoperator) with either the Celery executor or Kubernetes executor.
# Export logs to AWS CloudWatch
Source: https://astronomer.io/docs/astro/export-cloudwatch
Configure your Deployment to forward observability data to your AWS CloudWatch instance.
By forwarding Astro data to AWS CloudWatch, you can integrate Astro into your existing observability practices by analyzing information about your Deployments' performance with CloudWatch monitoring tools. Currently, you can send the following data to AWS CloudWatch:
* Airflow task logs
Complete the following setup to authenticate your Deployments to AWS CloudWatch and forward your observability data to your AWS CloudWatch instance.
At this time, you can export only Airflow task logs to CloudWatch from Astro Deployments on AWS. You can export both Airflow metrics and task logs to [Datadog](/docs/astro/export-datadog) from Astro for all cloud providers.
## Export task logs to AWS CloudWatch
You can forward Airflow task logs from a Deployment to [AWS CloudWatch](https://aws.amazon.com/cloudwatch/) using an IAM role or user. This allows you to view and manage task logs across all Deployments from a centralized observability plane.
By default, Astro sets a unique log stream for each Deployment, and log groups are defined to include log streams from Deployments which share the same Workspace and cluster. You can override these definitions using Deployment environment variables if you want to change how your task logs are organized on CloudWatch. See [AWS documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html) for more information about log groups and log streams.
### Prerequisites
* Your Deployment must run Astro Runtime 9 or later. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
### Setup
1. On AWS, create an IAM role and a trust policy that allows your Deployment to write logs to CloudWatch. See [Authorize Deployments to your cloud](/docs/astro/authorize-deployments-to-your-cloud#step-1-authorize-the-deployment-in-your-cloud-aws-alternative-setup).
2. Create a permissions policy with the following configuration:
```json wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Resource": "*"
}
]
}
```
Attach this policy to your IAM role. See [Creating policies using the JSON editor](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html#access_policies_create-json-editor) and [Adding IAM identity permissions (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html#add-policies-console).
3. Set the following [environment variables](/docs/astro/environment-variables) in your Deployment:
* **Key 1**: `ASTRO_CLOUDWATCH_TASK_LOGS_ENABLED`
* **Value 1**: `True`
* **Key 2**: `ASTRO_CLOUDWATCH_ROLE_ARN`
* **Value 2**: The ARN for your IAM role. It should look similar to `arn:aws:iam::123456789012:role/rolename`
If your CloudWatch instance is not in the same region as your Deployment, you must also set the following variable:
* **Key**: `ASTRO_CLOUDWATCH_AWS_REGION`
* **Value**: ``
4. (Optional) Set the following environment variables if you require custom naming for your log streams or log groups. For example, you might set these names to make them more readable for CloudWatch admins who need to set targeted policies for log groups, or to organize log streams only by cluster instead of cluster and Workspace:
* **Key 1**: `ASTRO_CLOUDWATCH_TASK_LOGS_LOG_GROUP`
* **Value 1**: Your log group name.
* **Key 2**: `ASTRO_CLOUDWATCH_TASK_LOGS_LOG_STREAM`
* **Value 2**: Your log stream name.
# Export metrics and logs to Datadog
Source: https://astronomer.io/docs/astro/export-datadog
Configure your Deployment to forward observability data to your Datadog instance.
By forwarding Astro data to Datadog, you can integrate Astro into your existing observability practices by analyzing information about your Deployments' performance with Datadog cloud monitoring tools. Currently, you can send the following data to Datadog:
* Airflow task logs.
* Supported Datadog [Airflow metrics](https://docs.datadoghq.com/integrations/airflow/?tab=host#data-collected).
Complete the following setup to authenticate your Deployments to Datadog and forward your observability data to your Datadog instance.
## Export task logs to Datadog
You can forward Airflow task logs from a Deployment to [Datadog](https://www.datadoghq.com/) using a Datadog API key. This allows you to view and manage task logs across all Deployments from a centralized observability plane.
### Prerequisites
* Your Deployment must run Astro Runtime 9 (AWS) or 9.1 (Azure and GCP) or later. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
* If your Deployment runs Astro Runtime 3.x, add `apache-airflow-providers-datadog` to your Astro project `requirements.txt` file. Astro Runtime 3.x images don't include this package by default.
### Setup
1. Create a new Datadog API key or copy an existing API key. See [API and Application Keys](https://docs.datadoghq.com/account_management/api-app-keys/).
2. Set the following [environment variable](/docs/astro/environment-variables) on your Deployment:
* **Key 1**: `DATADOG_API_KEY`
* **Value 1**: Your Datadog API key.
* **Key 2**: `ASTRO_DATADOG_TASK_LOGS_ENABLED`
* **Value 2**: `true`
Select the **Secret?** checkbox for `DATADOG_API_KEY`. This ensures that your Datadog API key is saved securely and is not available to Workspace users in plain text.
By default, the Astro Datadog integration also sends a Deployment's [Airflow metrics](https://docs.datadoghq.com/integrations/airflow/?tab=host#data-collected) to Datadog. To send only task logs to Datadog, add the following environment variable:
* **Key**: `ASTRO_DATADOG_METRICS_DISABLED`
* **Value**: `true`
1. (Optional) Set the following [environment variable](/docs/astro/environment-variables) on your Deployment to send your logs to a specific [Datadog site](https://docs.datadoghq.com/getting_started/site/):
* **Key**: `DATADOG_SITE`
* **Value**: Your Datadog **Site Parameter**. For example, `datadoghq.com`.
2. (Optional) For Astro Runtime 9.2.0 and greater, set the following [environment variable](/docs/astro/environment-variables) on your Deployment to [add specific tags to your logs](https://docs.datadoghq.com/getting_started/tagging/):
* **Key**: `ASTRO_DATADOG_TASK_LOGS_TAGS`
* **Value**: `:,:`
By default, Astro uses the tags `source=astronomer` and `service=astronomer-task-logs`. Astro automatically adds `dag_id`, `task_id`, `run_id`, and `try_number` tags to logs sent to Datadog.
The minimum Astro Runtime versions in which logs are enriched with task instance data are 9.15.0, 10.9.0, and 11.5.0 across all cloud providers. To export logs enriched with task instance data to Datadog with a lower Astro Runtime version, upgrade `astronomer-providers-logging` to at least `1.5.1` in the `requirements.txt` file.
## Export Airflow metrics to Datadog
Airflow metrics for Dags or tasks with non-ASCII characters in their IDs are not supported and are not exported. Ensure all Dag IDs, task IDs, and TaskGroup IDs contain only ASCII characters (`A–Z`, `a–z`, `0–9`, `_`, `-`, `.`).
Export over 40 Airflow metrics related to the state and performance of your Astro Deployment to [Datadog](https://www.datadoghq.com/) by adding a Datadog API key to your Deployment. These metrics include most information that is available in the Astro UI, as well as additional metrics that Datadog automatically collects, including number of queued tasks, dag processing time, and more. For a complete list of supported metrics, see [Data Collected](https://docs.datadoghq.com/integrations/airflow/?tab=host#data-collected) in the Datadog documentation.
Astro does not export any [service checks](https://docs.datadoghq.com/integrations/airflow/?tab=host#service-checks) to Datadog. Information about the general health of your Deployment is available only as part of the Astro UI's Deployment health metric.
If your Deployment runs Astro Runtime 3.x, add `apache-airflow-providers-datadog` to your Astro project `requirements.txt` file. Astro Runtime 3.x images don't include this package by default.
1. Create a new Datadog API key or copy an existing API key. See [API and Application Keys](https://docs.datadoghq.com/account_management/api-app-keys/).
2. In the Astro UI, click **Deployments**, then select the Astro Deployment for which you want to export metrics.
3. Create a new [environment variable](/docs/astro/manage-env-vars#use-the-astro-ui) in your Deployment with the Datadog API key from step 1:
* **Key:** `DATADOG_API_KEY`
* **Value:** ``.
Select the **Secret?** checkbox. This ensures that your Datadog API key is saved securely and is not available to Workspace users in plain text.
4. (Optional) Add the following environment variable if your organization doesn't use the default Datadog site `datadoghq.com`:
* **Key:** `DATADOG_SITE`
* **Value:** ``
5. (Optional) Add the following environment variables to create [custom Datadog tags](https://docs.datadoghq.com/getting_started/tagging/) associated with your Deployment:
* **Key 1**: `AIRFLOW__METRICS__STATSD_DATADOG_ENABLED`
* **Value 1**: `True`
* **Key 2**: `AIRFLOW__METRICS__STATSD_DATADOG_TAGS`
* **Value 2**: `:,:`
6. Click **Save variable**.
After you complete this setup, Astro automatically launches a sidecar container in your Deployment that runs [DogStatsD](https://docs.datadoghq.com/developers/dogstatsd/?tab=hostagent). This container works with your Deployment's existing infrastructure to export Airflow metrics to the Datadog instance associated with your API key.
For [Remote Execution](/docs/astro/remote-execution-configure-agents) Deployments, you must manually configure a sidecar container with DogStatsD to export Airflow metrics for Remote Execution Agent components such as the triggerer, worker, and dag processor. This is because the [Datadog Agent's Airflow integration](https://docs.datadoghq.com/integrations/airflow/?tab=host#configure-datadog-agent-airflow-integration) does not yet support Airflow 3. You can specify the sidecar container details using `extraContainers` in the Remote Execution Agent's `values.yaml` Helm chart.
### View metrics in Datadog
1. In the Datadog UI, go to **Metrics** > **Summary**.
2. Search for metrics starting with `airflow` and open any Airflow metric.
3. In the **Tags** table, check the values for the `namespace` tag key. The namespaces of the Deployments you configured to export logs should appear as tag values.
To check the health of a Deployment's DogStatsD container, open the `datadog.dogstatsd.running` metric in the Datadog UI. If the Deployment's namespace appears under the metric's `host` tag key, its DogStatsD container is healthy and exporting metrics to Datadog.
# Export metrics from Astro
Source: https://astronomer.io/docs/astro/export-metrics
Export Airflow infrastructure and task metrics from Astro to any Prometheus-compatible monitoring system using the Universal Metrics Exporter.
You can export comprehensive metrics about your Apache Airflow usage on Astro directly to any third-party monitoring and alerting system using the Universal Metrics Exporter. This gives you unlimited access to all infrastructure metrics that are available to Astronomer and allows you to use your preferred observability tooling, such as Grafana or CloudWatch.
While [Deployment Analytics](/docs/astro/deployment-metrics), [Deployment health incidents](/docs/astro/deployment-health-incidents), and [exporting metrics and logs to Datadog](/docs/astro/export-datadog) on Astro can all help you understand your Airflow usage and infrastructure resource consumption, the Universal Metrics Exporter is additionally valuable because it:
* Gives you access to both Kubernetes-level infrastructure metrics as well as task-level execution information specific to Apache Airflow.
* Provides metrics that aren't available to [Datadog's supported Airflow metrics](https://docs.datadoghq.com/integrations/airflow/?tab=host#data-collected).
* Uses the [Prometheus data model](https://prometheus.io/docs/concepts/data_model/) format using the remote-write capability, making it flexible and easy to use.
* Allows you to configure a metrics export at the per-Deployment level or at the Workspace level.
* Enables you to customize your observability experience with your tooling and create custom dashboards or alerts that aren't currently available in Astro.
* Offers a way to add custom metadata as labels to your exported metrics or HTTP request headers.
You can use this information to right-size Astro and Celery workers, optimize your usage of the Kubernetes executor, and stay informed about task execution status.
## Metric categories
There are two categories of metrics that you can export using the Universal Metrics Exporter:
* Airflow application level metrics
* Infrastructure level metrics
Both application and infrastructure metrics have metadata labels associated with them. The following list shows the default standard set of labels that Astro attaches to each metric:
* `cloud_provider`
* `cloud_region`
* `cluster_organization_id`
* `clusterId` (Deployments on Dedicated clusters only)
* `container`
* `namespace`
* `pod`
* `deploymentId`
* `organizationId`
* `workspaceId`
Some metrics additionally include labels that are specific and unique to that metric. Use these metadata labels to identify each individual metric with its corresponding environment in Astro.
### Custom metadata
In addition to the default metadata included by Astro with your metrics, you can also add **Custom headers** and **Custom labels** to your metrics exports.
* Custom headers add key-value pairs to the HTTP request made by Astro to your Prometheus server.
* Custom labels add key-value pairs to the export metadata, so you can filter your metrics downstream.
### Airflow application metrics
Airflow application metrics are defined by Apache Airflow and describe the health, success, and performance of the Dags that Airflow orchestrates and executes. Examples include task instance failure counts, scheduler heartbeat counts, pool slot utilization, and Dag run durations.
Astro normalizes the StatsD-format metrics that Airflow emits, then exports them to your Prometheus endpoint. For the full list of supported metrics, the Prometheus labels available on each, and how each Astro metric name maps to its upstream Airflow name, see the [Metrics reference](/docs/astro/export-metrics-reference#airflow-application-metrics).
### Infrastructure metrics
Infrastructure metrics describe the resource usage, health, and performance of the Kubernetes Pods that run each Airflow component. Use them to track CPU, memory, storage, and Pod lifecycle status across your Deployment. For the full list of supported infrastructure metrics, see the [Metrics reference](/docs/astro/export-metrics-reference#infrastructure-metrics).
## Prerequisites
* Supported Auth: Bearer token or license key, username and password, SigV4Authorization (AWS Deployments only), or custom HTTP header(s) of your target data observability server *(Optional)*
* A Prometheus data endpoint
* Network connectivity between your Astro resources and Prometheus endpoint
## Set up your Prometheus endpoint
The following list includes the setup instructions of different, commonly used Prometheus endpoints. Use these resources to set up your observability tools to receive metrics exports from Astro.
* [Chronosphere](https://docs.chronosphere.io/ingest/metrics-traces/collector/configure/prometheus-backend)
* [Coralogix](https://coralogix.com/docs/prometheus/)
* [Cribl](https://docs.cribl.io/stream/4.2/sources-prometheus-remote-write/)
* [Elastic](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-metricset-prometheus-remote_write.html)
* [Grafana Cloud](https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/#send-data-from-a-prometheus-instance)
* [Logz.io](https://docs.logz.io/docs/shipping/other/prometheus-remote-write/)
* [New Relic](https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/install-configure-remote-write/set-your-prometheus-remote-write-integration/)
* [Sysdig](https://docs.sysdig.com/en/sysdig-monitor/install-prometheus-remote-write/)
* [Prometheus](https://prometheus.io/docs/prometheus/latest/feature_flags/#remote-write-receiver)
## Enable metrics export
You can enable metrics export at both the Workspace and Deployment level.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
### Workspace metrics
1. In the Astro UI, go to **Environment** > **Metrics Exports**.
2. Click **+ New Metric Export** to create a new export connection.
3. Enter the required information for your export, the **Name** and **Endpoint**.
For the endpoint, you might need to use a format like `http://prometheus./api/v1/write`
4. (Optional) Click **More Options** to add additional information for your endpoint:
* **Authentication Type** - **None**, **Basic Authentication**, **Bearer Authentication**, or **SigV4Authorization**. **SigV4Authorization** is available only for AWS Deployments on dedicated clusters and enables you to use IAM role-based authentication for metrics export.
* If you select **SigV4Authorization**, you must configure a trust policy that allows Astro to assume an IAM role in your AWS account. You can view and copy this trust policy from the **Trust Policies** tab.
* **Token** - Bearer token or license key for your Prometheus endpoint for bearer authentication, if needed.
* **Username** and **Password** - Credentials for basic authentication, if needed.
* **AWS Role** - IAM role that Astro assumes to communicate with your Amazon Managed Prometheus.
* **Region** - AWS region of the Amazon Managed Prometheus.
* Custom **Headers** - Add a **Name** and **Value** pair that can be sent to your server as part of the HTTP request with each remote write. If you add a custom header, any default values are overwritten by your custom configuration. You can add Deployment-specific labels when configuring **Deployment metrics**.
* Custom **Labels** - Add a **Name** and **Value** pair that can be sent to your server. You can add Deployment-specific labels when configuring **Deployment metrics**.
5. Click **Create metrics export**.
6. (Optional) Allow all Deployments to link to this metrics export configuration. See [Link metrics export](#share-metrics-exports-across-deployments).
1. In the Astro UI, select **Environment** on the sidebar menu.
2. Click the **Metrics Export** tab to configure your metrics export.
3. Click **+ Metrics Export** to create a new export connection.
4. Enter the required information for your export, the **Name** and **Endpoint**.
For the endpoint, you might need to use a format like `http://prometheus./api/v1/write`
5. (Optional) Click **More Options** to add additional information for your endpoint:
* **Authentication Type** - **None**, **Basic Authentication**, **Bearer Authentication**, or **SigV4Authorization**. **SigV4Authorization** is available only for AWS Deployments on dedicated clusters and enables you to use IAM role-based authentication for metrics export.
* If you select **SigV4Authorization**, you must configure a trust policy that allows Astro to assume an IAM role in your AWS account. You can view and copy this trust policy from the **Trust Policies** tab.
* **Token** - Bearer token or license key for your Prometheus endpoint for bearer authentication, if needed.
* **Username** and **Password** - Credentials for basic authentication, if needed.
* **AWS Role** - IAM role that Astro assumes to communicate with your Amazon Managed Prometheus.
* **Region** - AWS region of the Amazon Managed Prometheus.
* Custom **Headers** - Add a **Name** and **Value** pair that can be sent to your server as part of the HTTP request with each remote write. If you add a custom header, any default values are overwritten by your custom configuration. You can add Deployment-specific labels when configuring **Deployment metrics**.
* Custom **Labels** - Add a **Name** and **Value** pair that can be sent to your server. You can add Deployment-specific labels when configuring **Deployment metrics**.
6. Click **Create metrics export**.
7. (Optional) Allow all Deployments to link to this metrics export configuration. See [Link metrics export](#share-metrics-exports-across-deployments).
### Deployment metrics
1. In the Astro UI, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Toggle to **Metrics Exports**.
3. Click **+ New Metric Export** to configure a new export connection.
4. Enter the required information for your export, the **Name** and **Endpoint**.
For the endpoint, you might need to use a format like `http://prometheus./api/v1/write`
5. (Optional) Click **More Options** to add additional information for your endpoint:
* **Authentication Type** - **None**, **Basic Authentication**, **Bearer Authentication**, or **SigV4Authorization**. **SigV4Authorization** is available only for AWS Deployments on dedicated clusters and enables you to use IAM role-based authentication for metrics export.
* If you select **SigV4Authorization**, you must configure a trust policy that allows Astro to assume an IAM role in your AWS account. You can view and copy this trust policy from the **Trust Policies** tab.
* **Token** - Bearer token or license key for your Prometheus endpoint for bearer authentication, if needed.
* **Username** and **Password** - Credentials for basic authentication, if needed.
* **AWS Role** - IAM role that Astro assumes to communicate with your Amazon Managed Prometheus.
* **Region** - AWS region of the Amazon Managed Prometheus.
* Custom **Headers** - Add a **Name** and **Value** pair that can be sent to your server with as part of the HTTP request with each remote write. If you add a custom header, any default values or values configured at the Workspace level are overwritten by your custom configuration.
* Custom **Labels** - Add a **Name** and **Value** pair that can be sent to your server. You can add Deployment-specific labels when configuring **Deployment metrics**.
6. Click **Create metrics export**.
1. In the Astro UI, select a Workspace, click **Deployments**, select a Deployment, then click the **Environment** tab.
2. Toggle to **Metrics Exports**.
3. Click **+ Metrics Export** to configure a new export connection.
4. Enter the required information for your export, the **Name** and **Endpoint**.
For the endpoint, you might need to use a format like `http://prometheus./api/v1/write`
5. (Optional) Click **More Options** to add additional information for your endpoint:
* **Authentication Type** - **None**, **Basic Authentication**, **Bearer Authentication**, or **SigV4Authorization**. **SigV4Authorization** is available only for AWS Deployments on dedicated clusters and enables you to use IAM role-based authentication for metrics export.
* If you select **SigV4Authorization**, you must configure a trust policy that allows Astro to assume an IAM role in your AWS account. You can view and copy this trust policy from the **Trust Policies** tab.
* **Token** - Bearer token or license key for your Prometheus endpoint for bearer authentication, if needed.
* **Username** and **Password** - Credentials for basic authentication, if needed.
* **AWS Role** - IAM role that Astro assumes to communicate with your Amazon Managed Prometheus.
* **Region** - AWS region of the Amazon Managed Prometheus.
* Custom **Headers** - Add a **Name** and **Value** pair that can be sent to your server with as part of the HTTP request with each remote write. If you add a custom header, any default values or values configured at the Workspace level are overwritten by your custom configuration.
* Custom **Labels** - Add a **Name** and **Value** pair that can be sent to your server. You can add Deployment-specific labels when configuring **Deployment metrics**.
6. Click **Create metrics export**.
If you successfully connected your metrics export to your observability service endpoint, after five minutes, your Astro metrics begin to populate in your observability service. If the connection has issues, you see the error log messages in the **Error Logs** tab.
### View SigV4Authorization trust policy
If you're using **SigV4Authorization** to authenticate your Metrics Export for AWS-based Deployments, you must configure your Amazon Managed Prometheus endpoint with a trust policy that allows Astro to assume an IAM role.
You can view and copy this trust policy from the **Trust Policies** tab of the Metrics Export.
## Share metrics exports across Deployments
You can configure Astro to link Workspace-level metrics exports to all Deployments in the Workspace by default.
This is useful, for example, when you need to configure a metrics export for development environments that all Deployments in a Workspace should start with. Then, when you create new Deployments, they automatically have a default metrics export configuration to your development resources.
When you're ready to move your Deployments' metrics exports to production configurations, you can either replace the metrics export or [override the configuration](#override-configuration-fields) values with your production resource information.
If you change the setting from **Restricted** to **Linked to all Deployments**, Astro respects any metrics exports fields that you might have configured for existing linked Deployments.
1. In the Astro UI, go to **Environment** > **Metrics Exports**.
2. Click the name of the export target that you want to add per-Deployment field overrides to.
3. Click **Deployment Sharing** and toggle the setting to choose either:
* **Restricted**: Only share individually to Deployments.
* **Linked to all Deployments**: Link to all current and future Deployments in this Workspace.
4. (Optional) Change the default field values.
5. Click **Update metrics export** to save.
## Override configuration fields
If you create a metrics export at the Workspace level and link it to a Deployment, you can later edit the endpoint within the Deployment to specify field overrides. When you override a field, you specify values that you want to use for a one Deployment, but not for others. This way, you can configure a metrics export for a single time, but still have the flexibility to customize it at the Deployment level.
For example, you might have created a metrics connection to a dev or internal observability endpoint, and then later you can add field overrides to specify production details you want each Deployment to use.
1. In the Astro UI, go to **Environment** > **Metrics Exports**.
2. Click the metrics export that you want to add per-Deployment field overrides to.
3. (Optional) Click **Deployment Sharing** and choose if you want to **Restrict** or **Link to all Deployments**. You can also change the default field values. Click **Update metrics export** to save.
4. Click **Edit** to open the metrics export configurations for a specific linked Deployment.
5. Add the override values to the fields you want to edit. You might need to open **More options** to find the full list of available fields.
6. Click **Update metrics export**.
## Example: Grafana Cloud dashboard
The [Astronomer Docs resources repository](https://github.com/astronomer/astronomer-docs-resources/tree/main/astro/metrics-export/grafana-cloud) includes two example dashboard configuration files for [Grafana Cloud](https://grafana.com/products/cloud/): `grafana-cloud-dash.json` for StatsD-based metrics and `grafana-cloud-dash-otel.json` for OpenTelemetry-based metrics on Astro Runtime 3.0 or later.
This configuration file allows you to create a dashboard that provides an at-a-glance view of your Astro resources and task execution status. The following image shows an example of the **Scheduler** dashboard view:
Or you can view details about resources like your **Workers**, such as in the following image.
# Universal Metrics Exporter metrics reference
Source: https://astronomer.io/docs/astro/export-metrics-reference
Complete list of Airflow application and infrastructure metrics that the Universal Metrics Exporter exports from Astro.
This document lists every metric that Astro exports through the [Universal Metrics Exporter](/docs/astro/export-metrics). Use this reference to identify which metrics are available, the Prometheus labels you can query against, and how each Astro metric name maps to its upstream Apache Airflow name.
Airflow metrics for Dags or tasks with non-ASCII characters in their IDs are not supported and are not exported. Ensure all Dag IDs, task IDs, and TaskGroup IDs contain only ASCII characters (`A–Z`, `a–z`, `0–9`, `_`, `-`, `.`).
Astro exports two categories of metrics:
* Airflow application metrics describe the health, success, and performance of Dag execution. Astro normalizes these from the StatsD format that Airflow emits before exporting them to your Prometheus endpoint.
* Infrastructure metrics describe the resource usage and lifecycle health of the Kubernetes Pods that run each Airflow component.
Astro doesn't export metrics outside of these tables. The mapping configuration drops any metric that doesn't match a rule.
## How Astro normalizes Airflow metrics
Astro applies the following transformations to Airflow metrics before they reach your Prometheus endpoint. For the source-of-truth mapping rules, see the [Astro StatsD mappings file](https://github.com/astronomer/ap-vendor/blob/main/statsd-exporter/include/mappings-gen2.yml).
* StatsD names become Prometheus names. Astro replaces dots with underscores. For example, `airflow.dag_processing.import_errors` becomes `airflow_dag_processing_import_errors`.
* Variable name parts become Prometheus labels. High-cardinality identifiers move out of the metric name and into labels so that one metric name covers many dimensions. For example, Astro exports the Airflow metric `airflow.dag...duration` as `airflow_task_duration` with `dag_id` and `task_id` labels.
* Legacy and current Airflow names both flow through. Astro maps metrics that Airflow renamed across versions under both their legacy and current names so that Dags running on different Astro Runtime versions both emit. For example, both `zombies_killed` (Airflow 2.x) and `task_instances_without_heartbeats_killed` (Airflow 3 and later) export when Airflow emits them.
* Astro adds default metadata labels. Every exported metric carries the standard Astro labels documented in [Export metrics](/docs/astro/export-metrics#metric-categories), such as `deploymentId`, `organizationId`, and `workspaceId`.
Dag IDs, task IDs, and TaskGroup IDs flow into metric names, so they must contain only ASCII characters (`A–Z`, `a–z`, `0–9`, `_`, `-`, `.`). Airflow's own validation accepts Unicode characters such as accented letters (`ç`, `ã`, `ö`), but metric backends don't. StatsD silently drops metrics whose names contain non-ASCII characters, and OpenTelemetry rejects them as invalid under the [instrument name syntax specification](https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-name-syntax). The allowed characters for StatsD metric names are defined in [Airflow's metric validation source](https://github.com/apache/airflow/blob/main/shared/observability/src/airflow_shared/observability/metrics/validators.py).
Audit your Dag files for non-ASCII identifiers before you enable metrics:
```sh wrap theme={null}
grep -rn '[^\x00-\x7F]' dags/ --include="*.py"
```
Rename any non-ASCII IDs to ASCII equivalents so that all metrics export correctly.
## Airflow application metrics
Apache Airflow classifies metrics into three types based on how the value behaves over time: counters, gauges, and timers. The following tables use Airflow's classification. For background on each type, see the [Apache Airflow metrics reference](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html).
### Counters
A counter records the cumulative count of events that occur over time, such as task failures or scheduler heartbeats.
| Name | Airflow name | Labels | Description |
| -------------------------------------------------- | ----------------------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `airflow_job_start` | `_start` | `job_name` | Started jobs, such as `SchedulerJob` or `LocalTaskJob`. |
| `airflow_job_end` | `_end` | `job_name` | Completed jobs. |
| `airflow_job_heartbeat_failure` | `_heartbeat_failure` | `job_name` | Heartbeat failures for a given job type. |
| `airflow_operator_successes` | `operator_successes_` | `operator` | Successful executions of a given operator type. |
| `airflow_operator_failures` | `operator_failures_` | `operator` | Failures of a given operator type. |
| `airflow_scheduler_heartbeat` | `scheduler_heartbeat` | `type` | Scheduler heartbeat occurrences. Astro sets the `type` label to `counter` so dashboards can distinguish counter-typed values from older gauge-typed emissions. |
| `airflow_dag_processor_heartbeat` | `dag_processor_heartbeat` | None | Standalone Dag processor heartbeat occurrences. Available on Airflow 3 and later. |
| `airflow_triggerer_heartbeat` | `triggerer_heartbeat` | None | Triggerer heartbeat occurrences. |
| `airflow_ti_start` | `ti.start..` | `dag_id`, `task_id` | Task instance initiations within a Dag. |
| `airflow_ti_finish` | `ti.finish...` | `dag_id`, `task_id`, `state` | Task instance completions, broken out by terminal state. |
| `airflow_ti_failures` | `ti_failures` | None | Total task instance failures across all Dags. |
| `airflow_ti_successes` | `ti_successes` | None | Total task instance successes across all Dags. |
| `airflow_task_instance_created` | `task_instance_created_` | `task_type` | Task instances created, broken out by operator type. |
| `airflow_scheduler_tasks_killed_externally` | `scheduler.tasks.killed_externally` | None | Tasks terminated by external processes. |
| `airflow_zombies_killed` | `zombies_killed` | None | Zombie task instances terminated by the scheduler. Replaced by `airflow_task_instances_without_heartbeats_killed` on Airflow 3 and later. |
| `airflow_task_instances_without_heartbeats_killed` | `task_instances_without_heartbeats_killed` | None | Task instances terminated due to missing heartbeats. Replaces `airflow_zombies_killed` on Airflow 3 and later. |
| `airflow_triggers_succeeded` | `triggers.succeeded` | None | Triggers that successfully fired at least one event. |
| `airflow_triggers_failed` | `triggers.failed` | None | Triggers that failed before firing. |
| `airflow_dataset_updates` | `dataset.updates` | None | Dataset updates. Replaced by `airflow_asset_updates` on Airflow 3 and later. |
| `airflow_dataset_triggered_dagruns` | `dataset.triggered_dagruns` | None | Dag runs triggered by dataset updates. Replaced by `airflow_asset_triggered_dagruns` on Airflow 3 and later. |
| `airflow_asset_updates` | `asset.updates` | None | Asset modifications. Available on Airflow 3 and later; replaces `airflow_dataset_updates`. |
| `airflow_asset_triggered_dagruns` | `asset.triggered_dagruns` | None | Dag runs initiated by asset updates. Available on Airflow 3 and later; replaces `airflow_dataset_triggered_dagruns`. |
| `airflow_ol_emit_failed` | `ol.emit.failed` | None | Failed attempts to emit OpenLineage events. |
| `airflow_astro_logging_write_failed` | `airflow.astro_logging..write.failed` | `provider` | Log-write failures from the `astronomer-providers-logging` package, broken out by provider. |
| `astro_bundle_backend_refresh_success` | Astronomer only | `instance`, `mount_path` | Successful refreshes of an Astro bundle backend mount. |
| `astro_bundle_backend_refresh_failure` | Astronomer only | `instance`, `mount_path` | Failed refreshes of an Astro bundle backend mount. |
| `astro_bundle_backend_download_urls_success` | Astronomer only | `instance`, `mount_path` | Successful download URL fetches by the Astro bundle backend. |
| `astro_bundle_backend_download_urls_failure` | Astronomer only | `instance`, `mount_path` | Failed download URL fetches by the Astro bundle backend. |
### Gauges
A gauge measures a point-in-time value that can rise and fall, such as the number of running tasks or open executor slots.
| Name | Airflow name | Labels | Description |
| --------------------------------------------- | ------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `airflow_dagbag_size` | `dagbag_size` | None | Number of Dags found during the last scheduler scan. |
| `airflow_dag_processing_import_errors` | `dag_processing.import_errors` | None | Number of errors encountered when parsing Dag files. |
| `airflow_dag_processing_total_parse_time` | `dag_processing.total_parse_time` | None | Total seconds spent scanning and importing Dag files in the most recent cycle. |
| `airflow_dag_processing_last_run_seconds_ago` | `dag_processing.last_run.seconds_ago.` | `dag_file` | Seconds elapsed since the named Dag file was last evaluated. |
| `airflow_executor_open_slots` | `executor.open_slots` | None | Available execution slots on the executor. |
| `airflow_executor_queued_tasks` | `executor.queued_tasks` | None | Tasks awaiting execution on the executor. |
| `airflow_executor_running_tasks` | `executor.running_tasks` | None | Tasks currently executing on the executor. |
| `airflow_pool_open_slots` | `pool.open_slots.` | `pool` | Open slots in a named pool. |
| `airflow_pool_used_slots` | `pool.used_slots.` | `pool` | Slots currently in use in a named pool. Available on Airflow 2.x. |
| `airflow_pool_queued_slots` | `pool.queued_slots.` | `pool` | Slots held by queued tasks in a named pool. |
| `airflow_pool_running_slots` | `pool.running_slots.` | `pool` | Slots held by running tasks in a named pool. |
| `airflow_pool_deferred_slots` | `pool.deferred_slots.` | `pool` | Slots held by deferred tasks in a named pool. |
| `airflow_pool_scheduled_slots` | `pool.scheduled_slots.` | `pool` | Slots held by scheduled tasks in a named pool. |
| `airflow_pool_starving_tasks` | `pool.starving_tasks.` | `pool` | Tasks in a named pool that can't proceed because pool resources are exhausted. |
| `airflow_scheduler_tasks_running` | `scheduler.tasks.running` | None | Tasks currently running according to the scheduler. Available on Airflow 2.x. |
| `airflow_scheduler_tasks_starving` | `scheduler.tasks.starving` | None | Tasks the scheduler can't run because pool resources are exhausted. |
| `airflow_triggers_running` | `triggers.running` | None | Triggers currently executing on a triggerer host. |
| `airflow_dataset_orphaned` | `dataset.orphaned` | None | Datasets no longer referenced by any Dag. Replaced by `airflow_asset_orphaned` on Airflow 3 and later. |
| `airflow_asset_orphaned` | `asset.orphaned` | None | Assets no longer referenced by any Dag schedule or task output. Available on Airflow 3 and later. |
| `airflow_runner_resources` | `airflow.executor.runner_resources.` | `resource` | Percentage of a resource in use on an executor runner. Values for the `resource` label include `slots`, `cpu`, and `memory`. |
| `airflow_executor_task_resources` | `airflow.executor.task_resources.` | `resource_stat` | Task-level resource statistics. Values for the `resource_stat` label include `memory_rss` and `cpu_times_system`. |
| `astro_bundle_backend_num_files` | Astronomer only | `instance`, `mount_path`, `le` | Histogram of file counts in Astro bundle backend mounts. |
| `astro_bundle_backend_tarball_size` | Astronomer only | `instance`, `mount_path`, `le` | Histogram of tarball sizes downloaded by the Astro bundle backend. |
### Timers
A timer measures the duration of an event, such as how long a task or Dag run takes to complete. Astro exports timer values in milliseconds.
| Name | Airflow name | Labels | Description |
| -------------------------------------------- | ------------------------------------------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| `airflow_task_duration` | `dag...duration` | `dag_id`, `task_id` | Total duration of a task instance. |
| `airflow_dagrun_duration` | `dagrun.duration.success.` | `dag_id` | Duration of a successful Dag run. |
| `airflow_dagrun_failed` | `dagrun.duration.failed.` | `dag_id` | Duration of a failed Dag run. |
| `airflow_dagrun_schedule_delay` | `dagrun.schedule_delay.` | `dag_id` | Delay between the scheduled and actual start of a Dag run. |
| `airflow_dagrun_first_task_scheduling_delay` | `dagrun..first_task_scheduling_delay` | `dag_id` | Delay between a Dag run's start and the scheduling of its first task. |
| `airflow_dagrun_dependency_check` | `dagrun.dependency-check`, `dagrun.dependency-check.` | `dag_id` | Time required to evaluate Dag run dependencies. The `dag_id` label is present only when Airflow emits the Dag-scoped form. |
| `airflow_dag_processing_last_duration` | `dag_processing.last_duration.` | `dag_file` | Time required to parse the named Dag file in the most recent cycle. |
| `airflow_dag_processing_last_runtime` | `dag_processing.last_runtime.` | `dag_file` | Legacy name for `airflow_dag_processing_last_duration`. Astro retains this mapping so older Airflow versions still emit. |
| `airflow_collect_db_dags` | `collect_db_dags` | None | Time spent fetching serialized Dags from the metadata database. |
| `airflow_ol_emit_attempts` | `ol.emit.attempts` | None | Time consumed by OpenLineage event emission attempts. |
| `astro_bundle_backend_download_time` | Astronomer only | `instance`, `mount_path`, `le` | Histogram of download durations for Astro bundle backend tarballs. |
| `astro_bundle_backend_extract_time` | Astronomer only | `instance`, `mount_path`, `le` | Histogram of extract durations for Astro bundle backend tarballs. |
### Astro event scheduler metrics
The Astro event scheduler emits metrics under the `airflow.astro_event_scheduler.*` namespace. Astro strips the `airflow.` prefix and exports each metric as `astro_event_scheduler_`. Because this is a catch-all mapping, the specific metric names emitted depend on the version of Astro Runtime running in your Deployment.
## Infrastructure metrics
Infrastructure metrics describe the Kubernetes Pods that run each Airflow component. Use them to track CPU, memory, storage, and lifecycle health.
| Name | Description |
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `container_cpu_usage_seconds_total` | CPU usage of each container. |
| `container_memory_working_set_bytes` | Memory usage of each container. |
| `kubelet_stats_ephemeral_storage_pod_usage` | Ephemeral storage usage of each Pod. |
| `kube_pod_status_*` | Kubernetes Pod status. |
| `kube_pod_labels` | Kubernetes Pod labels. |
| `kube_pod_container_resource_limits` | CPU, memory, and storage limits for Celery workers, Kubernetes executors, `KubernetesPodOperator` Pods, the scheduler, and the Dag processor. |
| `kube_pod_container_status_terminated_reason` | Reason a Kubernetes container terminated. |
| `kube_resourcequota` | Resource quota usage and limits for namespaces in the cluster. |
# Export logs to a Secondary GCS Bucket
Source: https://astronomer.io/docs/astro/export-secondary-gcs-bucket
Configure your Deployment to forward Airflow task logs to a secondary GCS bucket in GCP.
## Export logs to a Secondary GCS Bucket
By forwarding Airflow task logs from your Astro Deployment to **an additional, customer‑managed GCS bucket**, you can keep redundant copies of your execution history, integrate with existing log‑processing pipelines, and satisfy compliance or retention requirements that extend beyond the built‑in Astro logs.
## Prerequisites
* Your Deployment must run **Astro Runtime 11.7.0** or later. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
* Your image must include `astronomer-providers-logging==1.6.4` or later. The secondary GCS logging feature was introduced in this version.
* You need a GCP account where you can create a GCP bucket and IAM resources.
* A role with the [minimum required permissions](#minimum-required-permissions)
### Minimum Required Permissions
For all authentication methods, the service account or identity needs the following minimum permissions on the GCS bucket:
* `storage.objects.list`: List matching log files
* `storage.objects.create`: To create new log files
* `storage.objects.get`: To read existing log files (for append operations)
* `storage.objects.update`: To update existing log files
These permissions are included in the predefined `roles/storage.objectUser` role, or you can create a custom role with just these specific permissions.
## Overview of configuration options
There are three methods to configure your Astro deployment to write logs to a secondary GCS bucket:
1. **Customer‑provided Workload Identity**: Recommended if you already use this mechanism for other GCP services.
2. **Service Account Impersonation**: Use this approach if you want to use an existing service account which is different than your Deployment's workload identity.
3. **Astro-provided Workload Identity**: Use this approach if you do not have an existing service account that your Deployment can impersonate.
The following environment variables are supported by this feature:
| Variable | Required | Example value |
| -------------------------------------------------------- | -------- | ---------------------------------------------------------------- |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_ENABLED` | Yes | `true` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_BASE_LOG_FOLDER` | Yes | `gs://your-bucket-name/logs` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_IMPERSONATION_CHAIN` | No | `target-service-account@YOUR_PROJECT_ID.iam.gserviceaccount.com` |
### Option 1: Customer‑Provided Workload Identity
This approach uses [Google Cloud Workload Identity](https://cloud.google.com/kubernetes-engine/multi-cloud/docs/attached/eks/concepts/workload-identity) to allow your Astro deployment to authenticate with Google Cloud using its Kubernetes service account identity.
1. [Attach a service account to your Astro Deployment](/docs/astro/authorize-deployments-to-your-cloud#attach-a-service-account-to-your-deployment)
2. Set the following environment variables in the Deployment:
```text wrap theme={null}
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_ENABLED=true
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_BASE_LOG_FOLDER="gs://your-bucket-name/logs"
```
### Option 2: Service Account Impersonation
Use this approach if you want to use an existing service account which is different than your Deployment's workload identity.
1. Follow the steps to setup [service account impersonation](/docs/astro/authorize-deployments-to-your-cloud#alternative-setup-authorize-your-deployment-through-gcp-service-account-impersonation), which allows your Astro deployment to impersonate a service account with the necessary permissions.
2. Set the following environment variables in the Deployment:
```text wrap theme={null}
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_ENABLED=true
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_BASE_LOG_FOLDER="gs://your-bucket-name/logs"
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_IMPERSONATION_CHAIN="target-service-account@YOUR_PROJECT_ID.iam.gserviceaccount.com"
```
### Option 3: Astro-provided Workload Identity
Use this approach if you do not have an existing service account that your deployment can impersonate.
1. Follow instructions to [grant an IAM role to your Deployment Workload Identity](/docs/astro/authorize-deployments-to-your-cloud#alternative-setup-grant-an-iam-role-to-your-deployment-workload-identity).
2. Set the following environment variables in the Deployment:
```text wrap theme={null}
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_ENABLED=true
AIRFLOW__ASTRO_SECONDARY_LOGS__GCS_BASE_LOG_FOLDER="gs://your-bucket-name/logs"
```
## Troubleshooting
If you encounter issues with logging to the secondary GCS bucket:
1. Check that the environment variables are correctly set in your Astro deployment
2. Verify that your service account or Workload Identity has the necessary permissions
3. For Workload Identity Federation, ensure the Kubernetes service account annotation is correctly configured
4. For impersonation, check that the impersonation chain is correctly configured and the source identity has token creator permissions
5. Check for any errors in your Airflow logs related to GCS authentication or permissions
6. Test your authentication setup using the `gcloud` CLI or Google Cloud Console
If issues persist, contact Astronomer Support with the Deployment ID and any relevant error output.
# Export logs to a Secondary S3 Bucket
Source: https://astronomer.io/docs/astro/export-secondary-s3-bucket
Configure your Deployment to forward Airflow task logs to a secondary AWS S3 bucket.
## Export logs to a Secondary S3 Bucket
By forwarding Airflow task logs from your Astro Deployment to **an additional, customer‑managed S3 bucket**, you can keep redundant copies of your execution history, integrate with existing log‑processing pipelines, and satisfy compliance or retention requirements that extend beyond the built‑in Astro logs.
## Prerequisites
* Your Deployment must run **Astro Runtime 11.7.0** or later. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
* Your image must include `astronomer-providers-logging==1.6.2` or later. The secondary S3 logging feature was introduced in this version.
* You need an AWS account where you can create an S3 bucket and IAM resources.
## Overview of configuration options
Astro supports two ways to grant your Deployment permissions to write to the secondary bucket:
1. **Customer‑provided Workload Identity**: Recommended if you already use this mechanism for other AWS services.
2. **Assume Role**: Allows your Deployment to assume a dedicated IAM role that has access to the bucket.
Both options require the same base environment variables:
| Variable | Required | Example value |
| --------------------------------------------------- | -------- | -------------------------------------------------------------------- |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__S3_BUCKET_ENABLED` | Yes | `true` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__S3_BASE_LOG_FOLDER` | Yes | `s3://my‑bucket/logs` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__REGION` | | `us‑east‑1` (omit if bucket is in the same region as the Deployment) |
## Option 1 : Customer‑Provided Workload Identity
If your Deployment already uses a **customer‑managed AWS Workload Identity**, you can attach S3 write permissions directly to that role.
1. [Configure a Workload Identity](/docs/astro/authorize-deployments-to-your-cloud#setup) for the Deployment if you don’t have one yet.
2. Grant that identity permissions to write to the bucket. Example policy:
```json wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ExternalS3Policy",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::my-bucket",
"arn:aws:s3:::my-bucket/*"
]
}
]
}
```
3. Set the following environment variables in the Deployment:
```text wrap theme={null}
AIRFLOW__ASTRO_SECONDARY_LOGS__S3_BUCKET_ENABLED=true
AIRFLOW__ASTRO_SECONDARY_LOGS__S3_BASE_LOG_FOLDER="s3://my-bucket/logs"
# Optional if bucket is in the same region as the deployment
AIRFLOW__ASTRO_SECONDARY_LOGS__REGION="us-east-1"
```
## Option 2: Assume Role
With this approach, your Deployment’s existing identity **assumes a separate IAM role** that has write access to the bucket.
#### Additional variable
| Variable | Required | Example value |
| ----------------------------------------- | -------- | ------------------------------------------------------ |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__ROLE_ARN` | Yes | `arn:aws:iam::123456789012:role/SecondaryS3LoggerRole` |
1. Create an IAM role with S3 write permissions (same JSON policy as above).
2. Configure the role’s **trust relationship** to allow your Deployment to assume it:
```json wrap theme={null}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:role/astro-deployment-role"
},
"Action": "sts:AssumeRole"
}
]
}
```
3. Set the environment variables:
```text wrap theme={null}
AIRFLOW__ASTRO_SECONDARY_LOGS__S3_BUCKET_ENABLED=true
AIRFLOW__ASTRO_SECONDARY_LOGS__S3_BASE_LOG_FOLDER="s3://my-bucket/logs"
AIRFLOW__ASTRO_SECONDARY_LOGS__ROLE_ARN="arn:aws:iam::123456789012:role/SecondaryS3LoggerRole"
# Optional if bucket is in the same region
AIRFLOW__ASTRO_SECONDARY_LOGS__REGION="us-east-1"
```
## Troubleshooting
If task logs are not appearing in the bucket:
1. Confirm that all required environment variables are set exactly as documented.
2. Verify that the IAM role attached to the Deployment, or the assumed role, includes **`s3:PutObject`** for the bucket path.
3. Check the role’s **trust relationship** (Assume Role options only).
4. Inspect the deployment worker logs for external S3 logging-related errors. Ensure that the Worker is selected in the dropdown - the default is Scheduler
If issues persist, contact Astronomer Support with the Deployment ID and any relevant error output.
# Export logs to a Secondary WASB Container
Source: https://astronomer.io/docs/astro/export-secondary-wasb
Configure your Deployment to forward Airflow task logs to a secondary Azure Storage (WASB) container.
## Export logs to a Secondary WASB Container
By forwarding Airflow task logs from your Astro Deployment to **an additional, customer‑managed Azure Storage (WASB) container**, you can keep redundant copies of your execution history, integrate with existing log‑processing pipelines, and satisfy compliance or retention requirements that extend beyond the built‑in Astro logs.
## Prerequisites
* Your Deployment must run **Astro Runtime 11.7.0** or later. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
* Your image must include **`astronomer-providers-logging==1.5.4`** or later. The secondary WASB logging feature was introduced in this version.
* An Azure **Storage Account** with a **container** created to hold the logs.
* An Azure **Managed Identity** (or Service Principal) that has **read/write** access to the container.
## Required environment variables
| Variable | Description | Example |
| ----------------------------------------------------- | ------------------------------------------------ | ------------------------------------ |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_ENABLED` | Turn on secondary WASB logging | `true` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_TENANT_ID` | Azure AD tenant where the Managed Identity lives | `random‑86f1‑41af‑91ab‑2d7cd011db47` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_CLIENT_ID` | Client ID of the Managed Identity | `a1b2c3d4‑e5f6‑1234‑5678‑random` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_STORAGE_ACCOUNT` | Name of the Storage Account (without protocol) | `mystorageacct` |
| `AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_CONTAINER` | Name of the container where logs are stored | `airflow‑task‑logs` |
Add these [environment variables](/docs/astro/environment-variables) in the Deployment.
```text wrap theme={null}
AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_ENABLED=true
AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_TENANT_ID=""
AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_CLIENT_ID=""
AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_STORAGE_ACCOUNT=""
AIRFLOW__ASTRO_SECONDARY_LOGS__WASB_CONTAINER=""
```
## Step 1: Create Azure resources
1. [Create a Storage Account](https://learn.microsoft.com/azure/storage/common/storage-account-create?tabs=azure-portal).
2. Inside the account, create a **blob container** to hold the logs.
## Step 2: Configure Astro Workload Identity
Follow [Authorize Deployments to your Azure cloud](/docs/astro/authorize-deployments-to-your-cloud?tab=azure#setup) to assign a **Managed Identity** to the Deployment.
## Step 3: Grant storage permissions
In Azure, assign the Managed Identity the **Storage Blob Data Contributor** or equivalent scoped role to the Storage Account or container.
## Step 4: Add environment variables and redeploy
Set the [environment variables](/docs/astro/environment-variables) listed in [required environment variables](#required-environment-variables) and redeploy.
## Troubleshooting
If task logs do not appear in the container:
1. Confirm that **all required environment variables** are set and have no extra quotes or spaces.
2. Verify that the Managed Identity has **read/write access** to the Storage Account and container.
3. Check Deployment logs for authentication or authorization errors related to Azure.
4. Ensure the container exists, Astro will not create it automatically.
If issues persist, contact Astronomer Support with the Deployment ID and any relevant error output.
# Set up IP Access List on Astro
Source: https://astronomer.io/docs/astro/ip-access-list
Configure IP Access list to control the IP addresses from where your users can log in to Astro.
This is feature is only available if you are on the **Enterprise** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).
You can restrict which IP addresses or IP address ranges can access the Astro service for your specific Organization. By default, Astro allows users to access their Organization from unsecured networks. However, by creating an IP access list, if your organization uses a VPN or other mechanism that limits the IP addresses your users might have, you can restrict access to Astro based on the IP addresses that you define in the Astro UI.
After you enable the IP access list, users and user-privileged resources can only interact with Astro while using a network with a permitted IP address, whether by using the Astro UI or programmatically with Astro API or Airflow API requests.
## Prerequisites
* Organization Owner permissions
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Set up IP Access list
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **IP Access List**.
2. Click **+ New IP Address Range**.
3. Add the IP address range or ranges in CIDR format, and click **Add Address Range**
1. In the Astro UI, click **Organization Settings**. This opens the **General** Organization page.
2. Select **Access Management** and then select the **IP Access List** tab.
3. Click **+ IP Address Range**.
4. Add the IP Address range or ranges in CIDR format.
You must make sure that you include critical services in your IP range. These include:
* Make sure the first IP range you add is inclusive of the IP you are currently using, or you will be locked out of your Astro Organization.
* You must include the IP address of your identity provider (IdP), if you have one, or it will also be locked out.
## Restore access
Because the IP Access List limits access to the Astro UI only to specific IP addresses, you can't access the Astro UI if you're not connected to a corresponding VPN or authorized network.
To restore access for a user that is blocked, an Organization Owner needs to either:
* Disable the IP Access list setting by deleting the list or
* Add the specific blocked user's IP address to the IP Access list.
If you disable the IP Access List setting to resolve the user's access issue temporarily, remember to enable the setting again to maintain the IP address restrictions.
## Enhanced Support Access bypass
Enhanced Support Access is enabled by default for all Organizations to ensure faster, more effective assistance from the Astronomer Support team. It grants **Read-only** Admin access to your Organization’s details. If you have IP Access List enabled, Enhanced Support Access permits Astronomer Support to bypass the IP restriction and allows Astronomer Support to view your Organization details. Support can't make any changes to your Organization or resources.
See [Enhanced Support Access](/docs/astro/user-permissions#enhanced-support-access) for information about the permission scope and how to disable the feature.
# Configure tasks to run with the Kubernetes executor
Source: https://astronomer.io/docs/astro/kubernetes-executor
Learn how to configure the Pods that the Kubernetes executor runs your tasks in.
The Kubernetes executor runs each Airflow task in a dedicated Kubernetes [Pod](https://kubernetes.io/docs/concepts/workloads/pods/). On Astro, you can customize these Pods on a per-task basis using a `pod_override` configuration. If a task doesn't contain a `pod_override` configuration, it runs using the default Pod as configured in your Deployment resource settings.
This document describes how to configure individual task Pods for different use cases. To configure defaults for all Kubernetes executor task pods, see [Configure Kubernetes Pod resources](/docs/astro/deployment-resources#configure-kubernetes-pod-resources).
## Prerequisites
* An Astro Deployment using Astro Runtime version 8.1.0 or later.
If you use the Kubernetes executor on Astro, you can't change the [PYTHONPATH](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/modules_management.html) of your Astro project from its default value. If you do, the Kubernetes executor will be unable to read `airflow_local_settings.py` and will fail to start up new Pods.
## Customize a task's Kubernetes Pod
By default, Astro supports a maximum `KubernetesExecutor` Pod size of 43 vCPU and 86 GiB of memory. Astro can support Pod sizes up to 86 vCPU and 172 GiB of memory on request. Contact [Astro support](/docs/astro/astro-support) if you need to run larger jobs on `KubernetesExecutor`.While you can customize all values for a worker Pod, Astronomer does not recommend configuring complex Kubernetes infrastructure in your Pods, such as sidecars. These configurations have not been tested by Astronomer.
For each task running with the Kubernetes executor, you can customize its individual worker Pod and override the defaults used in Astro by configuring a `pod_override` file.
1. Add the following import to your dag file:
```python wrap theme={null}
from kubernetes.client import models as k8s
```
2. Add a `pod_override` configuration to the dag file containing the task. See the [`kubernetes-client`](https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Container.mdx) GitHub for a list of all possible settings you can include in the configuration.
3. Specify the `pod_override` in the task's parameters.
See the following example of a `pod_override` configuration.
### Example: Set CPU or memory limits and requests
You can request a specific amount of resources for a Kubernetes worker Pod so that a task always has enough resources to run successfully. When requesting resources, make sure that your requests don't exceed the resource limits in your Deployment's [max pod size](/docs/astro/deployment-resources#configure-kubernetes-pod-resources).
The following example shows how you can use a `pod_override` configuration in your dag code to request custom resources for a task:
```python expandable wrap theme={null}
import pendulum
import time
from airflow.models.dag import DAG
from airflow.decorators import task
from airflow.operators.bash import BashOperator
from airflow.example_dags.libs.helper import print_stuff
from kubernetes.client import models as k8s
k8s_exec_config_resource_requirements = {
"pod_override": k8s.V1Pod(
spec=k8s.V1PodSpec(
containers=[
k8s.V1Container(
name="base",
resources=k8s.V1ResourceRequirements(
requests={"cpu": 0.5, "memory": "1024Mi", "ephemeral-storage": "1Gi"},
limits={"cpu": 0.5, "memory": "1024Mi", "ephemeral-storage": "1Gi"}
)
)
]
)
)
}
with DAG(
dag_id="example_kubernetes_executor_pod_override_sources",
schedule=None,
start_date=pendulum.datetime(2023, 1, 1, tz="UTC"),
catchup=False
):
BashOperator(
task_id="bash_resource_requirements_override_example",
bash_command="echo hi",
executor_config=k8s_exec_config_resource_requirements
)
@task(executor_config=k8s_exec_config_resource_requirements)
def resource_requirements_override_example():
print_stuff()
time.sleep(60)
resource_requirements_override_example()
```
When this dag runs, it launches a Kubernetes Pod with exactly 0.5m of CPU and 1024Mi of memory, as long as that infrastructure is available in your Deployment. After the task finishes, the Pod terminates gracefully.
On Astro Hosted, Astro automatically sets resource requests equal to limits for KubernetesExecutor worker Pods. This ensures Pods receive a Kubernetes [Guaranteed Quality of Service (QoS) class](https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed), which prevents resource contention and eviction. Because Astro uses the limit values as both requests and limits, your Pods are billed based on the limits you configure, even if actual usage is lower. To avoid unexpected charges, set limits close to the resources your task requires. Check your [Billing and usage](/docs/astro/manage-billing) to view your resource use and associated charges.
## Use secret environment variables in worker Pods
On Astro Deployments, secret [environment variable](/docs/astro/environment-variables) values are stored in a Kubernetes secret called `env-secrets`. These environment variables are available to your worker Pods, and you can access them in your tasks just like any other environment variable. For example, you can use `os.environ[]` or `os.getenv(, None)` in your dag code to access the variable value.
However, if you can’t use Python, or you are using a pre-defined code that expects specific keys for environment variables, you must pull the secret value from `env-secrets` and mount it to the Pod running your task as a new Kubernetes Secret.
1. Add the following import to your dag file:
```python wrap theme={null}
from airflow.kubernetes.secret import Secret
```
2. Define a Kubernetes `Secret` in your dag instantiation using the following format:
```python wrap theme={null}
secret_env = Secret(deploy_type="env", deploy_target="", secret="env-secrets", key="")
namespace = conf.get("kubernetes", "NAMESPACE")
```
3. Specify the `Secret` in the `secret_key_ref` section of your `pod_override` configuration.
4. In the task where you want to use the secret value, add the following task-level argument:
```python wrap theme={null}
op_kwargs={
"env_name": secret_env.deploy_target
},
```
5. In the executable for the task, call the secret value using `os.environ[env_name]`.
In the following example, a secret named `MY_SECRET` is pulled from `env-secrets` and printed to logs.
```python expandable wrap theme={null}
import pendulum
from kubernetes.client import models as k8s
from airflow.configuration import conf
from airflow.kubernetes.secret import Secret
from airflow.models import DAG
from airflow.operators.python import PythonOperator
def print_env(env_name):
import os
print(os.environ[env_name])
with DAG(
dag_id="test-secret",
start_date=pendulum.datetime(2022, 1, 1, tz="UTC"),
end_date=pendulum.datetime(2022, 1, 5, tz="UTC"),
schedule="@once",
) as dag:
secret_env = Secret(deploy_type="env", deploy_target="MY_SECRET", secret="env-secrets", key="MY_SECRET")
namespace = conf.get("kubernetes", "NAMESPACE")
p = PythonOperator(
python_callable=print_env,
op_kwargs={
"env_name": secret_env.deploy_target
},
task_id="test-py-env",
executor_config={
"pod_override": k8s.V1Pod(
spec=k8s.V1PodSpec(
containers=[
k8s.V1Container(
name="base",
env=[
k8s.V1EnvVar(
name=secret_env.deploy_target,
value_from=k8s.V1EnvVarSource(
secret_key_ref=k8s.V1SecretKeySelector(name=secret_env.secret,
key=secret_env.key)
),
)
],
)
]
)
),
}
)
```
## See also
* [Configure Kubernetes Pod resources](/docs/astro/deployment-resources#configure-kubernetes-pod-resources)
* [How to use cluster ConfigMaps, Secrets, and Volumes with Pods](https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes/stable/operators.html#how-to-use-cluster-configmaps-secrets-and-volumes-with-pod)
* [Run the `KubernetesPodOperator` on Astro](/docs/astro/kubernetespodoperator)
* [Airflow Executors explained](/docs/learn/airflow-executors-explained)
# Lineage
Source: https://astronomer.io/docs/astro/lineage-graph
View lineage graph in Astro Observe.
Astro visualizes real-time lineage based on Airflow run metadata. You can view the lineage for a specific [data product](/docs/astro/create-data-products) or [asset](/docs/astro/assets-overview) to understand data dependencies and run history.
## View lineage
To view lineage, navigate to a [data product](/docs/astro/create-data-products) or [asset](/docs/astro/assets-overview) and click **Open Lineage**.
By default, the lineage graph displays dags, tasks, datasets, and tables that ran or were updated any time in the last 90 days. You can update this time range by changing the **Lineage captured from** filter in the top right of the lineage graph.
Click any asset to highlight its upstream and downstream dependencies in the graph and see asset metadata, like an **Event Timeline** of its run or update history and which **Data Products** the asset belongs to.
## Search and filter lineage
Use the controls to customize your view of the lineage graph:
* **Search**: Use the search box in the upper left of the graph to find specific assets by name.
* **Lineage captured from**: Determines which assets appear in the graph. Any asset with a run or update event in the selected time range will appear in the graph.
* **Hide Datasets**: Toggle to hide or show dataset nodes from the graph to reduce noise.
* **Highlight Last Run Status**: Toggle to highlight assets based on their last run status. The **Before** filter allows you to see run status before a specific point in time. For example, you can view the last run status before the timestamp of a known failure to see which exactly task in your pipeline failed. This time filter also affects which events show up in the **Event Timeline** tab of a selected asset.
* **Layers**: **Highlight Deployments** highlights Astro Deployments across the lineage graph. **Highlight Key Assets** highlights the final assets in data product graphs, and the primary asset in asset graphs.
## Adjust graph depth
By default, data product graphs include 10 levels upstream of the selected final assets. In asset graphs, you can control how many levels of dependencies to display:
* **Upstream**: Adjust the number of upstream dependency levels to show using the **+** and **-** buttons.
* **Downstream**: Adjust the number of downstream dependency levels to show using the **+** and **-** buttons.
The graph depth controls help you focus on the most relevant dependencies for your analysis.
## View asset details in lineage
Click any asset in the lineage graph to open a side panel with detailed information, including:
* **Basic**: Asset metadata including FQDN, Name, and Namespace
* **Dag Metadata**: Owner and Tags (for Airflow assets)
* **Source**: Last updated timestamp and last updated by information
The side panel also includes tabs for:
* **Impact Analysis**: View assets downstream of the selected asset. By default, this view only shows leaf nodes, or nodes with no further downstream assets. You can change this by toggling the **Only Leaf Assets** control.
* **Upstream Issues**: See any issues in upstream dependencies. By default, this view only shows upstream issues that had a failure or anomaly. You can change this by toggling the **Only Problems** control.
* **Event Timeline**: View a history of run events or update events for this asset. Failed dag and task runs display a summary of the failure logs for troubleshooting.
* **Data Products**: See which data products this asset is part of to understand the potential impact across the business.
# Manage Deployments programmatically using Deployment files
Source: https://astronomer.io/docs/astro/manage-deployments-as-code
Manage an Astro Deployment using a Deployment file in YAML or JSON format
You can configure Deployments programmatically using Deployment files and Deployment template files. *Deployment files* are used to update the same Deployment programmatically, and *Deployment template files* are used to create new Deployments based on a single template.
Managing Deployments with files is essential to automating Deployment management at scale. For example, you can:
* Create a template file in a central GitHub repository and use it as a source of truth for new Deployments that fit a particular use case. For example, you can standardize your team's development Deployments by creating a template file with configurations for that type of Deployment.
* Create a Deployment file that represents the configurations of an existing Deployment and store it in your GitHub repository. You can make changes to this file to update a Deployment using CI/CD, which maintains the history of your changes.
Use this document to learn how to create and manage Deployment files and Deployment template files. See the [Deployment file reference](/docs/astro/deployment-file-reference) for a list of configurable Deployment file values. When you're ready to programmatically run Deployment file workflows, see [Authenticate your workflow](/docs/astro/automation-authentication).
## Create a template file or Deployment file
To create a template file based on an existing Deployment, run the following command:
```sh wrap theme={null}
astro deployment inspect --template > .yaml
```
To create a Deployment file based on an existing Deployment, run the following command:
```sh wrap theme={null}
astro deployment inspect > .yaml
```
Alternatively, you can manually create a template file without using an existing Deployment as explained in [Create a Deployment using a template file](#create-a-deployment-using-a-template-file).
## Create a Deployment using a template file
These are the minimum values required to create a Deployment using a template file. Any configurations not specified are set to default values. To add more configurations, see [Deployment file reference](/docs/astro/deployment-file-reference).
1. Copy one of the following templates to a local `yaml` file:
```yaml title="deployment.yaml" wrap theme={null}
deployment:
configuration:
name:
deployment_type: HOSTED_SHARED
cloud_provider: aws
description:
runtime_version: 9.1.0
dag_deploy_enabled: true
executor: CeleryExecutor
cluster_name: us-east-1
region: us-east-1
workspace_name:
scheduler_size: small
```
Note that for Deployments on a standard cluster, the `region` and `cluster-name` parameters must both contain the region name for the standard cluster. See [Available regions for your cloud provider](/docs/astro/resource-reference-hosted#standard-cluster-regions).
```yaml title="deployment.yaml" wrap theme={null}
deployment:
configuration:
name:
deployment_type: HOSTED_DEDICATED
cloud_provider: aws
description:
runtime_version: 9.1.0
dag_deploy_enabled: true
executor: KubernetesExecutor
cluster_name:
region: us-east-1
workspace_name:
scheduler_size: small
```
The `cluster_name` field must include the name of the dedicated cluster that exists in your Astro Organization.
2. Adjust the template file values for the Deployment you want to create. When working with template files, keep the following in mind:
* The `name` field must include a unique name within the Workspace.
* The `workspace_name` field must include a valid Workspace name that exists in your Astro Organization.
* The possible values for `cloud_provider`, `executor`, and `scheduler_size` are the same possible values when you create a Deployment with [`astro deployment create`](/docs/cli/v1.43/astro-deployment-create#options-astro).
* See [Airflow and Astro Runtime version parity](/docs/runtime/runtime-image-architecture#astro-runtime-and-apache-airflow-parity) to choose your Astro Runtime version.
See [Deployment file reference](/docs/astro/deployment-file-reference) for a list of all configurable Deployment template file values.
3. Run the following command to create the Deployment:
```sh wrap theme={null}
astro deployment create --deployment-file
```
4. (Optional) Either open the Astro UI or run the following command to confirm that you successfully created your Deployment:
```sh wrap theme={null}
astro deployment list
```
5. (Optional) Reconfigure any Airflow connections or variables from the Deployment that you copied into the template file. Airflow connections and variables cannot be configured using template files. See [Manage connections in Airflow](/docs/astro/manage-connections-variables).
## Update a Deployment using a Deployment file
A Deployment file is a complete snapshot of an existing Deployment at the point you inspected it. It's similar to a template file, but also contains your Deployment's name, description, and metadata. In the same way you use a template file to create a new Deployment, you use a Deployment file to update an existing Deployment with a new set of configurations.
When you update a Deployment with a Deployment file, keep the following in mind:
* You can’t change the cluster or Workspace the Deployment runs on. To transfer a Deployment to a different Workspace, see [Transfer a Deployment](/docs/astro/transfer-a-deployment).
* You can't change the Astro Runtime version of the Deployment. To upgrade Astro Runtime, you must update the Dockerfile in your Astro project. See [Upgrade Astro Runtime](/docs/runtime/upgrade-astro-runtime).
* Environment variables marked as secret in the Astro UI will be exported with a blank `value` to your Deployment file. To redeploy using the Deployment file, you either need to provide the `value` again in the Deployment file or delete the object for the variable. Otherwise, `astro deployment create` will fail. See [`deployment.environment_variables`](/docs/astro/deployment-file-reference#deployment-environment_variables) for more details.
When you update a Deployment with a Deployment file, you must push a complete Deployment file that lists all of your existing worker queues. If a worker queue exists on Astro but doesn't exist in your Deployment file, the worker queue is deleted when you push your Deployment file.
To update a Deployment using a Deployment file:
1. Inspect an existing Deployment and create a Deployment file for its current configurations:
```sh wrap theme={null}
astro deployment inspect > .yaml
```
2. Modify the Deployment file and save your changes. See [Deployment file reference](/docs/astro/deployment-file-reference) for fields that you can modify.
3. Update your Deployment according to the configurations in the Deployment file:
```sh wrap theme={null}
astro deployment update --deployment-file
```
4. (Optional) Confirm that your Deployment was updated successfully by running the following command. You can also go to the Deployment page in the Astro UI to confirm the new values.
```sh wrap theme={null}
astro deployment inspect
```
## See also
* [Authenticate an automation tool to Astro](/docs/astro/automation-authentication)
* [Deploy Code](/docs/astro/deploy-code)
* [Choose a CI/CD Strategy for deploying code to Astro](/docs/astro/set-up-ci-cd)
# Create and manage domains for your Organization
Source: https://astronomer.io/docs/astro/manage-domains
Create and map domains to single sign-on platforms on Astro.
Authorization policies in Astro are based on email domains, which ensures that all users with an approved email domain authenticate with a specific authentication method. Domains can be mapped to single sign-on (SSO) methods so that users who have an email with a domain are automatically directed to your SSO platform when they sign in to Astro.
You can only configure a single domain for an SSO connection. However, if you have multiple managed domains, then you can set up multiple different SSO connections, with a separate SSO connection for each domain.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a domain
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Click **+ New Managed Domain**.
3. In the **Domain** field, enter the domain that you want to map.
4. Click **Create Managed Domain**. The domain is added to your managed domains and marked as **Unverified**.
5. In the entry for your domain, click **Verify Domain**. A new window appears with steps to verify your domain.
6. Follow the steps to verify your domain. If you can't complete the steps yourself, contact the administrator for your domain and ask them to complete the steps instead.
7. Click **Verify Domain** to notify Astro to check your DNS record.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **Managed Domains** menu, click **Managed Domain**.
3. In the **Domain** field, enter the domain that you want to map.
4. Click **Create**. The domain is added to your **Managed Domains** and marked as **Unverified**.
5. In the entry for your domain, click **Verify**. A new window appears with steps to verify your domain.
6. Follow the steps to verify your domain. If you can't complete the steps yourself, contact the administrator for your domain and ask them to complete the steps instead.
7. Click **Verify** to notify Astro to check your DNS record.
Typically, a change in the DNS record takes only minutes to propagate; however, there are cases where it may take up to 72 hours.
After your domain is verified, you can map the domain to an SSO connection. Mapping a domain ensures that all users with the same email address domain have the same authentication experience when they sign in to Astro. You can later use this mapping to enforce specific sign in methods for users with emails from a specific domain. See [Configure SSO](/docs/astro/configure-idp#configure-your-sso-identity-provider).
## Delete a domain
1. In the Astro UI, go to **Settings**, then in the **Security** section, click **Authentication**.
2. Next to the domain you want to delete, click the trash bin.
3. Follow the prompts to confirm the deletion.
1. In the Astro UI, click **Organization Settings**, then click **Authentication**.
2. In the **Managed Domains** menu, click the trash bin next to the domain you want to delete.
3. Follow the prompts to confirm the deletion.
# Manage environment variables on Astro
Source: https://astronomer.io/docs/astro/manage-env-vars
Learn how to manage environment variables on Astro
This document covers how to manage **Deployment-level environment variables** on Astro. For information about creating **Workspace-level environment variables** that can be shared across multiple Deployments, see [Create environment variables in Astro](/docs/astro/create-and-link-environment-variables).
On Astro, you can create, update, or delete Deployment-level environment variables in the following ways:
* Using the Deployment's **Environment Variables** tab in your Deployment's **Environment** settings.
* Using your Astro project `Dockerfile`.
The way you manage environment variables can affect security and access for your variable data. See [Choose a strategy](/docs/astro/environment-variables#choose-a-strategy) to determine which management strategy is right for your use case.
Additionally, you can test environment variables from your local Astro environment and export them to the Astro UI. See [Manage environment variables locally](#manage-environment-variables-locally).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Use the Astro UI
Setting environment variables using the Astro UI is the quickest and easiest way to manage Deployment-level environment variables on Astro.
When you view the **Environment Variables** page for a Deployment, you'll see both Deployment-level environment variables (which you can edit on this page) and Workspace-level environment variables (which are managed through the [Workspace Environment Manager](/docs/astro/create-and-link-environment-variables)). Deployment-level environment variables take precedence over Workspace-level environment variables with the same key.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the **Environment** tab.
3. Click **Environment variables**.
4. Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet).
5. Enter an environment variable key and value. For sensitive credentials that should be treated with an additional layer of security, select the **Secret** checkbox. This permanently hides the variable's value from all users in your Workspace.
6. Click **Update Environment Variables** to save your changes. Your Airflow scheduler, webserver, and workers restart. After saving, it can take up to two minutes for new variables to be applied to your Deployment.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Environment** tab.
3. Click **Environment variables**.
4. Click **Edit Deployment Variables** (or **+ New Environment Variable** if you have no variables configured yet).
5. Enter an environment variable key and value. For sensitive credentials that should be treated with an additional layer of security, select the **Secret** checkbox. This permanently hides the variable's value from all users in your Workspace.
6. Click **Update Environment Variables** to save your changes. Your Airflow scheduler, webserver, and workers restart. After saving, it can take up to two minutes for new variables to be applied to your Deployment.
### Edit or delete existing values
After you set an environment variable key, only the environment variable value can be modified. You can modify environment variables that are set as **Secret**, but the existing secret variable value is never shown. When you modify a secret environment variable, the existing value is erased and you are prompted to enter a new value.
1. In the Astro UI, click **Deployments**, then select a Deployment.
2. Click the **Environment** tab.
3. Click the **Environment Variables** tab.
4. Click **Edit Deployment Variables**.
5. Modify the value of the variable you want to edit.
6. Click **Update Environment Variables** to save your changes. Your Airflow scheduler, webserver, and workers restart. After saving, it can take up to two minutes for updated variables to be applied to your Deployment.
1. In the Astro UI, select a Workspace, click **Deployments**, and then select a Deployment.
2. Click the **Environment** tab.
3. Click the **Environment Variables** tab.
4. Click **Edit Deployment Variables**.
5. Modify the value of the variable you want to edit.
6. Click **Update Environment Variables** to save your changes. Your Airflow scheduler, webserver, and workers restart. After saving, it can take up to two minutes for updated variables to be applied to your Deployment.
## Using your Dockerfile
If you want to store environment variables with an external version control tool, Astronomer recommends setting them in your `Dockerfile`. This file is automatically created when you first initialize an Astro project using `astro dev init`.
Environment variables set in your `Dockerfile` are stored in plain text. For this reason, Astronomer recommends storing sensitive environment variables using the Astro UI or a third-party secrets backend. For more information, see [Configure a secrets backend](/docs/astro/secrets-backend).
1. Open your Astro project `Dockerfile`.
2. To add the environment variables, declare an ENV command with the environment variable key and value. For example, the following `Dockerfile` sets two environment variables:
```dockerfile title="Dockerfile" wrap theme={null}
FROM astrocrpublic.azurecr.io/runtime:3.1-5
ENV AIRFLOW__CORE__MAX_ACTIVE_RUNS_PER_DAG=1
ENV AIRFLOW_VAR_MY_VAR=25
```
3. Save your Dockerfile and run `astro deploy` to deploy your variables to an Astro Deployment. To apply your changes locally, use `astro dev restart` to rebuild your image.
4. (Optional) To verify if the environment variables are applied correctly to Astro Deployment or your local Airflow environment, you can use `os.getenv("AIRFLOW_VAR_MY_VAR")` inside of Airflow Dags and tasks.
To delete an environment variable from your Astro Runtime image, remove or comment the line in your `Dockerfile` that defines it.
Environment variables set in your Dockerfile aren't visible in the Astro UI.
## Manage environment variables locally
You can use the Astro CLI to set environment variables on Astro and your local Airflow environment. If you're developing locally, the best way to manage environment variables is using your Astro project `.env` file.
1. Open your Astro project `.env` file.
2. Use the following format to set your environment variables in the `.env` file:
```text wrap theme={null}
KEY=VALUE
```
Environment variables should be in all-caps and not include spaces.
Alternatively, you can run `astro deployment variable list --save` to copy environment variables from an existing Deployment to a file.
3. Restart your local environment using `astro dev restart`.
To confirm that your environment variables were applied:
1. Run `astro dev bash --scheduler` to sign in to the scheduler container.
2. Run `printenv | grep ` in the container to print all environment variables that are applied to your environment.
3. Run `exit` to exit the container.
To export the contents of your `.env` file to an Astro Deployment, run the following command:
```sh wrap theme={null}
astro deployment variable update --deployment-id --load .env
```
When you use the `.env` file to add or update environment variables on Astro, it will overwrite all existing variables in your Astro Deployment. To update only select environment variables, run `astro deployment variable create` without the `--load` option. For example, the following command creates two new environment variables without affecting existing Deployment environment variables:
```sh wrap theme={null}
astro deployment variable create AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT=60 ENVIRONMENT_TYPE=dev --deployment-id cl03oiq7d80402nwn7fsl3dmv
```
After you deploy environment variables, your Deployment automatically restarts and applies the variables. To verify if the environment variables were applied correctly, go to **Environment** > **Environment Variables** of your Deployment settings in the Astro UI.
### Use multiple .env files
The Astro CLI looks for `.env` by default, but if you want to specify multiple files, make `.env` a top-level directory and create sub-files within that folder, as shown in the example directory below. If you make `.env` a top-level directory, make sure to specify the specific filepath(s) with the `--env` flag. For example, to specify `dev.env` as your environment variable file with the `astro dev start` command:
```sh wrap theme={null}
astro dev start --env .env/dev.env
```
```text wrap theme={null}
my_project
├── Dockerfile
├── dags
│ └── my_dag
├── include
│ └── my_operators
├── airflow_settings.yaml
└── .env
├── dev.env
└── prod.env
```
## See also
* [Set Airflow connections](/docs/learn/connections#define-connections-with-environment-variables) using environment variables.
* [Set Airflow variables](/docs/learn/airflow-variables#using-environment-variables) using environment variables.
* [Import and export environment variables](/docs/astro/import-export-connections-variables#from-environment-variables)
# Manage users in an Astro Organization
Source: https://astronomer.io/docs/astro/manage-organization-users
Add, edit, or remove users within an Organization on Astro.
As an Organization Owner, you can add new team members to Astro and grant them user roles with permissions for specific actions across your Organization.
To manage users at the Workspace level, see [Manage Workspace users](/docs/astro/manage-workspace-users). To manage groups of users, see [Manage Teams](/docs/astro/manage-teams).
## Prerequisites
* Organization Owner permissions.
For more information on user roles, see [Manage user permissions on Astro](/docs/astro/user-permissions).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Add a user to an Organization
If your Organization has [configured an identity provider (IdP) with Astro](/docs/astro/configure-idp#configure-your-sso-identity-provider), assign users to Astro from your identity provider. By default, any users that you assign can join your Organization as an Organization Member without an invite. To change this behavior, see [Disable just-in-time provisioning](/docs/astro/configure-idp#configure-just-in-time-provisioning).
You can also manually add users to an Organization. You must manually add users in the following circumstances:
* You don't have an IdP configured.
* You disabled just-in-time provisioning.
* You want to invite a user to an Organization from a domain that you don't own, such as a third party consultant.
* You want to invite someone from your company to Astro as a role other than Organization Member.
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Users**.
2. Click **+ Invite User**.
3. Enter the user's email.
4. Select an Organization role for the user. See [Organization roles reference](/docs/astro/user-permissions#organization-roles).
5. Click **Invite User**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Invite member**:
3. Enter the user's email.
4. Select an Organization role for the user. See [Organization roles reference](/docs/astro/user-permissions#organization-roles).
5. Click **Invite member**.
After you add the user, their information appears in the **Users** tab in **Access Management**. To access Astro, the user needs to accept the invitation sent by email and then create an Astro account.
## Update or remove an Organization user
See [User permissions](/docs/astro/user-permissions) to view the permissions for each available Organization role.
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Users**.
2. Find the user in the **Users** list.
3. To edit the user's role, click the user's **More actions** menu (⋯), select **Edit User**, change their access type, then click **Update User**.
4. To remove the user, click the user's **More actions** menu (⋯), select **Remove User…**, then click **Yes, Continue**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Find the user in the **Users** list. To view or manage the user's Organization, Workspace, and Deployment roles, either click the user's row to open the **User Details** page, or open the action menu (⋯) on the user's row and select **Edit User**.
3. (Optional) Edit the user's role. See [Organization roles](/docs/astro/user-permissions). If you opened the action menu, you can change the user's Organization role from the **Edit User** option. On the **User Details** page you can view and edit the user's Organization, Workspace, Deployment, and Dag roles.
4. If you updated the user's role, click **Update member**. To delete the user, open the action menu and select **Remove user…**, or click **Remove member** on the **User Details** page.
To remove yourself from an Organization as an Organization Owner, one or more Organization Owners must be assigned to the Organization. If you're the only Organization Owner for your Organization, you'll need to assign another Organization Owner before removing yourself from the Organization.
## Add a group of users to Astro using the Astro CLI
You can use the Astro CLI and a shell script to add multiple users to an Organization at once. The shell script reads from a text file which contains user information. You can generate the text file for each new batch of users that need to assigned to an Organization and run the script using the Astro CLI.
1. Create a text file named `users.txt`.
2. Open the text file. On each line, add a user's email and their role separated by a space. The following is an example of how you can write a list for inviting users to an Organization:
```text wrap theme={null}
user1@astronomer.io ORGANIZATION_MEMBER
user2@astronomer.io ORGANIZATION_OWNER
user3@astronomer.io ORGANIZATION_BILLING_ADMIN
user4@astronomer.io ORGANIZATION_OWNER
```
3. Create a file named `add-users.sh` and then add the following script to it:
```bash title="add-users.sh" wrap theme={null}
#!/bin/bash
# Check if a file was provided as an argument
if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1
fi
# Loop through the file to read each user email address and the role, and use Astro CLI to invite them
while read line; do
email=$(echo "$line" | cut -d' ' -f1)
role=$(echo "$line" | cut -d' ' -f2)
echo "Inviting $email as $role..."
astro organization invite "$email" --role "$role"
done < "$1"
```
4. Sign in to the Astro CLI using `astro login`, and then run `astro organization list` to ensure that you're in the same Organization where you want to add the users. If you're not in the right Organization, run `astro organization switch`.
5. Run the following command to execute the shell script:
```sh wrap theme={null}
sh path/to/add-users.sh path/to/users.txt
```
6. (Optional) To use this script as part of a CI/CD pipeline, create an [Organization API token](/docs/astro/organization-api-tokens) and specify the environment variable `ASTRO_API_TOKEN=` in your CI/CD environment.
## See also
* [Manage Workspace users](/docs/astro/manage-workspace-users)
* [Manage Teams](/docs/astro/manage-teams)
* [Manage user permissions on Astro](/docs/astro/user-permissions)
* [Dag-level access control](/docs/astro/dag-level-access-control)
# Configure Teams on Astro
Source: https://astronomer.io/docs/astro/manage-teams
Create, delete, and update Teams on Astro.
This is feature is only available if you are on the **Team** tier or above. See [Astro Plans and Pricing](https://www.astronomer.io/pricing/).Team plans are limited to two Teams, but Business plans allow you to have unlimited Teams. See [pricing](https://www.astronomer.io/pricing/).
As an Organization Owner or Workspace Owner, you can use Teams to batch assign Organization and Workspace roles to groups of users. Organization Owners create, update, or delete Teams. Then, either Organization Owners or Workspace Owners can assign Teams to different Workspaces and define their [Workspace permissions](/docs/astro/user-permissions#workspace-roles). For Deployments running Astro Runtime 3.1-12 or later, you can also assign Teams to individual Dags with Dag-specific roles. See [Dag-level access control](/docs/astro/dag-level-access-control#assign-dag-roles-to-teams).
A *Team* is a group of users in an Organization that share the same Organization and Workspace permissions. You can use Teams to securely assign permissions for a large group of users across multiple Workspaces. For example, you can create a Team of dag authors, then assign that Team to each of your development Workspaces as a Workspace author.
You can also assign different roles for each Workspace. For example, you can have a group of dag authors that has full Workspace Owner permissions for development Workspaces, and that same Team can have only Workspace Member permissions for production Workspaces.
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a Team
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Teams**.
2. Click **+ New Team**.
3. In the **New Team** panel, enter a **Team Name** and **Team Description**, select an **Organization Role**, and optionally **Add Users**. If you can't find a user, you might need to [add them to your Organization](/docs/astro/manage-organization-users#add-a-user-to-an-organization) first.
4. Click **Create Team**.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Teams**.
3. Click **+ Team** to create a new Team.
4. Configure the following details about your Team:
* **Team Name**: The name for your Team.
* **Team description**: (Optional) The description for your Team.
* **Organization role**: The Organization role for your Team.
* **Add users**: Choose the Organization users you want to add to the Team.
If you don't find the user you want to add, you might need to [add the user to your Organization](/docs/astro/manage-organization-users#add-a-user-to-an-organization).
5. After you finish adding users to the Team, click **Add Team**.
You can now [add your Team to a Workspace](/docs/astro/manage-teams#add-a-team-to-a-workspace) and define the Team users' permissions in the Workspace.
## Update existing Teams
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Teams**.
2. Click a Team to open its detail page. The **Members** tab is selected by default.
3. To add a member, click **+ Add Member**, use the **Add Users** dropdown to find the user, then click **Add Members**.
4. To remove a member, hover over their row and click the trash icon.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Click **Teams**.
3. Click the name of the Team you want to update.
4. Update your Team:
* Click **+ Member** to add an existing Organization member to your Team.
* Click the delete icon to remove Team members.
## Add a Team to a Workspace
1. In the Astro UI, go to **Settings** > **Workspaces**.
2. Select your Workspace, then go to **Access Management** > **Teams**.
3. Click **+ Add Team**.
4. Select the **Team** you want to add and define their **Workspace Role**, which determines their [Workspace user permissions](/docs/astro/user-permissions#workspace-roles).
1. In the Astro UI, select a Workspace and click **Workspace Settings** > **Access Management**.
2. Click **Teams**.
3. Click **+ Team**.
4. Select the **Team** you want to add and define their **Workspace Role**, which determines their [Workspace user permissions](/docs/astro/user-permissions#workspace-roles).
**Centralized access management for Organization Owners**
[Organization Owners](/docs/astro/user-permissions#organization-roles) can also add or update a Team for a Workspace from your Organization's access management settings:
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Teams**.
2. Select the Team.
3. Click the **Workspaces** tab, then click **+ Add Workspace** to add them to a Workspace, or **Edit Role** to change their role for an existing Workspace.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Select the Team to add or update.
3. Click the **Workspaces** tab, then click **+ Workspace** to add them to a Workspace, or open the **More actions** menu (⋯) and select **Edit role** next to an existing Workspace to change their role.
**CLI**
You can add a Team to multiple Workspaces programmatically using the Astro CLI. See [`astro workspace team add`](/docs/cli/v1.43/astro-workspace-team-add) for example output and commands.
## Add a Team to a Dag
You can assign a Team to specific Dags within a Deployment, giving all Team members the same Dag-level permissions. For complete instructions, see [Assign Dag roles to Teams](/docs/astro/dag-level-access-control#assign-dag-roles-to-teams).
## Add a Team to multiple Workspaces using the Astro CLI
You can use the Astro CLI and a shell script to add a Team to multiple Workspaces at once. The shell script reads from a text file which contains Team information. You can generate a text file for each Team that needs to be assigned to Workspaces and run a script to process the file. You must have Organization Owner or Workspace Owner level permissions to add Teams to Workspaces.
1. Create a text file named `teams.txt`.
2. Open the text file. On each line, add a Team ID, the Team's role, and the Workspace ID delimited by spaces. Your text file should look similar to the following:
```text wrap theme={null}
uclk17xqgm124q01hkrgilsr49 WORKSPACE_MEMBER tbkj96wpfl913p90glqfgkrq398
uclk17xqgm124q01hkrgilsr49 WORKSPACE_OWNER salk85voek802q89fkpefjqp287
uclk17xqgm124q01hkrgilsr49 WORKSPACE_OPERATOR rzkj74undj791p78ejofeipo178
vdml28yrhn235r12ilshjmts50 WORKSPACE_OWNER tbkj96wpfl913p90glqfgkrq398
```
3. Create a file named `add-teams.sh` and add the following script to it:
```bash title="add-teams.sh" wrap theme={null}
#!/bin/bash
# Check if a file was provided as an argument
if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1
fi
while read line; do
team_id=$(echo "$line" | cut -d' ' -f1)
role=$(echo "$line" | cut -d' ' -f2)
workspace_id=$(echo "$line" | cut -d' ' -f3)
echo "Inviting ${team_id} to ${workspace_id} as $role..."
astro workspace team add "$team_id" --role "$role" --workspace-id "$workspace_id"
done < "$1"
```
4. (Optional) Log in to the Astro CLI using `astro login`, then run `astro workspace list` to ensure that you have access to the Workspaces where you want to add the users.
5. Run the following command to execute the shell script:
```sh wrap theme={null}
sh path/to/add-teams.sh path/to/teams.txt
```
6. (Optional) To use this script as part of a CI/CD pipeline, create an [Organization API token](/docs/astro/organization-api-tokens) and specify the following environment variable in your CI/CD environment:
* **Key**: `ASTRO_API_TOKEN`
* **Value**: ``
## Teams and SCIM provisioning
To preserve a single source of truth for user group management, some Team management actions are limited when you [set up SCIM provisioning](/docs/astro/set-up-scim-provisioning). Specifically, when you set up SCIM provisioning:
* You can't create new Teams.
* You can't add users to existing Teams.
For any Teams that were created before you set up SCIM provisioning, you can still complete the following actions:
* Update the Team's permissions.
* Remove users from the Team.
* Delete the Team.
# Manage users in your Astro Workspace
Source: https://astronomer.io/docs/astro/manage-workspace-users
Add, edit, or remove users within a Workspace on Astro.
As a Workspace Owner or an Organization Owner, you can add new team members to Astro and grant them user roles with permissions for specific actions across your Workspace.
To manage users at the Organization level, see [Manage Organization users](/docs/astro/manage-organization-users). To manage groups of users, see [Manage Teams](/docs/astro/manage-teams).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Prerequisites
To add, edit, or remove Workspace users from a given Workspace, you need either Organization Owner permissions or Workspace Owner permissions for the Workspace.
**Centralized access management for Organization Owners**
Organization Owners can also add or update a user or Team for a Workspace from your Organization's access management settings:
1. In the Astro UI, go to **Settings**, then in the **Access Management** section, click **Users** or **Teams**.
2. Select the user or Team.
3. Click the **Workspaces** tab, then click **+ Add Workspace** to add them to a Workspace, or **Edit Role** to change their role for an existing Workspace.
1. In the Astro UI, click **Organization Settings** > **Access Management**.
2. Select the user or team to add or update.
3. Click the **Workspaces** tab, then click **+ Workspace** to add them to a Workspace, or open the **More actions** menu (⋯) and select **Edit role** next to an existing Workspace to change their role.
## Add a user to a Workspace
1. In the Astro UI, go to **Settings** > **Workspaces**.
2. Select your Workspace, then in the **Access Management** section, click **Users**.
3. Click **+ Add User**.
4. In the **User** field, enter the email address of the user you want to invite.
5. From the dropdown, select the **Invite new user** option for the email you entered.
6. Choose a **Workspace Role**. See [Workspace roles reference](/docs/astro/user-permissions#workspace-roles).
7. Click **Invite User to Workspace**.
1. In the Astro UI, click **Workspace Settings** > **Access Management**.
2. In the **Users** tab, click **+ Member**.
3. Select the user's name and email address in the **Organization Member** list.
4. Select a role for the user and then click **Add member**. See [Workspace roles reference](/docs/astro/user-permissions#workspace-roles).
After you add the user, their information appears in the **Users** tab as a new entry in the **Members** list.
You can also add groups of users to a Workspace through Teams. See [Manage Teams](/docs/astro/manage-teams).
## Update or remove a Workspace user
1. In the Astro UI, go to **Settings** > **Workspaces**.
2. Select your Workspace, then in the **Access Management** section, click **Users**.
3. To edit the user's role, click the user's **More actions** menu (⋯), select **Edit User**, change their access type, then click **Update User**.
4. To remove the user, click the user's **More actions** menu (⋯), select **Remove User…**, then click **Yes, Continue**.
1. In the Astro UI, go to **Workspace Settings** > **Access Management**.
2. Find the user in the **Users** list. To view or manage the user's roles, either click the user's row to open the **User Details** page, or click the **More actions** button on the user's row and select **Edit User**.
3. (Optional) Edit the user's name and role. See [Workspace roles](/docs/astro/user-permissions).
4. If you've updated the user's role, click **Update member**. To delete the user, open the action menu and select **Remove user…**, or click **Remove member** on the **User Details** page.
## Add a group of users to a Workspace using the Astro CLI
You can use the Astro CLI and a shell script to add multiple users to a Workspace at once. The shell script reads from a text file which contains user information. You can generate a text file for each new batch of users that need to be assigned to a Workspace and run the script with the Astro CLI.
1. Create a text file named `users.txt`.
2. Open the text file. On each line, add a user's email and their role separated by a space. The following is an example of how you can write a list for inviting users to a Workspace:
```text wrap theme={null}
user1@astronomer.io WORKSPACE_MEMBER
user2@astronomer.io WORKSPACE_OWNER
user3@astronomer.io WORKSPACE_OPERATOR
user4@astronomer.io WORKSPACE_OWNER
```
3. Create a file named `add-users.sh` and add the following script to it:
```bash title="add-users.sh" wrap theme={null}
#!/bin/bash
# Check if a file was provided as an argument
if [ $# -ne 1 ]; then
echo "Usage: $0 "
exit 1
fi
while read line; do
email=$(echo "$line" | cut -d' ' -f1)
role=$(echo "$line" | cut -d' ' -f2)
echo "Inviting $email as $role..."
astro workspace user add "$email" --role "$role"
done < "$1"
```
4. Log in to the Astro CLI using `astro login`, then run `astro workspace list` to ensure that you're in the same Workspace where you want to add the users. If you're not in the right Workspace, run `astro workspace switch`.
5. Run the following command to execute the shell script:
```sh wrap theme={null}
sh path/to/add-users.sh path/to/users.txt
```
6. (Optional) To use this script as part of a CI/CD pipeline, create an [Organization API token](/docs/astro/organization-api-tokens) or [Workspace API token](/docs/astro/workspace-api-tokens) and specify the environment variable `ASTRO_API_TOKEN=` in your CI/CD environment. Note that you can use Workspace API tokens to manage users only at the Workspace level.
## See also
* [Manage Organization users](/docs/astro/manage-organization-users)
* [Manage Teams](/docs/astro/manage-teams)
* [Manage user permissions on Astro](/docs/astro/user-permissions)
# Configure Workspaces on Astro
Source: https://astronomer.io/docs/astro/manage-workspaces
Create, delete, and update Workspaces on Astro.
Workspaces are collections of Deployments that can be accessed by a specific group of users. You can use Workspaces to group Deployments that share a business use case or trait.
Some common ways to implement Workspaces are:
* Using a **single Workspace** for an entire Organization, with all development and production pipelines hosted together.
* Using a **Workspace per team**. For example, you might have a Workspace for your Data Science team and a separate Workspace for your Data Engineer team, with each team's Workspace hosting both production and development pipelines.
* Using a **Workspace per project**. For example, you might have a Workspace called "Sales Analytics Project" that hosts both production and development pipelines.
This document explains how to configure Workspace details. To manage Workspace users, see [Manage Workspace users](/docs/astro/manage-workspace-users).
**A new Astro UI is here**
Astronomer has redesigned the Astro UI. Try the new experience and switch your instructions using the **New Astro UI** and **Legacy UI** tabs on this page. Your selection is remembered across the docs.
## Create a Workspace
To create a Workspace, you must have an [Organization-level](/docs/astro/user-permissions#organization-roles) role.
1. In the Astro UI, go to **Settings** > **Workspaces**.
2. Click **+ New Workspace**.
1. In the Astro UI, open the Workspace selection menu, then select **Manage Workspaces**.
2. Click **Add Workspace**.
During this initial setup, you can configure the Workspace's name and description. You can update all other Workspace settings later from the Workspace's settings.
## Navigate your Workspace
The new Astro UI doesn't have a separate Workspace view. To scope to a specific Workspace, use the Workspace dropdown in the **Deployments**, **DAGs**, and **Environment** sections. To manage a Workspace's settings, go to **Settings** > **Workspaces**, then select the Workspace.
To enter your Workspace, click the Workspace in the **Overview** tab. When you click into a Workspace and see a list of that Workspace's Deployments, you are in the **Workspace view** of the Astro UI. The Workspace view contains several pages for managing your Workspace which are accessible from a sidebar on the left of the screen:
* **Home**: View the status of your Deployments and select recently accessed Deployments.
* **Deployments:** Create new Deployments and see key metrics about existing Deployments in the Workspace. For more information, see [Create a Deployment](/docs/astro/create-deployment).
* **Dags:** View metrics about individual dags across your Workspace. For more information, see [Deployment metrics](/docs/astro/deployment-metrics#dag-and-task-runs).
* **Workspace Settings:** Update Workspace details, including Workspace user permissions, the Workspace name, and the Workspace description.
## Update general Workspace settings
1. In the Astro UI, go to **Settings** > **Workspaces**, then select your Workspace.
2. In the **General** section, click **Edit**, update the **Name** and **Description** as needed, then click **Save**.
3. To set the CI/CD enforcement default, toggle **CI/CD Enforcement** in the **Deployment Defaults** section. This determines whether new Deployments in the Workspace enforce CI/CD deploys by default, and can be overridden at the Deployment level. See [Enforce CI/CD deploys](/docs/astro/deployment-details#enforce-ci/cd-deploys).
1. In the Astro UI, select a Workspace.
2. Click **Workspace Settings** and then click the **Details** tab.
3. Click **Edit Details**, then update the following settings as needed:
* **Name**: The name of your Workspace
* **Description**: The description of your Workspace
* **CI/CD Enforcement Default**: Determines whether new Deployments in the Workspace enforce CI/CD deploys by default. This default can be overridden at the Deployment level. See [Enforce CI/CD deploys](/docs/astro/deployment-details#enforce-ci/cd-deploys).
## Configure Otto investigation guidance
Otto investigation guidance is custom text you provide to tailor [Otto investigations](/docs/astro/otto-investigate) to your environment. For example, you can instruct Otto to treat tasks that begin with `validate` as non-blocking data quality tests, or to interpret a specific log pattern in a particular way. Guidance set at the Workspace level applies to every Deployment in the Workspace. Individual Deployments can override it. See [Configure Otto investigation guidance for a Deployment](/docs/astro/deployment-settings#configure-otto-investigation-guidance).
1. In the Astro UI, go to **Settings** > **Workspaces**, then select your Workspace.
2. In the **AI Agents** section, click the **Edit** icon next to **Otto Investigation Guidance**.
3. Enter up to 10,000 characters of markdown guidance, then save your changes.
1. In the Astro UI, select a Workspace.
2. Click **Workspace Settings** and then click the **AI Agents** tab.
3. Enter up to 10,000 characters of markdown guidance, then save your changes.
## Delete a Workspace
1. In the Astro UI, go to **Settings** > **Workspaces**, then select your Workspace.
2. Scroll to the **Danger Zone** section, then click **Delete Workspace**. This option isn't available when there are active Deployments in the Workspace.
3. In the confirmation dialog, enter `delete` and then click **Yes, Continue**.
1. In the Astro UI, select a Workspace.
2. Click **Workspace Settings**.
3. Click the option menu at the top of the page and select **Delete Workspace**. This option isn't available when there are active Deployments in the Workspace.
4. In the confirmation dialog, enter `delete` and then click **Yes, Continue**.
# Create network connections between Astro and external resources
Source: https://astronomer.io/docs/astro/networking-overview
Learn about the fundamentals of creating network connections from Astro.
To maximize the power of Airflow, your dags need to be able access data and services that exist outside of Astro. A *network connection* is the basic requirement for accessing external resources from Astro. After you create a network connection, you can configure an Airflow connection to access specific resources that are available through the connection.
Network connections can be either public or private, and each type of connection has a different implementation for security and authorization.
In a public connection, data travels over the public internet to publicly accessible IP addresses on either side of the connection. For example, consider a Deployment that accesses an S3 bucket using an AWS connection with a configured AWS access key and secret. Because the only limitation for accessing the S3 bucket is API authentication, this is an example of a public connection.
In a private connection, data travels over a private network through private IP addresses. Private connections have significantly more security requirements and are recommended whenever you're accessing sensitive or private data.
Astronomer can support alternative networking solutions that are not covered in documentation. If you have specific networking requirements that aren't covered in documentation, or you need help to create a custom network connection, reach out to [Astronomer support](https://cloud.astronomer.io/open-support-request).
## Network connection recommendations
If you're just starting out on Astro and you're working with publicly available services and testing data, you only need a public connection. For example, if you're accessing a publicly available API, you only need to configure an [HTTP Airflow connection](https://airflow.apache.org/docs/apache-airflow-providers-http/stable/connections/http.html) to establish a connection between your Deployment and the API.
To access or write data on your company's cloud, Astronomer strongly recommends establishing a private network connection between Astro and your cloud. For most use cases, Astronomer recommends creating a VPC peering connection between Astro and your cloud. After the connection is established, you can authorize individual Deployments to specific resources using workload identity. This method is simple to set up and ensures private and secure connectivity between Astro and any support cloud provider.
To create a VPC peering connection to Astro, you must use a dedicated cluster. In general, dedicated clusters support more secure networking types, such as AWS PrivateLink and Azure VNet peering. See:
* [AWS: Create a private connection between Astro and AWS](/docs/astro/connect-aws#private-networking-connections)
* [GCP: Create a private connection between Astro and GCP](/docs/astro/connect-gcp#create-a-private-connection-between-astro-and-gcp)
* [Azure: Create a private connection between Astro and Azure](/docs/astro/connect-azure#create-a-private-connection-between-astro-and-azure)
After you create your VPC peering connection, follow the steps in [Authorize your Deployment to cloud resources](/docs/astro/authorize-deployments-to-your-cloud) for each Deployment that needs access to your cloud.
Astronomer monitors the health of Deployments and dags, but it doesn't monitor the status of network connections because they exist outside of Astronomer's observable control plane and data plane.
# Add custom metadata to OpenLineage assets
Source: https://astronomer.io/docs/astro/observe-custom-metadata
Use the astroCustomMetadata OpenLineage facet to attach links to assets displayed in Astro Observe.
Astro Observe supports a custom OpenLineage facet, `astroCustomMetadata`, that you can use to attach links to assets sourced from OpenLineage, such as datasets and tasks. The links appear on the asset in the **Details** tab and in the **Asset Overview** in [Lineage](/docs/astro/lineage-graph). Use them to surface contextual resources, such as documentation, dashboards, or runbooks, alongside your assets.
Astro Observe supports up to five links per asset.
## Prerequisites
* A Deployment that emits OpenLineage events to Astro Observe. See [Configure OpenLineage on Astro](/docs/astro/observe-openlineage).
* A Dag that emits OpenLineage events for an Observe asset (supported for now: `Airflow Task`, `OpenLineage Dataset`).
## Facet structure
Attach the facet using the `facets` keyword argument. The facet body contains an `observeAssetMetadata` array, where each item describes a single link.
| Field | Description |
| ----------------------------------- | ---------------------------------------------------------------------------------- |
| `observeAssetMetadata` | Array of metadata items to display on the asset. |
| `observeAssetMetadata[].value` | The URL to link to. |
| `observeAssetMetadata[].type` | The metadata type. Must be `url`. Astro Observe ignores items with any other type. |
| `observeAssetMetadata[].typeParams` | Optional. For `url`, set `displayText` to the text shown for the link. |
## Example
The following custom facet attaches one link to an OpenLineage dataset:
```python wrap theme={null}
from airflow.providers.common.compat.openlineage.facet import Dataset as OLDataset
def observe_facet():
return {
"astroCustomMetadata": {
"observeAssetMetadata": [
{
"value": "https://www.astronomer.io/docs/astro/astro-observe",
"type": "url",
"typeParams": {"displayText": "Go to Astro Observe documentation"},
},
],
}
}
# See https://openlineage.io/docs/spec/naming#dataset-naming
ol_dataset = OLDataset(
name="",
namespace="",
facets=observe_facet(),
)
task = BashOperator(
task_id="task",
bash_command="exit 0;",
outlets=[ol_dataset],
)
```
Use this dataset as an `outlets` value on any task that writes to it. The OpenLineage event for that task includes the dataset with this facet, and Astro Observe attaches the link to the corresponding dataset asset.
To attach the facet to a task run instead of a dataset, emit it as a custom run facet. See [Custom facets](https://airflow.apache.org/docs/apache-airflow-providers-openlineage/stable/configurations-ref.html#custom-facets) in the Apache Airflow documentation.
# Data quality
Source: https://astronomer.io/docs/astro/observe-data-quality
Monitor tables and columns for volume, schema changes, and null percentages. View an overall data quality dashboard and investigate triggered issues.
**Preview**
This feature is in [Preview](/docs/astro/feature-previews).
Astro Observe data quality helps you monitor tables to ensure data accuracy, completeness, and integrity across your pipelines. It automatically tracks key metrics such as column null percentages, schema changes, and table row counts to detect anomalies or unexpected shifts in your data.
## Configure permissions
Before connecting to Astro Observe, configure the necessary permissions for your data platform.
For Snowflake connections, the Observe role must have access to both the `ACCOUNT_USAGE` and `INFORMATION_SCHEMA` system tables. The service user must have a default warehouse configured to support discovery and ongoing data quality monitoring.