2024-10-05 08:52:04 -07:00
|
|
|
# Integrating HashiCorp Vault with Coder
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<a href="https://github.com/matifali" style="text-decoration: none; color: inherit;">
|
|
|
|
|
<span style="vertical-align:middle;">Muhammad Atif Ali</span>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
August 05, 2024
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-01-03 14:13:46 -05:00
|
|
|
This guide describes the process of integrating [HashiCorp Vault](https://www.vaultproject.io/) into Coder workspaces.
|
2024-10-05 08:52:04 -07:00
|
|
|
|
|
|
|
|
Coder makes it easy to integrate HashiCorp Vault with your workspaces by
|
2025-01-03 14:13:46 -05:00
|
|
|
providing official Terraform modules to integrate Vault with Coder. This guide
|
2024-10-05 08:52:04 -07:00
|
|
|
will show you how to use these modules to integrate HashiCorp Vault with Coder.
|
|
|
|
|
|
2025-01-03 14:13:46 -05:00
|
|
|
## The `vault-github` module
|
2024-10-05 08:52:04 -07:00
|
|
|
|
2025-01-03 14:13:46 -05:00
|
|
|
The [`vault-github`](https://registry.coder.com/modules/vault-github) module is a Terraform module that allows you to
|
|
|
|
|
authenticate with Vault using a GitHub token. This module uses the existing
|
2025-06-16 13:18:55 -04:00
|
|
|
GitHub [external authentication](../external-auth/index.md) to get the token and authenticate with Vault.
|
2024-10-05 08:52:04 -07:00
|
|
|
|
2025-01-03 14:13:46 -05:00
|
|
|
To use this module, add the following code to your Terraform configuration.
|
2024-10-05 08:52:04 -07:00
|
|
|
|
|
|
|
|
```tf
|
|
|
|
|
module "vault" {
|
|
|
|
|
source = "registry.coder.com/modules/vault-github/coder"
|
|
|
|
|
version = "1.0.7"
|
|
|
|
|
agent_id = coder_agent.example.id
|
|
|
|
|
vault_addr = "https://vault.example.com"
|
|
|
|
|
coder_github_auth_id = "my-github-auth-id"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2025-01-03 14:13:46 -05:00
|
|
|
This module installs and authenticates the `vault` CLI in your Coder workspace.
|
2024-10-05 08:52:04 -07:00
|
|
|
|
2025-01-03 14:13:46 -05:00
|
|
|
Users then can use the `vault` CLI to interact with Vault; for example, to fetch
|
|
|
|
|
a secret stored in the KV backend.
|
2024-10-05 08:52:04 -07:00
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
vault kv get -namespace=YOUR_NAMESPACE -mount=MOUNT_NAME SECRET_NAME
|
|
|
|
|
```
|