[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B7C97PNNMMP2FZXD9BM1TM":3,"skill-same:01M7B7C97PNNMMP2FZXD9BM1TM":112},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":76,"commitSha":77,"skillDirectory":78,"forksCount":13,"repositoryHtmlUrl":79,"repositoryHomepageUrl":6,"ownerHtmlUrl":80,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":81,"install":82,"resources":95},"01M7B7C97PNNMMP2FZXD9BM1TM","implementing-hashicorp-vault-dynamic-secrets",null,"Configures HashiCorp Vault dynamic secrets engines for database credentials, AWS IAM keys, and PKI certificates, with automatic generation, lease management, and rotation to eliminate static secrets in application configuration. Use when eliminating long-lived static credentials, configuring a Vault secrets engine, generating ephemeral database or cloud credentials, or automating credential rotation for compliance (PCI-DSS, NIST 800-53 IA-5).","vikasvardhanv\u002Fjerry_skills","vikasvardhanv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99010657?v=4","01M7B2B0VN78W7529RQX5BR6DZ","01M7B2B0WDNTXJHRK3QNPNWRP6",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fimplementing-hashicorp-vault-dynamic-secrets\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fimplementing-hashicorp-vault-dynamic-secrets\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: implementing-hashicorp-vault-dynamic-secrets\ndescription: 'Configures HashiCorp Vault dynamic secrets engines for database credentials,\n  AWS IAM keys, and PKI certificates, with automatic generation, lease management,\n  and rotation to eliminate static secrets in application configuration. Use when\n  eliminating long-lived static credentials, configuring a Vault secrets engine,\n  generating ephemeral database or cloud credentials, or automating credential rotation\n  for compliance (PCI-DSS, NIST 800-53 IA-5).\n\n  '\ndomain: cybersecurity\nsubdomain: identity-access-management\ntags:\n- HashiCorp-Vault\n- dynamic-secrets\n- secrets-management\n- database-credentials\n- AWS-secrets\n- PKI\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.AA-01\n- PR.AA-02\n- PR.AA-05\n- PR.AA-06\nmitre_attack:\n- T1078\n- T1110\n- T1556\n- T1098\n- T1003\nmitre_f3:\n  version: '1.1'\n  tactics:\n  - initial-access\n  - positioning\n  - stealth\n  - resource-development\n  techniques:\n  - id: F1006.001\n    name: 'Account Takeover: Exposed API Key'\n    tactic: initial-access\n    source: f3\n  - id: F1006.002\n    name: 'Account Takeover: Exposed Login Credential'\n    tactic: initial-access\n    source: f3\n  - id: T1586\n    name: Compromise Accounts\n    tactic: resource-development\n    source: attack\n  - id: T1555\n    name: Credentials from Password Stores\n    tactic: reconnaissance\n    source: attack\n  - id: F1005.004\n    name: 'Account Manipulation: Change Account Details'\n    tactic: positioning\n    source: f3\n  - id: F1033\n    name: Insider Access Abuse\n    tactic: initial-access\n    source: f3\n---\n\n# Implementing HashiCorp Vault Dynamic Secrets\n\n## When to Use\n\n- Applications use static database credentials stored in configuration files or environment variables\n- AWS IAM access keys are long-lived and shared across services\n- Need to eliminate credential sprawl by generating short-lived, per-request secrets\n- Compliance requirements mandate credential rotation (PCI-DSS Requirement 8, NIST 800-53 IA-5)\n- Implementing zero-trust secret management where credentials are never stored at rest\n- Migrating from manual credential management to automated secrets lifecycle\n\n**Do not use** for storing static secrets that cannot be dynamically generated (use Vault's KV secrets engine instead); dynamic secrets are for credentials that can be programmatically created and revoked on target systems.\n\n## Prerequisites\n\n- HashiCorp Vault 1.15+ (Community or Enterprise edition)\n- Vault server initialized and unsealed with auto-unseal configured (AWS KMS, Azure Key Vault, or Transit)\n- Target database systems with admin credentials for Vault to create\u002Frevoke dynamic accounts\n- AWS IAM account with permissions to create\u002Fdelete IAM users and access keys\n- Network connectivity from Vault to all target systems\n- Vault policies and authentication methods configured for consuming applications\n\n## Workflow\n\n### Step 1: Deploy and Configure Vault Server\n\nInitialize Vault with production-grade configuration:\n\n```hcl\n# vault-config.hcl - Production Vault server configuration\nstorage \"raft\" {\n  path    = \"\u002Fopt\u002Fvault\u002Fdata\"\n  node_id = \"vault-1\"\n\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-2.corp.local:8200\"\n  }\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-3.corp.local:8200\"\n  }\n}\n\nlistener \"tcp\" {\n  address       = \"0.0.0.0:8200\"\n  tls_cert_file = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault-cert.pem\"\n  tls_key_file  = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault-key.pem\"\n}\n\nseal \"awskms\" {\n  region     = \"us-east-1\"\n  kms_key_id = \"alias\u002Fvault-unseal-key\"\n}\n\napi_addr      = \"https:\u002F\u002Fvault-1.corp.local:8200\"\ncluster_addr  = \"https:\u002F\u002Fvault-1.corp.local:8201\"\n\ntelemetry {\n  prometheus_retention_time = \"24h\"\n  disable_hostname          = true\n}\n\nui = true\n```\n\n```bash\n# Initialize Vault cluster\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 AppRole authentication for applications\nvault auth enable approle\n\n# Create policy for database secret consumers\nvault policy write db-consumer - \u003C\u003CEOF\n# Allow reading dynamic database credentials\npath \"database\u002Fcreds\u002Fapp-readonly\" {\n  capabilities = [\"read\"]\n}\npath \"database\u002Fcreds\u002Fapp-readwrite\" {\n  capabilities = [\"read\"]\n}\n\n# Allow renewing and revoking own leases\npath \"sys\u002Fleases\u002Frenew\" {\n  capabilities = [\"update\"]\n}\npath \"sys\u002Fleases\u002Frevoke\" {\n  capabilities = [\"update\"]\n}\n\n# Allow reading own token info\npath \"auth\u002Ftoken\u002Flookup-self\" {\n  capabilities = [\"read\"]\n}\nEOF\n\n# Create AppRole for application\nvault write auth\u002Fapprole\u002Frole\u002Fwebapp \\\n    token_policies=\"db-consumer\" \\\n    token_ttl=1h \\\n    token_max_ttl=4h \\\n    secret_id_ttl=720h \\\n    secret_id_num_uses=0\n```\n\n### Step 2: Configure Database Secrets Engine\n\nSet up dynamic credential generation for PostgreSQL and MySQL:\n\n```bash\n# Enable the database secrets engine\nvault secrets enable database\n\n# Configure PostgreSQL connection\nvault write database\u002Fconfig\u002Fproduction-postgres \\\n    plugin_name=postgresql-database-plugin \\\n    allowed_roles=\"app-readonly,app-readwrite,app-admin\" \\\n    connection_url=\"postgresql:\u002F\u002F{{username}}:{{password}}@db-primary.corp.local:5432\u002Fappdb?sslmode=verify-full\" \\\n    username=\"vault_admin\" \\\n    password=\"$VAULT_DB_PASSWORD\" \\\n    password_authentication=\"scram-sha-256\"\n\n# Rotate the root credentials so Vault manages them exclusively\nvault write -force database\u002Frotate-root\u002Fproduction-postgres\n\n# Create read-only role (TTL: 1 hour, max 24 hours)\nvault write database\u002Froles\u002Fapp-readonly \\\n    db_name=production-postgres \\\n    creation_statements=\"CREATE ROLE \\\"{{name}}\\\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; \\\n        GRANT SELECT ON ALL TABLES IN SCHEMA public TO \\\"{{name}}\\\"; \\\n        ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO \\\"{{name}}\\\";\" \\\n    revocation_statements=\"REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM \\\"{{name}}\\\"; \\\n        DROP ROLE IF EXISTS \\\"{{name}}\\\";\" \\\n    default_ttl=\"1h\" \\\n    max_ttl=\"24h\"\n\n# Create read-write role (TTL: 30 minutes, max 8 hours)\nvault write database\u002Froles\u002Fapp-readwrite \\\n    db_name=production-postgres \\\n    creation_statements=\"CREATE ROLE \\\"{{name}}\\\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; \\\n        GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO \\\"{{name}}\\\"; \\\n        ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO \\\"{{name}}\\\";\" \\\n    revocation_statements=\"REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM \\\"{{name}}\\\"; \\\n        DROP ROLE IF EXISTS \\\"{{name}}\\\";\" \\\n    default_ttl=\"30m\" \\\n    max_ttl=\"8h\"\n\n# Configure MySQL connection\nvault write database\u002Fconfig\u002Fproduction-mysql \\\n    plugin_name=mysql-database-plugin \\\n    allowed_roles=\"mysql-readonly,mysql-readwrite\" \\\n    connection_url=\"{{username}}:{{password}}@tcp(mysql-primary.corp.local:3306)\u002F\" \\\n    username=\"vault_admin\" \\\n    password=\"$VAULT_MYSQL_PASSWORD\"\n\nvault write database\u002Froles\u002Fmysql-readonly \\\n    db_name=production-mysql \\\n    creation_statements=\"CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}'; \\\n        GRANT SELECT ON appdb.* TO '{{name}}'@'%';\" \\\n    revocation_statements=\"DROP USER IF EXISTS '{{name}}'@'%';\" \\\n    default_ttl=\"1h\" \\\n    max_ttl=\"24h\"\n\n# Test dynamic credential generation\necho \"Testing PostgreSQL dynamic credentials:\"\nvault read database\u002Fcreds\u002Fapp-readonly\n# Returns: username=v-approle-app-read-xxxxx, password=\u003Crandom>, lease_id=database\u002Fcreds\u002Fapp-readonly\u002Fxxxxx\n```\n\n### Step 3: Configure AWS Secrets Engine\n\nGenerate ephemeral AWS IAM credentials:\n\n```bash\n# Enable the AWS secrets engine\nvault secrets enable aws\n\n# Configure the AWS secrets engine with root credentials\nvault write aws\u002Fconfig\u002Froot \\\n    access_key=\"$AWS_ACCESS_KEY_ID\" \\\n    secret_key=\"$AWS_SECRET_ACCESS_KEY\" \\\n    region=\"us-east-1\"\n\n# Configure lease settings\nvault write aws\u002Fconfig\u002Flease \\\n    lease=\"30m\" \\\n    lease_max=\"1h\"\n\n# Create IAM User role for S3 read-only access\nvault write aws\u002Froles\u002Fs3-readonly \\\n    credential_type=iam_user \\\n    policy_document=-\u003C\u003CEOF\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"s3:GetObject\",\n        \"s3:ListBucket\",\n        \"s3:GetBucketLocation\"\n      ],\n      \"Resource\": [\n        \"arn:aws:s3:::app-data-bucket\",\n        \"arn:aws:s3:::app-data-bucket\u002F*\"\n      ]\n    }\n  ]\n}\nEOF\n\n# Create Assumed Role for EC2 management (preferred over IAM users)\nvault write aws\u002Froles\u002Fec2-admin \\\n    credential_type=assumed_role \\\n    role_arns=\"arn:aws:iam::123456789012:role\u002FVaultEC2AdminRole\" \\\n    default_sts_ttl=\"30m\" \\\n    max_sts_ttl=\"1h\"\n\n# Create Federation Token role for cross-account access\nvault write aws\u002Froles\u002Fcross-account-readonly \\\n    credential_type=federation_token \\\n    policy_document=-\u003C\u003CEOF\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"sts:AssumeRole\"\n      ],\n      \"Resource\": \"arn:aws:iam::987654321098:role\u002FCrossAccountReadOnly\"\n    }\n  ]\n}\nEOF\n\n# Test AWS dynamic credentials\necho \"Testing AWS STS credentials:\"\nvault read aws\u002Fcreds\u002Fec2-admin\n# Returns: access_key, secret_key, security_token with 30-minute TTL\n```\n\n### Step 4: Configure PKI Secrets Engine for Dynamic Certificates\n\nGenerate short-lived TLS certificates on demand:\n\n```bash\n# Enable PKI secrets engine for root CA\nvault secrets enable -path=pki pki\nvault secrets tune -max-lease-ttl=87600h pki\n\n# Generate root CA certificate\nvault write pki\u002Froot\u002Fgenerate\u002Finternal \\\n    common_name=\"Corp Internal Root CA\" \\\n    ttl=87600h \\\n    key_type=ec \\\n    key_bits=384\n\n# Enable PKI for intermediate CA\nvault secrets enable -path=pki_int pki\nvault secrets tune -max-lease-ttl=43800h pki_int\n\n# Generate intermediate CA CSR\nvault write pki_int\u002Fintermediate\u002Fgenerate\u002Finternal \\\n    common_name=\"Corp Intermediate CA\" \\\n    key_type=ec \\\n    key_bits=256\n\n# Sign intermediate CA with root CA\nvault write pki\u002Froot\u002Fsign-intermediate \\\n    csr=@intermediate.csr \\\n    format=pem_bundle \\\n    ttl=43800h\n\n# Configure issuing URLs\nvault write pki_int\u002Fconfig\u002Furls \\\n    issuing_certificates=\"https:\u002F\u002Fvault.corp.local:8200\u002Fv1\u002Fpki_int\u002Fca\" \\\n    crl_distribution_points=\"https:\u002F\u002Fvault.corp.local:8200\u002Fv1\u002Fpki_int\u002Fcrl\"\n\n# Create role for web server certificates (TTL: 30 days)\nvault write pki_int\u002Froles\u002Fweb-server \\\n    allowed_domains=\"corp.local,internal.corp.com\" \\\n    allow_subdomains=true \\\n    max_ttl=720h \\\n    key_type=ec \\\n    key_bits=256 \\\n    require_cn=true \\\n    enforce_hostnames=true\n\n# Create role for service mesh certificates (TTL: 24 hours)\nvault write pki_int\u002Froles\u002Fservice-mesh \\\n    allowed_domains=\"service.consul\" \\\n    allow_subdomains=true \\\n    max_ttl=24h \\\n    key_type=ec \\\n    key_bits=256 \\\n    allow_ip_sans=true \\\n    server_flag=true \\\n    client_flag=true\n\n# Issue a certificate\nvault write pki_int\u002Fissue\u002Fweb-server \\\n    common_name=\"api.corp.local\" \\\n    alt_names=\"api.internal.corp.com\" \\\n    ttl=720h\n```\n\n### Step 5: Integrate Applications with Vault\n\nConfigure applications to consume dynamic secrets:\n\n```python\n\"\"\"\nApplication integration with HashiCorp Vault for dynamic database credentials.\nUses the hvac Python client with automatic lease renewal.\n\"\"\"\nimport hvac\nimport threading\nimport time\nimport logging\n\nclass VaultDynamicCredentialManager:\n    def __init__(self, vault_addr, role_id, secret_id):\n        self.client = hvac.Client(url=vault_addr)\n        self.role_id = role_id\n        self.secret_id = secret_id\n        self.logger = logging.getLogger(\"vault_credentials\")\n        self._current_creds = None\n        self._lease_id = None\n        self._renewal_thread = None\n        self._stop_event = threading.Event()\n\n    def authenticate(self):\n        \"\"\"Authenticate to Vault using AppRole.\"\"\"\n        response = self.client.auth.approle.login(\n            role_id=self.role_id,\n            secret_id=self.secret_id\n        )\n        self.client.token = response[\"auth\"][\"client_token\"]\n        self.logger.info(\"Authenticated to Vault via AppRole\")\n\n    def get_database_credentials(self, role=\"app-readonly\"):\n        \"\"\"Request dynamic database credentials from Vault.\"\"\"\n        self.authenticate()\n\n        response = self.client.secrets.database.generate_credentials(\n            name=role\n        )\n\n        self._current_creds = {\n            \"username\": response[\"data\"][\"username\"],\n            \"password\": response[\"data\"][\"password\"],\n        }\n        self._lease_id = response[\"lease_id\"]\n        lease_duration = response[\"lease_duration\"]\n\n        self.logger.info(\n            f\"Obtained dynamic credentials: user={self._current_creds['username']}, \"\n            f\"lease={self._lease_id}, ttl={lease_duration}s\"\n        )\n\n        # Start background lease renewal\n        self._start_renewal(lease_duration)\n\n        return self._current_creds\n\n    def _start_renewal(self, lease_duration):\n        \"\"\"Start background thread to renew lease before expiration.\"\"\"\n        if self._renewal_thread and self._renewal_thread.is_alive():\n            self._stop_event.set()\n            self._renewal_thread.join()\n\n        self._stop_event.clear()\n        renewal_interval = lease_duration * 0.7  # Renew at 70% of TTL\n\n        def renew_loop():\n            while not self._stop_event.wait(renewal_interval):\n                try:\n                    self.client.sys.renew_lease(\n                        lease_id=self._lease_id,\n                        increment=lease_duration\n                    )\n                    self.logger.info(f\"Renewed lease: {self._lease_id}\")\n                except hvac.exceptions.InvalidRequest:\n                    self.logger.warning(\"Lease expired, obtaining new credentials\")\n                    self.get_database_credentials()\n                    break\n                except Exception as e:\n                    self.logger.error(f\"Lease renewal failed: {e}\")\n\n        self._renewal_thread = threading.Thread(target=renew_loop, daemon=True)\n        self._renewal_thread.start()\n\n    def revoke_credentials(self):\n        \"\"\"Explicitly revoke current dynamic credentials.\"\"\"\n        if self._lease_id:\n            self._stop_event.set()\n            self.client.sys.revoke_lease(self._lease_id)\n            self.logger.info(f\"Revoked lease: {self._lease_id}\")\n            self._current_creds = None\n            self._lease_id = None\n\n    def get_aws_credentials(self, role=\"s3-readonly\"):\n        \"\"\"Request dynamic AWS credentials from Vault.\"\"\"\n        self.authenticate()\n\n        response = self.client.secrets.aws.generate_credentials(\n            name=role\n        )\n\n        return {\n            \"access_key\": response[\"data\"][\"access_key\"],\n            \"secret_key\": response[\"data\"][\"secret_key\"],\n            \"security_token\": response[\"data\"].get(\"security_token\"),\n            \"lease_id\": response[\"lease_id\"],\n            \"ttl\": response[\"lease_duration\"]\n        }\n\n# Usage example\nvault_mgr = VaultDynamicCredentialManager(\n    vault_addr=\"https:\u002F\u002Fvault.corp.local:8200\",\n    role_id=\"\u003Capprole-role-id>\",\n    secret_id=\"\u003Capprole-secret-id>\"\n)\n\ndb_creds = vault_mgr.get_database_credentials(\"app-readonly\")\n# Use db_creds[\"username\"] and db_creds[\"password\"] for database connection\n```\n\n### Step 6: Monitor Vault Operations and Lease Management\n\nTrack dynamic secret usage and lease lifecycle:\n\n```bash\n# Monitor active leases\nvault list sys\u002Fleases\u002Flookup\u002Fdatabase\u002Fcreds\u002Fapp-readonly\nvault list sys\u002Fleases\u002Flookup\u002Faws\u002Fcreds\u002Fs3-readonly\n\n# Check lease details\nvault write sys\u002Fleases\u002Flookup lease_id=\"database\u002Fcreds\u002Fapp-readonly\u002Fabcd1234\"\n\n# Revoke all leases for a specific path (emergency credential rotation)\nvault lease revoke -prefix database\u002Fcreds\u002Fapp-readonly\n\n# Vault metrics for monitoring (Prometheus format)\n# Key metrics to monitor:\n# vault.expire.num_leases - Total active leases\n# vault.expire.revoke - Lease revocations per second\n# vault.secret.kv.count - Total stored secrets\n# vault.runtime.alloc_bytes - Memory allocation\n\n# Configure Vault audit log analysis\ncat > vault_audit_monitor.sh \u003C\u003C 'SCRIPT'\n#!\u002Fbin\u002Fbash\n# Monitor Vault audit logs for suspicious activity\n\nAUDIT_LOG=\"\u002Fvar\u002Flog\u002Fvault\u002Faudit.log\"\n\n# Count credential requests per hour\necho \"=== Dynamic Credential Requests (Last Hour) ===\"\njq -r 'select(.type == \"response\" and .request.path | startswith(\"database\u002Fcreds\u002F\")) |\n    \"\\(.time) \\(.request.path) \\(.auth.display_name)\"' \\\n    \"$AUDIT_LOG\" | tail -100\n\n# Detect unusual credential request patterns\necho \"\"\necho \"=== High-Volume Credential Consumers ===\"\njq -r 'select(.type == \"request\" and .request.path | startswith(\"database\u002Fcreds\u002F\")) |\n    .auth.display_name' \\\n    \"$AUDIT_LOG\" | sort | uniq -c | sort -rn | head -10\n\n# Check for failed authentication attempts\necho \"\"\necho \"=== Failed Auth Attempts ===\"\njq -r 'select(.type == \"response\" and .error != null and\n    .request.path | startswith(\"auth\u002F\")) |\n    \"\\(.time) \\(.request.path) \\(.error)\"' \\\n    \"$AUDIT_LOG\" | tail -20\nSCRIPT\nchmod +x vault_audit_monitor.sh\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Dynamic Secrets** | Credentials generated on-demand by Vault with automatic expiration, ensuring each consumer receives unique short-lived credentials |\n| **Lease** | Time-bound agreement where Vault guarantees the credential is valid; consumers must renew before expiration or request new credentials |\n| **Secrets Engine** | Vault plugin that generates, stores, or encrypts data; database, AWS, PKI, and KV are common engines |\n| **AppRole** | Vault authentication method designed for machine-to-machine authentication using role ID and secret ID pairs |\n| **Root Credential Rotation** | Process of having Vault take exclusive ownership of the admin credential used to create dynamic secrets, eliminating human knowledge of the root password |\n| **Lease Revocation** | Immediate invalidation of dynamic credentials, used during incident response to revoke all credentials for compromised paths |\n\n## Tools & Systems\n\n- **HashiCorp Vault**: Secrets management platform providing dynamic secrets, encryption as a service, and identity-based access control\n- **Vault Agent**: Sidecar process that handles Vault authentication, token renewal, and secret caching for applications\n- **Vault Secrets Operator**: Kubernetes operator that syncs Vault secrets into Kubernetes Secrets for pod consumption\n- **hvac**: Python client library for HashiCorp Vault API operations\n\n## Common Scenarios\n\n### Scenario: Eliminating Static Database Credentials in Microservices\n\n**Context**: 50 microservices share 3 static PostgreSQL credentials stored in environment variables across Kubernetes deployments. A credential leak requires rotating all 50 services simultaneously.\n\n**Approach**:\n1. Deploy Vault with Raft storage in a 3-node HA cluster within Kubernetes\n2. Configure database secrets engine with PostgreSQL connection using admin credentials\n3. Create per-service Vault roles with least-privilege SQL grants\n4. Deploy Vault Secrets Operator to inject dynamic credentials into pod environment variables\n5. Update application connection logic to handle credential rotation via lease renewal\n6. Rotate the Vault root credential to remove human knowledge of the admin password\n7. Monitor lease lifecycle and set alerts for renewal failures\n\n**Pitfalls**:\n- Not handling credential rotation in application connection pools (connections using expired credentials fail)\n- Setting TTLs too short causes excessive credential generation load on the database\n- Not configuring proper revocation statements leaves orphaned database users after lease expiration\n- Running Vault without HA causes single point of failure for all application authentication\n\n## Output Format\n\n```\nHASHICORP VAULT DYNAMIC SECRETS REPORT\n=========================================\nVault Version:     1.16.2 Enterprise\nCluster Status:    HA Active (3 nodes)\nSeal Type:         AWS KMS (auto-unseal)\n\nSECRETS ENGINES\ndatabase\u002F:         PostgreSQL, MySQL (2 connections)\naws\u002F:              IAM User, Assumed Role, Federation Token\npki_int\u002F:          Internal CA (EC P-256)\n\nDYNAMIC CREDENTIAL METRICS (Last 24 Hours)\nTotal Credentials Generated:    4,287\n  Database (PostgreSQL):        2,891\n  Database (MySQL):             543\n  AWS STS:                      612\n  PKI Certificates:             241\n\nACTIVE LEASES\nTotal Active:                   387\n  database\u002Fcreds\u002Fapp-readonly:  198\n  database\u002Fcreds\u002Fapp-readwrite: 89\n  aws\u002Fcreds\u002Fs3-readonly:        67\n  pki_int\u002Fissue\u002Fweb-server:     33\n\nLEASE LIFECYCLE\nAverage TTL:                    45 minutes\nRenewals (24h):                 12,847\nRevocations (24h):              3,901\nExpired (not renewed):          12\n\nSECURITY\nFailed Auth Attempts (24h):     3\nRoot Credential Rotated:        YES (all databases)\nAudit Logging:                  ENABLED (file + syslog)\nPolicy Violations (24h):        7 (permission denied)\n```\n","# Implementing HashiCorp Vault Dynamic Secrets\n\n## When to Use\n\n- Applications use static database credentials stored in configuration files or environment variables\n- AWS IAM access keys are long-lived and shared across services\n- Need to eliminate credential sprawl by generating short-lived, per-request secrets\n- Compliance requirements mandate credential rotation (PCI-DSS Requirement 8, NIST 800-53 IA-5)\n- Implementing zero-trust secret management where credentials are never stored at rest\n- Migrating from manual credential management to automated secrets lifecycle\n\n**Do not use** for storing static secrets that cannot be dynamically generated (use Vault's KV secrets engine instead); dynamic secrets are for credentials that can be programmatically created and revoked on target systems.\n\n## Prerequisites\n\n- HashiCorp Vault 1.15+ (Community or Enterprise edition)\n- Vault server initialized and unsealed with auto-unseal configured (AWS KMS, Azure Key Vault, or Transit)\n- Target database systems with admin credentials for Vault to create\u002Frevoke dynamic accounts\n- AWS IAM account with permissions to create\u002Fdelete IAM users and access keys\n- Network connectivity from Vault to all target systems\n- Vault policies and authentication methods configured for consuming applications\n\n## Workflow\n\n### Step 1: Deploy and Configure Vault Server\n\nInitialize Vault with production-grade configuration:\n\n```hcl\n# vault-config.hcl - Production Vault server configuration\nstorage \"raft\" {\n  path    = \"\u002Fopt\u002Fvault\u002Fdata\"\n  node_id = \"vault-1\"\n\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-2.corp.local:8200\"\n  }\n  retry_join {\n    leader_api_addr = \"https:\u002F\u002Fvault-3.corp.local:8200\"\n  }\n}\n\nlistener \"tcp\" {\n  address       = \"0.0.0.0:8200\"\n  tls_cert_file = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault-cert.pem\"\n  tls_key_file  = \"\u002Fopt\u002Fvault\u002Ftls\u002Fvault-key.pem\"\n}\n\nseal \"awskms\" {\n  region     = \"us-east-1\"\n  kms_key_id = \"alias\u002Fvault-unseal-key\"\n}\n\napi_addr      = \"https:\u002F\u002Fvault-1.corp.local:8200\"\ncluster_addr  = \"https:\u002F\u002Fvault-1.corp.local:8201\"\n\ntelemetry {\n  prometheus_retention_time = \"24h\"\n  disable_hostname          = true\n}\n\nui = true\n```\n\n```bash\n# Initialize Vault cluster\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 AppRole authentication for applications\nvault auth enable approle\n\n# Create policy for database secret consumers\nvault policy write db-consumer - \u003C\u003CEOF\n# Allow reading dynamic database credentials\npath \"database\u002Fcreds\u002Fapp-readonly\" {\n  capabilities = [\"read\"]\n}\npath \"database\u002Fcreds\u002Fapp-readwrite\" {\n  capabilities = [\"read\"]\n}\n\n# Allow renewing and revoking own leases\npath \"sys\u002Fleases\u002Frenew\" {\n  capabilities = [\"update\"]\n}\npath \"sys\u002Fleases\u002Frevoke\" {\n  capabilities = [\"update\"]\n}\n\n# Allow reading own token info\npath \"auth\u002Ftoken\u002Flookup-self\" {\n  capabilities = [\"read\"]\n}\nEOF\n\n# Create AppRole for application\nvault write auth\u002Fapprole\u002Frole\u002Fwebapp \\\n    token_policies=\"db-consumer\" \\\n    token_ttl=1h \\\n    token_max_ttl=4h \\\n    secret_id_ttl=720h \\\n    secret_id_num_uses=0\n```\n\n### Step 2: Configure Database Secrets Engine\n\nSet up dynamic credential generation for PostgreSQL and MySQL:\n\n```bash\n# Enable the database secrets engine\nvault secrets enable database\n\n# Configure PostgreSQL connection\nvault write database\u002Fconfig\u002Fproduction-postgres \\\n    plugin_name=postgresql-database-plugin \\\n    allowed_roles=\"app-readonly,app-readwrite,app-admin\" \\\n    connection_url=\"postgresql:\u002F\u002F{{username}}:{{password}}@db-primary.corp.local:5432\u002Fappdb?sslmode=verify-full\" \\\n    username=\"vault_admin\" \\\n    password=\"$VAULT_DB_PASSWORD\" \\\n    password_authentication=\"scram-sha-256\"\n\n# Rotate the root credentials so Vault manages them exclusively\nvault write -force database\u002Frotate-root\u002Fproduction-postgres\n\n# Create read-only role (TTL: 1 hour, max 24 hours)\nvault write database\u002Froles\u002Fapp-readonly \\\n    db_name=production-postgres \\\n    creation_statements=\"CREATE ROLE \\\"{{name}}\\\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; \\\n        GRANT SELECT ON ALL TABLES IN SCHEMA public TO \\\"{{name}}\\\"; \\\n        ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO \\\"{{name}}\\\";\" \\\n    revocation_statements=\"REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM \\\"{{name}}\\\"; \\\n        DROP ROLE IF EXISTS \\\"{{name}}\\\";\" \\\n    default_ttl=\"1h\" \\\n    max_ttl=\"24h\"\n\n# Create read-write role (TTL: 30 minutes, max 8 hours)\nvault write database\u002Froles\u002Fapp-readwrite \\\n    db_name=production-postgres \\\n    creation_statements=\"CREATE ROLE \\\"{{name}}\\\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; \\\n        GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO \\\"{{name}}\\\"; \\\n        ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO \\\"{{name}}\\\";\" \\\n    revocation_statements=\"REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM \\\"{{name}}\\\"; \\\n        DROP ROLE IF EXISTS \\\"{{name}}\\\";\" \\\n    default_ttl=\"30m\" \\\n    max_ttl=\"8h\"\n\n# Configure MySQL connection\nvault write database\u002Fconfig\u002Fproduction-mysql \\\n    plugin_name=mysql-database-plugin \\\n    allowed_roles=\"mysql-readonly,mysql-readwrite\" \\\n    connection_url=\"{{username}}:{{password}}@tcp(mysql-primary.corp.local:3306)\u002F\" \\\n    username=\"vault_admin\" \\\n    password=\"$VAULT_MYSQL_PASSWORD\"\n\nvault write database\u002Froles\u002Fmysql-readonly \\\n    db_name=production-mysql \\\n    creation_statements=\"CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}'; \\\n        GRANT SELECT ON appdb.* TO '{{name}}'@'%';\" \\\n    revocation_statements=\"DROP USER IF EXISTS '{{name}}'@'%';\" \\\n    default_ttl=\"1h\" \\\n    max_ttl=\"24h\"\n\n# Test dynamic credential generation\necho \"Testing PostgreSQL dynamic credentials:\"\nvault read database\u002Fcreds\u002Fapp-readonly\n# Returns: username=v-approle-app-read-xxxxx, password=\u003Crandom>, lease_id=database\u002Fcreds\u002Fapp-readonly\u002Fxxxxx\n```\n\n### Step 3: Configure AWS Secrets Engine\n\nGenerate ephemeral AWS IAM credentials:\n\n```bash\n# Enable the AWS secrets engine\nvault secrets enable aws\n\n# Configure the AWS secrets engine with root credentials\nvault write aws\u002Fconfig\u002Froot \\\n    access_key=\"$AWS_ACCESS_KEY_ID\" \\\n    secret_key=\"$AWS_SECRET_ACCESS_KEY\" \\\n    region=\"us-east-1\"\n\n# Configure lease settings\nvault write aws\u002Fconfig\u002Flease \\\n    lease=\"30m\" \\\n    lease_max=\"1h\"\n\n# Create IAM User role for S3 read-only access\nvault write aws\u002Froles\u002Fs3-readonly \\\n    credential_type=iam_user \\\n    policy_document=-\u003C\u003CEOF\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"s3:GetObject\",\n        \"s3:ListBucket\",\n        \"s3:GetBucketLocation\"\n      ],\n      \"Resource\": [\n        \"arn:aws:s3:::app-data-bucket\",\n        \"arn:aws:s3:::app-data-bucket\u002F*\"\n      ]\n    }\n  ]\n}\nEOF\n\n# Create Assumed Role for EC2 management (preferred over IAM users)\nvault write aws\u002Froles\u002Fec2-admin \\\n    credential_type=assumed_role \\\n    role_arns=\"arn:aws:iam::123456789012:role\u002FVaultEC2AdminRole\" \\\n    default_sts_ttl=\"30m\" \\\n    max_sts_ttl=\"1h\"\n\n# Create Federation Token role for cross-account access\nvault write aws\u002Froles\u002Fcross-account-readonly \\\n    credential_type=federation_token \\\n    policy_document=-\u003C\u003CEOF\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"sts:AssumeRole\"\n      ],\n      \"Resource\": \"arn:aws:iam::987654321098:role\u002FCrossAccountReadOnly\"\n    }\n  ]\n}\nEOF\n\n# Test AWS dynamic credentials\necho \"Testing AWS STS credentials:\"\nvault read aws\u002Fcreds\u002Fec2-admin\n# Returns: access_key, secret_key, security_token with 30-minute TTL\n```\n\n### Step 4: Configure PKI Secrets Engine for Dynamic Certificates\n\nGenerate short-lived TLS certificates on demand:\n\n```bash\n# Enable PKI secrets engine for root CA\nvault secrets enable -path=pki pki\nvault secrets tune -max-lease-ttl=87600h pki\n\n# Generate root CA certificate\nvault write pki\u002Froot\u002Fgenerate\u002Finternal \\\n    common_name=\"Corp Internal Root CA\" \\\n    ttl=87600h \\\n    key_type=ec \\\n    key_bits=384\n\n# Enable PKI for intermediate CA\nvault secrets enable -path=pki_int pki\nvault secrets tune -max-lease-ttl=43800h pki_int\n\n# Generate intermediate CA CSR\nvault write pki_int\u002Fintermediate\u002Fgenerate\u002Finternal \\\n    common_name=\"Corp Intermediate CA\" \\\n    key_type=ec \\\n    key_bits=256\n\n# Sign intermediate CA with root CA\nvault write pki\u002Froot\u002Fsign-intermediate \\\n    csr=@intermediate.csr \\\n    format=pem_bundle \\\n    ttl=43800h\n\n# Configure issuing URLs\nvault write pki_int\u002Fconfig\u002Furls \\\n    issuing_certificates=\"https:\u002F\u002Fvault.corp.local:8200\u002Fv1\u002Fpki_int\u002Fca\" \\\n    crl_distribution_points=\"https:\u002F\u002Fvault.corp.local:8200\u002Fv1\u002Fpki_int\u002Fcrl\"\n\n# Create role for web server certificates (TTL: 30 days)\nvault write pki_int\u002Froles\u002Fweb-server \\\n    allowed_domains=\"corp.local,internal.corp.com\" \\\n    allow_subdomains=true \\\n    max_ttl=720h \\\n    key_type=ec \\\n    key_bits=256 \\\n    require_cn=true \\\n    enforce_hostnames=true\n\n# Create role for service mesh certificates (TTL: 24 hours)\nvault write pki_int\u002Froles\u002Fservice-mesh \\\n    allowed_domains=\"service.consul\" \\\n    allow_subdomains=true \\\n    max_ttl=24h \\\n    key_type=ec \\\n    key_bits=256 \\\n    allow_ip_sans=true \\\n    server_flag=true \\\n    client_flag=true\n\n# Issue a certificate\nvault write pki_int\u002Fissue\u002Fweb-server \\\n    common_name=\"api.corp.local\" \\\n    alt_names=\"api.internal.corp.com\" \\\n    ttl=720h\n```\n\n### Step 5: Integrate Applications with Vault\n\nConfigure applications to consume dynamic secrets:\n\n```python\n\"\"\"\nApplication integration with HashiCorp Vault for dynamic database credentials.\nUses the hvac Python client with automatic lease renewal.\n\"\"\"\nimport hvac\nimport threading\nimport time\nimport logging\n\nclass VaultDynamicCredentialManager:\n    def __init__(self, vault_addr, role_id, secret_id):\n        self.client = hvac.Client(url=vault_addr)\n        self.role_id = role_id\n        self.secret_id = secret_id\n        self.logger = logging.getLogger(\"vault_credentials\")\n        self._current_creds = None\n        self._lease_id = None\n        self._renewal_thread = None\n        self._stop_event = threading.Event()\n\n    def authenticate(self):\n        \"\"\"Authenticate to Vault using AppRole.\"\"\"\n        response = self.client.auth.approle.login(\n            role_id=self.role_id,\n            secret_id=self.secret_id\n        )\n        self.client.token = response[\"auth\"][\"client_token\"]\n        self.logger.info(\"Authenticated to Vault via AppRole\")\n\n    def get_database_credentials(self, role=\"app-readonly\"):\n        \"\"\"Request dynamic database credentials from Vault.\"\"\"\n        self.authenticate()\n\n        response = self.client.secrets.database.generate_credentials(\n            name=role\n        )\n\n        self._current_creds = {\n            \"username\": response[\"data\"][\"username\"],\n            \"password\": response[\"data\"][\"password\"],\n        }\n        self._lease_id = response[\"lease_id\"]\n        lease_duration = response[\"lease_duration\"]\n\n        self.logger.info(\n            f\"Obtained dynamic credentials: user={self._current_creds['username']}, \"\n            f\"lease={self._lease_id}, ttl={lease_duration}s\"\n        )\n\n        # Start background lease renewal\n        self._start_renewal(lease_duration)\n\n        return self._current_creds\n\n    def _start_renewal(self, lease_duration):\n        \"\"\"Start background thread to renew lease before expiration.\"\"\"\n        if self._renewal_thread and self._renewal_thread.is_alive():\n            self._stop_event.set()\n            self._renewal_thread.join()\n\n        self._stop_event.clear()\n        renewal_interval = lease_duration * 0.7  # Renew at 70% of TTL\n\n        def renew_loop():\n            while not self._stop_event.wait(renewal_interval):\n                try:\n                    self.client.sys.renew_lease(\n                        lease_id=self._lease_id,\n                        increment=lease_duration\n                    )\n                    self.logger.info(f\"Renewed lease: {self._lease_id}\")\n                except hvac.exceptions.InvalidRequest:\n                    self.logger.warning(\"Lease expired, obtaining new credentials\")\n                    self.get_database_credentials()\n                    break\n                except Exception as e:\n                    self.logger.error(f\"Lease renewal failed: {e}\")\n\n        self._renewal_thread = threading.Thread(target=renew_loop, daemon=True)\n        self._renewal_thread.start()\n\n    def revoke_credentials(self):\n        \"\"\"Explicitly revoke current dynamic credentials.\"\"\"\n        if self._lease_id:\n            self._stop_event.set()\n            self.client.sys.revoke_lease(self._lease_id)\n            self.logger.info(f\"Revoked lease: {self._lease_id}\")\n            self._current_creds = None\n            self._lease_id = None\n\n    def get_aws_credentials(self, role=\"s3-readonly\"):\n        \"\"\"Request dynamic AWS credentials from Vault.\"\"\"\n        self.authenticate()\n\n        response = self.client.secrets.aws.generate_credentials(\n            name=role\n        )\n\n        return {\n            \"access_key\": response[\"data\"][\"access_key\"],\n            \"secret_key\": response[\"data\"][\"secret_key\"],\n            \"security_token\": response[\"data\"].get(\"security_token\"),\n            \"lease_id\": response[\"lease_id\"],\n            \"ttl\": response[\"lease_duration\"]\n        }\n\n# Usage example\nvault_mgr = VaultDynamicCredentialManager(\n    vault_addr=\"https:\u002F\u002Fvault.corp.local:8200\",\n    role_id=\"\u003Capprole-role-id>\",\n    secret_id=\"\u003Capprole-secret-id>\"\n)\n\ndb_creds = vault_mgr.get_database_credentials(\"app-readonly\")\n# Use db_creds[\"username\"] and db_creds[\"password\"] for database connection\n```\n\n### Step 6: Monitor Vault Operations and Lease Management\n\nTrack dynamic secret usage and lease lifecycle:\n\n```bash\n# Monitor active leases\nvault list sys\u002Fleases\u002Flookup\u002Fdatabase\u002Fcreds\u002Fapp-readonly\nvault list sys\u002Fleases\u002Flookup\u002Faws\u002Fcreds\u002Fs3-readonly\n\n# Check lease details\nvault write sys\u002Fleases\u002Flookup lease_id=\"database\u002Fcreds\u002Fapp-readonly\u002Fabcd1234\"\n\n# Revoke all leases for a specific path (emergency credential rotation)\nvault lease revoke -prefix database\u002Fcreds\u002Fapp-readonly\n\n# Vault metrics for monitoring (Prometheus format)\n# Key metrics to monitor:\n# vault.expire.num_leases - Total active leases\n# vault.expire.revoke - Lease revocations per second\n# vault.secret.kv.count - Total stored secrets\n# vault.runtime.alloc_bytes - Memory allocation\n\n# Configure Vault audit log analysis\ncat > vault_audit_monitor.sh \u003C\u003C 'SCRIPT'\n#!\u002Fbin\u002Fbash\n# Monitor Vault audit logs for suspicious activity\n\nAUDIT_LOG=\"\u002Fvar\u002Flog\u002Fvault\u002Faudit.log\"\n\n# Count credential requests per hour\necho \"=== Dynamic Credential Requests (Last Hour) ===\"\njq -r 'select(.type == \"response\" and .request.path | startswith(\"database\u002Fcreds\u002F\")) |\n    \"\\(.time) \\(.request.path) \\(.auth.display_name)\"' \\\n    \"$AUDIT_LOG\" | tail -100\n\n# Detect unusual credential request patterns\necho \"\"\necho \"=== High-Volume Credential Consumers ===\"\njq -r 'select(.type == \"request\" and .request.path | startswith(\"database\u002Fcreds\u002F\")) |\n    .auth.display_name' \\\n    \"$AUDIT_LOG\" | sort | uniq -c | sort -rn | head -10\n\n# Check for failed authentication attempts\necho \"\"\necho \"=== Failed Auth Attempts ===\"\njq -r 'select(.type == \"response\" and .error != null and\n    .request.path | startswith(\"auth\u002F\")) |\n    \"\\(.time) \\(.request.path) \\(.error)\"' \\\n    \"$AUDIT_LOG\" | tail -20\nSCRIPT\nchmod +x vault_audit_monitor.sh\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Dynamic Secrets** | Credentials generated on-demand by Vault with automatic expiration, ensuring each consumer receives unique short-lived credentials |\n| **Lease** | Time-bound agreement where Vault guarantees the credential is valid; consumers must renew before expiration or request new credentials |\n| **Secrets Engine** | Vault plugin that generates, stores, or encrypts data; database, AWS, PKI, and KV are common engines |\n| **AppRole** | Vault authentication method designed for machine-to-machine authentication using role ID and secret ID pairs |\n| **Root Credential Rotation** | Process of having Vault take exclusive ownership of the admin credential used to create dynamic secrets, eliminating human knowledge of the root password |\n| **Lease Revocation** | Immediate invalidation of dynamic credentials, used during incident response to revoke all credentials for compromised paths |\n\n## Tools & Systems\n\n- **HashiCorp Vault**: Secrets management platform providing dynamic secrets, encryption as a service, and identity-based access control\n- **Vault Agent**: Sidecar process that handles Vault authentication, token renewal, and secret caching for applications\n- **Vault Secrets Operator**: Kubernetes operator that syncs Vault secrets into Kubernetes Secrets for pod consumption\n- **hvac**: Python client library for HashiCorp Vault API operations\n\n## Common Scenarios\n\n### Scenario: Eliminating Static Database Credentials in Microservices\n\n**Context**: 50 microservices share 3 static PostgreSQL credentials stored in environment variables across Kubernetes deployments. A credential leak requires rotating all 50 services simultaneously.\n\n**Approach**:\n1. Deploy Vault with Raft storage in a 3-node HA cluster within Kubernetes\n2. Configure database secrets engine with PostgreSQL connection using admin credentials\n3. Create per-service Vault roles with least-privilege SQL grants\n4. Deploy Vault Secrets Operator to inject dynamic credentials into pod environment variables\n5. Update application connection logic to handle credential rotation via lease renewal\n6. Rotate the Vault root credential to remove human knowledge of the admin password\n7. Monitor lease lifecycle and set alerts for renewal failures\n\n**Pitfalls**:\n- Not handling credential rotation in application connection pools (connections using expired credentials fail)\n- Setting TTLs too short causes excessive credential generation load on the database\n- Not configuring proper revocation statements leaves orphaned database users after lease expiration\n- Running Vault without HA causes single point of failure for all application authentication\n\n## Output Format\n\n```\nHASHICORP VAULT DYNAMIC SECRETS REPORT\n=========================================\nVault Version:     1.16.2 Enterprise\nCluster Status:    HA Active (3 nodes)\nSeal Type:         AWS KMS (auto-unseal)\n\nSECRETS ENGINES\ndatabase\u002F:         PostgreSQL, MySQL (2 connections)\naws\u002F:              IAM User, Assumed Role, Federation Token\npki_int\u002F:          Internal CA (EC P-256)\n\nDYNAMIC CREDENTIAL METRICS (Last 24 Hours)\nTotal Credentials Generated:    4,287\n  Database (PostgreSQL):        2,891\n  Database (MySQL):             543\n  AWS STS:                      612\n  PKI Certificates:             241\n\nACTIVE LEASES\nTotal Active:                   387\n  database\u002Fcreds\u002Fapp-readonly:  198\n  database\u002Fcreds\u002Fapp-readwrite: 89\n  aws\u002Fcreds\u002Fs3-readonly:        67\n  pki_int\u002Fissue\u002Fweb-server:     33\n\nLEASE LIFECYCLE\nAverage TTL:                    45 minutes\nRenewals (24h):                 12,847\nRevocations (24h):              3,901\nExpired (not renewed):          12\n\nSECURITY\nFailed Auth Attempts (24h):     3\nRoot Credential Rotated:        YES (all databases)\nAudit Logging:                  ENABLED (file + syslog)\nPolicy Violations (24h):        7 (permission denied)\n```\n",{"name":5,"tags":24,"author":31,"domain":32,"license":14,"version":33,"mitre_f3":34,"nist_csf":63,"subdomain":68,"description":69,"mitre_attack":70},[25,26,27,28,29,30],"HashiCorp-Vault","dynamic-secrets","secrets-management","database-credentials","AWS-secrets","PKI","mahipal","cybersecurity","1.0",{"tactics":35,"version":40,"techniques":41},[36,37,38,39],"initial-access","positioning","stealth","resource-development","1.1",[42,46,49,53,57,60],{"id":43,"name":44,"source":45,"tactic":36},"F1006.001","Account Takeover: Exposed API Key","f3",{"id":47,"name":48,"source":45,"tactic":36},"F1006.002","Account Takeover: Exposed Login Credential",{"id":50,"name":51,"source":52,"tactic":39},"T1586","Compromise Accounts","attack",{"id":54,"name":55,"source":52,"tactic":56},"T1555","Credentials from Password Stores","reconnaissance",{"id":58,"name":59,"source":45,"tactic":37},"F1005.004","Account Manipulation: Change Account Details",{"id":61,"name":62,"source":45,"tactic":36},"F1033","Insider Access Abuse",[64,65,66,67],"PR.AA-01","PR.AA-02","PR.AA-05","PR.AA-06","identity-access-management","Configures HashiCorp Vault dynamic secrets engines for database credentials, AWS IAM keys, and PKI certificates, with automatic generation, lease management, and rotation to eliminate static secrets in application configuration. Use when eliminating long-lived static credentials, configuring a Vault secrets engine, generating ephemeral database or cloud credentials, or automating credential rotation for compliance (PCI-DSS, NIST 800-53 IA-5).\n",[71,72,73,74,75],"T1078","T1110","T1556","T1098","T1003","main","1eb986d0b0ecc180291597e08eb5a58288843536","skills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fimplementing-hashicorp-vault-dynamic-secrets","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv","2026-08-25 13:16:33",{"source":8,"skillName":5,"commands":83,"prompt":93,"zipAvailable":94},[84,87,90],{"tool":85,"command":86},"npx","npx skills add vikasvardhanv\u002Fjerry_skills --skill implementing-hashicorp-vault-dynamic-secrets",{"tool":88,"command":89},"bunx","bunx skills add vikasvardhanv\u002Fjerry_skills --skill implementing-hashicorp-vault-dynamic-secrets",{"tool":91,"command":92},"pnpm","pnpm dlx skills add vikasvardhanv\u002Fjerry_skills --skill implementing-hashicorp-vault-dynamic-secrets","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fimplementing-hashicorp-vault-dynamic-secrets\u002FSKILL.md",true,[96,100,106],{"path":97,"resourceType":97,"resourceTypeDesc":98,"sizeBytes":99,"sourceHtmlUrl":15},"LICENSE","许可证",11255,{"path":101,"resourceType":102,"resourceTypeDesc":103,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Fapi-reference.md","REFERENCE","参考文档",2591,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fimplementing-hashicorp-vault-dynamic-secrets\u002Freferences\u002Fapi-reference.md",{"path":107,"resourceType":108,"resourceTypeDesc":109,"sizeBytes":110,"sourceHtmlUrl":111},"scripts\u002Fagent.py","SCRIPT","脚本",8828,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fimplementing-hashicorp-vault-dynamic-secrets\u002Fscripts\u002Fagent.py",[113,121,128,135,142,149],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":19},"01M7BESR1CJ3H5SP9XM8KYJZ9W","syllabus","Generates a curated supplementary reading list from any course syllabus using Consensus academic search. Grill-me intake (syllabus input format + course audience + year range) plus a grouping forcing-options checkpoint before any search runs — so the reading list matches the course's level and recency need. Parses the syllabus to extract topics and learning outcomes, searches Consensus for recent peer-reviewed papers per topic, and produces a professionally formatted .docx with clickable Consensus links, plain-language summaries calibrated to audience level, and Bloom-higher-order discussion questions tied to course learning goals. Use when the user uploads a syllabus, course outline, or curriculum document and wants supplementary readings (e.g., 'create a reading list from this syllabus', 'find recent papers for my course') — even casual mentions with a syllabus attached should trigger this skill.","MIT","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fsyllabus\u002Fskills\u002Fsyllabus\u002FSKILL.md",[],[],{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":19},"01M7BES1YA6R97W7QPMFFM1PED","pulse","Multi-source recency research skill that takes the pulse of any topic across Reddit, Hacker News, the open web, and optionally X\u002FTwitter within a configurable recent window (default 30 days). Forcing intake clarifies topic specificity, angle (trend\u002Fsentiment\u002Fproblems\u002Fopportunities\u002Fcomparison), time window, and platform scope before searching. Returns a synthesized briefing with citations, engagement metrics, and cross-platform pattern analysis. Use when the user requests multi-source recency intelligence on a topic (e.g., 'pulse on [topic]', 'what's happening with [topic]', 'what are people saying about [topic]', 'current conversation about [topic]', 'take the pulse of [topic]', 'trending: [topic]', 'find me info on [topic]'), and for competitor research, trend discovery, tool comparisons, and audience sentiment analysis.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpulse\u002Fskills\u002Fpulse\u002FSKILL.md",[],[],{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":19},"01M7BERNHYGY035AR00VRT03KE","patent","Patent prior-art and landscape intelligence skill — not generic patent help. Commits to one of five sub-use-cases via forcing intake (novelty search \u002F freedom-to-operate \u002F competitive landscape \u002F acquisition diligence \u002F litigation prior-art) before any search runs. Searches Google Patents, Espacenet, USPTO, and optionally Lens.org for citation-graph signals. Output is an editable Word document (.docx) with verdict, ranked closest art (claim-text extracted), CPC-class-aware landscape, family-resolved hits, geographic coverage, FTO flags where applicable, strategy recommendations, and full audit log. Use when the user asks for patent searching or analysis (e.g., 'prior art search for [invention]', 'freedom to operate analysis for [product]'). Produces search signal, not legal advice — always recommends consulting a patent attorney before filing or licensing decisions. Trademark, copyright, and trade-secret questions are out of scope.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpatent\u002Fskills\u002Fpatent\u002FSKILL.md",[],[],{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":19},"01M7BERCK1EAKTWW7R436WAR0J","notebooklm","Browser automation skill for controlling Google's NotebookLM. Use when the user wants anything done in NotebookLM (e.g., 'open NotebookLM', 'check my [name] notebook', 'ask my notebook about X', 'add [source] to NotebookLM', 'generate a Video Overview from my notebook', 'use NotebookLM Studio'). Handles reading and querying notebooks, adding sources (URLs, text, files, YouTube links, synthesized content), generating Studio outputs (Audio\u002FVideo Overviews, Mind Maps, Reports incl. Briefing Doc\u002FStudy Guide\u002FFAQ, Flashcards, Quiz, slide decks, infographics — discover the exact set from the live Studio panel; the UI evolves fast), and creating new notebooks. Requires browser automation environment — fails gracefully when unavailable.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fnotebooklm\u002Fskills\u002Fnotebooklm\u002FSKILL.md",[],[],{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":19},"01M7BEQZAZAQRTXFJRY7RHV3TY","litreview","Academic literature orientation skill that searches papers via free keyless APIs (PubMed E-utilities + OpenAlex) by default — with the Consensus MCP as an optional enhancement lane when connected — builds a strategic search plan using PICO (default) or SPIDER \u002F Decomposition \u002F hybrid as fallbacks, and synthesizes findings into a formatted Word (.docx) research guide. Grill-me intake (research question specificity + framework hint + tentative depth) before the recon search; a second forcing checkpoint after Phase 2 confirms framework + sub-areas + depth before searches consume budget. Configurable depth (5\u002F10\u002F20 queries) controls coverage vs. speed. Output is a 'launching pad' — an orientation guide that lets a researcher dive in confidently, not a finished review. Use when the user starts literature-oriented research (e.g., 'litreview on [topic]', 'literature review on [topic]', 'I'm starting a literature review on X', 'I'm writing a paper on X', 'help me research X', 'I'm doing research on X', 'can you help me research X'). Do NOT use for single one-off paper searches wanting a quick list — that's a plain PubMed\u002FOpenAlex (or Consensus) query.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Flitreview\u002Fskills\u002Flitreview\u002FSKILL.md",[],[],{"skillNo":150,"name":151,"nameZh":6,"description":152,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":117,"licenseFileUrl":6,"sourceHtmlUrl":153,"categories":154,"keywords":155,"publishedAt":19},"01M7BEQKJ45K31QK5VRAQSVJCJ","grants","NIH grant research skill for clinical researchers. Grill-me intake (research idea + career stage + preliminary data + environment + submission posture + known institute targets) locks down the funding strategy before any search runs. Runs a 5-facet Consensus positioning analysis (with draft Significance\u002FInnovation language), maps the research to the right NIH institutes and study sections via RePORTER, finds NOSIs and funded overlap, and produces an editable Word document (.docx) with budget\u002Fscope-aware mechanism recommendations, submission timelines, and a mandatory program officer recommendation. Use when the user asks about research funding or makes any grant-related request (e.g., 'grants for [topic]', 'find grants for my research idea', 'what grants match my research', 'help me find NIH funding', 'grant opportunities for my research'). NIH-only scope — non-NIH funders (PCORI, DOD CDMRP, VA, foundations) are out of scope and flagged at intake.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fgrants\u002Fskills\u002Fgrants\u002FSKILL.md",[],[]]