terraform-infra-common

module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: Apache-2.0

README

terraform-infra-common

Static Badge

A repository containing a collection of common infrastructure modules for encapsulating common Cloud Run and GCP patterns.

Modules

See MODULES.md for a summary of all available modules.

Usage

To use components in this library, you must provide the project in a provider.google resource in your top-level main.tf:

provider "google" {
  project = var.project
}

Resource Labeling Convention

All modules in this repository follow a consistent labeling pattern for GCP cost allocation and resource organization:

locals {
  default_labels = {
    basename(abspath(path.module)) = var.name
    terraform-module               = basename(abspath(path.module))
    product                        = var.product
    team                           = var.team
  }

  merged_labels = merge(local.default_labels, var.labels)
}

This pattern:

  • Enables cost tracking to break down each module by use
  • Maintains consistency across all infrastructure modules
  • Supports team attribution through team labels (with backward compatibility for deprecated squad)
  • Allows custom labels via the labels variable
  • Provides module identification via the terraform-module label
  • Sets both squad and team labels to the same value for resource tagging

The basename(abspath(path.module)) automatically derives the module name (e.g., "gke", "redis", "workqueue") without requiring hardcoded values.

Team vs Squad

All modules support both team and squad variables for backward compatibility:

  • Use team for new code (preferred)
  • squad is deprecated but still supported
  • team takes precedence if both are provided
  • If neither is specified, both labels default to "unknown"

Submitting Changes

These modules are canonically located within a private Chainguard repository, and are continuously pushed from there to this repository.

If you would like to submit a PR, please do make one against this repository. After the review process, someone at Chainguard will merge it into our internal repository, and the change will then be pushed here.

Directories

Path Synopsis
cmd
replayer command
modules
cron/example module
pkg
httpmetrics
Package httpmetrics provides HTTP middleware and transport wrappers that instrument requests with Prometheus metrics, OpenTelemetry tracing, and structured logging for Cloud Run services.
Package httpmetrics provides HTTP middleware and transport wrappers that instrument requests with Prometheus metrics, OpenTelemetry tracing, and structured logging for Cloud Run services.
httpmetrics/cloudevents
Package cloudevents provides helpers for creating CloudEvents HTTP clients and targets that are instrumented with httpmetrics middleware.
Package cloudevents provides helpers for creating CloudEvents HTTP clients and targets that are instrumented with httpmetrics middleware.
prober
Package prober provides a framework for implementing Chainguard probers that expose an HTTP endpoint for health checking.
Package prober provides a framework for implementing Chainguard probers that expose an HTTP endpoint for health checking.
profiler
Package profiler provides helpers for enabling Google Cloud Profiler in Cloud Run services.
Package profiler provides helpers for enabling Google Cloud Profiler in Cloud Run services.
pubsub
Package pubsub provides helpers for converting CloudEvents to and from Google Cloud Pub/Sub messages.
Package pubsub provides helpers for converting CloudEvents to and from Google Cloud Pub/Sub messages.
rotate
Package rotate provides utilities for uploading and rotating log files to cloud blob storage.
Package rotate provides utilities for uploading and rotating log files to cloud blob storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL