Skip to main content

Python module to implement the the Hashicorp Cloud Platform vault secrets API

Project description

hcp-vault-secrets

Python package to implement the Hashicorp Cloud Platform - Vault Secrets API

Description

Python package to implement the Hashicorp Cloud Platform - Vault Secrets API. In order for the code to function properly, we will need to set a few environment variables to provide authentication against the HCP API such that, we can retrieve the secret values containing sensitive information (i.e passwords, api_tokens, etc..) from various vault secret applications located within a given project. Please refer to the Package Requirements section for more information on the (4) required environment variables

You can find the organizationID and projectID in their respective settings tab in HCP. However, in order to get the clientID and clientSecret, you will need to navigate to the Projects -> <Project Name> -> Access Control (IAM) -> Service Principals tab within your organization. Create a service principal with the Contributer Role and generate keys. This will populate a clientID and clientSecret that the code will use to authenticate to the HCP API

Installation

pip install hcp-vault-secrets

Package Requirements

Packages

pip install requests

Environment Variables

  • clientID: This is the clientID that is associated with the service principal in HashiCorp Cloud Platform.

  • clientSecret: This is the clientSecret that is associated with the service principal in HashiCorp Cloud Platform.

  • organizationID: The HashiCorp Cloud Platform organization ID that owns the Vault Secrets application

  • projectID: The HashiCorp Cloud Platform project ID where the Vault Secrets application is located

Hashicorp Cloud Platform (HCP)

HCP Topology

  • Organization -> Project(s) -> Service(s) [e.g Vault Secrets] -> Application -> Key/Value (secret)

How to use

Create Hashicorp Cloud Platform Instance

# import hcp_vault_secrets package
import hcp_vault_secrets.vaultsecrets as vaultsecrets

# create hcp instance
hcp = vaultsecrets.vaultsecrets()

API ENDPOINTS Implemented

/apps/{app_name}/open/{secret_name}

GET

Path Parameters

name type description required
appName string The name of the vault secrets application where the key is stored True
secretName string The name of the secrets' key you want to retrieve True

EXAMPLES

import hcp_vault_secrets.vaultsecrets as vaultsecrets

# create hcp instance
hcp = vaultsecrets.vaultsecrets()

# get the secret named "token" from the "assisted-installer" vault secrets application
# return type is <str>
token = hcp.getAppSecret(appName="assisted-installer", secretName="token")

# get the secret named "pull_secret" from the "assisted-installer" vault secrets application
# return type is <str>
pull_secret = hcp.getAppSecret(appName="assisted-installer", secretName="pull_secret")

# get the secret named "password" from the "proxmox" vault secrets application (in the same project)
# return type is <str>
prox = hcp.getAppSecret("proxmox", "password")

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hcp_vault_secrets-0.0.4.tar.gz (74.5 kB view details)

Uploaded Source

Built Distribution

hcp_vault_secrets-0.0.4-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file hcp_vault_secrets-0.0.4.tar.gz.

File metadata

  • Download URL: hcp_vault_secrets-0.0.4.tar.gz
  • Upload date:
  • Size: 74.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for hcp_vault_secrets-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2b5032c3cf2177e48f0d627a40a015af83036a2b57f8d77f59cadad48ef4fa82
MD5 7f6790f7fa2e3664f74874ec02fa6c51
BLAKE2b-256 d2d2764fb0551a70dcf80fdb7804208784e757b81960a6ae0c97c87beda09d86

See more details on using hashes here.

File details

Details for the file hcp_vault_secrets-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for hcp_vault_secrets-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f58e58453e96026d9b42c5850f6135a3f6f4f99de084abb148075afd26ab24e2
MD5 b92c04c7465d7755cb11c213ed5b24cb
BLAKE2b-256 6eeb007a6817c51b2b28f35d6a08c2b5e867c4a1117d8008d010b3f84e6d8fcd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page