forked from pierront/but3-iac
presque fini (je pense)
This commit is contained in:
@@ -4,6 +4,10 @@ terraform {
|
||||
source = "hashicorp/google"
|
||||
version = "~> 6.12.0"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = "~> 2.5.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +19,19 @@ provider "google" {
|
||||
module "network" {
|
||||
source = "../../modules/network"
|
||||
project_name = var.project_name
|
||||
region = var.region
|
||||
frontend_cidr = var.frontend_cidr
|
||||
backend_cidr = var.backend_cidr
|
||||
database_cidr = var.database_cidr
|
||||
region = var.region
|
||||
frontend_cidr = var.frontend_cidr
|
||||
backend_cidr = var.backend_cidr
|
||||
database_cidr = var.database_cidr
|
||||
ssh_source_ranges = var.ssh_source_ranges
|
||||
|
||||
}
|
||||
|
||||
module "compute" {
|
||||
source = "../../modules/compute"
|
||||
|
||||
project_name = var.project_name
|
||||
zone = var.zone
|
||||
instance_type = var.instance_type
|
||||
|
||||
project_name = var.project_name
|
||||
zone = var.zone
|
||||
instance_type = var.instance_type
|
||||
frontend_subnet_id = module.network.subnet_ids["frontend"]
|
||||
backend_subnet_id = module.network.subnet_ids["backend"]
|
||||
database_subnet_id = module.network.subnet_ids["database"]
|
||||
@@ -41,3 +43,15 @@ module "iam" {
|
||||
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" {
|
||||
type = string
|
||||
description = "but3-iac"
|
||||
description = "Nom logique du projet"
|
||||
default = "projet-virtualisation"
|
||||
}
|
||||
|
||||
@@ -38,14 +37,13 @@ variable "database_cidr" {
|
||||
variable "ssh_source_ranges" {
|
||||
type = string
|
||||
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"{
|
||||
description = "id du projet"
|
||||
type = string
|
||||
default = "projet-virtualisation-478713"
|
||||
variable "project_id" {
|
||||
description = "ID du projet GCP"
|
||||
type = string
|
||||
default = "projet-virtualisation-478713"
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
|
||||
@@ -53,7 +53,7 @@ resource "google_compute_instance" "database" {
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = "debian-cloud/debian-11"
|
||||
size = 10
|
||||
size = 20
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
variable "project_name" {
|
||||
type = string
|
||||
description = "Nom du projet / préfixe pour les VMs"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
type = string
|
||||
description = "Type de machine à utiliser pour les instances"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
type = string
|
||||
description = "Zone où déployer les instances"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "frontend_subnet_id" {
|
||||
type = string
|
||||
description = "ID du sous-réseau frontend"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "backend_subnet_id" {
|
||||
type = string
|
||||
description = "ID du sous-réseau backend"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "database_subnet_id" {
|
||||
type = string
|
||||
description = "ID du sous-réseau database"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
variable "project_id" {
|
||||
type = string
|
||||
description = "ID du projet GCP"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "ssh_public_key_path" {
|
||||
type = string
|
||||
description = "Chemin vers la clé publique SSH"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ resource "google_compute_subnetwork" "database_network" {
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "ssh_firewall" {
|
||||
name = "${var.project_name}-ssh"
|
||||
network = google_compute_network.vpc.name
|
||||
direction = "INGRESS"
|
||||
priority = 1000
|
||||
target_tags = ["ssh"]
|
||||
name = "${var.project_name}-ssh"
|
||||
network = google_compute_network.vpc.name
|
||||
direction = "INGRESS"
|
||||
priority = 1000
|
||||
target_tags = ["ssh"]
|
||||
source_ranges = [var.ssh_source_ranges]
|
||||
|
||||
allow {
|
||||
@@ -39,11 +39,11 @@ resource "google_compute_firewall" "ssh_firewall" {
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "frontend_firewall" {
|
||||
name = "${var.project_name}-frontend-http-https"
|
||||
network = google_compute_network.vpc.name
|
||||
direction = "INGRESS"
|
||||
priority = 1000
|
||||
target_tags = ["frontend"]
|
||||
name = "${var.project_name}-frontend-http-https"
|
||||
network = google_compute_network.vpc.name
|
||||
direction = "INGRESS"
|
||||
priority = 1000
|
||||
target_tags = ["frontend"]
|
||||
source_ranges = ["0.0.0.0/0"]
|
||||
|
||||
allow {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
output "vpc_id" {
|
||||
value = google_compute_network.vpc.id
|
||||
description = "ID du VPC créé"
|
||||
value = google_compute_network.vpc.id
|
||||
}
|
||||
|
||||
output "subnet_ids" {
|
||||
description = "Map des IDs des sous-réseaux"
|
||||
value = {
|
||||
frontend = google_compute_subnetwork.frontend_network.id
|
||||
backend = google_compute_subnetwork.backend_network.id
|
||||
|
||||
@@ -1,36 +1,29 @@
|
||||
variable "project_name" {
|
||||
description = "Nom du projet / préfixe des ressources réseau"
|
||||
type = string
|
||||
description = "but3-iac-dick"
|
||||
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Région GCP"
|
||||
type = string
|
||||
description = "Région dans laquelle déployer les ressources"
|
||||
|
||||
}
|
||||
|
||||
variable "frontend_cidr" {
|
||||
description = "CIDR for frontend subnet"
|
||||
description = "CIDR pour le subnet frontend"
|
||||
type = string
|
||||
|
||||
}
|
||||
|
||||
variable "backend_cidr" {
|
||||
description = "CIDR for backend subnet"
|
||||
description = "CIDR pour le subnet backend"
|
||||
type = string
|
||||
|
||||
}
|
||||
|
||||
variable "database_cidr" {
|
||||
description = "CIDR for database subnet"
|
||||
description = "CIDR pour le subnet database"
|
||||
type = string
|
||||
|
||||
}
|
||||
|
||||
variable "ssh_source_ranges" {
|
||||
description = "Plage IP autorisée pour le SSH"
|
||||
type = string
|
||||
description = "Plages d’adresses autorisées à se connecter en SSH"
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user