Hi@akhtar,
A Security Policy defines an IP blacklist or whitelist that protects load-balanced Google Cloud services by denying or permitting traffic from specified IP ranges. You can see the below example. It will help you to create a rule in GCP using Terraform.
resource "google_compute_security_policy" "policy" {
name = "my-policy"
rule {
action = "deny(403)"
priority = "1000"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["9.9.9.0/24"]
}
}
description = "Deny access to IPs in 9.9.9.0/24"
}
rule {
action = "allow"
priority = "2147483647"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
}
}
description = "default rule"
}
}