sevalla-hosting/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.1.0, 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 theSEVALLA_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.
Deploy an application with a database
This configuration creates thestorefront 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
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_deploymenttriggers a deployment when it’s created. Itsis_restartdefaults totrue, which redeploys the existing build, so set it tofalsefor an application that has never been built. To deploy again when something changes, put the changing values in itstriggersmap: a change there replaces the resource and starts a new deployment. Destroying it doesn’t cancel or undo anything. cluster_idcan’t change after creation, on both the application and the database. Neither can the database’stype,version,db_name,db_userordb_password;resource_type_idcan, to resize the database.- 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.