1
0
Fork 0
mirror of https://github.com/imjasonh/terraform-playground synced 2026-07-06 23:12:22 +00:00
terraform-playground/container-vm
Jason Hall 4e047293ed dry
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-11-30 14:52:44 -05:00
..
cloud-init.yaml.tftpl dry 2025-11-30 14:52:44 -05:00
main.tf dry 2025-11-30 14:52:44 -05:00
outputs.tf Create outputs.tf 2025-11-27 22:35:23 -06:00
README.md dry 2025-11-30 14:52:44 -05:00
variables.tf container-vm: expose ports 2025-11-30 14:13:47 -05:00

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.