Install HCP CLI for Vault Secrets
Before you can interact with HCP Vault Secrets using the command-line interface (CLI), you will need to install the HCP CLI and configure it for your HCP environment.
Once installed, you can choose to authenticate interactively using your HCP Portal credentials, or non-interactively using a HCP service principal.
Prerequisites
- An existing HCP account
- Completed the Create a secret in HCP Vault Secrets tutorial
- Homebrew installed
Install HCP CLI
The HCP CLI is available for download from releases.hashicorp.com/hcp
as a zip archive and via popular package managers. To support HCP Vault secrets,
you must use version 0.3.0
or greater.
MacOS users can use Homebrew to install the HCP CLI. Refer to the Homebrew installation instructions if it is not already installed.
Open a new terminal.
Install the HashiCorp tap.
Install the HCP CLI.
Verify the installation.
Configure the HCP CLI for Vault Secrets
Interactive logins launch a web browser to have you authenticate with your HCP user account through a supported authorization method such as username and password, single sign-on (SSO), or GitHub.
Refer to the HCP Vault Secrets documentation to review HCP roles and permissions.
Log in to HCP Vault Secrets using the interactive login.
A new browser will open, log into your HCP account. Once complete, your browser will display
Login is successful. You may close the browser and return to the command line.
.Return to the terminal session.
Example output:
Create a profile.
If you are a member of multiple HCP organizations, select the organization you want to use. Use the arrow keys to select the HCP organization.
Example output:
If you have multiple projects in your HCP organization, select the project you want to use. Use the arrow keys to select the HCP project.
The HCP CLI will detect the
WebApplication
app you created in an earlier tutorial.Run
hcp vault-secrets secrets list
to review the existing secrets.If you create multiple HCP Vault Secrets apps, you can use the
--app
command line parameter followed by the name of the app.
Next steps
In this tutorial you installed and configured the HCP CLI, and authenticated using the interactive and non interactive methods.
In the next tutorial you will learn how to retrieve a secret using the command line interface (CLI) and API. Using the CLI or API will allow you to automate secret retrieval from HCP Vault Secrets.