You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
modules/vault-token
github-actions[bot] b90f6f9de8
chore: bump version to 1.0.7 in README.md files (#174)
Co-authored-by: matifali <matifali@users.noreply.github.com>
1 year ago
..
README.md chore: bump version to 1.0.7 in README.md files (#174) 1 year ago
main.test.ts Update Hashicorp vault modules (#140) 1 year ago
main.tf Update Hashicorp vault modules (#140) 1 year ago
run.sh fix(vault): fix version fetching logic (#172) 1 year ago

README.md

display_name description icon maintainer_github partner_github verified tags
Hashicorp Vault Integration (Token) Authenticates with Vault using Token ../.icons/vault.svg coder hashicorp true
helper
integration
vault
token

Hashicorp Vault Integration (Token)

This module lets you authenticate with Hashicorp Vault in your Coder workspaces using a Vault token.

variable "vault_token" {
  type        = string
  description = "The Vault token to use for authentication."
  sensitive   = true
}

module "vault" {
  source      = "registry.coder.com/modules/vault-token/coder"
  version     = "1.0.7"
  agent_id    = coder_agent.example.id
  vault_token = var.token
  vault_addr  = "https://vault.example.com"
}

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

vault kv get -namespace=coder -mount=secrets coder

or using the Vault API:

curl -H "X-Vault-Token: ${VAULT_TOKEN}" -X GET "${VAULT_ADDR}/v1/coder/secrets/data/coder"

Configuration

To configure the Vault module, you must create a Vault token with the the required permissions and configure the module with the token and Vault address.

  1. Create a vault policy with read access to the secret mount you need your developers to access.
    vault policy write read-coder-secrets - <<EOF
     path "coder/data/*" {
       capabilities = ["read"]
     }
     path "coder/metadata/*" {
       capabilities = ["read"]
     }
     EOF
    
  2. Create a token using this policy.
    vault token create -policy="read-coder-secrets"
    
  3. Copy the generated token and use in your template.

Examples

Configure Vault integration and install a specific version of the Vault CLI

variable "vault_token" {
  type        = string
  description = "The Vault token to use for authentication."
  sensitive   = true
}

module "vault" {
  source            = "registry.coder.com/modules/vault-token/coder"
  version           = "1.0.7"
  agent_id          = coder_agent.example.id
  vault_addr        = "https://vault.example.com"
  vault_token       = var.token
  vault_cli_version = "1.15.0"
}