Introduction
Google Cloud Storage is a scalable, fully-managed, and highly durable object storage service. It allows you to store and retrieve any amount of data at any time. This module will cover the basics of Cloud Storage, including how to create and manage storage buckets, upload and download objects, and configure access controls.
Key Concepts
- Buckets: Containers for storing objects. Each bucket has a globally unique name.
- Objects: The individual pieces of data that you store in Cloud Storage. Objects can be any type of file.
- Access Control: Mechanisms to control who can access your data and what they can do with it.
- Storage Classes: Different classes for different use cases, such as Standard, Nearline, Coldline, and Archive.
Setting Up Cloud Storage
Creating a Bucket
-
Navigate to Cloud Storage:
- Go to the GCP Console.
- Select "Storage" from the left-hand menu.
-
Create a New Bucket:
- Click on "Create bucket".
- Enter a unique name for your bucket.
- Choose a location type (region, dual-region, or multi-region).
- Select a storage class (Standard, Nearline, Coldline, Archive).
- Configure access control (Uniform or Fine-grained).
- Click "Create".
Example: Creating a Bucket Using the gcloud Command-Line Tool
# Create a bucket named "my-bucket" in the US multi-region with Standard storage class gcloud storage buckets create gs://my-bucket --location=US --storage-class=STANDARD
Uploading Objects
-
Using the Console:
- Navigate to your bucket.
- Click "Upload files" or "Upload folder".
- Select the files or folder you want to upload.
-
Using the gcloud Command-Line Tool:
Downloading Objects
-
Using the Console:
- Navigate to your bucket.
- Click on the object you want to download.
- Click "Download".
-
Using the gcloud Command-Line Tool:
Access Control
Uniform vs. Fine-Grained Access Control
- Uniform: Applies the same access control to all objects in the bucket.
- Fine-Grained: Allows you to set different access controls for individual objects.
Setting Access Control
-
Using the Console:
- Navigate to your bucket.
- Click on "Permissions".
- Add members and set their roles (e.g., Storage Object Viewer, Storage Object Admin).
-
Using the gcloud Command-Line Tool:
# Grant read access to all users for a specific object gcloud storage objects add-iam-policy-binding gs://my-bucket/my-file.txt --member=allUsers --role=roles/storage.objectViewer
Storage Classes
Storage Class | Use Case | Availability | Durability | Cost |
---|---|---|---|---|
Standard | Frequently accessed data | High | 99.999999999% | High |
Nearline | Infrequently accessed data (once a month) | High | 99.999999999% | Lower than Standard |
Coldline | Rarely accessed data (once a year) | High | 99.999999999% | Lower than Nearline |
Archive | Long-term storage | High | 99.999999999% | Lowest |
Practical Exercise
Exercise: Create a Bucket and Upload a File
- Objective: Create a new bucket and upload a file to it.
- Steps:
- Create a bucket named "my-exercise-bucket" in the US region with Standard storage class.
- Upload a file named "exercise-file.txt" to the bucket.
Solution
- Create the Bucket:
- Upload the File:
Common Mistakes and Tips
- Bucket Naming: Ensure your bucket name is globally unique and follows the naming conventions.
- Access Control: Be cautious with public access settings to avoid exposing sensitive data.
- Storage Class Selection: Choose the appropriate storage class based on your data access patterns to optimize costs.
Conclusion
In this module, you learned the basics of Google Cloud Storage, including how to create and manage buckets, upload and download objects, and configure access controls. You also explored different storage classes and their use cases. With this knowledge, you can efficiently store and manage your data on Google Cloud Platform.
Google Cloud Platform (GCP) Course
Module 1: Introduction to Google Cloud Platform
- What is Google Cloud Platform?
- Setting Up Your GCP Account
- GCP Console Overview
- Understanding Projects and Billing
Module 2: Core GCP Services
Module 3: Networking and Security
Module 4: Data and Analytics
Module 5: Machine Learning and AI
Module 6: DevOps and Monitoring
- Cloud Build
- Cloud Source Repositories
- Cloud Functions
- Stackdriver Monitoring
- Cloud Deployment Manager
Module 7: Advanced GCP Topics
- Hybrid and Multi-Cloud with Anthos
- Serverless Computing with Cloud Run
- Advanced Networking
- Security Best Practices
- Cost Management and Optimization