How can I configure a cloud storage bucket to hold data only for a single day

0 votes
I want to configure a bucket such that it holds data in it only for 24 hours and automatically deletes it after the time elapses. How do I do that? Can somebody help me with it?
Nov 22, 2019 in GCP by anonymous
• 19,610 points
683 views

1 answer to this question.

0 votes

Suppose you only want to keep files in a particular bucket around for just one day, then you can set up the lifecycle rule for the bucket with:

echo '{ "rule": [{ "action": {"type": "Delete"}, "condition": {"age": 1}}]}' > lifecycle_config.json
gsutil lifecycle set lifecycle_config.json gs://example-bucket

Now, any objects in your bucket older than a day will automatically get deleted from this bucket. 

You can verify the configuration you just set with the gsutil lifecycle command (other configuration commands work in a similar fashion):

gsutil lifecycle get gs://example-bucket
answered Nov 22, 2019 by Sirajul
• 59,230 points

Related Questions In GCP

0 votes
1 answer
0 votes
1 answer

How can i grant access to a GCP project for a large scale multiple users at once?

gcloud auth to service accounts is allowed. ...READ MORE

answered Oct 16, 2019 in GCP by Sirajul
• 59,230 points
1,333 views
0 votes
1 answer

GCP Error: 403: Access Denied

Check that your credentials are correct. For ...READ MORE

answered Oct 9, 2019 in GCP by Sirajul
• 59,230 points
3,984 views
0 votes
1 answer

Permissions issue with Google Cloud Storage Bucket.

You can regain access to the object by assigning an applicable role, like roles/storage.objectAdmin, to ...READ MORE

answered Oct 10, 2019 in GCP by Sirajul
• 59,230 points
4,916 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP