Created
April 5, 2022 09:37
-
-
Save rtrentin73/131c94db4c89201a74415068621c1ded 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 "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