Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit f8faea1

Browse files
authored
feat(vault-github): use coder_env to set VAULT_ADDR in workspace (#112)
1 parent 1e3bd2b commit f8faea1

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

vault-github/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ module "vault" {
1717
agent_id = coder_agent.example.id
1818
vault_addr = "https://vault.example.com"
1919
}
20-
21-
# A workaround until we have https://github.com/coder/terraform-provider-coder/issues/170
22-
resource "coder_agent" "example" {
23-
...
24-
env = {
25-
VAULT_ADDR = "https://vault.example.com"
26-
}
27-
...
28-
}
29-
3020
```
3121

3222
Then you can use the Vault CLI in your workspaces to fetch secrets from Vault:

vault-github/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
coder = {
66
source = "coder/coder"
7-
version = ">= 0.12"
7+
version = ">= 0.12.4"
88
}
99
}
1010
}
@@ -43,6 +43,7 @@ variable "vault_cli_version" {
4343
}
4444

4545
data "coder_workspace" "me" {}
46+
4647
resource "coder_script" "vault" {
4748
agent_id = var.agent_id
4849
display_name = "Vault (GitHub)"
@@ -57,6 +58,12 @@ resource "coder_script" "vault" {
5758
start_blocks_login = true
5859
}
5960

61+
resource "coder_env" "vault_addr" {
62+
agent_id = var.agent_id
63+
name = "VAULT_ADDR"
64+
value = var.vault_addr
65+
}
66+
6067
data "coder_external_auth" "github" {
6168
id = var.coder_github_auth_id
6269
}

0 commit comments

Comments
 (0)