π 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.
π 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:
- If the password is about to expire (e.g., 7 days before expiry). β Sends an alert notification via SNS to the secret owner.
- 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:
-
Receive payload from Lambda #1 (secret details).
-
Invoke Lambda #2 (Rotation Engine).
-
On success, invoke Lambda #3 (Verification Lambda).
-
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:
- Delete old secret from Vault (or mark inactive).
- Generate new password using AWS Secrets Manager (
GenerateRandomPassword). - Update Vault with the new password.
- Reset password in all connected databases (PostgreSQL, MySQL, etc.) by connecting via admin accounts and issuing password reset queries.
- Encrypt and store password metadata in PostgreSQL (encrypted with AWS KMS).
- 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_Name | Rotation_Date | Expiry_Date | Status | Encrypted_Password | Rotated_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
| Component | Description |
|---|---|
| Lambda #1 | Scans Vault, detects expiring secrets, sends alerts, triggers Step Function |
| Lambda #2 | Deletes old passwords, generates new ones, updates Vault & all databases, stores metadata |
| Lambda #3 | Verifies new credentials in all systems |
| Vault (EKS) | Central secret store |
| EventBridge | Scheduler and trigger for periodic scans |
| Step Function | Orchestrates rotation and verification workflow |
| SNS | Sends alerts and rotation status |
| PostgreSQL | Stores audit metadata and encrypted password entries |
| KMS | Encrypts passwords and sensitive data |
Related Documents
MCP Integration Workflows and Orchestration Guide
title: MCP Integration Workflows and Orchestration Guide
Valet V1 β Architecture & Implementation Plan
1. [Vision & Scope](#1-vision--scope)
Writing Effective Skills
What makes a skill actually work vs. being ignored or misapplied. Based on studying production skills across Claude Code (Superpowers, Trail of Bits, Anthropic's official plugins), Codex (babysit-pr, skill-creator, curated catalog), OpenClaw (55 bundled skills, 13,700+ community), and Cursor/Cline rule systems (BMAD-METHOD, RIPER-5, steipete/agent-rules).
Spotipy Types - Implementation Plan
A standalone type stub package for spotipy using Pydantic models generated from the official Spotify Web API OpenAPI schema.