Skip to content

Instantly share code, notes, and snippets.

@rtrentin73
Created April 5, 2022 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtrentin73/131c94db4c89201a74415068621c1ded to your computer and use it in GitHub Desktop.
Save rtrentin73/131c94db4c89201a74415068621c1ded to your computer and use it in GitHub Desktop.
resource "random_id" "instance_id_spoke3" {
byte_length = 8
}
resource "google_compute_instance" "instance-1-spoke3" {
name = "spoke3-vm-${random_id.instance_id_spoke3.hex}"
machine_type = "f1-micro"
zone = "${var.region}-b"
boot_disk {
initialize_params {
image = "centos-cloud/centos-stream-9"
}
}
network_interface {
network = aviatrix_vpc.vpc_spoke3.name
subnetwork = aviatrix_vpc.vpc_spoke3.subnets[0].name
access_config {}
}
metadata = {
ssh-keys = "centos:${file("~/.ssh/id_rsa.pub")}"
}
metadata_startup_script = "sudo yum update -y; sudo yum install httpd -y; sudo systemctl start httpd; sudo systemctl enable httpd"
}
resource "google_compute_firewall" "firewall-instance-spoke3" {
name = "instance-spoke3-rules"
network = aviatrix_vpc.vpc_spoke3.name
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = ["${data.http.ip.body}/32"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment