Table Of Contents


User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . ecr ]



Retrieves the results of the specified lifecycle policy preview request.

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.


[--registry-id <value>]
--repository-name <value>
[--image-ids <value>]
[--next-token <value>]
[--max-results <value>]
[--filter <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]


--registry-id (string)

The AWS account ID associated with the registry that contains the repository. If you do not specify a registry, the default registry is assumed.

--repository-name (string)

The name of the repository with the policy to retrieve.

--image-ids (list)

The list of imageIDs to be included.

Shorthand Syntax:

imageDigest=string,imageTag=string ...

JSON Syntax:

    "imageDigest": "string",
    "imageTag": "string"

--next-token (string)

The nextToken value returned from a previous paginated GetLifecyclePolicyPreviewRequest request where maxResults was used and theresults exceeded the value of that parameter. Pagination continues from the end of theprevious results that returned the nextToken value. This value is null when there are no more results to return.

--max-results (integer)

The maximum number of repository results returned by GetLifecyclePolicyPreviewRequest inpaginated output. When this parameter is used, GetLifecyclePolicyPreviewRequest only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sendinganother GetLifecyclePolicyPreviewRequest request with the returned nextToken value. This value can be between 1 and 100. If thisparameter is not used, then GetLifecyclePolicyPreviewRequest returns up to100 results and a nextToken value, ifapplicable.

--filter (structure)

An optional parameter that filters results based on image tag status and all tags, if tagged.

Shorthand Syntax:


JSON Syntax:

  "tagStatus": "TAGGED"|"UNTAGGED"

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values.

--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. 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.


To retrieve details for a lifecycle policy preview

This example retrieves the result of a lifecycle policy preview for a repository called project-a/amazon-ecs-sample in the default registry for an account.


aws ecr get-lifecycle-policy --repository-name "project-a/amazon-ecs-sample"


    "registryId": "<aws_account_id>",
    "repositoryName": "project-a/amazon-ecs-sample",
    "lifecyclePolicyText": "{\n    \"rules\": [\n        {\n            \"rulePriority\": 1,\n            \"description\": \"Expire images older than 14 days\",\n            \"selection\": {\n                \"tagStatus\": \"untagged\",\n                \"countType\": \"sinceImagePushed\",\n                \"countUnit\": \"days\",\n                \"countNumber\": 14\n            },\n            \"action\": {\n                \"type\": \"expire\"\n            }\n        }\n    ]\n}\n",
    "status": "COMPLETE",
    "previewResults": [],
    "summary": {
        "expiringImageTotalCount": 0


registryId -> (string)

The registry ID associated with the request.

repositoryName -> (string)

The repository name associated with the request.

lifecyclePolicyText -> (string)

The JSON repository policy text.

status -> (string)

The status of the lifecycle policy preview request.

nextToken -> (string)

The nextToken value to include in a future get-lifecycle-policy-preview request. When the results of a get-lifecycle-policy-preview request exceed maxResults , this value can be used to retrieve the next page of results. This value is null when there are no more results to return.

previewResults -> (list)

The results of the lifecycle policy preview request.


The result of the lifecycle policy preview.

imageTags -> (list)

The list of tags associated with this image.


imageDigest -> (string)

The sha256 digest of the image manifest.

imagePushedAt -> (timestamp)

The date and time, expressed in standard JavaScript date format, at which the current image was pushed to the repository.

action -> (structure)

The type of action to be taken.

type -> (string)

The type of action to be taken.

appliedRulePriority -> (integer)

The priority of the applied rule.

summary -> (structure)

The list of images that is returned as a result of the action.

expiringImageTotalCount -> (integer)

The number of expiring images.