Back to .md Directory

πŸ” Automated Password Rotation System – Architecture & Design Document

This project aims to automate **password rotation** across the organization’s AWS and database ecosystem, ensuring compliance with internal security policies and reducing manual operational overhead.

May 2, 2026
0 downloads
0 views
ai rag automation
View source

πŸ” Automated Password Rotation System – Architecture & Design Document


πŸ“˜ 1. Project Overview

This project aims to automate password rotation across the organization’s AWS and database ecosystem, ensuring compliance with internal security policies and reducing manual operational overhead. Whenever a service (like DynamoDB, EC2, or application database) is created, credentials are stored securely in Vault (running inside EKS) and synchronized with AWS Secrets Manager.

The goal of this system is to automatically detect expiring passwords, rotate them securely, update all dependent systems, and notify relevant users β€” using a combination of AWS Lambda, AWS Step Functions, EventBridge, SNS, and KMS.


🎯 2. Scope

The automation covers:

  • Detection of secrets nearing expiration (Vault β†’ Scanner Lambda).
  • Automatic rotation of expired secrets (Secrets Manager β†’ Rotation Lambda).
  • Update of new passwords across all target systems (databases, apps, etc.).
  • Verification of rotated credentials (Verification Lambda).
  • Centralized orchestration and logging using Step Functions.
  • Notifications and audit via SNS.
  • Secure storage and encryption of credentials using KMS and Vault.

🧩 3. High-Level Architecture

          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚       EventBridge Rule       β”‚
          β”‚  (Triggers daily/weekly scan)β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
                         β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚ Lambda #1: Scannerβ”‚
                 β”‚ - Scans Vault for β”‚
                 β”‚   expiring secretsβ”‚
                 β”‚ - Sends alert or  β”‚
                 β”‚   triggers StepFn β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ AWS Step Function         β”‚
                β”‚ - Orchestrates rotation   β”‚
                β”‚ - Calls Lambda #2 β†’ #3    β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β–Ό                                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Lambda #2:     β”‚                         β”‚Lambda #3:      β”‚
β”‚Rotation Engineβ”‚                         β”‚Verification    β”‚
β”‚- Delete old    β”‚                         β”‚- Verify rotatedβ”‚
β”‚  Vault secret  β”‚                         β”‚  credentials   β”‚
β”‚- Generate new  β”‚                         β”‚  in all systemsβ”‚
β”‚  password (SM) β”‚                         β”‚- Return status β”‚
β”‚- Update Vault  β”‚                         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚- Update DBs    β”‚                                β”‚
β”‚- Store metadataβ”‚                                β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β”‚
       β–Ό                                          β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚     SNS Notifications (Success/Fail)  β”‚
        β”‚     PostgreSQL Audit Logs             β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧠 4. Component-Level Description

🟩 1. EventBridge

EventBridge acts as the scheduler and event trigger for the entire rotation process. It triggers Lambda #1 (Scanner Lambda) periodically β€” typically once every 24 hours or based on organizational policy. It ensures no manual intervention is required for initiating the password checks.

Responsibilities:

  • Schedule recurring runs.
  • Trigger Lambda #1 based on time-based rules.
  • Ensure reliable event delivery to Lambda.

🟦 2. Lambda #1 β€” Scanner Lambda

This Lambda is the entry point of the workflow. It connects to the Vault running in EKS and scans all secrets stored within, checking two main conditions:

  1. If the password is about to expire (e.g., 7 days before expiry). β†’ Sends an alert notification via SNS to the secret owner.
  2. If the password has reached its expiry date. β†’ Triggers the Step Function to begin the automated rotation process.

Responsibilities:

  • Authenticate to Vault using AppRole or service account.
  • Retrieve secret metadata (name, path, creation/expiry date).
  • Compare expiry dates.
  • Send SNS alerts or trigger Step Function accordingly.
  • Log scan results to CloudWatch.

🟨 3. AWS Step Function

Step Function acts as the orchestration layer for the password rotation workflow. It defines and controls the sequence of Lambda executions and failure handling.

Flow:

  1. Receive payload from Lambda #1 (secret details).

  2. Invoke Lambda #2 (Rotation Engine).

  3. On success, invoke Lambda #3 (Verification Lambda).

  4. Based on verification output:

    • Send success notification (password rotation successful).
    • Send failure notification (rotation/verification failed).

Responsibilities:

  • Manage the rotation workflow.
  • Provide retry, timeout, and rollback logic.
  • Maintain full execution logs and history.

🟧 4. Lambda #2 β€” Rotation Engine

This is the core Lambda function responsible for executing the rotation itself. It handles the full lifecycle of the secret β€” from deletion of the old password to propagation of the new one across all systems.

Responsibilities:

  1. Delete old secret from Vault (or mark inactive).
  2. Generate new password using AWS Secrets Manager (GenerateRandomPassword).
  3. Update Vault with the new password.
  4. Reset password in all connected databases (PostgreSQL, MySQL, etc.) by connecting via admin accounts and issuing password reset queries.
  5. Encrypt and store password metadata in PostgreSQL (encrypted with AWS KMS).
  6. Return success/failure status to Step Function.

Security Considerations:

  • Uses AWS KMS to encrypt credentials before storing.
  • Uses least-privileged IAM roles for Vault and database access.
  • Logs all rotation actions for auditing.

πŸŸͺ 5. Lambda #3 β€” Verification Lambda

This Lambda ensures the new credentials are valid and functional. It runs immediately after Lambda #2 (via Step Function) and tests the updated credentials against all systems that were updated.

Responsibilities:

  • Retrieve new password from Vault.
  • Connect to each target database/system using new credentials.
  • Perform a simple query or authentication test.
  • Return consolidated result to Step Function (Success or Failure).
  • Write verification logs to CloudWatch and PostgreSQL.

If verification fails:

  • Step Function sends a β€œRotation Failed” SNS alert.
  • Optionally trigger a rollback or manual review.

🟫 6. Vault (Running in EKS)

Vault serves as the central credential store and is already integrated with organizational applications. It holds credentials for all AWS and non-AWS services.

Responsibilities:

  • Store service credentials securely.
  • Provide versioning and metadata (creation, expiry).
  • Allow read/write/delete operations via authenticated Lambdas.
  • Act as the source of truth for all service passwords.

Integration Notes:

  • Lambdas authenticate to Vault using AppRole or Kubernetes service accounts.
  • Vault policies restrict access to only required secrets.

πŸŸ₯ 7. Databases (PostgreSQL, MySQL, etc.)

Each target database holds user credentials that are rotated as part of this automation. These databases are updated by Lambda #2 using an admin or rotation-specific role.

Responsibilities:

  • Accept password reset commands from Lambda #2.
  • Maintain audit logs of user credential changes.
  • Reflect new credentials for continued service access.

🟧 8. SNS (Simple Notification Service)

SNS acts as the notification and alerting mechanism across the system. It is used by Lambda #1, Lambda #2, and Step Function for various alerts.

Notification Types:

  • Warning Alert: Secret about to expire (from Lambda #1).
  • Success Alert: Password rotated and verified successfully (from Step Function).
  • Failure Alert: Rotation or verification failed (from Step Function).

Notifications can be configured to send emails, Slack messages, or PagerDuty alerts to the relevant team or service owner.


🟨 9. PostgreSQL (Audit Database)

This database serves as the audit and metadata store for all password rotation activities. It does not store raw passwords β€” only encrypted values and metadata.

Responsibilities:

  • Store encrypted password blobs (via KMS).
  • Store rotation history, timestamps, and version info.
  • Enable reporting and compliance checks.

Table Example:

Secret_NameRotation_DateExpiry_DateStatusEncrypted_PasswordRotated_By

🟦 10. AWS KMS (Key Management Service)

KMS provides encryption and decryption services for sensitive data such as passwords. It is used within Lambda #2 before writing credentials to PostgreSQL and optionally before updating Vault.

Responsibilities:

  • Encrypt/decrypt sensitive data.
  • Manage rotation keys for encryption.
  • Enforce access control using KMS key policies.

βš™οΈ 5. Security Controls

  • IAM Roles: Each Lambda uses a unique, least-privileged role.
  • Vault AppRole: Secure authentication mechanism for Vault.
  • KMS Encryption: Used for encrypting passwords before storage.
  • CloudWatch Logs: Every Lambda execution is logged for auditing.
  • SNS Alerts: Immediate visibility for failures or anomalies.
  • Step Function History: Centralized execution trace for compliance.

🧩 6. Future Enhancements

  • Add rollback Lambda to revert to last known good password in case of verification failure.
  • Integrate with Slack or ServiceNow for incident creation.
  • Build dashboard for rotation status monitoring.
  • Integrate AWS Config for compliance monitoring.

βœ… 7. Summary

ComponentDescription
Lambda #1Scans Vault, detects expiring secrets, sends alerts, triggers Step Function
Lambda #2Deletes old passwords, generates new ones, updates Vault & all databases, stores metadata
Lambda #3Verifies new credentials in all systems
Vault (EKS)Central secret store
EventBridgeScheduler and trigger for periodic scans
Step FunctionOrchestrates rotation and verification workflow
SNSSends alerts and rotation status
PostgreSQLStores audit metadata and encrypted password entries
KMSEncrypts passwords and sensitive data

Related Documents