[ aws . secretsmanager ]

delete-secret

Description

Deletes a secret and all of its versions. You can specify a recovery window during which you can restore the secret. The minimum recovery window is 7 days. The default recovery window is 30 days. Secrets Manager attaches a DeletionDate stamp to the secret that specifies the end of the recovery window. At the end of the recovery window, Secrets Manager deletes the secret permanently.

For information about deleting a secret in the console, see https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_delete-secret.html .

Secrets Manager performs the permanent secret deletion at the end of the waiting period as a background task with low priority. There is no guarantee of a specific time after the recovery window for the permanent delete to occur.

At any time before recovery window ends, you can use RestoreSecret to remove the DeletionDate and cancel the deletion of the secret.

In a secret scheduled for deletion, you cannot access the encrypted secret value. To access that information, first cancel the deletion with RestoreSecret and then retrieve the information.

Required permissions: secretsmanager:DeleteSecret . For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager .

See also: AWS API Documentation

See ‘aws help’ for descriptions of global parameters.

Synopsis

  delete-secret
--secret-id <value>
[--recovery-window-in-days <value>]
[--force-delete-without-recovery | --no-force-delete-without-recovery]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]

Options

--secret-id (string)

The ARN or name of the secret to delete.

For an ARN, we recommend that you specify a complete ARN rather than a partial ARN.

--recovery-window-in-days (long)

The number of days from 7 to 30 that Secrets Manager waits before permanently deleting the secret. You can’t use both this parameter and ForceDeleteWithoutRecovery in the same call. If you don’t use either, then Secrets Manager defaults to a 30 day recovery window.

--force-delete-without-recovery | --no-force-delete-without-recovery (boolean)

Specifies whether to delete the secret without any recovery window. You can’t use both this parameter and RecoveryWindowInDays in the same call. If you don’t use either, then Secrets Manager defaults to a 30 day recovery window.

Secrets Manager performs the actual deletion with an asynchronous background process, so there might be a short delay before the secret is permanently deleted. If you delete a secret and then immediately create a secret with the same name, use appropriate back off and retry logic.

Warning

Use this parameter with caution. This parameter causes the operation to skip the normal recovery window before the permanent deletion that Secrets Manager would normally impose with the RecoveryWindowInDays parameter. If you delete a secret with the ForceDeleteWithouRecovery parameter, then you have no opportunity to recover the secret. You lose the secret permanently.

--cli-input-json | --cli-input-yaml (string) Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. Similarly, if provided yaml-input it will print a sample input YAML that can be used with --cli-input-yaml. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See ‘aws help’ for descriptions of global parameters.

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 7

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 without a recovery window

The following delete-secret example deletes a secret without a recovery window. Yuo can’t recover this secret.

aws secretsmanager delete-secret \
    --secret-id MyTestSecret \
    ----force-delete-without-recovery

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.

Output

ARN -> (string)

The ARN of the secret.

Name -> (string)

The name of the secret.

DeletionDate -> (timestamp)

The date and time after which this secret Secrets Manager can permanently delete this secret, and it can no longer be restored. This value is the date and time of the delete request plus the number of days in RecoveryWindowInDays .