How to Find and Delete Unused AWS Secrets
If you have unused AWS secrets in your account, you are paying a monthly charge for no reason. In this guide, we'll show you how to detect and remove unused AWS secrets to lower your cloud costs.
If you have unused AWS secrets in your account, you are paying a monthly charge for no reason. In this guide, we'll show you how to detect and remove unused AWS secrets to lower your cloud costs.
The AWS Secrets Manager makes it easy to create and store secrets, so you can reference them via API call instead of including them in your actual code.
There is still some basic maintenance you should do to make sure you are lowering your security risk and cloud costs. Each secret in AWS costs $0.40/month, including the same rate per replica. If you have unused secrets, they could be a waste of money and a security liability. It’s better to delete them when you are sure they are not being used.
In this guide, we’ll show you how you can find unused AWS secrets and delete them.
You can use either the AWS console or the AWS CLI for this task.
To find all secrets in your account using AWS CLI, you can run this list-secrets command:
Here’s an example output:
You can then check when a secret was last retrieved by running this describe-secret command:
You’ll see an output that looks like this:
The "LastAccessedDate" field will answer how long it’s been since the secret was retrieved. You can use a timestamp converter like this one to see the actual date.
To do so, you can use AWS Console or AWS CLI as follows:
If you need to restore a secret during the recovery window, you can click the Preferences icon next to the list of secrets and apply Show disabled secrets. Then, select the secret you want to recover and click Cancel deletion in the Secret details section.
These replica secrets will be removed immediately.
To delete a secret with a preset recovery window, you can include the --recovery-window-in-days flag with a certain value:
You can also choice to delete a secret immediately:
Deleting a secret immediately results in permanent deletion. If you set up a recovery window instead, then you can still restore the secret during that window.
You can restore a secret with this command:
Now, you know how to clean up unused secrets across your AWS regions.
The steps to find unused secrets and remove them are not hard, but when you are operating in multiple regions and you want to conduct this check regularly, it becomes a manual, time-consuming chore.
Instead of running this ad hoc and doing it yourself, you can use automation to run checks like this and notify you when there are secrets that are eligible for deletion due to inactivity.
With Blink, you can run this automation to survey your AWS account across regions and send a report of unused secrets to a designated email address.
When this automation runs, it executes the following actions:
You can import this automation from the Blink library and customize it however you like. For example, you could send a weekly Slack notification with a report on AWS secrets that haven’t been used in 90 days, with the ability to approve their deletion.
In Blink, you can also create automations from scratch to meet your team’s unique needs using the hundreds of drag-and-drop actions available from a wide range of tools.
Get started with Blink today to see how easy automation can be.
Blink is an automation copilot that enables you to create full ready-to-run workflows between tools – just type a prompt.