0
0
GCPcloud~30 mins

Storage classes (Standard, Nearline, Coldline, Archive) in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
GCP Storage Classes Setup
📖 Scenario: You are managing files for a company on Google Cloud Platform (GCP). Different files need different storage classes based on how often they are accessed.Standard storage is for files accessed frequently. Nearline is for files accessed less than once a month. Coldline is for files accessed less than once a quarter. Archive is for files rarely accessed but must be kept for years.
🎯 Goal: Create a Google Cloud Storage bucket configuration that sets the storage class for files based on their access frequency.
📋 What You'll Learn
Create a dictionary called files with file names as keys and their access frequency in days as values.
Create a variable called storage_classes that maps access frequency ranges to GCP storage classes.
Write a function called assign_storage_class that takes the access frequency and returns the correct storage class.
Create a dictionary called file_storage that assigns each file its storage class using the function.
💡 Why This Matters
🌍 Real World
Cloud storage costs depend on how often data is accessed. Choosing the right storage class saves money and meets access needs.
💼 Career
Cloud engineers and architects must configure storage classes correctly to optimize cost and performance in cloud projects.
Progress0 / 4 steps
1
Create the files dictionary
Create a dictionary called files with these exact entries: 'report.pdf': 5, 'backup.zip': 40, 'archive.tar': 100, 'old_logs.log': 400 where the values represent access frequency in days.
GCP
Need a hint?

Use a Python dictionary with file names as keys and numbers as values.

2
Create the storage_classes mapping
Create a dictionary called storage_classes with these exact entries: 'Standard': 0, 'Nearline': 30, 'Coldline': 90, 'Archive': 365. These numbers represent the minimum days of access frequency for each storage class.
GCP
Need a hint?

Use a dictionary with storage class names as keys and minimum days as values.

3
Write the assign_storage_class function
Write a function called assign_storage_class that takes a parameter days and returns the correct storage class string based on these rules: if days is less than 30, return 'Standard'; if less than 90, return 'Nearline'; if less than 365, return 'Coldline'; otherwise return 'Archive'.
GCP
Need a hint?

Use if-elif-else statements to check the days and return the storage class.

4
Assign storage classes to files
Create a dictionary called file_storage that uses a dictionary comprehension to assign each file in files its storage class by calling assign_storage_class with the file's access frequency.
GCP
Need a hint?

Use a dictionary comprehension to map each file to its storage class.