Standing Up an Amazon Aurora Database with an Automatically Rotated Password Using AWS Secrets Manag
Learning Objectives
Successfully complete this lab by achieving the following learning objectives.
Verify MySQL Client Installation
Connect to the
DatabaseClient
EC2 instance using Session ManagerVerify the MySQL client is installed:
If not installed, install it:
Create MySQL-compatible Amazon Aurora Database
Create a new Amazon Aurora MySQL-compatible database
Use the standard create option
Leave the engine version as the default
Select a
Dev/Test
templateUse
employees-database
as the DB cluster identifierUse
admin
as the master usernameEnable using AWS Secrets Manager to manage the master credentials
Use the default KMS key for encryption of the password (aws/secretsmanager)
Use an Aurora Standard configuration option
Select a
db.t3.medium
burstable class instance typeDo not create an Aurora replica
Enable connectivity to
Connect to an EC2 compute resource
Select the
DatabaseClient
EC2 instanceCreate a new VPC Security Group called
database-sg
Create an initial database named
employees_db
Connect to the Aurora Database and Import Data
Find and select your RDS credentials secret from the AWS Secrets Manager service (Example: rds!cluster-a5fd421e-64e5-4580-be8e-006919539758)
Refresh the page to ensure you are using the latest version of the secret. RDS will run an initial rotation once the RDS instance is created!
Retrieve the secret value from the secret and keep the tab open
Go back to your
DatabaseClient
EC2 connectionChange the directory to the ssm-user home and
cat
the file to ensure the data was written.Confirm the status of the Amazon Aurora database writer endpoint is Available and copy the endpoint name.
In Session Manager, connect to your RDS instance writer endpoint using the below command. Make sure you change the value for host to the writer endpoint name. The user and password are your Secrets Manager secret that you set in previous steps.
Once prompted for the password, use the value retrieved from AWS Secrets Manager. (If you get an error, refresh the page, copy the latest secret value, rerun the command, and enter the new value for the password prompt).
You should now see the MySQL prompt!
Verify the data was imported by viewing data in the table:
Trigger Credential Rotation
Quit your RDS connection within the EC2 Session Manager terminal and go back to the ssm-user home directory
Within the AWS Secrets Manager service (console or API/CLI), trigger an immediate rotation of the RDS credential secret
Ensure the version status has changed before moving on
Test Connection with New Credentials
After the rotation is completed in AWS Secrets Manager navigate back to your EC2 Session Manager connection
Attempt to connect to RDS using the same credentials from before (This should fail now)
Within AWS Secrets Manager, retrieve the update secret value for the RDS credentials
Re-connect to RDS using the new password value for your Master Username
Last updated
Was this helpful?