Skip to content

Commit 610187f

Browse files
feat: added organization management by terraform
1 parent 27a40a8 commit 610187f

File tree

9 files changed

+303
-2
lines changed

9 files changed

+303
-2
lines changed

.github/workflows/terraform.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Apply the configuration'
2+
3+
# Attention this workflow can update or even delete repositories it is NOT RECOMMENDED to set it on push.
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
terraform:
9+
name: 'Terraform'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Setup Terraform
16+
uses: hashicorp/setup-terraform@v2
17+
with:
18+
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
19+
20+
- name: Terraform Format
21+
id: fmt
22+
run: terraform fmt -check
23+
24+
- name: Terraform Init
25+
id: init
26+
run: terraform init
27+
28+
- name: Terraform Validate
29+
id: validate
30+
run: terraform validate -no-color
31+
32+
- name: Terraform Apply
33+
if: github.ref == 'refs/heads/main'
34+
run: |
35+
terraform apply -auto-approve -input=false

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
### JetBrains template
2+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
3+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
4+
5+
# JetBrains settings
6+
.idea/
7+
8+
# User-specific stuff
9+
.idea/**/workspace.xml
10+
.idea/**/tasks.xml
11+
.idea/**/usage.statistics.xml
12+
.idea/**/dictionaries
13+
.idea/**/shelf
14+
15+
# Generated files
16+
.idea/**/contentModel.xml
17+
18+
# Sensitive or high-churn files
19+
.idea/**/dataSources/
20+
.idea/**/dataSources.ids
21+
.idea/**/dataSources.local.xml
22+
.idea/**/sqlDataSources.xml
23+
.idea/**/dynamic.xml
24+
.idea/**/uiDesigner.xml
25+
.idea/**/dbnavigator.xml
26+
27+
# Gradle
28+
.idea/**/gradle.xml
29+
.idea/**/libraries
30+
31+
# Gradle and Maven with auto-import
32+
# When using Gradle or Maven with auto-import, you should exclude module files,
33+
# since they will be recreated, and may cause churn. Uncomment if using
34+
# auto-import.
35+
# .idea/artifacts
36+
# .idea/compiler.xml
37+
# .idea/jarRepositories.xml
38+
# .idea/modules.xml
39+
# .idea/*.iml
40+
# .idea/modules
41+
# *.iml
42+
# *.ipr
43+
44+
# CMake
45+
cmake-build-*/
46+
47+
# Mongo Explorer plugin
48+
.idea/**/mongoSettings.xml
49+
50+
# File-based project format
51+
*.iws
52+
53+
# IntelliJ
54+
out/
55+
56+
# mpeltonen/sbt-idea plugin
57+
.idea_modules/
58+
59+
# JIRA plugin
60+
atlassian-ide-plugin.xml
61+
62+
# Cursive Clojure plugin
63+
.idea/replstate.xml
64+
65+
# Crashlytics plugin (for Android Studio and IntelliJ)
66+
com_crashlytics_export_strings.xml
67+
crashlytics.properties
68+
crashlytics-build.properties
69+
fabric.properties
70+
71+
# Editor-based Rest Client
72+
.idea/httpRequests
73+
74+
# Android studio 3.1+ serialized cache file
75+
.idea/caches/build_file_checksums.ser
76+
77+
# Created by .ignore support plugin (hsz.mobi)
78+
### Terraform template
79+
# Local .terraform directories
80+
.terraform/
81+
82+
# .tfstate files
83+
*.tfstate
84+
*.tfstate.*
85+
86+
# Crash log files
87+
crash.log
88+
89+
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
90+
# password, private keys, and other secrets. These should not be part of version
91+
# control as they are data points which are potentially sensitive and subject
92+
# to change depending on the environment.
93+
#
94+
*.tfvars
95+
96+
# Ignore override files as they are usually used to override resources locally and so
97+
# are not checked in
98+
override.tf
99+
override.tf.json
100+
*_override.tf
101+
*_override.tf.json
102+
103+
# Include override files you do wish to add to version control using negated pattern
104+
#
105+
# !example_override.tf
106+
107+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
108+
# example: *tfplan*
109+
110+
# Ignore CLI configuration files
111+
.terraformrc
112+
terraform.rc
113+
.terraform.lock.hcl

.terraformignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git/
2+
.github/
3+
.gitignore
4+
.terraformrc
5+
profile/

README.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,86 @@
11
# dotgithub template
22

3-
Ce dépôt a pour vocation de décrire votre projet sur la page d'accueil de l'organisation GitHub.
3+
Ce dépôt a pour vocation de décrire votre projet sur la page d'accueil de l'organization GitHub.
44

55
Le contenu affiché est rédigé dans le fichier [README.md du dossier profile](./profile/README.md).
6+
7+
# Développement avec Terraform
8+
9+
## Installation
10+
11+
La commande suivante permet d'utiliser la ligne de commande terraform via Docker :
12+
```shell
13+
docker run --rm -it --name terraform -v ~/:/root/ -v $(pwd):/workspace -w /workspace hashicorp/terraform:light
14+
```
15+
16+
Pour une utilisation simplifiée, il est possible de créer un alias :
17+
```shell
18+
alias terraform='docker run --rm -it --name terraform -v ~/:/root/ -v $(pwd):/workspace -w /workspace hashicorp/terraform:light'
19+
```
20+
21+
Avec cet alias, il n'y a plus de différence entre une commande terraform exécutée avec Docker ou avec Terraform CLI.
22+
23+
## Utilisation
24+
25+
### Vérifier et corriger la syntaxe des fichiers `.tf`
26+
27+
```shell
28+
terraform fmt
29+
```
30+
31+
### Vérifier la cohérence de l'infrastructure
32+
33+
```shell
34+
terraform validate
35+
```
36+
37+
### Récupérer un jeton d'authentification à Terraform Cloud en local
38+
39+
```shell
40+
terraform login
41+
```
42+
43+
### Initialiser l'état et les plugins en local
44+
45+
```shell
46+
terraform init
47+
```
48+
49+
### Planifier une exécution pour voir les différences avec l'état précédent de l'infrastructure
50+
51+
```shell
52+
terraform plan
53+
```
54+
55+
## Contribution
56+
57+
### Appliquer la mise à jour de l'infrastructure
58+
59+
Pour que les modifications de la description de l'infrastructure soient appliquées en production, il suffit de publier les changements sur la branche `main`.
60+
61+
## Construit avec
62+
63+
### Langages & Frameworks
64+
65+
- [Terraform](https://www.terraform.io/) est un outil de description d'infrastructure par le code qui permet de créer et de maintenir une infrastructure de manière sûre et prévisible
66+
67+
### Outils
68+
69+
#### CI
70+
71+
- [Github Actions](https://docs.github.com/en/actions) est l'outil d'intégration et de déploiement continu intégré à GitHub
72+
- L'historique des déploiements est disponible [sous l'onglet Actions](https://github.com/romain-cambonie/taxi-network-infrastructure/actions/)
73+
- Secrets du dépôt :
74+
- `TF_API_TOKEN` : Le token d'api Terraform Cloud qui permet à la CI d'opérer des actions sur Terraform Cloud
75+
76+
#### Déploiement
77+
78+
- [Terraform Cloud](https://app.terraform.io/) est la plateforme proposée par HashiCorp pour administrer les modifications d'infrastructure
79+
- Organization : [YourOrgName](https://app.terraform.io/app/YourOrgName/workspaces)
80+
- Workspaces : `organization`
81+
- [organization](https://app.terraform.io/app/YourOrgName/workspaces/organization)
82+
83+
84+
## Licence
85+
86+
Voir le fichier [LICENSE.md](./LICENSE.md) du dépôt.

global.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
locals {
2+
product_information = {
3+
context : {
4+
product = var.organization_name
5+
service = "organization"
6+
start_date = "2023-04-02"
7+
end_date = "unknown"
8+
}
9+
purpose : {
10+
disaster_recovery = "medium"
11+
service_class = "bronze"
12+
}
13+
organization : {
14+
client = var.organization_name
15+
}
16+
stakeholders : {
17+
business_owner = "romain-cambonie@gmail.com"
18+
technical_owner = "romain-cambonie@gmail.com"
19+
approver = "romain-cambonie@gmail.com"
20+
creator = "terraform"
21+
team = "romain-cambonie"
22+
}
23+
repository : ".github"
24+
}
25+
}

main.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
terraform {
2+
backend "remote" {
3+
hostname = "app.terraform.io"
4+
organization = "$ORGANIZATION"
5+
6+
workspaces {
7+
name = "organization"
8+
}
9+
}
10+
11+
required_providers {
12+
github = {
13+
source = "integrations/github"
14+
version = "~> 4.0"
15+
}
16+
}
17+
}
18+
19+
provider "github" {
20+
token = var.github_token
21+
owner = var.organization_name
22+
}
23+
24+

profile/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# My awesome github organisation !
1+
# My awesome github organization !
22

33
A brief description of your project would do wonders here !
44

repositories.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "github_repository" "test_repository" {
2+
name = "test"
3+
description = "Bla bla bla"
4+
visibility = "public"
5+
6+
delete_branch_on_merge = true
7+
}

variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "github_token" {
2+
description = "Your GitHub Personal Access Token"
3+
nullable = false
4+
default = false
5+
}
6+
7+
variable "organization_name" {
8+
description = "Your Organization Name"
9+
nullable = false
10+
default = false
11+
}

0 commit comments

Comments
 (0)