[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M751HTSTXV8ZD0T4WKF3WZE7":3,"skill-same:01M751HTSTXV8ZD0T4WKF3WZE7":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":36,"commitSha":37,"skillDirectory":5,"forksCount":14,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":6,"updatedAt":41,"install":42,"resources":55},"01M751HTSTXV8ZD0T4WKF3WZE7","implementing-secrets-management-with-vault",null,"This skill covers deploying HashiCorp Vault for centralized secrets management across cloud environments, including dynamic secret generation for databases and cloud providers, transit encryption, PKI certificate management, and Kubernetes integration. It addresses eliminating hardcoded credentials from application code and CI\u002FCD pipelines by implementing short-lived, automatically rotated secrets.","SamuelChien\u002Fmega-skills-collection","SamuelChien","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F4652114?v=4","01M74KK34WVHA0P5ZYSJRDDFMG","Samuel Chien","01M74KK35FQN1N9VZ9EPTH3P2S",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fimplementing-secrets-management-with-vault\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fimplementing-secrets-management-with-vault\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: implementing-secrets-management-with-vault\ndescription: >\n  This skill covers deploying HashiCorp Vault for centralized secrets management across\n  cloud environments, including dynamic secret generation for databases and cloud providers,\n  transit encryption, PKI certificate management, and Kubernetes integration. It addresses\n  eliminating hardcoded credentials from application code and CI\u002FCD pipelines by implementing\n  short-lived, automatically rotated secrets.\ndomain: cybersecurity\nsubdomain: cloud-security\ntags: [hashicorp-vault, secrets-management, dynamic-secrets, credential-rotation, zero-trust]\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\n---\n\n# Implementing Secrets Management with Vault\n\n## When to Use\n\n- When applications store database passwords, API keys, or certificates in environment variables or config files\n- When migrating from static long-lived credentials to dynamic short-lived secrets\n- When Kubernetes workloads need secure access to database credentials or cloud provider APIs\n- When compliance requirements mandate centralized credential management with audit logging\n- When CI\u002FCD pipelines contain hardcoded secrets that represent supply chain risk\n\n**Do not use** for AWS-only environments where AWS Secrets Manager suffices without multi-cloud requirements, for application-level encryption logic (though Vault Transit can help), or for identity federation (see managing-cloud-identity-with-okta).\n\n## Prerequisites\n\n- HashiCorp Vault server deployed in HA mode (Consul or Raft storage backend)\n- TLS certificates for Vault listener endpoints\n- Vault Enterprise license for namespaces, Sentinel policies, and replication (optional)\n- Kubernetes cluster with Vault Agent Injector or CSI provider for workload integration\n\n## Workflow\n\n### Step 1: Deploy Vault in High Availability Mode\n\nDeploy Vault using Integrated Storage (Raft) for HA without external dependencies. Configure TLS, audit logging, and auto-unseal using a cloud KMS.\n\n```hcl\n# vault-config.hcl\nstorage \"raft\" {\n  path    = \"\u002Fopt\u002Fvault\u002Fdata\"\n  node_id = \"vault-node-1\"\n\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-node-2.internal:8200\"\n  }\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-node-3.internal:8200\"\n  }\n}\n\nlistener \"tcp\" {\n  address     = \"0.0.0.0:8200\"\n  tls_cert_file = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault.crt\"\n  tls_key_file  = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault.key\"\n}\n\nseal \"awskms\" {\n  region     = \"us-east-1\"\n  kms_key_id = \"alias\u002Fvault-unseal-key\"\n}\n\napi_addr      = \"https:\u002F\u002Fvault-node-1.internal:8200\"\ncluster_addr  = \"https:\u002F\u002Fvault-node-1.internal:8201\"\n\ntelemetry {\n  prometheus_retention_time = \"30s\"\n  disable_hostname         = true\n}\n```\n\n```bash\n# Initialize Vault\nvault operator init -key-shares=5 -key-threshold=3\n\n# Enable audit logging\nvault audit enable file file_path=\u002Fvar\u002Flog\u002Fvault\u002Faudit.log\n\n# Enable syslog audit for SIEM integration\nvault audit enable syslog tag=\"vault\" facility=\"AUTH\"\n```\n\n### Step 2: Configure Authentication Methods\n\nEnable authentication backends for human operators, applications, and CI\u002FCD pipelines. Use AppRole for machine authentication and OIDC for human access.\n\n```bash\n# Enable OIDC auth for human users via Okta\nvault auth enable oidc\nvault write auth\u002Foidc\u002Fconfig \\\n  oidc_discovery_url=\"https:\u002F\u002Fcompany.okta.com\u002Foauth2\u002Fdefault\" \\\n  oidc_client_id=\"vault-client-id\" \\\n  oidc_client_secret=\"vault-client-secret\" \\\n  default_role=\"default\"\n\n# Enable AppRole for application authentication\nvault auth enable approle\nvault write auth\u002Fapprole\u002Frole\u002Fweb-app \\\n  secret_id_ttl=10m \\\n  token_num_uses=10 \\\n  token_ttl=20m \\\n  token_max_ttl=30m \\\n  secret_id_num_uses=1 \\\n  token_policies=\"web-app-policy\"\n\n# Enable Kubernetes auth for pod-based access\nvault auth enable kubernetes\nvault write auth\u002Fkubernetes\u002Fconfig \\\n  kubernetes_host=\"https:\u002F\u002Fkubernetes.default.svc:443\" \\\n  token_reviewer_jwt=@\u002Fvar\u002Frun\u002Fsecrets\u002Fkubernetes.io\u002Fserviceaccount\u002Ftoken \\\n  kubernetes_ca_cert=@\u002Fvar\u002Frun\u002Fsecrets\u002Fkubernetes.io\u002Fserviceaccount\u002Fca.crt\n```\n\n### Step 3: Enable Dynamic Secret Engines\n\nConfigure database secret engines to generate short-lived credentials on demand. Each credential set has a TTL and is automatically revoked when it expires.\n\n```bash\n# Enable database secrets engine for PostgreSQL\nvault secrets enable database\nvault write database\u002Fconfig\u002Fproduction-db \\\n  plugin_name=postgresql-database-plugin \\\n  allowed_roles=\"readonly,readwrite\" \\\n  connection_url=\"postgresql:\u002F\u002F{{username}}:{{password}}@db.internal:5432\u002Fproduction?sslmode=require\" \\\n  username=\"vault_admin\" \\\n  password=\"initial-password\"\n\n# Rotate the root credentials so Vault manages them exclusively\nvault write -force database\u002Frotate-root\u002Fproduction-db\n\n# Create a readonly role with 1-hour TTL\nvault write database\u002Froles\u002Freadonly \\\n  db_name=production-db \\\n  creation_statements=\"CREATE ROLE \\\"{{name}}\\\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO \\\"{{name}}\\\";\" \\\n  revocation_statements=\"REVOKE ALL ON ALL TABLES IN SCHEMA public FROM \\\"{{name}}\\\"; DROP ROLE IF EXISTS \\\"{{name}}\\\";\" \\\n  default_ttl=\"1h\" \\\n  max_ttl=\"24h\"\n\n# Enable AWS secrets engine for dynamic IAM credentials\nvault secrets enable aws\nvault write aws\u002Fconfig\u002Froot \\\n  access_key=AKIAEXAMPLE \\\n  secret_key=secretkey \\\n  region=us-east-1\n\nvault write aws\u002Froles\u002Fdeploy-role \\\n  credential_type=iam_user \\\n  policy_document=@deploy-policy.json \\\n  default_sts_ttl=3600\n```\n\n### Step 4: Integrate with Kubernetes Workloads\n\nUse the Vault Agent Injector or CSI Provider to deliver secrets to pods without application code changes. Secrets are rendered as files in a shared volume.\n\n```yaml\n# Kubernetes deployment with Vault Agent Injector annotations\napiVersion: apps\u002Fv1\nkind: Deployment\nmetadata:\n  name: web-app\nspec:\n  template:\n    metadata:\n      annotations:\n        vault.hashicorp.com\u002Fagent-inject: \"true\"\n        vault.hashicorp.com\u002Frole: \"web-app\"\n        vault.hashicorp.com\u002Fagent-inject-secret-db-creds: \"database\u002Fcreds\u002Freadonly\"\n        vault.hashicorp.com\u002Fagent-inject-template-db-creds: |\n          {{- with secret \"database\u002Fcreds\u002Freadonly\" -}}\n          export DB_USERNAME=\"{{ .Data.username }}\"\n          export DB_PASSWORD=\"{{ .Data.password }}\"\n          {{- end }}\n    spec:\n      serviceAccountName: web-app\n      containers:\n        - name: web-app\n          image: company\u002Fweb-app:v2.1\n          command: [\"\u002Fbin\u002Fsh\", \"-c\", \"source \u002Fvault\u002Fsecrets\u002Fdb-creds && .\u002Fstart.sh\"]\n```\n\n### Step 5: Implement Transit Encryption and PKI\n\nUse the Transit secrets engine for application-level encryption without managing keys in application code. Deploy the PKI engine for automatic TLS certificate management.\n\n```bash\n# Enable Transit engine for encryption as a service\nvault secrets enable transit\nvault write -f transit\u002Fkeys\u002Fpayment-data type=aes256-gcm96\n\n# Encrypt sensitive data\nvault write transit\u002Fencrypt\u002Fpayment-data \\\n  plaintext=$(echo \"card-number-4111-1111-1111-1111\" | base64)\n\n# Enable PKI for internal certificate management\nvault secrets enable pki\nvault secrets tune -max-lease-ttl=87600h pki\n\n# Generate root CA\nvault write pki\u002Froot\u002Fgenerate\u002Finternal \\\n  common_name=\"Internal Root CA\" \\\n  ttl=87600h\n\n# Configure intermediate CA for issuing certificates\nvault secrets enable -path=pki_int pki\nvault write pki_int\u002Fintermediate\u002Fgenerate\u002Finternal \\\n  common_name=\"Internal Intermediate CA\" \\\n  ttl=43800h\n\n# Create a role for issuing certificates\nvault write pki_int\u002Froles\u002Finternal-services \\\n  allowed_domains=\"internal.company.com\" \\\n  allow_subdomains=true \\\n  max_ttl=720h\n```\n\n### Step 6: Establish Policies and Audit Trail\n\nDefine fine-grained ACL policies following least privilege. Enable comprehensive audit logging for all secret access and administrative operations.\n\n```hcl\n# web-app-policy.hcl\npath \"database\u002Fcreds\u002Freadonly\" {\n  capabilities = [\"read\"]\n}\n\npath \"transit\u002Fencrypt\u002Fpayment-data\" {\n  capabilities = [\"update\"]\n}\n\npath \"transit\u002Fdecrypt\u002Fpayment-data\" {\n  capabilities = [\"update\"]\n}\n\npath \"secret\u002Fdata\u002Fweb-app\u002F*\" {\n  capabilities = [\"read\", \"list\"]\n}\n\n# Deny access to admin paths\npath \"sys\u002F*\" {\n  capabilities = [\"deny\"]\n}\n```\n\n```bash\n# Apply the policy\nvault policy write web-app-policy web-app-policy.hcl\n\n# Verify audit log captures all operations\nvault audit list -detailed\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| Dynamic Secrets | Credentials generated on-demand with automatic expiration and revocation, eliminating long-lived static credentials |\n| Secret Engine | Vault component that stores, generates, or encrypts data; includes KV, database, AWS, PKI, and Transit engines |\n| Auto-Unseal | Cloud KMS-based mechanism that automatically unseals Vault nodes on restart without manual key entry |\n| AppRole | Machine-oriented authentication method using Role ID and Secret ID for application and CI\u002FCD pipeline access |\n| Transit Engine | Encryption-as-a-service engine that handles cryptographic operations without exposing encryption keys to applications |\n| Lease | Time-bound credential with a TTL that Vault automatically revokes on expiration unless renewed |\n| Namespace | Vault Enterprise feature providing tenant isolation with separate auth, secrets, and policy management |\n| Response Wrapping | Technique that wraps secret responses in a single-use token to prevent man-in-the-middle exposure during delivery |\n\n## Tools & Systems\n\n- **HashiCorp Vault**: Core secrets management platform providing dynamic secrets, encryption, and identity-based access\n- **Vault Agent Injector**: Kubernetes mutating webhook that automatically injects Vault secrets into pod volumes via sidecar containers\n- **Vault CSI Provider**: Kubernetes CSI driver that mounts Vault secrets directly into pod volumes without sidecar containers\n- **consul-template**: Template rendering daemon that watches Vault secrets and re-renders configuration files when secrets change\n- **Vault Radar**: Secret scanning tool that detects hardcoded credentials in source code, CI\u002FCD pipelines, and cloud configurations\n\n## Common Scenarios\n\n### Scenario: Eliminating Hardcoded Database Credentials from CI\u002FCD Pipeline\n\n**Context**: A DevOps team stores PostgreSQL credentials in GitHub Actions secrets and Jenkins credential stores. The same credentials are shared across staging and production environments with no rotation for 18 months.\n\n**Approach**:\n1. Deploy Vault with AppRole auth enabled for CI\u002FCD systems\n2. Configure the database secrets engine with separate roles for staging (readwrite, 2h TTL) and production (readonly, 1h TTL)\n3. Create separate Vault policies for each pipeline stage restricting access to the appropriate database role\n4. Update GitHub Actions workflows to authenticate via AppRole and request dynamic credentials at the start of each job\n5. Rotate the static PostgreSQL credentials and hand root access to Vault exclusively\n6. Enable audit logging to track every credential request with pipeline job metadata\n\n**Pitfalls**: Failing to rotate the original static credentials after Vault migration leaves the old credentials valid. Setting TTLs too short causes credential expiry mid-deployment for long-running jobs.\n\n## Output Format\n\n```\nVault Secrets Management Audit Report\n=======================================\nVault Cluster: vault.internal.company.com\nVersion: 1.18.1 Enterprise\nHA Mode: Raft (3 nodes)\nSeal Type: AWS KMS Auto-Unseal\nReport Date: 2025-02-23\n\nSECRET ENGINES:\n  database\u002F         PostgreSQL dynamic creds   Leases Active: 47\n  aws\u002F              Dynamic IAM credentials    Leases Active: 12\n  transit\u002F          Encryption as a service    Keys: 8\n  pki\u002F              Root CA                    Certs Issued: 0\n  pki_int\u002F          Intermediate CA            Certs Issued: 234\n  secret\u002F           KV v2 static secrets       Versions: 1,892\n\nAUTH METHODS:\n  oidc\u002F             Okta SSO for humans        Active Tokens: 23\n  approle\u002F          CI\u002FCD pipelines            Active Tokens: 156\n  kubernetes\u002F       Pod-based auth             Active Tokens: 89\n\nAUDIT FINDINGS:\n  [WARN] 3 AppRole secret_id_num_uses set to 0 (unlimited)\n  [WARN] 12 KV secrets not accessed in 90+ days (potential orphans)\n  [PASS] All dynamic secret TTLs under 24 hours\n  [PASS] Audit logging enabled on all nodes\n  [PASS] Root token revoked after initial setup\n\nCREDENTIAL HYGIENE:\n  Static Secrets (KV): 234\n  Dynamic Secrets Active: 59\n  Average Lease TTL: 2.3 hours\n  Secrets Rotated This Month: 12,456\n```\n","# Implementing Secrets Management with Vault\n\n## When to Use\n\n- When applications store database passwords, API keys, or certificates in environment variables or config files\n- When migrating from static long-lived credentials to dynamic short-lived secrets\n- When Kubernetes workloads need secure access to database credentials or cloud provider APIs\n- When compliance requirements mandate centralized credential management with audit logging\n- When CI\u002FCD pipelines contain hardcoded secrets that represent supply chain risk\n\n**Do not use** for AWS-only environments where AWS Secrets Manager suffices without multi-cloud requirements, for application-level encryption logic (though Vault Transit can help), or for identity federation (see managing-cloud-identity-with-okta).\n\n## Prerequisites\n\n- HashiCorp Vault server deployed in HA mode (Consul or Raft storage backend)\n- TLS certificates for Vault listener endpoints\n- Vault Enterprise license for namespaces, Sentinel policies, and replication (optional)\n- Kubernetes cluster with Vault Agent Injector or CSI provider for workload integration\n\n## Workflow\n\n### Step 1: Deploy Vault in High Availability Mode\n\nDeploy Vault using Integrated Storage (Raft) for HA without external dependencies. Configure TLS, audit logging, and auto-unseal using a cloud KMS.\n\n```hcl\n# vault-config.hcl\nstorage \"raft\" {\n  path    = \"\u002Fopt\u002Fvault\u002Fdata\"\n  node_id = \"vault-node-1\"\n\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-node-2.internal:8200\"\n  }\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-node-3.internal:8200\"\n  }\n}\n\nlistener \"tcp\" {\n  address     = \"0.0.0.0:8200\"\n  tls_cert_file = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault.crt\"\n  tls_key_file  = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault.key\"\n}\n\nseal \"awskms\" {\n  region     = \"us-east-1\"\n  kms_key_id = \"alias\u002Fvault-unseal-key\"\n}\n\napi_addr      = \"https:\u002F\u002Fvault-node-1.internal:8200\"\ncluster_addr  = \"https:\u002F\u002Fvault-node-1.internal:8201\"\n\ntelemetry {\n  prometheus_retention_time = \"30s\"\n  disable_hostname         = true\n}\n```\n\n```bash\n# Initialize Vault\nvault operator init -key-shares=5 -key-threshold=3\n\n# Enable audit logging\nvault audit enable file file_path=\u002Fvar\u002Flog\u002Fvault\u002Faudit.log\n\n# Enable syslog audit for SIEM integration\nvault audit enable syslog tag=\"vault\" facility=\"AUTH\"\n```\n\n### Step 2: Configure Authentication Methods\n\nEnable authentication backends for human operators, applications, and CI\u002FCD pipelines. Use AppRole for machine authentication and OIDC for human access.\n\n```bash\n# Enable OIDC auth for human users via Okta\nvault auth enable oidc\nvault write auth\u002Foidc\u002Fconfig \\\n  oidc_discovery_url=\"https:\u002F\u002Fcompany.okta.com\u002Foauth2\u002Fdefault\" \\\n  oidc_client_id=\"vault-client-id\" \\\n  oidc_client_secret=\"vault-client-secret\" \\\n  default_role=\"default\"\n\n# Enable AppRole for application authentication\nvault auth enable approle\nvault write auth\u002Fapprole\u002Frole\u002Fweb-app \\\n  secret_id_ttl=10m \\\n  token_num_uses=10 \\\n  token_ttl=20m \\\n  token_max_ttl=30m \\\n  secret_id_num_uses=1 \\\n  token_policies=\"web-app-policy\"\n\n# Enable Kubernetes auth for pod-based access\nvault auth enable kubernetes\nvault write auth\u002Fkubernetes\u002Fconfig \\\n  kubernetes_host=\"https:\u002F\u002Fkubernetes.default.svc:443\" \\\n  token_reviewer_jwt=@\u002Fvar\u002Frun\u002Fsecrets\u002Fkubernetes.io\u002Fserviceaccount\u002Ftoken \\\n  kubernetes_ca_cert=@\u002Fvar\u002Frun\u002Fsecrets\u002Fkubernetes.io\u002Fserviceaccount\u002Fca.crt\n```\n\n### Step 3: Enable Dynamic Secret Engines\n\nConfigure database secret engines to generate short-lived credentials on demand. Each credential set has a TTL and is automatically revoked when it expires.\n\n```bash\n# Enable database secrets engine for PostgreSQL\nvault secrets enable database\nvault write database\u002Fconfig\u002Fproduction-db \\\n  plugin_name=postgresql-database-plugin \\\n  allowed_roles=\"readonly,readwrite\" \\\n  connection_url=\"postgresql:\u002F\u002F{{username}}:{{password}}@db.internal:5432\u002Fproduction?sslmode=require\" \\\n  username=\"vault_admin\" \\\n  password=\"initial-password\"\n\n# Rotate the root credentials so Vault manages them exclusively\nvault write -force database\u002Frotate-root\u002Fproduction-db\n\n# Create a readonly role with 1-hour TTL\nvault write database\u002Froles\u002Freadonly \\\n  db_name=production-db \\\n  creation_statements=\"CREATE ROLE \\\"{{name}}\\\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO \\\"{{name}}\\\";\" \\\n  revocation_statements=\"REVOKE ALL ON ALL TABLES IN SCHEMA public FROM \\\"{{name}}\\\"; DROP ROLE IF EXISTS \\\"{{name}}\\\";\" \\\n  default_ttl=\"1h\" \\\n  max_ttl=\"24h\"\n\n# Enable AWS secrets engine for dynamic IAM credentials\nvault secrets enable aws\nvault write aws\u002Fconfig\u002Froot \\\n  access_key=AKIAEXAMPLE \\\n  secret_key=secretkey \\\n  region=us-east-1\n\nvault write aws\u002Froles\u002Fdeploy-role \\\n  credential_type=iam_user \\\n  policy_document=@deploy-policy.json \\\n  default_sts_ttl=3600\n```\n\n### Step 4: Integrate with Kubernetes Workloads\n\nUse the Vault Agent Injector or CSI Provider to deliver secrets to pods without application code changes. Secrets are rendered as files in a shared volume.\n\n```yaml\n# Kubernetes deployment with Vault Agent Injector annotations\napiVersion: apps\u002Fv1\nkind: Deployment\nmetadata:\n  name: web-app\nspec:\n  template:\n    metadata:\n      annotations:\n        vault.hashicorp.com\u002Fagent-inject: \"true\"\n        vault.hashicorp.com\u002Frole: \"web-app\"\n        vault.hashicorp.com\u002Fagent-inject-secret-db-creds: \"database\u002Fcreds\u002Freadonly\"\n        vault.hashicorp.com\u002Fagent-inject-template-db-creds: |\n          {{- with secret \"database\u002Fcreds\u002Freadonly\" -}}\n          export DB_USERNAME=\"{{ .Data.username }}\"\n          export DB_PASSWORD=\"{{ .Data.password }}\"\n          {{- end }}\n    spec:\n      serviceAccountName: web-app\n      containers:\n        - name: web-app\n          image: company\u002Fweb-app:v2.1\n          command: [\"\u002Fbin\u002Fsh\", \"-c\", \"source \u002Fvault\u002Fsecrets\u002Fdb-creds && .\u002Fstart.sh\"]\n```\n\n### Step 5: Implement Transit Encryption and PKI\n\nUse the Transit secrets engine for application-level encryption without managing keys in application code. Deploy the PKI engine for automatic TLS certificate management.\n\n```bash\n# Enable Transit engine for encryption as a service\nvault secrets enable transit\nvault write -f transit\u002Fkeys\u002Fpayment-data type=aes256-gcm96\n\n# Encrypt sensitive data\nvault write transit\u002Fencrypt\u002Fpayment-data \\\n  plaintext=$(echo \"card-number-4111-1111-1111-1111\" | base64)\n\n# Enable PKI for internal certificate management\nvault secrets enable pki\nvault secrets tune -max-lease-ttl=87600h pki\n\n# Generate root CA\nvault write pki\u002Froot\u002Fgenerate\u002Finternal \\\n  common_name=\"Internal Root CA\" \\\n  ttl=87600h\n\n# Configure intermediate CA for issuing certificates\nvault secrets enable -path=pki_int pki\nvault write pki_int\u002Fintermediate\u002Fgenerate\u002Finternal \\\n  common_name=\"Internal Intermediate CA\" \\\n  ttl=43800h\n\n# Create a role for issuing certificates\nvault write pki_int\u002Froles\u002Finternal-services \\\n  allowed_domains=\"internal.company.com\" \\\n  allow_subdomains=true \\\n  max_ttl=720h\n```\n\n### Step 6: Establish Policies and Audit Trail\n\nDefine fine-grained ACL policies following least privilege. Enable comprehensive audit logging for all secret access and administrative operations.\n\n```hcl\n# web-app-policy.hcl\npath \"database\u002Fcreds\u002Freadonly\" {\n  capabilities = [\"read\"]\n}\n\npath \"transit\u002Fencrypt\u002Fpayment-data\" {\n  capabilities = [\"update\"]\n}\n\npath \"transit\u002Fdecrypt\u002Fpayment-data\" {\n  capabilities = [\"update\"]\n}\n\npath \"secret\u002Fdata\u002Fweb-app\u002F*\" {\n  capabilities = [\"read\", \"list\"]\n}\n\n# Deny access to admin paths\npath \"sys\u002F*\" {\n  capabilities = [\"deny\"]\n}\n```\n\n```bash\n# Apply the policy\nvault policy write web-app-policy web-app-policy.hcl\n\n# Verify audit log captures all operations\nvault audit list -detailed\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| Dynamic Secrets | Credentials generated on-demand with automatic expiration and revocation, eliminating long-lived static credentials |\n| Secret Engine | Vault component that stores, generates, or encrypts data; includes KV, database, AWS, PKI, and Transit engines |\n| Auto-Unseal | Cloud KMS-based mechanism that automatically unseals Vault nodes on restart without manual key entry |\n| AppRole | Machine-oriented authentication method using Role ID and Secret ID for application and CI\u002FCD pipeline access |\n| Transit Engine | Encryption-as-a-service engine that handles cryptographic operations without exposing encryption keys to applications |\n| Lease | Time-bound credential with a TTL that Vault automatically revokes on expiration unless renewed |\n| Namespace | Vault Enterprise feature providing tenant isolation with separate auth, secrets, and policy management |\n| Response Wrapping | Technique that wraps secret responses in a single-use token to prevent man-in-the-middle exposure during delivery |\n\n## Tools & Systems\n\n- **HashiCorp Vault**: Core secrets management platform providing dynamic secrets, encryption, and identity-based access\n- **Vault Agent Injector**: Kubernetes mutating webhook that automatically injects Vault secrets into pod volumes via sidecar containers\n- **Vault CSI Provider**: Kubernetes CSI driver that mounts Vault secrets directly into pod volumes without sidecar containers\n- **consul-template**: Template rendering daemon that watches Vault secrets and re-renders configuration files when secrets change\n- **Vault Radar**: Secret scanning tool that detects hardcoded credentials in source code, CI\u002FCD pipelines, and cloud configurations\n\n## Common Scenarios\n\n### Scenario: Eliminating Hardcoded Database Credentials from CI\u002FCD Pipeline\n\n**Context**: A DevOps team stores PostgreSQL credentials in GitHub Actions secrets and Jenkins credential stores. The same credentials are shared across staging and production environments with no rotation for 18 months.\n\n**Approach**:\n1. Deploy Vault with AppRole auth enabled for CI\u002FCD systems\n2. Configure the database secrets engine with separate roles for staging (readwrite, 2h TTL) and production (readonly, 1h TTL)\n3. Create separate Vault policies for each pipeline stage restricting access to the appropriate database role\n4. Update GitHub Actions workflows to authenticate via AppRole and request dynamic credentials at the start of each job\n5. Rotate the static PostgreSQL credentials and hand root access to Vault exclusively\n6. Enable audit logging to track every credential request with pipeline job metadata\n\n**Pitfalls**: Failing to rotate the original static credentials after Vault migration leaves the old credentials valid. Setting TTLs too short causes credential expiry mid-deployment for long-running jobs.\n\n## Output Format\n\n```\nVault Secrets Management Audit Report\n=======================================\nVault Cluster: vault.internal.company.com\nVersion: 1.18.1 Enterprise\nHA Mode: Raft (3 nodes)\nSeal Type: AWS KMS Auto-Unseal\nReport Date: 2025-02-23\n\nSECRET ENGINES:\n  database\u002F         PostgreSQL dynamic creds   Leases Active: 47\n  aws\u002F              Dynamic IAM credentials    Leases Active: 12\n  transit\u002F          Encryption as a service    Keys: 8\n  pki\u002F              Root CA                    Certs Issued: 0\n  pki_int\u002F          Intermediate CA            Certs Issued: 234\n  secret\u002F           KV v2 static secrets       Versions: 1,892\n\nAUTH METHODS:\n  oidc\u002F             Okta SSO for humans        Active Tokens: 23\n  approle\u002F          CI\u002FCD pipelines            Active Tokens: 156\n  kubernetes\u002F       Pod-based auth             Active Tokens: 89\n\nAUDIT FINDINGS:\n  [WARN] 3 AppRole secret_id_num_uses set to 0 (unlimited)\n  [WARN] 12 KV secrets not accessed in 90+ days (potential orphans)\n  [PASS] All dynamic secret TTLs under 24 hours\n  [PASS] Audit logging enabled on all nodes\n  [PASS] Root token revoked after initial setup\n\nCREDENTIAL HYGIENE:\n  Static Secrets (KV): 234\n  Dynamic Secrets Active: 59\n  Average Lease TTL: 2.3 hours\n  Secrets Rotated This Month: 12,456\n```\n",{"name":5,"tags":25,"author":31,"domain":32,"license":15,"version":33,"subdomain":34,"description":35},[26,27,28,29,30],"hashicorp-vault","secrets-management","dynamic-secrets","credential-rotation","zero-trust","mahipal","cybersecurity","1.0.0","cloud-security","This skill covers deploying HashiCorp Vault for centralized secrets management across cloud environments, including dynamic secret generation for databases and cloud providers, transit encryption, PKI certificate management, and Kubernetes integration. It addresses eliminating hardcoded credentials from application code and CI\u002FCD pipelines by implementing short-lived, automatically rotated secrets.\n","main","c2b1fdccc779e99ac814e55fb69ca8d71215dd0f","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection","https:\u002F\u002Fgithub.com\u002FSamuelChien","http:\u002F\u002Fsamuelchien.com\u002F","2026-05-26 08:27:14",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add SamuelChien\u002Fmega-skills-collection --skill implementing-secrets-management-with-vault",{"tool":48,"command":49},"bunx","bunx skills add SamuelChien\u002Fmega-skills-collection --skill implementing-secrets-management-with-vault",{"tool":51,"command":52},"pnpm","pnpm dlx skills add SamuelChien\u002Fmega-skills-collection --skill implementing-secrets-management-with-vault","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fimplementing-secrets-management-with-vault\u002FSKILL.md",true,[56,60,66],{"path":57,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fapi-reference.md","REFERENCE","参考文档",4193,"https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fimplementing-secrets-management-with-vault\u002Freferences\u002Fapi-reference.md",{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"scripts\u002Fagent.py","SCRIPT","脚本",10933,"https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fimplementing-secrets-management-with-vault\u002Fscripts\u002Fagent.py",[73,81,88,95,102,109],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":20},"01M76R4WZQZAXGGXMQCA0FZ716","zustand-store-ts","Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state\u002Faction separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.","MIT","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzustand-store-ts\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":20},"01M76R4T9KENDH7FENGZQHBW4G","zustand-store-creator","Zustand Store Creator - Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":20},"01M76R3YWN84B7SANJ52X799ZE","zero-trust-config-helper","Zero Trust Config Helper - Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":20},"01M76R3HNSV2AEYSKHM915GJ58","zapier-integration-helper","Zapier Integration Helper - Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":20},"01M76R3DJSKAT4FA7DV4BF3GCE","zai-cli","Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP.\nUse when user needs image\u002Fvideo analysis, OCR, UI-to-code conversion, error diagnosis,\nreal-time web search, web page to markdown extraction, or GitHub code exploration.\nTrigger with phrases like \"analyze this image\", \"search the web for\", \"read this page\",\n\"explore this repo\", or \"use zai\". Requires Z_AI_API_KEY.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzai-cli\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":20},"01M76R2KAM699XE9AJVAWE4H2E","yt-research","Research competitor YouTube channels, niches, and trending topics for your content strategy.\nUse this skill whenever the user says \"research channels\", \"analyze competitors\", \"find trending topics\",\n\"niche analysis\", \"competitive research\", \"what are other creators doing\", \"scrape YouTube channels\",\nor wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fyt-research\u002FSKILL.md",[],[]]