Skip to main content

Common Secrets Patterns

This guide covers common patterns and best practices for working with secrets that apply across all Julep SDKs.

Secret Management Lifecycle

The typical lifecycle for secrets in Julep applications includes:
  1. Creation: Establishing new secrets
  2. Retrieval: Accessing secret metadata (not values)
  3. Usage: Referencing secrets in tasks and tools
  4. Update: Rotating or changing secret values
  5. Deletion: Removing secrets when no longer needed

Naming Conventions

Consistent naming helps with secret organization:
  • Use snake_case formatting (e.g., aws_access_key)
  • Be descriptive but concise
  • Include service name as prefix (stripe_secret_key vs just secret_key)
  • For multiple environments, include environment prefix (dev_stripe_key, prod_stripe_key)

Secret Reference Patterns

When using secrets in tasks, you have several reference patterns available:

Direct Reference

Reference a secret directly by name:

Multiple Secrets

For operations requiring multiple secrets:

Expression Reference

Reference secrets within expressions:

LLM Provider Keys

Store LLM API keys with standard names for automatic lookup:

Error Handling

Common error scenarios when working with secrets:
  1. Secret Not Found: The referenced secret doesn’t exist
  2. Permission Denied: No access to the requested secret
  3. Validation Error: Secret name doesn’t match required format
  4. Duplicate Name: Attempting to create a secret with a name that already exists
Handle these consistently across your application:

Testing with Secrets

For testing applications that use secrets:
  1. Create a separate set of test secrets with appropriate prefixes
  2. Use mocking in unit tests to avoid requiring real secrets
  3. For integration tests, use dedicated test accounts and credentials
  4. Never use production secrets in test environments
Example of mocking secrets for testing:

Migrating from Environment Variables

When migrating from environment variables to Julep secrets:
  1. Create a list of all environment variables used in your application
  2. Create corresponding secrets in Julep with the same names
  3. Update your code to reference Julep secrets instead of environment variables
  4. Validate functionality before removing the original environment variables
Migration script example:

Integration with External Secret Managers

For organizations using external secret managers, you can sync to Julep:

Security Best Practices

  1. Limit who has access to create and manage secrets
  2. Never log secret values, even in debug environments
  3. Rotate secrets regularly, especially for high-value credentials
  4. Use the most specific scope possible for each secret
  5. Audit secret usage and access patterns
  6. Use metadata to track important information about secrets
  7. Implement an encrypted backup strategy for critical secrets

Next Steps