Expire old objects with an S3 lifecycle rule

Delete objects under logs/ after 30 days automatically to save on storage.

aws --endpoint-url=https://storage.yandexcloud.net s3api put-bucket-lifecycle-configuration --bucket <name> --lifecycle-configuration '{"Rules":[{"ID":"expire-logs","Status":"Enabled","Filter":{"Prefix":"logs/"},"Expiration":{"Days":30}}]}'

tool
yc32 commands
tags
ycclouddisk

More yc commands

  • yc container registry create --name <name> && yc container registry configure-docker

    Create a Container Registry and set yc as Docker's credential helper, so no docker login is needed.

  • docker tag <name>:<id> cr.yandex/$(yc container registry get --name <name> --format json | jq -r .id)/<name>:<id> && docker push cr.yandex/$(yc container registry get --name <name> --format json | jq -r .id)/<name>:<id>

    Tag the image with the registry ID looked up on the fly, then push it, so cr.yandex/<reg-id> is not hardcoded.

  • yc container repository list --format json | jq -r '.[].name' | while read r; do yc container image list --repository-name "$r" --format json | jq -r '.[] | "\(.name):\(.tags[]? // "<none>")"'; done

    List every tag in every repository; handy before a registry cleanup.

  • yc serverless container create --name <name>; yc serverless container revision deploy --container-name <name> --image cr.yandex/<id>/<name>:<id> --cores 1 --memory 512M --service-account-id <id> --concurrency 4

    Deploy a new revision from a Container Registry image; --concurrency limits parallel requests per instance.

  • yc logging read --group-name <name> --since 1h --levels ERROR,WARN --format json | jq -r '.[] | "\(.timestamp) \(.level) \(.message)"'

    Read Cloud Logging entries with ERROR and WARN levels only; --since also takes values like 30m.

all 32 yc commands