terraform-provider-ko

command module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MPL-2.0 Imports: 3 Imported by: 0

README

Terraform Provider for ko

🚨 This is a work in progress. 🚨

https://registry.terraform.io/providers/imjasonh/ko

Usage

To use this provider to build and image and deploy it to Cloud Run:

terraform {
  required_providers {
    ko = {
      source  = "imjasonh/ko"
      version = "0.0.1-pre-3" // Or whatever release
    }
    google = {
      source  = "hashicorp/google"
      version = "4.26.0" // Or whatever release
    }
  }
}

provider "ko" {}

variable "project" {
  type = string
}

provider "google" {
  project = var.project
}

resource "ko_image" "test" {
  // This is a simple HTTP server.
  importpath = "github.com/imjasonh/terraform-provider-ko/cmd/test"
}

resource "google_cloud_run_service" "svc" {
  name = "terraformed"
  location = "us-east4"
  template {
    spec {
      containers {
        image = ko_image.test.image_ref
      }
    }
  }
  traffic {
    percent         = 100
    latest_revision = true
  }
}

(See docs for google_cloud_run_service)

Setup your environment with:

export KO_DOCKER_REPO=gcr.io/[MY-PROJECT]
gcloud auth login
gcloud auth application-default login
terraform init

Then you can build and apply this change with:

terraform apply -var project=[MY-PROJECT]

In this case, the image will be rebuilt every time it's referenced, and will only report as having changed if the image that was built was different since the last time the image resource was read.

This means that terraform plan will rebuild all referenced images, but only show diffs if rebuilds resulted in new images since last time the plan was made.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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