Complete the code to specify the direction of the firewall rule.
resource "google_compute_firewall" "default" { name = "allow-internal" network = "default" direction = "[1]" }
The direction field in a firewall rule specifies if the rule applies to incoming (INGRESS) or outgoing (EGRESS) traffic.
Complete the code to allow TCP traffic on port 80.
resource "google_compute_firewall" "http" { name = "allow-http" network = "default" allow { protocol = "[1]" ports = ["80"] } }
The protocol field specifies the network protocol. For web traffic on port 80, TCP is used.
Fix the error in the source range specification to allow traffic from any IP.
resource "google_compute_firewall" "allow-all" { name = "allow-all" network = "default" allow { protocol = "tcp" ports = ["0-65535"] } source_ranges = ["[1]"] }
The source_ranges field requires a CIDR notation. To allow all IPs, use '0.0.0.0/0'.
Fill both blanks to create a firewall rule that denies all egress UDP traffic.
resource "google_compute_firewall" "deny-udp-egress" { name = "deny-udp-egress" network = "default" direction = "[1]" deny { protocol = "[2]" } }
To block outgoing UDP traffic, set direction to 'EGRESS' and protocol to 'udp' in the deny block.
Fill all three blanks to create a firewall rule allowing SSH from a specific IP range.
resource "google_compute_firewall" "allow-ssh" { name = "allow-ssh" network = "default" direction = "[1]" allow { protocol = "[2]" ports = ["[3]"] } source_ranges = ["192.168.1.0/24"] }
SSH uses TCP protocol on port 22 and is usually allowed for incoming (INGRESS) traffic.