Skip to main content

lifecycle_policies

Creates, updates, deletes, gets or lists a lifecycle_policies resource.

Overview

Namelifecycle_policies
TypeResource
Idaws.ecr.lifecycle_policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
last_evaluated_atstring (date-time)The time stamp of the last time that the lifecycle policy was run.
lifecycle_policy_textstringThe JSON lifecycle policy text.
registry_idstringThe registry ID associated with the request. (pattern: <code>[0-9]{12}</code>)
repository_namestringThe repository name associated with the request. (pattern: <code>[a-z0-9]+((.||__|-+)[a-z0-9]+)*(/[a-z0-9]+((.||__|-+)[a-z0-9]+))</code>)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_lifecycle_policyselectregionRetrieves the lifecycle policy for the specified repository.
put_lifecycle_policyreplaceregion, repositoryName, lifecyclePolicyTextCreates or updates the lifecycle policy for the specified repository. For more information, see Lifecycle policy template.
delete_lifecycle_policydeleteregionDeletes the lifecycle policy associated with the specified repository.
start_lifecycle_policy_previewexecregion, repositoryNameStarts a preview of a lifecycle policy for the specified repository. This allows you to see the results before associating the lifecycle policy with the repository.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Retrieves the lifecycle policy for the specified repository.

SELECT
last_evaluated_at,
lifecycle_policy_text,
registry_id,
repository_name
FROM aws.ecr.lifecycle_policies
WHERE region = '{{ region }}' -- required
;

REPLACE examples

Creates or updates the lifecycle policy for the specified repository. For more information, see Lifecycle policy template.

REPLACE aws.ecr.lifecycle_policies
SET
registryId = '{{ registryId }}',
repositoryName = '{{ repositoryName }}',
lifecyclePolicyText = '{{ lifecyclePolicyText }}'
WHERE
region = '{{ region }}' --required
AND repositoryName = '{{ repositoryName }}' --required
AND lifecyclePolicyText = '{{ lifecyclePolicyText }}' --required
RETURNING
lifecycle_policy_text,
registry_id,
repository_name;

DELETE examples

Deletes the lifecycle policy associated with the specified repository.

DELETE FROM aws.ecr.lifecycle_policies
WHERE region = '{{ region }}' --required
;

Lifecycle Methods

Starts a preview of a lifecycle policy for the specified repository. This allows you to see the results before associating the lifecycle policy with the repository.

EXEC aws.ecr.lifecycle_policies.start_lifecycle_policy_preview
@region='{{ region }}' --required
@@json=
'{
"registryId": "{{ registryId }}",
"repositoryName": "{{ repositoryName }}",
"lifecyclePolicyText": "{{ lifecyclePolicyText }}"
}'
;