mini lab : Cloud Storage : 2 (Solution)

A passionate full-stack developer from @ePlus.DEV
Search for a command to run...

A passionate full-stack developer from @ePlus.DEV
No comments yet. Be the first to comment.
Quick and practical tips to help users optimize tasks, improve skills, and solve common problems effectively across various areas like tech, lifestyle, productivity, and more.
Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary Vercel AI Gateway thêm Grok Imagine Image 2.0 Preview, đưa image gene

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary Cloudflare đang hợp nhất Workers AI và AI Gateway thành một control p

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary GitHub thay đổi hành vi của Code Quality: bật Code Quality sẽ không c

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary OpenAI thay đổi thời điểm tính phí seat mới của ChatGPT Business từ n

Overview Dataplex is an intelligent data fabric that enables organizations to centrally discover, manage, monitor, and govern their data across data lakes, data warehouses, and data marts to power ana

Labs are timed and cannot be paused. The timer starts when you click Start Lab.
The included cloud terminal is preconfigured with the gcloud SDK.
Use the terminal to execute commands and then click Check my progress to verify your work.
You are managing a Cloud Storage bucket named BUCKET_NAME. This bucket serves multiple purposes within your organization and contains a mix of active project files, archived documents, and temporary logs. To optimize storage costs, you need to implement a lifecycle management policy that automatically aligns the storage classes of these files with their access patterns.
Design a lifecycle management policy with the following objectives:
Active Project Files: Files within the /projects/active/ folder modified within the last 30 days should reside in Standard storage for fast access.
Archives: Files within /archive/ modified within the last 90 days should be moved to Nearline storage. After 180 days, they should transition to Coldline storage.
Temporary Logs: Files within /processing/temp_logs/ should be automatically deleted after 7 days.
Click Check my progress to verify the objective.
Create a lifecycle management policy
curl -LO raw.githubusercontent.com/ePlus-DEV/storage/refs/heads/main/labs/mini%20lab%20%3A%20Cloud%20Storage%20%3A%202/lab.sh
source lab.sh
Script Alternative
cat > lifecycle.json << EOF
{
"rule": [
{
"action": {
"storageClass": "NEARLINE",
"type": "SetStorageClass"
},
"condition": {
"daysSinceNoncurrentTime": 30,
"matchesPrefix": [
"/projects/active/"
]
}
},
{
"action": {
"storageClass": "NEARLINE",
"type": "SetStorageClass"
},
"condition": {
"daysSinceNoncurrentTime": 90,
"matchesPrefix": [
"/archive/"
]
}
},
{
"action": {
"storageClass": "COLDLINE",
"type": "SetStorageClass"
},
"condition": {
"daysSinceNoncurrentTime": 180,
"matchesPrefix": [
"/archive/"
]
}
},
{
"action": {
"type": "Delete"
},
"condition": {
"age": 7,
"matchesPrefix": [
"/processing/temp_logs/"
]
}
}
]
}
EOF
export PROJECT_ID=$(gcloud config get-value project)
gsutil lifecycle set lifecycle.json gs://$PROJECT_ID-bucket