Security
python
Intermediate
Secrets Rotation Script
Rotate an AWS Secrets Manager secret and update the consuming service automatically.
python
import boto3, secrets, string
client = boto3.client('secretsmanager')
def rotate_secret(secret_id: str):
alphabet = string.ascii_letters + string.digits + '!@#'
new_value = ''.join(secrets.choice(alphabet) for _ in range(32))
client.put_secret_value(SecretId=secret_id, SecretString=new_value)
print(f'Rotated {secret_id}')
Prerequisites
- boto3
- AWS Secrets Manager
Pro Tips
- → Use Lambda + EventBridge for scheduled rotation.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- python
- Level
- Intermediate
- Read time
- 4 min
- Published
- Feb 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
TOTP Two-Factor Auth
Generate and verify time-based one-time passwords (TOTP) compatible with Google Authenticator.
python
·
Advanced
Express CSRF Protection with Double Submit
Implement double-submit CSRF protection in Express without server-side session storage.
javascript
·
Intermediate
ClamAV Malware Scanner Cron
Run ClamAV on upload directory and quarantine infected files automatically.
bash
·
Advanced