Skip to content

Instantly share code, notes, and snippets.

@Tensho
Last active October 25, 2024 15:02
Show Gist options
  • Save Tensho/924eefb126ee1f38c60c46988eed12a8 to your computer and use it in GitHub Desktop.
Save Tensho/924eefb126ee1f38c60c46988eed12a8 to your computer and use it in GitHub Desktop.

Revisions

  1. Tensho revised this gist Oct 25, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions security_policy.tf
    Original file line number Diff line number Diff line change
    @@ -29,10 +29,10 @@ resource "google_compute_security_policy" "default" {
    match {
    versioned_expr = "SRC_IPS_V1"
    config {
    src_ip_ranges = ["2.2.2.2/32"]
    src_ip_ranges = ["22.22.22.22/32"]
    }
    }
    description = "Deny access to IPs in 2.2.2.2/32"
    description = "Deny access to IPs in 22.22.22.22/32"
    }

    rule {
  2. Tensho revised this gist Oct 25, 2024. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions security_policy.tf
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,18 @@ resource "google_compute_security_policy" "default" {
    description = "Deny access to IPs in 1.1.1.1/32"
    }

    rule {
    action = "deny(403)"
    priority = "2000"
    match {
    versioned_expr = "SRC_IPS_V1"
    config {
    src_ip_ranges = ["2.2.2.2/32"]
    }
    }
    description = "Deny access to IPs in 2.2.2.2/32"
    }

    rule {
    action = "allow"
    priority = "2147483647"
  3. Tensho created this gist Oct 25, 2024.
    37 changes: 37 additions & 0 deletions security_policy.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    terraform {
    required_providers {
    google = {
    source = "hashicorp/google"
    version = "~> 6.8"
    }
    }
    }

    resource "google_compute_security_policy" "default" {
    name = "test"
    description = "https://github.com/GoogleCloudPlatform/terraform-google-cloud-armor/issues/136"

    rule {
    action = "deny(403)"
    priority = "1000"
    match {
    versioned_expr = "SRC_IPS_V1"
    config {
    src_ip_ranges = ["1.1.1.1/32"]
    }
    }
    description = "Deny access to IPs in 1.1.1.1/32"
    }

    rule {
    action = "allow"
    priority = "2147483647"
    match {
    versioned_expr = "SRC_IPS_V1"
    config {
    src_ip_ranges = ["*"]
    }
    }
    description = "Default rule"
    }
    }