forked from pierront/but3-iac
Update
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
google = {
|
||||
source = "hashicorp/google"
|
||||
version = ">= 4.0"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = ">= 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "google" {
|
||||
project = var.project_id
|
||||
region = var.region
|
||||
zone = var.zone
|
||||
}
|
||||
|
||||
provider "local" {}
|
||||
|
||||
module "iam" {
|
||||
source = "../../modules/iam"
|
||||
|
||||
|
||||
project_id = var.project_id
|
||||
sa_name = "tf-sa"
|
||||
sa_display_name = "Terraform SA for TP"
|
||||
}
|
||||
|
||||
module "compute" {
|
||||
source = "../../modules/compute"
|
||||
|
||||
project_id = var.project_id
|
||||
region = var.region
|
||||
zone = var.zone
|
||||
instance_type = var.instance_type
|
||||
network = var.network
|
||||
frontend_subnet_id = var.frontend_subnet_id
|
||||
backend_subnet_id = var.backend_subnet_id
|
||||
database_subnet_id = var.database_subnet_id
|
||||
ssh_pub_key = var.ssh_pub_key
|
||||
service_account_email = module.iam.service_account_email
|
||||
}
|
||||
|
||||
module "network" {
|
||||
source = "../../modules/network"
|
||||
|
||||
project_name = var.project_id
|
||||
region = var.region
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
output "frontend_public_ip" {
|
||||
value = module.compute.frontend_public_ip
|
||||
}
|
||||
|
||||
output "frontend_internal_ip" {
|
||||
value = module.compute.frontend_internal_ip
|
||||
}
|
||||
|
||||
output "backend_internal_ip" {
|
||||
value = module.compute.backend_internal_ip
|
||||
}
|
||||
|
||||
output "database_internal_ip" {
|
||||
value = module.compute.database_internal_ip
|
||||
}
|
||||
|
||||
output "service_account_email" {
|
||||
value = module.iam.service_account_email
|
||||
}
|
||||
|
||||
output "service_account_key" {
|
||||
value = module.iam.service_account_key
|
||||
sensitive = true
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
variable "project_id" {
|
||||
type = string
|
||||
description = "GCP project id"
|
||||
default = "school-478713"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
description = "The region of the VM"
|
||||
default = "europe-west1"
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
type = string
|
||||
description = "The zone of the VM"
|
||||
default = "europe-west1-b"
|
||||
}
|
||||
|
||||
variable "frontend_subnet_id" {
|
||||
type = string
|
||||
description = "self_link du subnet frontend"
|
||||
default = "projects/my-gcp-project/regions/europe-west1/subnetworks/frontend-subnet"
|
||||
}
|
||||
|
||||
variable "backend_subnet_id" {
|
||||
type = string
|
||||
description = "self_link du subnet backend"
|
||||
default = "projects/my-gcp-project/regions/europe-west1/subnetworks/backend-subnet"
|
||||
}
|
||||
|
||||
variable "database_subnet_id" {
|
||||
type = string
|
||||
description = "self_link du subnet database"
|
||||
default = "projects/my-gcp-project/regions/europe-west1/subnetworks/database-subnet"
|
||||
}
|
||||
|
||||
variable "network" {
|
||||
type = string
|
||||
description = "VPC network self_link or name"
|
||||
default = "projects/my-gcp-project/global/networks/my-vpc"
|
||||
}
|
||||
|
||||
variable "ssh_pub_key" {
|
||||
type = string
|
||||
description = "SSH public key to provision (optional)"
|
||||
default = "ssh-ed25519 AAAA... user@example.com"
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
type = string
|
||||
description = "Type of the VM instance"
|
||||
default = "e2-minimal"
|
||||
}
|
||||
Reference in New Issue
Block a user