Run Vault Agent to Interact with HashiCorp Vault
Vault Agent simplifies the process of authenticating to Vault and retrieving secrets. It is essentially a client daemon that has features including templating, caching, auto-auth, and api proxy. We will be using approle
authentication in this Shortcut, but there are a number of other authentication methods that vault-agent
supports.
Prerequisites
-
You need a running Vault cluster. Refer to the Shortcut “Run HashiCorp Vault with Helm” for a refresher on running Vault.
-
You need the
approle auth
method enabled in Vault. Refer to the Shortcut “Manage Machine Access to Secrets with AppRole in HashiCorp Vault” for a refresher.
Approle for Vault Agent
-
Create an
approle
in Vault to use withvault-agent
:vault write auth/approle/role/my-agent-role policies="my-agent-policy"
Make sure you see a success message.
-
Create the
my-agent-policy
used in step 1:vault policy write my-agent-policy -<<EOF > path "secret/data/agent-secret"{ > capabilities = ["read", "update"] > } > EOF
You should see a success message like the following:
-
Create a
secret-id
for themy-agent-role approle
:vault write -f auth/approle/role/my-agent-role/secret-id
You should receive an output like the following:
-
Read the
role-id
formy-agent-role
:vault read auth/approle/role/my-agent-role/role-id ...
Get Run Vault Agent to Interact with HashiCorp Vault now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.