Managing Secrets with Node.js SDK
How to manage secrets using the Julep Node.js SDK
Managing Secrets with Node.js SDK
This guide covers how to manage secrets using the Julep Node.js SDK. Secrets allow you to securely store and use sensitive information like API keys, passwords, and access tokens in your Julep applications.
Installation
Ensure you have the latest version of the Node.js SDK:
Authentication
Initialize the client with your API key:
Creating Secrets
Create a new secret:
Required Parameters
name
: The name of the secret (must be a valid identifier)value
: The secret value to encrypt and store
Optional Parameters
description
: A description of what the secret is used formetadata
: An object of metadata to associate with the secret
Listing Secrets
List all available secrets:
Pagination
Use pagination to handle large numbers of secrets:
Filtering by Metadata
Filter secrets based on metadata:
Retrieving Secrets
Get a specific secret by name:
Note: For security, when listing secrets, the
.value
field will always show “ENCRYPTED”. The actual secret value is only returned when specifically requesting a single secret by name.
Updating Secrets
Update an existing secret:
Partial Updates
You can update specific fields without changing others:
Deleting Secrets
Delete a secret when it’s no longer needed:
Using Secrets in Tasks
Reference secrets when executing tasks:
Using Secrets in Expressions
You can reference secrets in expressions:
Using Multiple Secrets
For tools that require multiple secrets:
Error Handling
Handle common errors when working with secrets:
Secret Rotation Example
Implement a secret rotation policy:
Working with Async/Await
All methods in the Node.js SDK return Promises, making them compatible with async/await:
Best Practices
- Use a consistent naming convention for all secrets
- Add detailed descriptions and metadata to make secrets discoverable
- Implement a rotation policy for sensitive secrets
- Log secret operations (creation, updates, deletions) but never log values
- Use try/catch blocks to handle potential errors gracefully
- Consider automating secret rotation for important credentials
- Use metadata to track important dates and ownership information
Next Steps
- Common Secrets Patterns - Patterns that work across all SDKs
- Secrets Management - Advanced guide for managing secrets
- Using Secrets in Julep - Step-by-step guide for using secrets