forked from pierront/but3-iac
43 lines
1.0 KiB
HCL
43 lines
1.0 KiB
HCL
# Provider Google
|
|
provider "google" {
|
|
project = var.project_id
|
|
region = var.region
|
|
zone = var.zone
|
|
}
|
|
|
|
# Module IAM
|
|
module "iam" {
|
|
source = "../../modules/iam"
|
|
project_id = var.project_id
|
|
}
|
|
|
|
# Module Compute
|
|
module "compute" {
|
|
source = "../../modules/compute"
|
|
instance_type = var.instance_type
|
|
zone = var.zone
|
|
frontend_subnet_id = var.frontend_subnet_id
|
|
backend_subnet_id = var.backend_subnet_id
|
|
database_subnet_id = var.database_subnet_id
|
|
}
|
|
|
|
# Exemple de création d'un template pour Ansible
|
|
data "template_file" "ansible_inventory" {
|
|
template = <<EOT
|
|
[frontend]
|
|
${module.compute.frontend_internal_ip} ansible_user=YOUR_SSH_USER
|
|
|
|
[backend]
|
|
${module.compute.backend_internal_ip} ansible_user=YOUR_SSH_USER
|
|
|
|
[database]
|
|
${module.compute.database_internal_ip} ansible_user=YOUR_SSH_USER
|
|
EOT
|
|
}
|
|
|
|
# Optionnel : écrire le fichier sur le disque
|
|
resource "local_file" "ansible_inventory" {
|
|
content = data.template_file.ansible_inventory.rendered
|
|
filename = "${path.module}/inventory.ini"
|
|
}
|