locals map holds what differs between the environments, and for_each creates one copy of each resource per entry. Production uses a managed database from a blueprint, which needs an AWS cluster.
Configuration
variables.tf
main.tf
- Git branch: each environment builds its own branch.
- Instances: production runs three instances of the application.
- Database: development and staging run PostgreSQL in a container on the cluster. Production runs Amazon RDS for PostgreSQL, created from a blueprint of the service catalog with
qovery_blueprint. This blueprint needs an AWS cluster.instance_classandallocated_storageare variables of the blueprint. - Auto-deploy: new commits redeploy development and staging. Production is deployed by
qovery_deploymentor from the Console: to deploy it again after a change, setversionon itsqovery_deploymentto a new UUID.
DATABASE_URL. For a container database, it is an alias of a built-in secret. For the managed database, it is a secret that Qovery builds from the outputs of the blueprint when it deploys the application. Application with Database explains both.
Deploy
local.environments. To keep a separate state per environment, move the resources into a module and call it from one root configuration per environment, or use workspaces: see Advanced Patterns.
Next steps
Application with Database
Connect services with built-in variables
Advanced Patterns
Modules, workspaces and remote state
Terraform Exporter
Generate the configuration of an existing environment
Terraform Registry
Reference of every resource and data source