Introduction
Learn how to configure the AppRole authentication method in HashiCorp Vault using direct API calls. This guide covers:- Enabling the AppRole auth method
- Creating an AppRole with specific policies
- Retrieving the
Role IDandSecret ID - Authenticating with the generated credentials
Prerequisites
- A running Vault server at
http://127.0.0.1:8200 - A valid Vault token exported as an environment variable:
Never commit your
VAULT_TOKEN or any sensitive credentials to version control.1. Enable the AppRole Auth Method
First, enable the AppRole authentication backend:-
Create an
auth.jsonfile: -
Use
curlto enable AppRole: -
Verify the mount:
approle/.
2. Create an AppRole with Policies
Define which policies this AppRole will use:-
Create
policies.json: -
Create the AppRole named
vaultcourse:
3. Fetch the Role ID
Each AppRole has a uniqueRole ID. Retrieve it:
data.role_id in the JSON response.
4. Generate a Secret ID
Generate theSecret ID needed alongside the Role ID:
data.secret_iddata.secret_id_accessor