mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
docs: add coderd terraform provider (#14374)
This commit is contained in:
71
docs/templates/change-management.md
vendored
71
docs/templates/change-management.md
vendored
@ -1,7 +1,69 @@
|
||||
# Template Change Management
|
||||
|
||||
We recommend source-controlling your templates as you would other code. You can
|
||||
[install Coder](../install/) in CI/CD pipelines to push new template versions.
|
||||
We recommend source-controlling your templates as you would other any code, and
|
||||
automating the creation of new versions in CI/CD pipelines.
|
||||
|
||||
These pipelines will require tokens for your deployment. To cap token lifetime
|
||||
on creation,
|
||||
[configure Coder server to set a shorter max token lifetime](../reference/cli/server.md#--max-token-lifetime).
|
||||
|
||||
## coderd Terraform Provider
|
||||
|
||||
The
|
||||
[coderd Terraform provider](https://registry.terraform.io/providers/coder/coderd/latest)
|
||||
can be used to push new template versions, either manually, or in CI/CD
|
||||
pipelines. To run the provider in a CI/CD pipeline, and to prevent drift, you'll
|
||||
need to store the Terraform state
|
||||
[remotely](https://developer.hashicorp.com/terraform/language/settings/backends/configuration).
|
||||
|
||||
```hcl
|
||||
terraform {
|
||||
required_providers {
|
||||
coderd = {
|
||||
source = "coder/coderd"
|
||||
}
|
||||
}
|
||||
backend "gcs" {
|
||||
bucket = "example-bucket"
|
||||
prefix = "terraform/state"
|
||||
}
|
||||
}
|
||||
|
||||
provider "coderd" {
|
||||
// Can be populated from environment variables
|
||||
url = "https://coder.example.com"
|
||||
token = "****"
|
||||
}
|
||||
|
||||
// Get the commit SHA of the configuration's git repository
|
||||
variable "TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA" {
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "coderd_template" "kubernetes" {
|
||||
name = "kubernetes"
|
||||
description = "Develop in Kubernetes!"
|
||||
versions = [{
|
||||
directory = ".coder/templates/kubernetes"
|
||||
active = true
|
||||
# Version name is optional
|
||||
name = var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA
|
||||
tf_vars = [{
|
||||
name = "namespace"
|
||||
value = "default4"
|
||||
}]
|
||||
}]
|
||||
/* ... Additional template configuration */
|
||||
}
|
||||
```
|
||||
|
||||
For an example, see how we push our development image and template
|
||||
[with GitHub actions](https://github.com/coder/coder/blob/main/.github/workflows/dogfood.yaml).
|
||||
|
||||
## Coder CLI
|
||||
|
||||
You can also [install Coder](../install/) to automate pushing new template
|
||||
versions in CI/CD pipelines.
|
||||
|
||||
```console
|
||||
# Install the Coder CLI
|
||||
@ -25,8 +87,3 @@ coder templates push --yes $CODER_TEMPLATE_NAME \
|
||||
--directory $CODER_TEMPLATE_DIR \
|
||||
--name=$CODER_TEMPLATE_VERSION # Version name is optional
|
||||
```
|
||||
|
||||
To cap token lifetime on creation,
|
||||
[configure Coder server to set a shorter max token lifetime](../reference/cli/server.md#--max-token-lifetime).
|
||||
For an example, see how we push our development image and template
|
||||
[with GitHub actions](https://github.com/coder/coder/blob/main/.github/workflows/dogfood.yaml).
|
||||
|
4
docs/templates/creating.md
vendored
4
docs/templates/creating.md
vendored
@ -25,8 +25,8 @@ here!
|
||||
|
||||

|
||||
|
||||
If you prefer to use Coder on the [command line](../reference/cli/README.md),
|
||||
use `coder templates init`.
|
||||
If you prefer to use Coder on the [command line](../reference/cli), use
|
||||
`coder templates init`.
|
||||
|
||||
> Coder starter templates are also available on our
|
||||
> [GitHub repo](https://github.com/coder/coder/tree/main/examples/templates).
|
||||
|
Reference in New Issue
Block a user