Closed kelvintaywl closed 1 year ago
After some quick digging, it looks possible to implement with the Go SDK. The runner resource class and token management are via RESTful APIs: Ref: https://github.com/CircleCI-Public/circleci-cli/blob/develop/api/runner/runner.go
After exploring and confirming the APIs, I've made a (separate) Go SDK for the Runner APIs here: https://github.com/kelvintaywl/circleci-runner-go-sdk
reasons for separate SDK: https://github.com/kelvintaywl/circleci-runner-go-sdk#notes
Right now, CircleCI users have to set up self-hosted Runners by creating resources like a Runner resource class and token. Users have to create these resource via a CircleCI CLI.
Ref: https://circleci.com/docs/runner-overview/
It would improve developer experience if this (or any) CircleCI Terraform provider can map the management of Runner resource class and tokens via Terraform then. I imagine platform teams can leverage this to define their self-hosted runners completely in IaC.
For reference, Buildkite's Terraform provider does allow their users to manage tokens for runners (agents): https://registry.terraform.io/providers/buildkite/buildkite/latest/docs/resources/agent_token
One challenge is mapping the CircleCI CLI commands though. Under the hood, likely it fires a GraphQL or RESTful API, so we may be able to take advantage of that.
context: this provider uses CircleCI V2 API (through this SDK) so this does not include any Runner related APIs to manage Runner resource class.