Home » Vault Setup for the local environment

Vault Setup for the local environment

Last Updated on July 8, 2023 by KnownSense

Follow the Steps below to setup vault for you local use:

Go to the Spring Native Vault project and in the vault-setup folder you will find a docker compose file. In that directory using cmd/ x64native tools command prompt use the below command:
1. docker compose up


2. Now post execution of the above command vault image will be downloaded and then vault image will get executed to run as docker image. Once vault is up you can access it on http://localhost:8200. Once the UI is open use the root token present in the terminal for login.
3. Create Secret on clicking Secret tab and then click on Enable New Engine.
4. Enter path as vault-backend and click on Enable Engine. Now click on Create Secrets with path name as spring-native/dev. Once Secrets name is done then you can provide the actual credential details in form of key value or json. For now we are going to use key name as test.demo and value as knownsense.
5. Click on create secrets and secrets as now done.
6. Now click on Access and then click on Enable New Method. Select Approle and then let the pathname be same as approle. Click on Enable Method.
7. Now go to the Policies section and click on Create Acl Policies. Give the name as test-policy and in the policies section add the below:

path "vault-backend/data/spring-native/**"
{
capabilities = ["list", "read"]
}

Click on Create Policy.

8. Once done, adjacent to Status you will see a Cli/ Terminal icon. Click on it and run the following commands:
A. To Add a Policy:
vault write auth/approle/role/demo policies="test-policy"
B. To generate the Role-id:
vault read auth/approle/role/demo/role-id
You will get a role-id. Copy it to use in the application.
C. To generate Secret-id:
vault write -force auth/approle/role/demo/secret-id

You will get a secret-id. Copy it to use in the application.

Now you have the secret-id and role-id with you using which you can connect you application to vault and access the saved credentials/ secrets in vault.

Scroll to Top