Resource overview

Connect to databases, APIs, and other external systems.
Resources in Airplane allow you to easily configure connections to external systems like databases and APIs and use them in your tasks and runbooks.
To create and manage resources, you must be a team admin. Visit Resources in the app to add a new resource.

Supported resources

For details on using each resource, refer to its specific documentation.

Databases

APIs

Messaging

Don't see what you're looking for? Let us know by emailing hello@airplane.dev—we're constantly adding resources based on feedback!

Using resources in tasks

Resources can be attached to tasks and referenced from within the task.

SQL

When creating a SQL task you can choose a database resource to query against. The database is chosen from the UI or set in the task definition.

REST

When you create a REST task, you can select a REST API. The REST API's base URL will be used, as well as any headers specified on the resource.
The REST API is chosen from the UI or set in the task definition.

JavaScript, Python, and other tasks

Resource attachment

Resources must be attached to tasks before they can be accessed via environment variables or built-ins.
typescript
Copied
1
export default airplane.task(
2
{
3
slug: "my_task",
4
resources: {
5
// Where backend_db is the slug of a resource.
6
db: "backend_db"
7
},
8
},
9
async () => {...}
10
);

Environment variables

When attached to a task, resources are passed as a map of alias to resource configuration in the JSON environment variable AIRPLANE_RESOURCES. The exact resource configuration fields depend on the resource kind and are documented in each resource's reference page.

Built-ins

The JavaScript and Python SDKs offer built-in functions for common operations against resources. Once a resource is attached to a task, you can refer to the resource by alias in the built-in.
For example, after attaching the SQL resource with slug db, you can refer to it using a built-in to query the SQL database:
typescript
Copied
1
const run = await airplane.sql.query<{ id: string; name: string; email: string }>(
2
"db", // Attached resource
3
"select * from users where name ilike :name", // SQL query to execute
4
{ args: { name: `%${name}%` } } // Query arguments
5
);

Using resources in runbooks

Resources can be used in blocks within runbooks.
For example, once a database resource like Postgres has been configured, you can add a SQL block and run queries using it:
That's all you have to do—Airplane will handle securely passing the connection information to the agent running the query.