diff --git a/docs/data-sources/git_auth.md b/docs/data-sources/git_auth.md new file mode 100644 index 00000000..5573993d --- /dev/null +++ b/docs/data-sources/git_auth.md @@ -0,0 +1,50 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "coder_git_auth Data Source - terraform-provider-coder" +subcategory: "" +description: |- + Use this data source to require users to authenticate with a Git provider prior to workspace creation. This can be used to perform an authenticated git clone in startup scripts. +--- + +# coder_git_auth (Data Source) + +Use this data source to require users to authenticate with a Git provider prior to workspace creation. This can be used to perform an authenticated `git clone` in startup scripts. + +## Example Usage + +```terraform +provider "coder" { +} + +data "coder_git_auth" "github" { + # Matches the ID of the git auth provider in Coder. + id = "github" +} + +resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + dir = "~/coder" + env = { + GITHUB_TOKEN : data.coder_git_auth.github.access_token + } + startup_script = < +## Schema + +### Required + +- `id` (String) The identifier of a configured git auth provider set up in your Coder deployment. + +### Read-Only + +- `access_token` (String) The access token returned by the git authentication provider. This can be used to pre-authenticate command-line tools. + + diff --git a/examples/data-sources/coder_git_auth/data-source.tf b/examples/data-sources/coder_git_auth/data-source.tf new file mode 100644 index 00000000..eeed89aa --- /dev/null +++ b/examples/data-sources/coder_git_auth/data-source.tf @@ -0,0 +1,21 @@ +provider "coder" { +} + +data "coder_git_auth" "github" { + # Matches the ID of the git auth provider in Coder. + id = "github" +} + +resource "coder_agent" "dev" { + os = "linux" + arch = "amd64" + dir = "~/coder" + env = { + GITHUB_TOKEN : data.coder_git_auth.github.access_token + } + startup_script = <