A Node.js application that demonstrates how to fetch secrets from AWS Secrets Manager.
This project provides a simple API endpoint to retrieve secrets stored in AWS Secrets Manager. It's built using Node.js and Express, and uses the AWS SDK v3 to interact with AWS Secrets Manager.
- Node.js installed on your machine
- AWS account with access to Secrets Manager
- AWS credentials (Access Key and Secret Access Key)
- A secret stored in AWS Secrets Manager named "eg. secret-name"
- Clone the repository
- Install dependencies:
npm install
- Create a
.env
file with your AWS credentials:AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key
Start the server:
npm start
The server will start on port 3000 (or the port specified in your environment variables).
Retrieves secrets from AWS Secrets Manager.
Response:
- Success: Returns a message confirming secrets were retrieved
- Error: Returns a 500 status code with error message
The expected secret format in AWS Secrets Manager:
- Never commit
.env
file or AWS credentials - Use IAM roles in production environments
- Implement proper authentication before deploying to production
- Keep your dependencies updated
- Follow AWS security best practices
The application includes basic error handling for:
- AWS Secrets Manager connection issues
- Invalid secret format
- Server errors
This project is licensed under the MIT License.