📖 Scenario: You are working as a cloud administrator for a small company that wants to keep its data safe on Google Cloud Platform (GCP). Your job is to set up basic security controls to protect the company's cloud resources from unauthorized access.
🎯 Goal: Build a simple GCP project configuration that includes a secure storage bucket with restricted access and a firewall rule that blocks all incoming traffic except from a trusted IP address.
📋 What You'll Learn
Create a GCP storage bucket named secure-data-bucket
Create a variable called trusted_ip with the value 203.0.113.5/32
Create a firewall rule named allow-trusted-ip that allows incoming TCP traffic on port 22 only from trusted_ip
Set the storage bucket's access control to private so only authorized users can access it
💡 Why This Matters
🌍 Real World
Companies use cloud security controls like storage bucket permissions and firewall rules to protect sensitive data and limit network access to trusted sources.
💼 Career
Cloud administrators and security engineers regularly configure access controls and firewall rules to safeguard cloud infrastructure and comply with security policies.
Progress0 / 4 steps
1
Create a secure storage bucket
Create a GCP storage bucket named secure-data-bucket with private access control.
GCP
Hint
Use google_storage_bucket resource with uniform_bucket_level_access = true to make the bucket private.
2
Add a trusted IP variable
Create a variable called trusted_ip and set it to the string "203.0.113.5/32".
GCP
Hint
Define a Terraform variable named trusted_ip with the exact default value.
3
Create a firewall rule to allow trusted IP
Create a firewall rule resource named allow-trusted-ip that allows incoming TCP traffic on port 22 only from the IP address stored in the variable trusted_ip.
GCP
Hint
Use google_compute_firewall resource with allow block and source_ranges set to var.trusted_ip.
4
Finalize bucket access control
Ensure the storage bucket secure-data-bucket has uniform_bucket_level_access set to true to enforce private access.
GCP
Hint
Make sure the bucket has uniform_bucket_level_access = true to keep it private.
Practice
(1/5)
1. Why is security important in Google Cloud Platform (GCP)?
easy
A. To protect data and services from unauthorized access
B. To make the cloud run faster
C. To reduce the cost of cloud services
D. To increase the number of users automatically
Solution
Step 1: Understand the purpose of security in cloud
Security is designed to keep data and services safe from unauthorized users or attacks.
Step 2: Identify the correct reason for security in GCP
Among the options, protecting data and services from unauthorized access matches the purpose of security best.
Final Answer:
To protect data and services from unauthorized access -> Option A
Quick Check:
Security purpose = Protect data and services [OK]
Hint: Security is about protection, not speed or cost [OK]
Common Mistakes:
Confusing security with performance improvements
Thinking security reduces costs directly
Assuming security increases user numbers automatically
2. Which of the following is the correct way to grant a user access in GCP using IAM?
easy
A. Share the project ID publicly
B. Assign a role to the user with specific permissions
C. Give the user your personal password
D. Disable all security settings temporarily
Solution
Step 1: Review IAM access control method
IAM grants access by assigning roles with permissions to users or groups.
Step 2: Identify the correct method among options
Assigning a role with specific permissions is the proper and secure way to grant access.
Final Answer:
Assign a role to the user with specific permissions -> Option B
Quick Check:
IAM access = Role assignment [OK]
Hint: Use roles, never share passwords or disable security [OK]
Common Mistakes:
Sharing personal passwords instead of using IAM
Making project info public accidentally
Turning off security settings to fix access
3. Consider this code snippet that sets an IAM policy in GCP:
<pre>policy = {
"bindings": [
{
"role": "roles/storage.objectViewer",
"members": ["user:alice@example.com"]
}
]
}
What does this policy do?
medium
A. Grants Alice admin rights on the project
B. Allows Alice to edit objects in Cloud Storage
C. Denies Alice any access to Cloud Storage
D. Allows Alice to view objects in Cloud Storage
Solution
Step 1: Analyze the IAM role in the policy
The role "roles/storage.objectViewer" allows read-only access to storage objects.
Step 2: Understand the member assignment
The member "user:alice@example.com" is assigned this role, so Alice can view objects.
Final Answer:
Allows Alice to view objects in Cloud Storage -> Option D