Secrets Management

Secure secrets management practices for CI/CD pipelines using Vault, AWS Secrets Manager, and other tools

What Is This?

The "Secrets Management" skill focuses on implementing robust and secure practices for handling sensitive information within CI/CD pipelines. It leverages industry-standard tools such as HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, and Google Secret Manager to securely store and manage credentials, API keys, certificates, and other confidential data. This skill is designed for software engineers, DevOps practitioners, and platform teams aiming to eliminate the risk of hardcoded secrets and automate the management, rotation, and access control of sensitive assets in CI/CD workflows.

By integrating secrets management into your CI/CD automation, you gain centralized control, auditability, and compliance while reducing the risk of accidental exposure in code repositories or build logs. This skill provides the foundational knowledge and practical steps necessary to secure your CI/CD pipelines using both open source and cloud-native secrets management solutions.

Why Use It?

Secrets management is a critical component of modern DevOps and cloud-native development. CI/CD environments often require access to sensitive information such as database passwords, API tokens, and TLS certificates. Hardcoding secrets or storing them in configuration files introduces serious security vulnerabilities, leading to potential leaks, unauthorized access, or compliance violations.

Adopting a centralized approach to secrets management enables you to:

  • Securely store and retrieve secrets at runtime
  • Enforce least-privilege access policies
  • Automate secret rotation to reduce exposure windows
  • Integrate with identity and access management (IAM) solutions
  • Audit access and usage of sensitive data

By using proven tools such as HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, or Google Secret Manager, you ensure that your secrets are managed in accordance with best practices and industry standards.

How to Use It

Integrating HashiCorp Vault

HashiCorp Vault is a popular open source tool providing centralized secrets management, dynamic secret generation, and fine-grained access control. Here’s how you might integrate Vault into your CI/CD pipeline:

1. Start a Development Instance of Vault

vault server -dev

2. Set Vault Environment Variables

export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN='root'

3. Enable the Key-Value Secrets Engine

vault secrets enable -path=secret kv-v2

4. Store a Secret

vault kv put secret/database/config username=admin password=secret

5. Retrieve a Secret (Example for CI/CD pipeline step)

vault kv get -field=password secret/database/config

Integrate these commands into your CI/CD workflow using environment variables or secret injection plugins to ensure credentials are never hardcoded or exposed.

Using AWS Secrets Manager

AWS Secrets Manager provides a cloud-native way to store and rotate secrets for AWS workloads. Integration is straightforward for pipelines running on AWS infrastructure:

1. Store a Secret via AWS CLI

aws secretsmanager create-secret --name MyDatabaseSecret \
    --secret-string '{"username":"admin","password":"secret"}'

2. Retrieve a Secret in a Deployment Script

aws secretsmanager get-secret-value --secret-id MyDatabaseSecret \
    --query SecretString --output text

Use AWS IAM roles to grant least-privilege access to your CI/CD runner or deployment jobs.

Azure Key Vault and Google Secret Manager

Both Azure Key Vault and Google Secret Manager offer similar capabilities as their AWS counterpart. They provide RBAC/IAM integration, versioning, and native SDKs for secure access within Azure or GCP-hosted pipelines.

Example: Retrieve a Secret from Azure Key Vault (using Azure CLI)

az keyvault secret show --vault-name MyKeyVault --name MySecret \
    --query value -o tsv

Example: Retrieve a Secret from Google Secret Manager (using gcloud)

gcloud secrets versions access latest --secret="my-secret"

Integrate these commands into your CI/CD automation scripts as needed.

When to Use It

Use the Secrets Management skill in the following scenarios:

  • Storing API keys, passwords, and sensitive configuration values
  • Managing and rotating database credentials in your deployment pipeline
  • Handling TLS certificates and encryption keys for secure service communication
  • Automating secret rotation to enforce security policies and reduce the risk of credential leakage
  • Enabling least-privilege access via IAM or RBAC, ensuring only authorized services and users can access specific secrets

This skill is essential whenever your CI/CD environment interacts with protected resources, needs to uphold compliance requirements, or must minimize the risk of exposing sensitive data.

Important Notes

  • Never store secrets in version control or plaintext configuration files.
  • Always use environment variables, secret injection tools, or built-in secrets support in your CI/CD platform.
  • Rotate secrets regularly and automate the process where possible.
  • Audit all secret access and usage to detect unauthorized attempts.
  • Choose a secrets manager that aligns with your infrastructure - for example, use Vault for hybrid and multi-cloud environments, or a cloud-native manager for single-cloud deployments.
  • Limit access to secrets using IAM, policies, or access control lists to enforce least-privilege principles.
  • Review and update your secrets management practices periodically to address new threats and compliance requirements.

By mastering the Secrets Management skill, you enable secure, compliant, and resilient CI/CD pipelines that safeguard your most critical assets throughout the software delivery lifecycle.