vulndb/terraform
Tatiana Bradley 49c7d2e77f terraform/environment: remove scan-modules job
Remove the "scan-modules" job from the terraform config. Once this
change is applied and we have verified that the endpoint is not being
hit, we will remove the code for scan-modules.

Change-Id: I1d76fbf504b9b1c71063470fae59163649512107
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/459598
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Run-TryBot: Tatiana Bradley <tatiana@golang.org>
2022-12-28 15:52:56 +00:00
..
environment terraform/environment: remove scan-modules job 2022-12-28 15:52:56 +00:00
README.md terraform: remove unused "dev" environment 2022-09-30 20:01:07 +00:00
main.tf terraform: remove unused "dev" environment 2022-09-30 20:01:07 +00:00

README.md

Terraform configuration for vuln worker

External variables

Some inputs to this config are not checked into the repo. You can provide them on the terraform command line, or create a terraform.tfvars file in this directory with the information, like this one:

prod_project    = "prod-project"
prod_issue_repo = "org/repo"
prod_client_id  = "xyzzy@apps.googleusercontent.com"

terraform.tfvars is in the repo's .gitignore file, so it won't show up in git status. Do not check it into the repo.

Cloud Run image

We use terraform to set up the Cloud Run service, but we deploy in other ways. Our deploy process changes only the Docker image for the service. If we hardcoded a Docker image into the config, our config would often be out of date (since we apply it rarely compared to deploying), and we would risk overwriting a newer image with the old one in the config.

For that reason, the Docker image in the config is obtained from the service itself, by using a data block:

resource "google_cloud_run_service" "worker" {
  ...
  template {
    spec {
      containers {
        image = data.google_cloud_run_service.worker.template[0].spec[0].containers[0].image
  ...
}

data "google_cloud_run_service" "worker" {
  name     = "${var.env}-vuln-worker"
  project  = var.project
  location = var.region
}

This works fine once the service exists, but before it does we have a circularity: to create the service we need to get the image from the service!

So to create the service:

  1. Build and push a Docker image.
  2. Replace the data.google_cloud_run_service.worker expressions (there are two) with the actual image label.
  3. Run terraform apply.
  4. Undo the replacement.