1
0
Fork 0
mirror of https://github.com/imjasonh/terraform-playground synced 2026-07-08 15:55:17 +00:00
terraform-playground/container-vm/README.md
Jason Hall 4e047293ed dry
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-11-30 14:52:44 -05:00

1.3 KiB

container-vm

Terraform module that creates a GCE instance template running Docker containers on Container-Optimized OS, managed via cloud-init and systemd.

This is intended to simulate and replace the deprecated container startup agent using cloud-init.

Features

  • Runs one or more containers with systemd service management
  • Supports Container-Optimized OS (COS) with pre-installed Docker
  • Artifact Registry authentication via docker-credential-gcr
  • Cloud Logging integration with gcplogs driver
  • Shielded VM with secure boot enabled
  • Requires digest-pinned container images for security

Usage

module "container_vm" {
  source = "./container-vm"

  project_id             = "my-project"
  region                 = "us-east4"
  network                = "default"
  subnetwork             = "default"
  service_account_email  = "my-sa@my-project.iam.gserviceaccount.com"

  containers = {
    web = {
      image = "us-east4-docker.pkg.dev/my-project/my-repo/app@sha256:abc123..."
      ports = ["8080:8080"]
      env = [{
        name  = "PORT"
        value = "8080"
      }]
    }
  }
}

// Next, create VM instances from this template, route traffic to them via GCLB, etc.