|
| 1 | +--- |
| 2 | +display_name: "HCP Vault Secrets" |
| 3 | +description: "Fetch secrets from HCP Vault" |
| 4 | +icon: ../.icons/vault.svg |
| 5 | +maintainer_github: coder |
| 6 | +partner_github: hashicorp |
| 7 | +verified: true |
| 8 | +tags: [helper, integration, vault, hashicorp, hvs] |
| 9 | +--- |
| 10 | + |
| 11 | +# HCP Vault Secrets |
| 12 | + |
| 13 | +This module lets you fetch all or selective secrets from a [HCP Vault Secrets](https://developer.hashicorp.com/hcp/docs/vault-secrets) app into your [Coder](https://coder.com) workspaces. It makes use of the [`hcp_vault_secrets_app`](https://registry.terraform.io/providers/hashicorp/hcp/latest/docs/data-sources/vault_secrets_app) data source from the [HCP provider](https://registry.terraform.io/providers/hashicorp/hcp/latest). |
| 14 | + |
| 15 | +```tf |
| 16 | +module "vault" { |
| 17 | + source = "registry.coder.com/modules/hcp-vault-secrets/coder" |
| 18 | + version = "1.0.3" |
| 19 | + agent_id = coder_agent.example.id |
| 20 | + app_name = "demo-app" |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +To configure the HCP Vault Secrets module, you must create an HCP Service Principal from the HCP Vault Secrets app in the HCP console. This will give you the `HCP_CLIENT_ID` and `HCP_CLIENT_SECRET` that you need to authenticate with HCP Vault Secrets. See the [HCP Vault Secrets documentation](https://developer.hashicorp.com/hcp/docs/vault-secrets) for more information. |
| 27 | + |
| 28 | +## Fetch All Secrets |
| 29 | + |
| 30 | +To fetch all secrets from the HCP Vault Secrets app, skip the `secrets` input. |
| 31 | + |
| 32 | +```tf |
| 33 | +module "vault" { |
| 34 | + source = "registry.coder.com/modules/hcp-vault-secrets/coder" |
| 35 | + version = "1.0.3" |
| 36 | + agent_id = coder_agent.example.id |
| 37 | + app_name = "demo-app" |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## Fetch Selective Secrets |
| 42 | + |
| 43 | +To fetch selective secrets from the HCP Vault Secrets app, set the `secrets` input. |
| 44 | + |
| 45 | +```tf |
| 46 | +module "vault" { |
| 47 | + source = "registry.coder.com/modules/hcp-vault-secrets/coder" |
| 48 | + version = "1.0.3" |
| 49 | + agent_id = coder_agent.example.id |
| 50 | + app_name = "demo-app" |
| 51 | + secrets = ["MY_SECRET_1", "MY_SECRET_2"] |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +## Set Client ID and Client Secret as Inputs |
| 56 | + |
| 57 | +Set `client_id` and `client_secret` as module inputs. |
| 58 | + |
| 59 | +```tf |
| 60 | +module "vault" { |
| 61 | + source = "registry.coder.com/modules/hcp-vault-secrets/coder" |
| 62 | + version = "1.0.3" |
| 63 | + agent_id = coder_agent.example.id |
| 64 | + app_name = "demo-app" |
| 65 | + client_id = "HCP_CLIENT_ID" |
| 66 | + client_secret = "HCP_CLIENT_SECRET" |
| 67 | +} |
| 68 | +``` |
0 commit comments