Terraform provider for buildkite
This allows you to manage buildkite pipelines with Terraform.
Run
go get github.com/saymedia/terraform-buildkite/terraform-provider-buildkite
go install github.com/saymedia/terraform-buildkite/terraform-provider-buildkite
Which gives you a terraform-provider-buildkite
in $GOPATH/bin
.
Add the provider to the plugin search path in your home directory (or, in CI, the home directory of whatever user runs terraform). You'll need to make sure the program conforms to the plugin naming convention noted in the Terraform documentation linked above. (eg: terraform-provider-buildkite_vX.Y.Z)
Check provider configuration for information about how to configure the provider.
This provider manages the following resources:
- buildkite_org_member
- buildkite_pipeline
- buildkite_pipeline_schedule
- buildkite_team
- buildkite_team_member
- buildkite_team_pipeline
provider "buildkite" {
# Get an API token from https://buildkite.com/user/api-access-tokens
# Needs: read_pipelines, write_pipelines
# Instead of embedding the API token in the .tf file,
# it can also be passed via env variable BUILDKITE_API_TOKEN
api_token = "YOUR_API_TOKEN"
# This is the part behind https://buildkite.com/, e.g. https://buildkite.com/some-org
# Instead of embedding the org slug in the .tf file,
# it can also be passed via env variable BUILDKITE_ORGANIZATION
organization = "YOUR_ORG_SLUG"
}
resource "buildkite_pipeline" "terraform_test" {
name = "terraform-test"
repository = "[email protected]:you/repo.git"
step = [
{
type = "script"
name = ":llama: Tests"
command = "echo Hello world!"
},
]
}
You can import existing pipeline definitions by their slug:
terraform import buildkite_pipeline.my_name my-pipeline-slug
To do local development you will most likely be working in a Github fork of the repository. After creating your fork you can add it as a remote on your local repository in GOPATH:
cd $GOPATH/src/github.com/saymedia/terraform-buildkite
git remote add mine [email protected]:yourname/terraform-buildkite
git checkout -b yourbranch
git push -u mine yourbranch
After this you should be able to git push
to your fork, and eventually open a PR if you like.
You can build like this:
go install github.com/saymedia/terraform-buildkite/terraform-provider-buildkite
This should produce a file at $GOPATH/bin/terraform-provider-buildkite
. To use this with Terraform you'll need to move that binary to the third-party plugins direcory to help Terraform find this file.
You can see debug output via TF_LOG=DEBUG terraform plan