feat(vault-github): use coder_env to set VAULT_ADDR in workspace (#112)

This commit is contained in:
Muhammad Atif Ali
2023-12-16 19:00:50 +03:00
committed by GitHub
parent 1e3bd2b04b
commit f8faea1855
2 changed files with 8 additions and 11 deletions

View File

@@ -17,16 +17,6 @@ module "vault" {
agent_id = coder_agent.example.id
vault_addr = "https://vault.example.com"
}
# A workaround until we have https://github.com/coder/terraform-provider-coder/issues/170
resource "coder_agent" "example" {
...
env = {
VAULT_ADDR = "https://vault.example.com"
}
...
}
```
Then you can use the Vault CLI in your workspaces to fetch secrets from Vault:

View File

@@ -4,7 +4,7 @@ terraform {
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.12"
version = ">= 0.12.4"
}
}
}
@@ -43,6 +43,7 @@ variable "vault_cli_version" {
}
data "coder_workspace" "me" {}
resource "coder_script" "vault" {
agent_id = var.agent_id
display_name = "Vault (GitHub)"
@@ -57,6 +58,12 @@ resource "coder_script" "vault" {
start_blocks_login = true
}
resource "coder_env" "vault_addr" {
agent_id = var.agent_id
name = "VAULT_ADDR"
value = var.vault_addr
}
data "coder_external_auth" "github" {
id = var.coder_github_auth_id
}