OIDC gcp format#3480
Merged
Merged
Conversation
Contributor
Author
|
@samgaudet i couldn't push changes to your branch so i made my own -- hope that's ok! |
samgaudet
reviewed
Sep 16, 2025
samgaudet
left a comment
Contributor
There was a problem hiding this comment.
LGTM—thank you for supporting these changes!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based off of @samgaudet's excellent work in #3472
Description
This PR introduces functionality to return Buildkite OIDC tokens wrapped in standard JSON expected by GCP for use in Workload Identity Federation Credentials. With this change in place, using GCP Workload Identity Federation with Buildkite is greatly simplified.
Context
When using Workload Identity Federation in GCP with Buildkite, Workload Identity JSON credentials can be structured in several ways (see: External Account Credentials (Workload Identity Federation)). Notably, the most streamlined and secure way of configuring these credentials is to provide a
credential_sourceof a command that returns a token (this nullifies the requirement to save the token anywhere along the way, and instead allows the GCP library to execute the command to fetch the token at the time its needed to exchange the token for a GCP access token).Using an executable
credential_sourcewith Buildkite'soidc request-tokencommand is incompatible, as the output of the executable command is expected to be in a JSON format, not the token by itself.Moreover, using some creative bash scripting to construct a "one-liner" is incompatible as the executable
credential_source, as the underlying method of executing the command in Google's libraries runs a.split()(in Python) that breaks any one-liner apart in an unusable way. For instance, something like this will not work:(Additionally, wrapping that whole thing in
'quotation marks and invoking/bin/bash, etc. won't work, either...)Changes
This PR adds a new CLI flag,
--format, to thebuildkite-agent oidc request-tokencommand. When this flag isgcp, thebuildkite-agent oidc request-tokencommand returns the token wrapped in JSON, as opposed to the default behavior of returning the token as a string.When the
--formatflag is set tojwt(the default), the token will be outputted as a regular base64-encoded JWT. This was the existing behaviour.Testing
go test ./...). Buildkite employees may check this if the pipeline has run automatically.go fmt ./...)Disclosures / Credits
This code was written with the help of Cursor and modified by a human (@samgaudet) before being pushed to this branch. It was then slightly modified further by me (@moskyb).
Closes #3472