Created
April 15, 2022 20:57
-
-
Save rtrentin73/d15eb574893c2f0bf60c6de12439be29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_compute_instance" "instance-1" { | |
name = "ce-spoke10-instance" | |
machine_type = "g1-small" | |
zone = "${var.region}-b" | |
tags = ["ce-spoke10-instance"] | |
boot_disk { | |
initialize_params { | |
image = "centos-cloud/centos-stream-8" | |
} | |
} | |
network_interface { | |
network = "gcp-spoke10-us-west1" | |
subnetwork = "gcp-spoke10-us-west1" | |
access_config {} | |
} | |
metadata = { | |
ssh-keys = "centos:${file("~/.ssh/id_rsa.pub")}" | |
} | |
metadata_startup_script = "sudo yum clean all; sudo yum update -y; sudo yum install httpd -y; sudo systemctl start httpd; sudo systemctl enable httpd" | |
resource_policies = ["https://www.googleapis.com/compute/v1/projects/rtrentin-01/regions/us-west1/resourcePolicies/stop-compute-engine"] | |
} | |
resource "google_compute_firewall" "firewall-instance-ingress-1" { | |
name = "ce-spoke10-instance-${var.region}-b-ingress-rules" | |
network = "gcp-spoke10-us-west1" | |
allow { | |
protocol = "icmp" | |
} | |
allow { | |
protocol = "tcp" | |
ports = ["22"] | |
} | |
allow { | |
protocol = "tcp" | |
ports = ["80"] | |
} | |
allow { | |
protocol = "tcp" | |
ports = ["443"] | |
} | |
target_tags = ["ce-spoke10-instance"] | |
source_ranges = ["${data.http.ip.body}/32", "172.16.0.0/12", "130.211.0.0/22", "35.191.0.0/16"] | |
} | |
resource "google_compute_instance" "instance-2" { | |
name = "ce-spoke20-instance" | |
machine_type = "g1-small" | |
zone = "${var.region}-b" | |
tags = ["ce-spoke20-instance"] | |
boot_disk { | |
initialize_params { | |
image = "centos-cloud/centos-stream-8" | |
} | |
} | |
network_interface { | |
network = "gcp-spoke20-us-west1" | |
subnetwork = "gcp-spoke20-us-west1" | |
access_config {} | |
} | |
metadata = { | |
ssh-keys = "centos:${file("~/.ssh/id_rsa.pub")}" | |
} | |
metadata_startup_script = "sudo yum clean all; sudo yum update -y; sudo yum install httpd -y; sudo systemctl start httpd; sudo systemctl enable httpd" | |
resource_policies = ["https://www.googleapis.com/compute/v1/projects/rtrentin-01/regions/us-west1/resourcePolicies/stop-compute-engine"] | |
} | |
resource "google_compute_firewall" "firewall-instance-ingress-2" { | |
name = "ce-spoke20-instance-${var.region}-b-ingress-rules" | |
network = "gcp-spoke20-us-west1" | |
allow { | |
protocol = "icmp" | |
} | |
allow { | |
protocol = "tcp" | |
ports = ["22"] | |
} | |
allow { | |
protocol = "tcp" | |
ports = ["80"] | |
} | |
allow { | |
protocol = "tcp" | |
ports = ["443"] | |
} | |
target_tags = ["ce-spoke20-instance"] | |
source_ranges = ["${data.http.ip.body}/32", "172.16.0.0/12", "130.211.0.0/22", "35.191.0.0/16"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment