Skip to content

Commit 03f2c83

Browse files
Infrastructure : utilisation de Terragrunt (#1826)
* Infrastructure : utilisation de Terragrunt * Ajout d'un workflow pour linter l'infrastructure * Apply suggestions from code review Co-authored-by: Nicolas Oudard <nicolas.oudard@beta.gouv.fr> * Update docs Co-authored-by: Nicolas Oudard <nicolas.oudard@beta.gouv.fr> --------- Co-authored-by: Nicolas Oudard <nicolas.oudard@beta.gouv.fr>
1 parent 1d24058 commit 03f2c83

25 files changed

+175
-485
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Terragrunt Lint'
2+
on:
3+
- pull_request
4+
5+
jobs:
6+
terragrunt:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
12+
- name: Install Terragrunt and OpenTofu
13+
uses: gruntwork-io/terragrunt-action@95fc057922e3c3d4cc021a81a213f088f333ddef
14+
with:
15+
tg_version: '0.83.2'
16+
tofu_version: '1.10.3'
17+
18+
- name: Run Tofu format check
19+
run: |
20+
cd infrastructure/
21+
tofu fmt -recursive -check
22+
23+
# Address actions/missing-workflow-permissions rule in
24+
# code scanning alerts
25+
permissions:
26+
contents: read

docs/reference/infrastructure/provisioning.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
Cette configuration OpenTofu gère l'infrastructure de QueFaireDeMesObjets sur Scaleway.
44

5-
## OpenTofu
5+
## OpenTofu & Terragrunt
66

7-
Nous utilisons OpenTofu, version open-source de `Terraform`, pour automatiser le provisionning de l'infractructure. \
8-
Suivre la documentation pour installer OpenTofu : https://opentofu.org/docs/intro/install/
7+
Nous utilisons OpenTofu, version open-source de `Terraform`, pour automatiser le provisionning de l'infractructure. [Suivre la documentation](https://opentofu.org/docs/intro/install/) pour installer OpenTofu.
8+
9+
[Terragrunt](https://terragrunt.gruntwork.io/) est utilisé en complément d'OpenTofu pour avoir une configuration DRY. [Suivre la documentation](https://terragrunt.gruntwork.io/docs/getting-started/install/) pour installer Terragrunt.
910

1011
La configuration est définie dans le dossier `infrastructure`
1112

@@ -23,9 +24,8 @@ Vérifer que vous avez les droits d'administration du projet concerné par cette
2324
infrastructure/
2425
├── environments/
2526
│ ├── prod/
26-
│ │ ├── main.tf
27-
│ │ ├── variables.tf
28-
│ │ ├── terraform.tfvars.exemple
27+
│ │ ├── terragrunt.hcl
28+
│ │ ├── terraform.tfvars.example
2929
│ │ └── terraform.tfvars -> non partagé
3030
│ ├── preprod/
3131
│ └── preview/
@@ -50,9 +50,7 @@ infrastructure/
5050

5151
#### tfstate
5252

53-
⚠️ le `state` est enregistré sur une répertoire s3 de Scaleway s3://
54-
55-
Si ce répertoire n'existe pas, il est nécessaire d'executer la configuration `backend`, cf. [infrastructure/environments/backend](../../../infrastructure/environments/backend/)
53+
⚠️ le `state` est enregistré sur une répertoire s3 de Scaleway `s3://lvao-terraform-state`
5654

5755
#### Par environnement
5856

@@ -63,18 +61,18 @@ Pour chaque environnement :
6361
- [Preprod](../../../infrastructure/environments/preprod)
6462
- [Prod](../../../infrastructure/environments/prod)
6563

66-
Se placer dans le répertoire `infrastructure` et exécuter les commandes suivantes
64+
Se placer dans le répertoire `infrastructure/environments/<ENV>` et exécuter les commandes suivantes
6765

6866
```sh
69-
tofu init -reconfigure
67+
terragrunt init -reconfigure
7068
```
7169

7270
```sh
73-
tofu plan
71+
teragrunt plan
7472
```
7573

7674
```sh
77-
tofu apply
75+
teragrunt apply
7876
```
7977

8078
Pour chaque commande, l'environnement doit-être précisé

infrastructure/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.tfstate
22
*.tfstate.*
33
terraform.tfvars
4-
.terraform
4+
.terraform
5+
.terragrunt-cache

infrastructure/environments/backend/.terraform.lock.hcl

Lines changed: 0 additions & 45 deletions
This file was deleted.

infrastructure/environments/backend/main.tf

Lines changed: 0 additions & 26 deletions
This file was deleted.

infrastructure/environments/backend/terraform.tfvars.example

Lines changed: 0 additions & 7 deletions
This file was deleted.

infrastructure/environments/backend/variables.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

infrastructure/environments/preprod/.terraform.lock.hcl

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/environments/preprod/backend.tf

Lines changed: 0 additions & 19 deletions
This file was deleted.

infrastructure/environments/preprod/main.tf

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)