locals map holds what differs between the environments, and for_each creates one copy of each resource per entry.
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 uses your cloud provider’s managed database service, which requires
instance_type.db.t3.mediumis an AWS RDS instance type: use one that your cloud provider offers. The databasemodecannot change after creation. - Auto-deploy: new commits redeploy development and staging. Production is deployed by
qovery_deploymentor from the Console.
DATABASE_URL, as explained in Application with Database.
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