Provisioning the infrastructure¶
This OpenTofu configuration manages the QueFaireDeMesObjets infrastructure on Scaleway.
Scaleway¶
All resources on Scaleway are provisioned in the organization Incubateur ADEME (Pathtech) and the project longuevieauxobjets.
All resources are named following the pattern lvao-{env}-{explicit-name} (for example: lvao-prod-webapp-db).
OpenTofu & Terragrunt¶
We use OpenTofu, the open-source version of Terraform, to automate infrastructure provisioning. Follow the documentation to install OpenTofu.
Terragrunt is used alongside OpenTofu to keep the configuration DRY. Follow the documentation to install Terragrunt.
The configuration is defined in the infrastructure directory.
Prerequisites¶
Install and configure the Scaleway CLI by following Scalewayâs instructions.
Make sure you have administration rights on the project targeted by this infrastructure plan.
IaC: Infrastructure as Code¶
Structure¶
infrastructure/
âââ environments/
â âââ prod/
â â âââ terragrunt.hcl
â â âââ terraform.tfvars.example
â â âââ terraform.tfvars -> not versioned
â âââ preprod/
â âââ preview/
âââ modules/
âââ database/
â âââ main.tf
â âââ variables.tf
â âââ outputs.tf
âââ provider/
Configuration¶
Copy
environments/<ENV>/terraform.tfvars.exampletoterraform.tfvars.Edit the values in
terraform.tfvarswith your information:project_id: Scaleway project IDorganization_id: Scaleway organization IDdb_password: secure password for the databaseâŠ
Execution¶
tfstate¶
â ïž The Terraform state is stored in a Scaleway S3 bucket: s3://lvao-terraform-state.
Per environment¶
The preview environment is used to test our IaC project. We intentionally destroy the infrastructure created in this environment once the Terraform configuration has been tested.
For each environment:
Preprod:
infrastructure/environments/preprodat the repository rootProd:
infrastructure/environments/prodat the repository root
Change directory to infrastructure/environments/<ENV> and run:
terragrunt init -reconfigure --all
terragrunt plan --all
terragrunt apply --all
For each command, the environment must be specified.