Retrieve a secret from HCP Vault Secrets
In the previous tutorial, you created a secret and learned how to authenticate with HCP Vault Secrets.
In this tutorial, you will learn how to retrieve secrets using the vlt
CLI and HCP Vault Secrets API.
Prerequisites
- An existing HCP account
- Completed the previous HCP Vault Secrets tutorials
- jq
- curl (API only)
- HCP service principal with
HCP_CLIENT_ID
andHCP_CLIENT_SECRET
environment variables set
Applications, services, and workflows need to retrieve secrets so teams do not have to store secret information such as usernames and passwords, or API keys in source code.
HCP Vault Secrets provides the flexibility to use either the vlt
CLI tool, or an API to interact
with secrets.
Tip
The HCP Vault Secrets CLI includes a --help
parameter. This parameter can be appended to the vlt
command, and any sub-commands.
Review the available secrets.
The
username
secret was created during the Create a secret in HCP Vault Secrets tutorial.The version was incremented to version
2
when you changed theusername
value fromdatabase-user
todb-user
.Retrieve details about the
username
secret.By default, the secret value is redacted.
You can control the CLI output using the
--format
parameter. Use--format json
to retrieve a secret in JSON format.Retrieve the
username
secret and display the value.The
username
secret valuedb-user
is displayed.
Next steps
In this tutorial you learned how to retrieve a secret using the HCP Vault Secrets CLI, and API.
You can learn more about supported integrations in the HCP Vault Secrets documentation