mirror of
https://github.com/ghndrx/GSP662.git
synced 2026-02-10 15:04:57 +00:00
commit new all
This commit is contained in:
41
modules/network/main.tf
Normal file
41
modules/network/main.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
# Define VPC
|
||||
resource "google_compute_network" "vpc_network" {
|
||||
name = var.vpc_name
|
||||
project = var.project_id
|
||||
auto_create_subnetworks = false
|
||||
}
|
||||
|
||||
# Define subnetwork
|
||||
resource "google_compute_subnetwork" "vpc_subnet" {
|
||||
name = var.subnet_name
|
||||
ip_cidr_range = var.subnet_cidr_range
|
||||
region = var.region
|
||||
network = google_compute_network.vpc_network.self_link
|
||||
}
|
||||
|
||||
# Define firewall rule for frontend instances
|
||||
resource "google_compute_firewall" "frontend_firewall" {
|
||||
name = "allow-frontend"
|
||||
network = google_compute_network.vpc_network.self_link
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = ["8080"]
|
||||
}
|
||||
|
||||
target_tags = ["frontend"]
|
||||
}
|
||||
|
||||
# Define firewall rule for backend instances
|
||||
resource "google_compute_firewall" "backend_firewall" {
|
||||
name = "allow-backend"
|
||||
network = google_compute_network.vpc_network.self_link
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = ["8081-8082"]
|
||||
}
|
||||
|
||||
target_tags = ["backend"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user