AWS Secrets Manager is a service that helps you protect access to your applications, services, and IT resources. It enables you to easily manage, retrieve, and rotate database credentials, application credentials, OAuth tokens, API keys, and other secrets throughout their lifecycles. Many AWS services can store and use secrets managed by Secrets Manager.
Using Secrets Manager significantly improves your security posture. Instead of hardcoding sensitive credentials in your application’s source code, you store them securely in Secrets Manager. This practice helps prevent credentials from being compromised if someone inspects your application or its components. Your application can then make a runtime call to the Secrets Manager service to retrieve these credentials dynamically when needed.
In this workshop, we will create a secret containing our database’s connection details (like the endpoint and credentials). We’ll use this secret for two main purposes:
1. Wait for database availability: Ensure your RDS database shows “Available” status. In the RDS Dashboard, click on your fcj-db database instance.
2. Copy the database endpoint:
3. Navigate to AWS Secrets Manager:
4. Click Store a new secret.
5. Configure the secret type:
6. Configure the key-value pair:
DB_CONNECTION_STRING
jdbc:postgresql://<DATABASE_ENDPOINT>:5432/FCJMomentum?user=postgres&password=fcj-db-123
<DATABASE_ENDPOINT>
with your actual database endpoint from step 27. Click Next.
8. Configure the secret name:
dev/fcj/momentum
Database connection string for FCJ Momentum application
9. Scroll down and click Next.
10. Configure rotation (optional):
11. Review and create:
12. Verify creation: Confirm that the secret dev/fcj/momentum appears in your Secrets Manager console with the correct key-value pair.
Your database connection string is now securely stored in AWS Secrets Manager and ready to be used by your ECS tasks and CodeBuild projects.