Merge branch 'main' of https://grond.iut-fbleau.fr/dariusy/DEV5.6TP7
This commit is contained in:
commit
5a738414d8
@ -1,40 +1,56 @@
|
|||||||
resource "google_compute_network" "vpc" {
|
resource "google_compute_network" "vpc" {
|
||||||
name = "nom2"
|
name = "myvpc"
|
||||||
auto_create_subnetworks = false
|
auto_create_subnetworks = false
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_subnetwork" "frontend" {
|
# Sous-réseau
|
||||||
name = "frontend"
|
resource "google_compute_subnetwork" "frontend_subnet" {
|
||||||
|
name = "frontend-subnet"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
ip_cidr_range = var.frontend_cidr
|
ip_cidr_range = var.frontend_cidr
|
||||||
region = var.region
|
region = var.region
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_subnetwork" "backend" {
|
# Sous-réseau
|
||||||
name = "backend"
|
resource "google_compute_subnetwork" "backend_subnet" {
|
||||||
|
name = "backend-subnet"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
ip_cidr_range = var.backend_cidr
|
ip_cidr_range = var.backend_cidr
|
||||||
region = var.region
|
region = var.region
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_subnetwork" "db" {
|
# Sous-réseau
|
||||||
name = "db"
|
resource "google_compute_subnetwork" "database_subnet" {
|
||||||
|
name = "database-subnet"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
ip_cidr_range = var.database_cidr
|
ip_cidr_range = var.database_cidr
|
||||||
region = var.region
|
region = var.region
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_firewall" "allow_http-https" {
|
resource "google_compute_firewall" "allow_http" {
|
||||||
name = "allow-http-https"
|
name = "allow-http"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
|
|
||||||
allow {
|
allow {
|
||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
ports = ["80", "443"]
|
ports = ["80"]
|
||||||
}
|
}
|
||||||
|
|
||||||
source_ranges = ["0.0.0.0/0"]
|
source_ranges = ["0.0.0.0/0"]
|
||||||
target_tags = ["web"]
|
target_tags = ["frontend"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_compute_firewall" "allow_https" {
|
||||||
|
name = "allow-https"
|
||||||
|
network = google_compute_network.vpc.id
|
||||||
|
|
||||||
|
allow {
|
||||||
|
protocol = "tcp"
|
||||||
|
ports = ["443"]
|
||||||
|
}
|
||||||
|
|
||||||
|
source_ranges = ["0.0.0.0/0"]
|
||||||
|
target_tags = ["frontend"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_firewall" "allow_ssh" {
|
resource "google_compute_firewall" "allow_ssh" {
|
||||||
@ -47,12 +63,11 @@ resource "google_compute_firewall" "allow_ssh" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
source_ranges = [var.ssh_source_ranges]
|
source_ranges = [var.ssh_source_ranges]
|
||||||
target_tags = ["web"]
|
target_tags = ["ssh"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "google_compute_firewall" "allow_frontend_to_backend" {
|
||||||
resource "google_compute_firewall" "front-to-back" {
|
name = "allow-frontend-to-backend"
|
||||||
name = "front-to-back"
|
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
|
|
||||||
allow {
|
allow {
|
||||||
@ -64,13 +79,13 @@ resource "google_compute_firewall" "front-to-back" {
|
|||||||
target_tags = ["backend"]
|
target_tags = ["backend"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "google_compute_firewall" "back-to-db" {
|
resource "google_compute_firewall" "allow-sql" {
|
||||||
name = "front-to-back"
|
name = "allow-sql"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
|
|
||||||
allow {
|
allow {
|
||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
ports = ["8000"]
|
ports = ["3306"]
|
||||||
}
|
}
|
||||||
|
|
||||||
source_ranges = [var.backend_cidr]
|
source_ranges = [var.backend_cidr]
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
output "id_vpc" {
|
||||||
|
value = google_compute_network.vpc.id
|
||||||
|
}
|
||||||
|
|
||||||
|
output "id_subnetwork" {
|
||||||
|
value = {
|
||||||
|
frontend = google_compute_subnetwork.frontend_subnet.id,
|
||||||
|
backend = google_compute_subnetwork.backend_subnet.id,
|
||||||
|
database = google_compute_subnetwork.database_subnet.id
|
||||||
|
}
|
||||||
|
}
|
@ -1,35 +1,35 @@
|
|||||||
|
|
||||||
variable "project_name" {
|
variable "project_name" {
|
||||||
description = "ID du projet GCP"
|
description = "Nom du projet"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "region" {
|
variable "region" {
|
||||||
description = "region du projet"
|
description = "Région du projet"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
variable "frontend_cidr" {
|
variable "frontend_cidr" {
|
||||||
description = "frontend"
|
description = "cidr du frontend"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "backend_cidr" {
|
variable "backend_cidr" {
|
||||||
description = "backend"
|
description = "cidr du backend"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "database_cidr" {
|
variable "database_cidr" {
|
||||||
description = "database"
|
description = "cidr du database"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_source_ranges" {
|
variable "ssh_source_ranges" {
|
||||||
description = "acces par ssh"
|
description = "Accès à internet"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "cidr_range" {
|
variable "cidr_range" {
|
||||||
description = "cidr-network"
|
description = "cidr de network"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user