forked from pierront/but3-iac
plan fonctionnel
This commit is contained in:
@@ -13,10 +13,10 @@ provider "google" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module "network" {
|
module "network" {
|
||||||
source = "../../modules/network"
|
source = "../../modules/network"
|
||||||
project_name = var.project_name
|
project_name = var.project_name
|
||||||
region = var.region
|
region = var.region
|
||||||
frontend_cidr = var.frontend_cidr
|
frontend_cidr = var.frontend_cidr
|
||||||
backend_cidr = var.backend_cidr
|
backend_cidr = var.backend_cidr
|
||||||
database_cidr = var.database_cidr
|
database_cidr = var.database_cidr
|
||||||
}
|
}
|
||||||
|
|||||||
9
terraform/environments/dev/terraform.tfstate
Normal file
9
terraform/environments/dev/terraform.tfstate
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"terraform_version": "1.14.1",
|
||||||
|
"serial": 1,
|
||||||
|
"lineage": "da2290d8-f11d-ccf7-84e7-3247a89ead2c",
|
||||||
|
"outputs": {},
|
||||||
|
"resources": [],
|
||||||
|
"check_results": null
|
||||||
|
}
|
||||||
@@ -16,26 +16,26 @@ variable "database_cidr" {
|
|||||||
default = "10.0.3.0/24"
|
default = "10.0.3.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "project_name"{
|
variable "project_name" {
|
||||||
description = "name of the project"
|
description = "name of the project"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.4.0/24"
|
default = "10.0.4.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "region"{
|
variable "region" {
|
||||||
description = "region of the project"
|
description = "region of the project"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.5.0/24"
|
default = "10.0.5.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "project_id"{
|
variable "project_id" {
|
||||||
description = "id of the project"
|
description = "id of the project"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.6.0/24"
|
default = "10.0.6.0/24"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh_source_ranges"{
|
variable "ssh_source_ranges" {
|
||||||
description = "range of sources"
|
description = "range of sources"
|
||||||
type = string
|
type = string
|
||||||
default = "10.0.7.0/24"
|
default = "10.0.7.0/24"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,43 +3,67 @@ resource "google_compute_network" "vpc" {
|
|||||||
auto_create_subnetworks = "false"
|
auto_create_subnetworks = "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "frontend" "subnet" {
|
resource "google_compute_subnetwork" "frontend" {
|
||||||
name = "sub_fr"
|
name = "subfr"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
ip_cidr_range = "10.0.1.0/24"
|
ip_cidr_range = "10.0.1.0/24"
|
||||||
region = "europe-west9"
|
region = "europe-west9"
|
||||||
provider = google
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "google_compute_subnetwork" "backend" {
|
||||||
|
name = "subba"
|
||||||
|
network = google_compute_network.vpc.id
|
||||||
|
ip_cidr_range = "10.0.2.0/24"
|
||||||
|
region = "europe-west9"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "google_compute_subnetwork" "database" {
|
||||||
|
name = "subda"
|
||||||
|
network = google_compute_network.vpc.id
|
||||||
|
ip_cidr_range = "10.0.3.0/24"
|
||||||
|
region = "europe-west9"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "google_compute_firewall" "allow_http_https"{
|
||||||
|
name = "allowhttphttps"
|
||||||
|
network = google_compute_network.vpc.id
|
||||||
|
|
||||||
allow {
|
allow {
|
||||||
protocol = ssh
|
protocol = "tcp"
|
||||||
|
ports = ["80", "443"]
|
||||||
|
}
|
||||||
|
|
||||||
|
source_ranges = ["0.0.0.0/0"]
|
||||||
|
target_tags = ["frontend"]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "google_compute_firewall" "ssh_f_b"{
|
||||||
|
name = "sshfb"
|
||||||
|
network = google_compute_network.vpc.id
|
||||||
|
|
||||||
|
allow {
|
||||||
|
protocol = "ssh"
|
||||||
ports = ["8000"]
|
ports = ["8000"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source_tags = ["frontend"]
|
||||||
target_tags = ["backend"]
|
target_tags = ["backend"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "backend" "subnet" {
|
resource "google_compute_firewall" "ssh_b_d"{
|
||||||
name = "sub_ba"
|
name = "sshbd"
|
||||||
network = google_compute_network.vpc.id
|
network = google_compute_network.vpc.id
|
||||||
ip_cidr_range = "10.0.2.0/24"
|
|
||||||
region = "europe-west9"
|
|
||||||
provider = google
|
|
||||||
|
|
||||||
allow {
|
allow {
|
||||||
protocol = ssh
|
protocol = "ssh"
|
||||||
ports = ["3306"]
|
ports = ["3306"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source_tags = ["backend"]
|
||||||
target_tags = ["database"]
|
target_tags = ["database"]
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
resource "database" "subnet" {
|
|
||||||
name = "sub_da"
|
|
||||||
network = google_compute_network.vpc.id
|
|
||||||
ip_cidr_range = "10.0.3.0/24"
|
|
||||||
region = "europe-west9"
|
|
||||||
provider = google
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
output "vpc_id" {
|
output "vpc_id" {
|
||||||
description = "id du vpc"
|
description = "id du vpc"
|
||||||
value = google_compute_network.id
|
value = google_compute_network.vpc.id
|
||||||
}
|
}
|
||||||
|
|
||||||
output "subnets" {
|
output "subnets" {
|
||||||
description = "ids of subnets"
|
description = "ids of subnets"
|
||||||
value = {
|
value = {
|
||||||
fr_id = frontend.id
|
fr_id = google_compute_subnetwork.frontend.id
|
||||||
ba_id = backend.id
|
ba_id = google_compute_subnetwork.backend.id
|
||||||
dat_id = database.id
|
dat_id = google_compute_subnetwork.database.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user