Resource
dcloud_ecr_lifecycle_policy
A repository's lifecycle policy — the AWS ECR policy JSON, so a policy written for ECR works unchanged. Applied hourly: the images it selects are deleted. Destroying it removes the policy.
Example Usage
resource "dcloud_ecr_lifecycle_policy" "api" {
repository_id = dcloud_ecr_repository.api.id
# The AWS ECR policy format: a policy written for ECR works unchanged.
policy = jsonencode({
rules = [
{
rulePriority = 1
description = "Untagged images after 14 days"
selection = {
tagStatus = "untagged"
countType = "sinceImagePushed"
countUnit = "days"
countNumber = 14
}
action = { type = "expire" }
},
{
rulePriority = 2
description = "Keep the last 30 release builds"
selection = {
tagStatus = "tagged"
tagPatternList = ["v*"]
countType = "imageCountMoreThan"
countNumber = 30
}
action = { type = "expire" }
},
]
})
}Schema
Required
policy(String) The policy,{ rules = [...] }; usejsonencode.repository_id(String) The id of the parent resource ({id}in the path). Changing it replaces the resource.
Read-Only
id(String) The resource's id.
Import
Import is supported using the following syntax:
The terraform import command can be used, for example:
terraform import dcloud_ecr_lifecycle_policy.api <repository-id>Generated from the provider's schema.