tree: 3e76f373ef6af84ce9774b120c1cab0b784a1e4f [path history] [tgz]
  1. bazel/
  2. bazel-testing/
  3. bazel-trusted/
  4. .gitignore
  5. migrate.py
  6. README.md
buildkite/terraform/README.md

This directory contains terraform configuration files to manage pipelines on Buildkite.

terraform
|
|- bazel            # Configuration files for bazel
|- bazel-testing    # Configuration files for bazel-testing
|- bazel-trusted    # Configuration files for bazel-trusted

The terraform state is stored in GCS bucket bazel-buildkite-tf-state (non-public).

Setup

Please follow these steps to setup your local terraform environment:

  1. Install terraform.
  2. Install Google Cloud SDK and authenticate using application default credentials. Make sure you have permissions to access bucket bazel-buildkite-tf-state. Check here for more details about authentication.
  3. Generate Buildkite API token by following this doc. Make sure required scopes are selected and GraphQL is enabled.
  4. Use environment to allow terraform read the API token:
    export BUILDKITE_API_TOKEN=TOKEN
    
  5. Run terraform init in one of the configurtion directories, e.g. terraform/bazel-testing.

Add new pipeline

  1. Add buildkite_pipeline resource, e.g.:
    resource "buildkite_pipeline" "android-testing" {
      name = "Android Testing"
      repository = "https://github.com/googlesamples/android-testing.git"
      steps = templatefile("pipeline.yml.tpl", { flags = ["--file_config=bazelci/buildkite-pipeline.yml"] })
    }
    
    You can check all available properties here.
  2. Run terraform plan to preview the change.
  3. Run terraform apply to apply the change.

Update managed pipeline

  1. Edit buildkite_pipeline resource.
  2. Run terraform plan to preview the change.
  3. Run terraform apply to apply the change.

Import existing pipeline from Buildkite

  1. Add buildkite_pipeline resource, e.g.:
    resource "buildkite_pipeline" "foo" {
    }
    
    It is recommended to name the resource with the slug of existing pipeline.
  2. Find the existing pipeline ID. You can find it in the GraphQL API Integration section of the Pipeline Settings of that pipeline on Buildkite. e.g. UGlwZWxpbmUtLS0xYmJmYmM2NS0wMzE5LTQxMDMtOGY2Yy0zOGQ3MDQyYzVlZjc=
  3. Bind the resource with existing pipeline:
    terraform import buildkite_pipeline.foo PIPELINE_ID
    
  4. The pipeline should be imported. Run terraform plan to see the difference and update the resource accordingly if you don't want to make the change.