ecr.lifecycle-defaults.put

Set the default and whether it is active, preview-only or off

PUT /ecr/api/lifecycle-defaultsIAM ecr:PutLifecyclePolicyChanges stateDestructive

Organizations created before the defaults existed see them preview-only until they enable them here. The answer says what would expire across the inheriting repositories.

Request syntax

PUT /ecr/api/lifecycle-defaults
{
  "policy": "object",
  "mode": "enum"
}

Request body

  • policyRequired

    object

    The default, in ews-lifecycle/v1 only (the AWS ECR format is accepted per repository, not here): {"version": "ews-lifecycle/v1", rules (at most 50), keep, softDeleteDays 1–30}. softDeleteDays 0 is refused with 400: a default always keeps expired images restorable for at least a day

    Constraints: JSON

  • modeRequired

    enum

    active: the hourly run expires what the default selects in every inheriting repository; preview: it only reports; off: the default does nothing

    One of: active, preview, off

Response

200 with what the saved default would do now: { source, mode, policy, repositories (how many inherit the default), wouldExpire { count, bytes }, kept, byRepository (the 50 repositories with the most bytes to expire: id, name, count, bytes), images (repositoryId, repositoryName, manifestId, label, action, reason, by, sizeBytes, pushedAt, lastPulledAt; the first 5,000) and totalImages }. 400 when softDeleteDays is 0.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow ecr:PutLifecyclePolicy on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud ecr lifecycle-defaults put --policy '{}' --mode active

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_ecr_lifecycle-defaults_put.