forked from pierront/but3-iac
presque fini (je pense)
This commit is contained in:
@@ -4,6 +4,10 @@ terraform {
|
|||||||
source = "hashicorp/google"
|
source = "hashicorp/google"
|
||||||
version = "~> 6.12.0"
|
version = "~> 6.12.0"
|
||||||
}
|
}
|
||||||
|
local = {
|
||||||
|
source = "hashicorp/local"
|
||||||
|
version = "~> 2.5.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +24,6 @@ module "network" {
|
|||||||
backend_cidr = var.backend_cidr
|
backend_cidr = var.backend_cidr
|
||||||
database_cidr = var.database_cidr
|
database_cidr = var.database_cidr
|
||||||
ssh_source_ranges = var.ssh_source_ranges
|
ssh_source_ranges = var.ssh_source_ranges
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module "compute" {
|
module "compute" {
|
||||||
@@ -29,7 +32,6 @@ module "compute" {
|
|||||||
project_name = var.project_name
|
project_name = var.project_name
|
||||||
zone = var.zone
|
zone = var.zone
|
||||||
instance_type = var.instance_type
|
instance_type = var.instance_type
|
||||||
|
|
||||||
frontend_subnet_id = module.network.subnet_ids["frontend"]
|
frontend_subnet_id = module.network.subnet_ids["frontend"]
|
||||||
backend_subnet_id = module.network.subnet_ids["backend"]
|
backend_subnet_id = module.network.subnet_ids["backend"]
|
||||||
database_subnet_id = module.network.subnet_ids["database"]
|
database_subnet_id = module.network.subnet_ids["database"]
|
||||||
@@ -41,3 +43,15 @@ module "iam" {
|
|||||||
ssh_public_key_path = "/home/adriendick18/.ssh/id_ed25519.pub"
|
ssh_public_key_path = "/home/adriendick18/.ssh/id_ed25519.pub"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data "google_client_openid_userinfo" "me" {}
|
||||||
|
|
||||||
|
resource "local_file" "ansible_cfg" {
|
||||||
|
filename = "${path.module}/ansible.cfg"
|
||||||
|
|
||||||
|
content = templatefile(
|
||||||
|
"${path.module}/../../templates/ansile.cfg.tpl",
|
||||||
|
{
|
||||||
|
remote_user = data.google_client_openid_userinfo.me.email
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# Commentaire
|
|
||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
type = string
|
type = string
|
||||||
description = "but3-iac"
|
description = "Nom logique du projet"
|
||||||
default = "projet-virtualisation"
|
default = "projet-virtualisation"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,11 +38,10 @@ variable "ssh_source_ranges" {
|
|||||||
type = string
|
type = string
|
||||||
description = "Plages d’adresses autorisées à se connecter en SSH"
|
description = "Plages d’adresses autorisées à se connecter en SSH"
|
||||||
default = "0.0.0.0/0"
|
default = "0.0.0.0/0"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "project_id" {
|
variable "project_id" {
|
||||||
description = "id du projet"
|
description = "ID du projet GCP"
|
||||||
type = string
|
type = string
|
||||||
default = "projet-virtualisation-478713"
|
default = "projet-virtualisation-478713"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ resource "google_compute_instance" "database" {
|
|||||||
boot_disk {
|
boot_disk {
|
||||||
initialize_params {
|
initialize_params {
|
||||||
image = "debian-cloud/debian-11"
|
image = "debian-cloud/debian-11"
|
||||||
size = 10
|
size = 20
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,29 @@
|
|||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
|
description = "Nom du projet / préfixe pour les VMs"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "instance_type" {
|
variable "instance_type" {
|
||||||
|
description = "Type de machine à utiliser pour les instances"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "zone" {
|
variable "zone" {
|
||||||
|
description = "Zone où déployer les instances"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "frontend_subnet_id" {
|
variable "frontend_subnet_id" {
|
||||||
|
description = "ID du sous-réseau frontend"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "backend_subnet_id" {
|
variable "backend_subnet_id" {
|
||||||
|
description = "ID du sous-réseau backend"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "database_subnet_id" {
|
variable "database_subnet_id" {
|
||||||
|
description = "ID du sous-réseau database"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
variable "project_id" {
|
variable "project_id" {
|
||||||
|
description = "ID du projet GCP"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_public_key_path" {
|
variable "ssh_public_key_path" {
|
||||||
type = string
|
|
||||||
description = "Chemin vers la clé publique SSH"
|
description = "Chemin vers la clé publique SSH"
|
||||||
|
type = string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
output "vpc_id" {
|
output "vpc_id" {
|
||||||
|
description = "ID du VPC créé"
|
||||||
value = google_compute_network.vpc.id
|
value = google_compute_network.vpc.id
|
||||||
}
|
}
|
||||||
|
|
||||||
output "subnet_ids" {
|
output "subnet_ids" {
|
||||||
|
description = "Map des IDs des sous-réseaux"
|
||||||
value = {
|
value = {
|
||||||
frontend = google_compute_subnetwork.frontend_network.id
|
frontend = google_compute_subnetwork.frontend_network.id
|
||||||
backend = google_compute_subnetwork.backend_network.id
|
backend = google_compute_subnetwork.backend_network.id
|
||||||
|
|||||||
@@ -1,36 +1,29 @@
|
|||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
|
description = "Nom du projet / préfixe des ressources réseau"
|
||||||
type = string
|
type = string
|
||||||
description = "but3-iac-dick"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "region" {
|
variable "region" {
|
||||||
|
description = "Région GCP"
|
||||||
type = string
|
type = string
|
||||||
description = "Région dans laquelle déployer les ressources"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "frontend_cidr" {
|
variable "frontend_cidr" {
|
||||||
description = "CIDR for frontend subnet"
|
description = "CIDR pour le subnet frontend"
|
||||||
type = string
|
type = string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "backend_cidr" {
|
variable "backend_cidr" {
|
||||||
description = "CIDR for backend subnet"
|
description = "CIDR pour le subnet backend"
|
||||||
type = string
|
type = string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "database_cidr" {
|
variable "database_cidr" {
|
||||||
description = "CIDR for database subnet"
|
description = "CIDR pour le subnet database"
|
||||||
type = string
|
type = string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_source_ranges" {
|
variable "ssh_source_ranges" {
|
||||||
|
description = "Plage IP autorisée pour le SSH"
|
||||||
type = string
|
type = string
|
||||||
description = "Plages d’adresses autorisées à se connecter en SSH"
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user