This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lambda_handler(event, context): | |
# Current Secret via SSM | |
current_secret = get_current_secret('/rds/PASSWORD') | |
# Connect to RDS using current secret | |
conn = get_connection(current_secret) | |
# Generates new random secret | |
new_secret = generate_secret() | |
# Connects to RDS and rotate secret | |
rotate_secret(conn, new_secret, current_secret) | |
# IMPORT! checks if the new secret is valid before update any SSM parameter |