Skip to main content
The Sevalla Terraform provider, sevalla/sevalla on the Terraform Registry, manages Sevalla services as code through the Sevalla API. It has 29 resources and 20 data sources. The current version is 1.2.1, and it works with Terraform 1.0 or later.

Before you begin

  • Terraform 1.0 or later.
  • An API key with the permissions for the resources you manage. A plan that creates applications and databases needs create, read, update and delete on them.

Configure the provider

Add the provider to your configuration and give it the API key through the SEVALLA_API_KEY environment variable:
main.tf
Without a key, terraform plan stops with The Sevalla API key must be set in the provider configuration or via the SEVALLA_API_KEY environment variable.

Move from the old provider address

The provider used to be published as sevalla-hosting/sevalla. That address stops at 1.1.0, and new versions are published only as sevalla/sevalla. To move an existing configuration:
1

Update the source

In required_providers, set source = "sevalla/sevalla" and version = "~> 1.2".
2

Move the state to the new address

Run these commands in the configuration’s directory. terraform state replace-provider lists the resources it changes and asks for confirmation.
terraform providers then lists registry.terraform.io/sevalla/sevalla for both the configuration and the state.

Deploy an application with a database

This configuration creates the storefront application from a public repository in Frankfurt, a PostgreSQL database orders-db in the same location, an internal connection between them, a DATABASE_URL environment variable, and the application’s first deployment.
main.tf
After terraform apply, the application appears under Applications with its first deployment running, and orders-db under Databases. Things to know about this configuration:
  • Creating an application doesn’t deploy it. sevalla_application_deployment triggers a deployment when it’s created. Its is_restart defaults to true, which redeploys the existing build, so set it to false for an application that has never been built. To deploy again when something changes, put the changing values in its triggers map: a change there replaces the resource and starts a new deployment. With wait_for_completion = true, terraform apply waits up to 60 minutes for the deployment to finish and fails if it fails or is cancelled. Destroying it doesn’t cancel or undo anything.
  • Changing cluster_id replaces the application or the database. So does changing the database’s type, version, db_name or db_user, and replacing a database deletes its data. resource_type_id changes in place to resize the database, and db_password changes in place by resetting the password.
  • Database versions depend on the engine and the location. The Create a database form shows the versions you can use.
  • The Terraform state holds the database password and environment variable values in plain text. Keep the state in an encrypted backend with restricted access.

Resources

Import an existing service so Terraform manages it, for example:

Data sources

Every resource’s arguments and attributes are on the Terraform Registry. The source and issues are on GitHub.