Firewall rules are defined at the VPC level (so ignore all the default firewall rules as they only apply to the default VPC).
For your custom VPC, to create a new rule (say ingress allow 80 and 443 traffic), you would create a new rule.
How do I apply this new rule to my compute instance in the VPC?
While creating the rule, you are offered a 'target' option. This is how you target either individual instances or ALL instances in the network (default).
Via Terraform
resource "google_compute_firewall" "sg_appliance" {
name = "${var.environment}-proxy-firewall"
network = "${var.network}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = [ "22", "443" ]
}
source_ranges = [ "0.0.0.0/0" ] // for testing
//source_ranges = ["${var.restricted_src_address}"] // for real
}
Next Steps?
Need help with your GCP efforts? Start the conversation today.