All skills
google avatar

/google-cloud-global-frontend-configuration

@becc4b8
by googlegoogle/skills21k stars
1,698

Guides agents through a 6-step discovery process to design and deploy Google Cloud global external Application Load Balancers with Cloud CDN, Cloud Armor, and Service Extensions, mapping workload requirements to best-practice configurations. Use when: - Designing, configuring, or deploying a Google Cloud global external Application Load Balancer, Cloud CDN, Cloud Armor WAF, or Service Extensions. - Discovering existing Google Cloud resources (Cloud Storage, MIGs, GKE, Cloud Run) to use as backends. - Generating production-grade Terraform HCL or gcloud CLI scripts for global external Application Load Balancers. - Actuating deployments via Infrastructure Manager or bash scripts, including IAM pre-checks. - Detecting, analyzing, or reconciling configuration drift on deployed global external Application Load Balancers. Don't use for: - Non-Google Cloud load balancing or security configurations. - Purely regional or internal load balancing setups (unless part of a hybrid/failover global design).

Use this Skill: https://skilld.dev/gh/google/skills/google-cloud-global-frontend-configuration

This session only. Nothing lands on disk.

referencesterraform-module.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Google Cloud global external Application Load Balancer Official Terraform Module Guidelines

This reference document provides guidelines and examples for designing and managing Google Cloud global external Application Load Balancer architectures using the official Google-managed Terraform modules (lb-http and cloud-armor).

Table of Contents


Core Directives

  1. Prefer Official Modules: Whenever generating complex, production-grade configurations, prefer using the official Google-supported modules to ensure best-practices, security defaults, and ongoing updates:
  2. Module Versioning: Always lock the module version to the latest stable major version (e.g., version = "~> 10.0" for lb-http or version = "~> 2.0" for cloud-armor) to prevent breaking changes.
  3. Backend Structure: Map the design spec origins to the backends map of the lb-http module. Each backend entry must configure protocol, enable_cdn, cdn_policy, and its target endpoint groups (groups).

Comprehensive Multi-Backend Example

The following example demonstrates a complete, production-ready main.tf using the official modules to configure a Google Cloud global external Application Load Balancer with three distinct backends (Serverless NEG for API, Google Cloud Storage bucket for static content, and Cloud Armor security policies):

terraform {
  required_version = ">= 1.0"
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 5.0"
    }
  }
}

provider "google" {
  project = var.project_id
  region  = var.region
}

# --- Cloud Armor Security Policies ---

module "security_policy_api" {
  source  = "GoogleCloudPlatform/cloud-armor/google"
  version = "~> 2.0"

  project_id   = var.project_id
  policy_name  = "${var.architecture_name}-waf-api"
  description  = "Cloud Armor WAF policy for API backends"
  default_action = "allow"

  # Rate limiting rule (100 RPM)
  rate_limiting_rules = [
    {
      action        = "throttle"
      priority      = 1000
      description   = "Rate limit API requests"
      src_ip_ranges = ["*"]
      
      rate_limit_options = {
        exceed_action            = "deny(403)"
        rate_limit_threshold = {
          count        = 100
          interval_sec = 60
        }
      }
    }
  ]

  # Preconfigured OWASP rules
  preconfigured_rules = [
    {
      action        = "deny(403)"
      priority      = 9000
      description   = "OWASP SQLi protection"
      expression    = "evaluatePreconfiguredExpr('sqli-v33-stable')"
      src_ip_ranges = ["*"]
    },
    {
      action        = "deny(403)"
      priority      = 9001
      description   = "OWASP XSS protection"
      expression    = "evaluatePreconfiguredExpr('xss-v33-stable')"
      src_ip_ranges = ["*"]
    }
  ]
}

# --- Serverless NEG (Cloud Run) ---

resource "google_compute_region_network_endpoint_group" "serverless_neg" {
  name                  = "${var.architecture_name}-serverless-neg"
  network_endpoint_type = "SERVERLESS"
  region                = var.region
  
  cloud_run {
    service = var.cloud_run_service_name
  }
}

# --- Global Load Balancer (Official Module) ---

module "gce_lb_http" {
  source  = "GoogleCloudPlatform/lb-http/google"
  version = "~> 10.0"

  project       = var.project_id
  name          = var.architecture_name
  firewall_networks = [] # Not creating internal firewall rules for global external LB

  # Frontend Configuration
  ssl                          = true
  use_ssl_certificates        = false
  ssl_certificates             = [google_compute_managed_ssl_certificate.default.id]
  http_forward                 = true

  backends = {
    # Default External Backend (API)
    default = {
      protocol        = "HTTP"
      enable_cdn      = true
      security_policy = module.security_policy_api.policy_id

      cdn_policy = {
        cache_mode = "USE_ORIGIN_HEADERS"
        cache_key_policy = {
          include_query_string = true
        }
      }

      groups = [
        {
          group = google_compute_global_network_endpoint_group.external_neg.id
        }
      ]
    }

    # Google Cloud Storage Bucket Backend
    gcs = {
      protocol        = "HTTP"
      enable_cdn      = true

      cdn_policy = {
        cache_mode  = "CACHE_ALL_STATIC"
        default_ttl = 2592000
        max_ttl     = 2592000
      }

      groups = [
        {
          group = "projects/${var.project_id}/global/backendBuckets/${var.architecture_name}-gcs-backend"
        }
      ]
    }

    # Serverless Backend
    serverless = {
      protocol        = "HTTP"
      enable_cdn      = true
      security_policy = module.security_policy_api.policy_id

      cdn_policy = {
        cache_mode  = "CACHE_ALL_STATIC"
        default_ttl = 2592000
        max_ttl     = 2592000
      }

      groups = [
        {
          group = google_compute_region_network_endpoint_group.serverless_neg.id
        }
      ]
    }
  }

  # Custom Path Routing Matchers
  url_map = {
    default_service = "default"
    path_matchers = {
      main-matcher = {
        default_service = "default"
        path_rules = [
          {
            paths   = ["/api", "/api/*"]
            service = "default"
          },
          {
            paths   = ["/static", "/static/*"]
            service = "gcs"
          },
          {
            paths   = ["/app", "/app/*"]
            service = "serverless"
          }
        ]
      }
    }
  }
}

resource "google_compute_managed_ssl_certificate" "default" {
  name = "${var.architecture_name}-cert"

  managed {
    domains = [var.domain_name]
  }
}

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    This skill facilitates the design and deployment of Google Cloud infrastructure by guiding the configuration of Application Load Balancers. It includes considerations such as automated resource discovery and deployment script generation, which are standard practices for cloud infrastructure management. See the detailed analysis for context on these operations.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at becc4b8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 weeks ago
metadata
{
  "version": "1.0.0",
  "category": "Networking"
}

README badge

README badge for google/skills/google-cloud-global-frontend-configuration