What is Vault and How to implement it??

Prabin Karki
3 min readJul 8, 2023

While developing software, I am trying to store my valuable or sensitive items in a secure place to prevent easy access by unauthorized individuals. I could potentially store them in a .env file, a Git variable, or some other location, but these methods can be easily accessed by others. So, I have been searching for a suitable solution, and guess what? I discovered a vault!

What is Vault??

A vault is essentially a highly secure storage space that is built to protect valuable or sensitive items. You can think of it as a specially designed room or container with strong walls, doors, and various security measures in place to prevent unauthorized access.Vault is a widely used open-source tool for securely managing secrets and sensitive data in modern software environments. It provides a secure storage and management solution for credentials, API keys, passwords, certificates, and other types of sensitive information.

Vault offers various features to enhance security, such as:

>. Secrets Management: Vault provides a secure API and command-line interface to manage secrets, allowing users and applications to store, retrieve, and delete secrets programmatically.

>. Dynamic Secrets: Vault can generate short-lived credentials on-demand for different systems and services. This approach reduces the risk of long-lived secrets being compromised.

>. Encryption as a Service: Vault offers encryption and decryption capabilities, enabling applications to encrypt data without directly accessing encryption keys. This helps to enforce separation of duties and enhances security.

>. Access Control: Vault provides fine-grained access control mechanisms, allowing administrators to define policies and permissions for different users, applications, or systems. This ensures that only authorized entities can access specific secrets.

>. Audit Logging: Vault maintains a detailed audit log of all actions performed on secrets, including read, write, and delete operations. This enables compliance with regulatory requirements and helps with security incident investigations.

>. Integration with Cloud Providers: Vault integrates with various cloud providers, allowing seamless integration with their native secrets management services and enhancing overall security in cloud environments.

Vault Implementation?

In Python Vault can be implement using a hashicorp in following way?


pip install hvac

If you would like to be able to return parsed HCL data as a Python dict for methods that support it:

pip install "hvac[parser]"
client = hvac.Client(
# Login with username and password
response = client.secrets.kv.read_secret_version(
return response
(response gives a items store in vau

VAULT_URL: ( this is a domain name or IP where we host our vault)
VAULT_USER: user_name to access a vault
VAULT_PASSWORD: password to access a vault
VAULT_ENV_PATH: path where we store our data
VAULT_SECRET_ENGINE_ENV: Vault main engine path

*note (We can also access a vault by token too and at first stage a vault is shield to unshield a vault we have to use our 4 token which we get while setting a vault)

Additional Info:

If you are using a FASTAPI with a pydantic settings you can use a “pydantic-vault” which help you to setup your FASTAPI with pydantic Basesettings.
for reference go through pydantic-vault .


You can use a vault as per your need, it’s not necessary to use as i mention above, their is various method to implement it.
Here i have not mention how to set a vault , you can setup your vault as your need.

Thank you so much from prabin-karki (Learn Grow & Share) .