Deleting a lifecycle policy
- In the management console
, select the folder where the registry was created. - In the list of services, select Container Registry.
- Select the registry and click the row with its name.
- Select the repository and click the row with its name.
- In the left-hand panel, click
Lifecycle. - Click
for the appropriate policy and select Delete. - In the window that opens, click Delete.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
-
Delete the policy by specifying its ID:
yc container repository lifecycle-policy delete <policy_ID>
To find out the policy ID, get a list of lifecycle policies in a repository or registry.
-
Make sure that the policy was deleted:
yc container repository lifecycle-policy list --repository-name crp2hlbs67tj********/ubuntu
Result:
+----+------+---------------+--------+---------+-------------+ | ID | NAME | REPOSITORY ID | STATUS | CREATED | DESCRIPTION | +----+------+---------------+--------+---------+-------------+ +----+------+---------------+--------+---------+-------------+
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
Open the configuration file and delete the fragment with the policy description:
Sample policy description in the Terraform configuration
resource "yandex_container_repository_lifecycle_policy" "my_lifecycle_policy" { name = "best-policy" status = "active" repository_id = "crpfvi6o4ra7********" rule { description = "rule for applying policy" untagged = true tag_regexp = ".*" retained_top = 1 expire_period = "48h" } }
-
Apply the changes:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
-
This will delete the lifecycle policy from the specified repository. You can check the deletion of the policy using the management console
yc container repository lifecycle-policy list --registry-id <registry_ID>
To delete a policy, use the Delete method for the LifecyclePolicyService resource. Specify the policy ID in the lifecycle_policy_id
parameter.
You can retrieve a list of policies using the List method for the LifecyclePolicyService resource.