Skip to content
tezvyn:
Menu

AWS Secrets Manager: Stop Hardcoding Credentials

Source: docs.aws.amazon.comMediumHow cards are made

AWS Secrets Manager is a digital vault for your app's credentials. Instead of hardcoding API keys or database passwords, your app fetches them at runtime. It's used for storing sensitive data securely, with built-in rotation and auditing.

Why it exists

Hardcoding credentials in source code or configuration files is a massive security risk. This “secret sprawl” makes credentials difficult to track, impossible to audit, and painful to rotate. Secrets Manager was created to provide a central, secure, and auditable source of truth for application secrets.

The mental model

Think of Secrets Manager as a password vault for your applications. Instead of embedding a database password in your app's configuration, you give the application an IAM role that lets it ask the vault for the password at runtime. The vault logs every request and can even change the password automatically on a schedule, without you needing to redeploy your app.

How it works

You create a secret, which is an encrypted key-value pair, in the Secrets Manager console or via API. Your application, running with an IAM role that has been granted permission, uses the AWS SDK to call the 'GetSecretValue' API endpoint. Secrets Manager validates the IAM permissions, and if authorized, returns the decrypted secret to your application over a secure TLS connection. All access is logged in AWS CloudTrail for auditing.

When to use it

Use it to store and manage credentials your applications need at runtime. This includes database connection strings, third-party API keys, or other sensitive tokens. It is especially powerful for meeting compliance requirements like PCI DSS or HIPAA, which mandate regular credential rotation and strict access control. You can also use it to securely share secrets across multiple applications or AWS accounts.

When not to use it

Secrets Manager is not for storing large binary data; use S3 for that. It's also not a replacement for a user identity service like Amazon Cognito for managing your application's end-user passwords. For non-secret configuration data, AWS AppConfig or Systems Manager Parameter Store are better-suited and more cost-effective choices. Parameter Store can store secrets, but Secrets Manager provides advanced features like automated rotation.

One canonical example

A web application on an EC2 instance needs to access an RDS database. Instead of putting the password in a config file, you store it in Secrets Manager. The EC2 instance is assigned an IAM role granting it 'GetSecretValue' permission for that specific secret. On startup, the application code fetches the credentials from Secrets Manager and uses them to connect. You then configure a 30-day automatic rotation policy, which Secrets Manager executes without any application downtime or manual intervention.

Interview question

What is the primary advantage of AWS Secrets Manager compared to AWS Systems Manager Parameter Store for storing application credentials?

  • a.Secrets Manager is designed for storing non-sensitive configuration data.
  • b.Secrets Manager offers automated rotation of stored credentials.Correct
  • c.Secrets Manager supports storing larger binary files.
  • d.Secrets Manager provides a lower cost for storing secrets.
Why?

The card explicitly states that "Parameter Store can store secrets, but Secrets Manager provides advanced features like automated rotation," making automated rotation the key advantage for credentials. Parameter Store is suggested for non-secret configuration data, not as a cheaper option for secrets.

Just read this? Test yourself on what you have been reading.

Read the original → docs.aws.amazon.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on aws — each one lists the topics its interview covers.

See open roles