Deploy an application
Build and deploy applications using Aiven Runtime from source code in a GitHub repository.
role:organization:admin to connect a GitHub account. project:services:write, role:project:manager, or role:project:admin to deploy applications.When you connect a GitHub account to your Aiven organization, all users in that organization can select that account in Aiven Runtime.
You cannot use Compose files to deploy applications through the Aiven API or Aiven MCP. Use Containerfiles or Dockerfiles instead.
Prerequisites
- Console
- CLI
- API
- A GitHub account
Deploy an application
- Console
- CLI
- API
When you connect a GitHub account to your Aiven organization, all users in that organization can select that account in Aiven Runtime.
- In your project, click Runtime.
- Click Deploy application.
- Select or connect your GitHub account.
- Select your Account, Repository, and Branch.
- Click Next.
- Select your manifest file and click Scan. Aiven Runtime automatically detects what applications and services are needed.
- To change the configuration of an application, click . To change the configuration of a service integration, click Configure.
- To deploy the application and create the services, click Deploy.
-
To choose a project, run:
avn project switch PROJECT_NAMEWhere
PROJECT_NAMEis the name of your Aiven project. -
Optional: Create data services for the app to use with the
avn service createcommand. The following example creates a PostgreSQL service:avn service create example-postgres \--project PROJECT_NAME \-t pg \--cloud aws-eu-west-1 \--plan startup-4 -
Get your
VCS_INTEGRATION_IDfrom the Aiven API. This is Aiven's ID for the GitHub Aiven App installation linked to your organization when you connected your GitHub account. To get your ID, run:curl -sS \"https://api.aiven.io/v1/organization/ORGANIZATION_ID/application/vcs-integrations" \-H "Authorization: Bearer $AIVEN_TOKEN"Where
ORGANIZATION_IDis the Aiven organization ID the GitHub account is connected to. -
Get the ID of the connected repository from the Aiven API. To get the
REMOTE_REPOSITORY_ID, run the following command using theVCS_INTEGRATION_ID:curl -sS \"https://api.aiven.io/v1/organization/ORGANIZATION_ID/application/vcs-integrations/VCS_INTEGRATION_ID/repositories" \-H "Authorization: Bearer $AIVEN_TOKEN" -
To create the application, run the following:
avn service create example-app \--project PROJECT_NAME \-t application \--cloud aws-eu-west-1 \--plan startup-50-1024 \-c application.source.vcs_integration_id=VCS_INTEGRATION_ID \-c application.source.remote_repository_id=REMOTE_REPOSITORY_ID \-c application.source.repository_url=REPOSITORY_URL \-c application.source.branch=BRANCH_NAME \-c application.source.build_path=. \-c application.source.containerfile_path=Dockerfile \-c 'application.ports=[{"name":"http","port":8080,"protocol":"HTTP"}]' \Where:
VCS_INTEGRATION_IDis the GitHub Aiven app ID.REMOTE_REPOSITORY_IDis the ID of the connected repository.REPOSITORY_URLis the URL of the connected repository.BRANCH_NAMEis the branch to deploy.
To use a project VPC, add
--project-vpc-id VPC_ID. -
Optional: Integrate your data services with the app. For example, to integrate the PostgreSQL service with the app, run:
avn service integration-create \--project PROJECT_NAME \-t application_service_credential \-s example-postgres \-d example-app \--user-config-json '{"service_type":"pg","exposed_values":{"connection_string":{"environment_variable_key":"DATABASE_URL"}}}'
To check the status of your services or applications, run
avn service wait SERVICE_NAME --project PROJECT_NAME.
-
Optional: Create data services to integrate with your application using the
POST /v1/project/{project}/serviceendpoint. For example, the following creates Aiven for PostgreSQL® service:curl -sS -X POST "https://api.aiven.io/v1/project/example-project/service" \-H "Authorization: Bearer $AIVEN_TOKEN" \-H "Content-Type: application/json" \-d '{"service_name": "example-postgres-service","service_type": "pg","plan": "startup-4","cloud": "aws-eu-west-1"}' -
To create the application, use the
POST/v1/project/{project}/serviceendpoint. The following example deploys an application, sets environment variables, and integrates the app with an existing PostgreSQL service:curl -sS -X POST \"https://api.aiven.io/v1/project/PROJECT_NAME/service" \-H "Authorization: Bearer $AIVEN_TOKEN" \-H "Content-Type: application/json" \-d '{"service_name": "example-app","service_type": "application","cloud": "aws-eu-west-1","plan": "startup-50-1024","user_config": {"application": {"source": {"repository_url": "REPOSITORY_URL","branch": "BRANCH_NAME","build_path": "./","containerfile_path": "Dockerfile"},"ports": [{ "name": "http", "port": 8080, "protocol": "HTTP" }],"environment_variables": [{ "key": "LOG_LEVEL", "value": "INFO", "kind": "variable" },{ "key": "API_KEY", "value": "secret", "kind": "secret" }]}},"service_integrations": [{"integration_type": "application_service_credential","source_service": "example-postgres-service","user_config": {"service_type": "pg","exposed_values": {"connection_string": {"environment_variable_key": "DATABASE_URL"}}}}]}'Where:
PROJECT_NAMEis the name of your Aiven project.REPOSITORY_URLis the URL of the connected repository.BRANCH_NAMEis the branch to deploy.containerfile_path: Use the repository-relative path for your Dockerfile or Containerfile. For example,./Dockerfileor./api/Dockerfile.prod.build_pathis the build context and defaults to./.. If you setbuild_pathand omitcontainerfile_path, Aiven searches that directory for a Dockerfile/Containerfile.source_serviceis the name of the service to integrate with the application.
To use a project VPC, add
"project_vpc_id": "VPC_ID".
Redeploy an application
When you redeploy an application, Aiven deploys the latest commit from the selected branch.
- In your project, click Runtime.
- Open your application.
- On the Overview page, click Actions > Deploy latest commit.