All Products
Search
Document Center

Key Management Service:Manage Dynamic ECS Secrets

Last Updated:Mar 31, 2026

Secrets Manager rotates ECS instance credentials — passwords or key pairs — automatically on a schedule or on demand, so a leaked credential can be invalidated within minutes. This topic explains how to create, rotate, delete, and restore a dynamic ECS secret in the Key Management Service (KMS) console.

How it works

When you create a dynamic ECS secret, KMS uses a service-linked role to connect to your ECS instance. On each rotation, KMS generates a new credential and applies it directly to the instance, replacing the previous password or key pair. Applications that retrieve the secret from Secrets Manager always get the current, valid credential.

Prerequisites

Before you begin, make sure you have:

Create a dynamic ECS secret

Note

Select the same region as the ECS instance you want to manage. A secret can only manage instances in the same region.

  1. Log on to the KMS console.

  2. In the top navigation bar, select the region where your ECS instance is located.

  3. In the left-side navigation pane, click Secret.

  4. Click Create Secret.

  5. In the Create Secret dialog box, configure the following parameters and click Next.

    ParameterDescription
    Select TypeSelect Managed ECS secret.
    Secret nameEnter a name for the secret.
    Managed instanceSelect the ECS instance to manage.
    Managed UserEnter the name of an existing OS user on the instance, such as root (Linux) or Administrator (Windows).
    Initial secret valueSelect Password or Key pair and enter the initial value. If the value is invalid, a valid credential is generated after the first rotation.
    Secret DescriptionEnter a description.
  6. In the Configuration rotation dialog box, configure rotation settings and click Next.

    • To enable automatic rotation, select Turn on automatic rotation and set the Rotation Period.

    • To skip automatic rotation for now, select Turn off automatic rotation. Manual rotation is still available at any time.

  7. In the Review and confirm dialog box, review the configuration and click OK.

The secret appears in the secret list with Secret Type set to Managed ECS secret.

Rotate a dynamic ECS secret

If a credential is exposed, rotate it immediately to replace the compromised value.

  1. In the secret list, click the name of the ECS secret. On the secret details page, click Rotate Immediately in the upper-right corner.

  2. In the Prompt dialog box, choose how to generate the new credential:

    • Use Custom Secret on: Enter a specific new secret value.

    • Use Custom Secret off: KMS automatically generates a 32-character random password or an RSA-2048 public-private key pair.

  3. Click Confirm rotation.

  4. In the Rotation triggered message, click Close.

Delete a dynamic ECS secret

Important

Deleting a secret does not change the password or key pair already configured on the ECS instance. Confirm the secret is no longer in use before proceeding.

To protect against accidental deletion, KMS supports a recovery window of 7 to 30 days before permanent removal.

  1. In the secret list, find the secret and choose More > Plan Deletion Secret in the Actions column.

  2. In the Delete Secret dialog box, select a deletion method and click OK.

    MethodDescription
    Plan Deletion SecretSet the Delete In (7-30 days) parameter. The secret is deleted after the specified number of days. During this period, you can restore the secret to cancel deletion.
    Delete Secret ImmediatelyDeletes the secret permanently.

Restore a dynamic ECS secret

If you scheduled a dynamic ECS secret for deletion, restore it before the recovery window expires to cancel deletion. After restoration, the secret works as normal.

  1. In the secret list, find the secret and choose More > Restore Secret in the Actions column.

  2. In the Restore Secret message, click OK.