1
1
# Template Change Management
2
2
3
- We recommend source-controlling your templates as you would other code. You can
4
- [ install Coder] ( ../install/ ) in CI/CD pipelines to push new template versions.
3
+ We recommend source-controlling your templates as you would other any code, and
4
+ automating the creation of new versions in CI/CD pipelines.
5
+
6
+ These pipelines will require tokens for your deployment. To cap token lifetime
7
+ on creation,
8
+ [ configure Coder server to set a shorter max token lifetime] ( ../reference/cli/server.md#--max-token-lifetime ) .
9
+
10
+ ## coderd Terraform Provider
11
+
12
+ The
13
+ [ coderd Terraform provider] ( https://registry.terraform.io/providers/coder/coderd/latest )
14
+ can be used to push new template versions, either manually, or in CI/CD
15
+ pipelines. To run the provider in a CI/CD pipeline, and to prevent drift, you'll
16
+ need to store the Terraform state
17
+ [ remotely] ( https://developer.hashicorp.com/terraform/language/settings/backends/configuration ) .
18
+
19
+ ``` hcl
20
+ terraform {
21
+ required_providers {
22
+ coderd = {
23
+ source = "coder/coderd"
24
+ }
25
+ }
26
+ backend "gcs" {
27
+ bucket = "example-bucket"
28
+ prefix = "terraform/state"
29
+ }
30
+ }
31
+
32
+ provider "coderd" {
33
+ // Can be populated from environment variables
34
+ url = "https://coder.example.com"
35
+ token = "****"
36
+ }
37
+
38
+ // Get the commit SHA of the configuration's git repository
39
+ variable "TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA" {
40
+ type = string
41
+ }
42
+
43
+ resource "coderd_template" "kubernetes" {
44
+ name = "kubernetes"
45
+ description = "Develop in Kubernetes!"
46
+ versions = [{
47
+ directory = ".coder/templates/kubernetes"
48
+ active = true
49
+ # Version name is optional
50
+ name = var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA
51
+ tf_vars = [{
52
+ name = "namespace"
53
+ value = "default4"
54
+ }]
55
+ }]
56
+ /* ... Additional template configuration */
57
+ }
58
+ ```
59
+
60
+ For an example, see how we push our development image and template
61
+ [ with GitHub actions] ( https://github.com/coder/coder/blob/main/.github/workflows/dogfood.yaml ) .
62
+
63
+ ## Coder CLI
64
+
65
+ You can also [ install Coder] ( ../install/ ) to automate pushing new template
66
+ versions in CI/CD pipelines.
5
67
6
68
``` console
7
69
# Install the Coder CLI
@@ -25,8 +87,3 @@ coder templates push --yes $CODER_TEMPLATE_NAME \
25
87
--directory $CODER_TEMPLATE_DIR \
26
88
--name=$CODER_TEMPLATE_VERSION # Version name is optional
27
89
```
28
-
29
- To cap token lifetime on creation,
30
- [ configure Coder server to set a shorter max token lifetime] ( ../reference/cli/server.md#--max-token-lifetime ) .
31
- For an example, see how we push our development image and template
32
- [ with GitHub actions] ( https://github.com/coder/coder/blob/main/.github/workflows/dogfood.yaml ) .
0 commit comments