CmdID / aws / aws secretsmanager
aws secretsmanager delete-secret
Deletes a secret and all of its versions. AWS CLI reference
2 examples 3 options Its page in the AWS CLI reference
Examples
Example 1: To delete a secret
The following delete-secret example deletes a secret. You can recover the secret with restore-secret until the date and time in the DeletionDate response field. To delete a secret that is replicated to other regions, first remove its replicas with remove-regions-from-replication, and then call delete-secret.
aws secretsmanager delete-secret --secret-id MyTestSecret --recovery-window-in-days 7Identify--secret-idThe ARN or name of the secret to delete.--recovery-window-in-daysThe number of days from 7 to 30 that Secrets Manager waits before permanently deleting the secret.Its output
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestSecret-a1b2c3",
"Name": "MyTestSecret",
"DeletionDate": 1524085349.095
}For more information, see Delete a secret in the Secrets Manager User Guide.
Example 2: To delete a secret immediately
The following delete-secret example deletes a secret immediately without a recovery window. You can't recover this secret.
aws secretsmanager delete-secret --secret-id MyTestSecret --force-delete-without-recoveryIdentify--secret-idThe ARN or name of the secret to delete.--force-delete-without-recoverySpecifies whether to delete the secret without any recovery window.Its output
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestSecret-a1b2c3",
"Name": "MyTestSecret",
"DeletionDate": 1508750180.309
}For more information, see Delete a secret in the Secrets Manager User Guide.
Options
--force-delete-without-recoverySpecifies whether to delete the secret without any recovery window.--recovery-window-in-daysThe number of days from 7 to 30 that Secrets Manager waits before permanently deleting the secret.--secret-idThe ARN or name of the secret to delete.