Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the issue of Secrets Manager secrets not being rotated frequently in AWS using the AWS console, follow these steps:
  1. Open the AWS Secrets Manager console.
  2. Select the secret that needs to be rotated.
  3. Click on the “Rotation” tab.
  4. Click on the “Edit rotation” button.
  5. In the “Configure rotation” section, select the rotation frequency and the number of days to keep the previous version of the secret.
  6. Click on the “Enable rotation” checkbox.
  7. Choose the Lambda function or AWS Secrets Manager to rotate the secret.
  8. Click on the “Save changes” button.
By following these steps, the Secrets Manager secret will be automatically rotated according to the selected frequency, and the previous versions of the secret will be kept for the specified number of days.

To remediate the misconfiguration of Secrets Manager Secrets not being rotated frequently in AWS using AWS CLI, follow these steps:
  1. Open the AWS CLI on your local machine.
  2. Run the following command to list all the secrets available in the Secrets Manager service:
  1. Identify the secret that needs to be rotated frequently.
  2. Run the following command to rotate the secret:
Note: Replace <secret-id> with the ID of the secret that needs to be rotated.
  1. After running the above command, the Secrets Manager service will create a new version of the secret and update the old version with a new password or other credentials.
  2. Update the applications or services that use the secret with the new credentials.
  3. Delete the old version of the secret using the following command:
Note: Replace <secret-id> with the ID of the old version of the secret.
  1. Repeat the above steps periodically to ensure that secrets are rotated frequently. It is recommended to set up automated rotation using AWS Lambda or other automation tools.
To remediate the issue of Secrets Manager Secrets not being rotated frequently in AWS, you can use the following steps using Python:
  1. Import the Boto3 library for AWS:
  1. Create an AWS Secrets Manager client:
  1. Get a list of all secrets in AWS Secrets Manager:
  1. Loop through the list of secrets and check if each secret has been rotated within the last 30 days:
  1. If a secret has not been rotated within the last 30 days, use the rotate_secret function to rotate the secret:
  1. Add logging and error handling to the script as needed.
  2. Schedule the script to run on a regular basis (e.g. daily) using AWS Lambda or a cron job.
By following these steps, you can ensure that all secrets in AWS Secrets Manager are rotated frequently, which helps to improve the security of your AWS environment.
This requires that ROTATION_LAMBDA_ARN already exists and has the correct IAM permissions for rotation; Terraform will fail to apply if the Lambda cannot be invoked by Secrets Manager. This configuration is update-in-place and does not force replacement of the secret.Verification: terraform plan should show creation (or update) of aws_secretsmanager_secret_rotation.this with rotation_lambda_arn = "ROTATION_LAMBDA_ARN" and rotation_rules.0.automatically_after_days = 90.