forked from pierront/but3-iac
Suite
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
# Commentaire
|
||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
google = {
|
google = {
|
||||||
@@ -21,4 +22,19 @@ module "network" {
|
|||||||
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" {
|
||||||
|
source = "../../modules/compute"
|
||||||
|
instance_type = var.instance_type
|
||||||
|
zone = var.zone
|
||||||
|
frontend_subnet_id = module.network.subnet_ids.frontend
|
||||||
|
backend_subnet_id = module.network.subnets.backend
|
||||||
|
database_subnet_id = module.network.subnets.database
|
||||||
|
}
|
||||||
|
|
||||||
|
module "iam" {
|
||||||
|
source = "../../modules/iam"
|
||||||
|
project_id = var.project_id
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
output "ip_internes" {
|
output "ip_internes" {
|
||||||
value = {
|
value = module.compute.ip_internes
|
||||||
frontend = google_compute_instance.vm_frontend.network_interface[0].network_ip
|
|
||||||
backend = google_compute_instance.vm_backend.network_interface[0].network_ip
|
|
||||||
database = google_compute_instance.vm_database.network_interface[0].network_ip
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output "ip_public_frontend" {
|
output "ip_public_frontend" {
|
||||||
value = google_compute_instance.vm_frontend.network_interface[0].access_config[0].nat_ip
|
value = module.compute.vm_frontend.network_interface[0].access_config[0].nat_ip
|
||||||
}
|
}
|
||||||
|
|
||||||
output "nom_instances" {
|
output "nom_instances" {
|
||||||
value = {
|
value = {
|
||||||
frontend = google_compute_instance.vm_frontend.name
|
frontend = module.compute.nom_instances.vm_frontend
|
||||||
backend = google_compute_instance.vm_backend.name
|
backend = google_compute_instance.vm_backend.name
|
||||||
database = google_compute_instance.vm_database.name
|
database = google_compute_instance.vm_database.name
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,4 +43,27 @@ variable "project_id"{
|
|||||||
default = "automaticsearch-477610"
|
default = "automaticsearch-477610"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "instance_type" {
|
||||||
|
description = "Type de machine à utiliser pour les instances"
|
||||||
|
type = string
|
||||||
|
default = "e2-small"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "zone" {
|
||||||
|
description = "Zone où déployer les instances"
|
||||||
|
type = string
|
||||||
|
default = "europe-west9-b"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
variable "project_id" {
|
||||||
|
description = "Le projet ID"
|
||||||
|
type = string
|
||||||
|
default = "instance-20251203-132021"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
resource "google_service_account" "myaccount" {
|
||||||
|
account_id = "terraform"
|
||||||
|
display_name = "terraform"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_service_account_key" "mykey" {
|
||||||
|
service_account_id = google_service_account.myaccount.name
|
||||||
|
public_key_type = "TYPE_X509_PEM_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "google_project_iam_binding" "project_iam" {
|
||||||
|
project = var.project_id
|
||||||
|
role = "roles/view"
|
||||||
|
|
||||||
|
members = [
|
||||||
|
"serviceAccount:${google_service_account.myaccount.email}",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
data "google_client_openid_userinfo" "me" {
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_os_login_ssh_public_key" "cache" {
|
||||||
|
user = data.google_client_openid_userinfo.me.email
|
||||||
|
key = file("~/.ssh/id_ed25519")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
variable "project_id" {
|
||||||
|
description = "Le projet ID"
|
||||||
|
type = string
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user