Day 3 of 5
⏱ ~60 minutes
Google Cloud in 5 Days — Day 3

Storage: GCS and Cloud SQL

Create Cloud Storage buckets, upload and serve files, use signed URLs for private access, and provision a Cloud SQL instance.

Cloud Storage Buckets

gsutil commands
# Create a bucket (name must be globally unique)
gsutil mb gs://my-unique-bucket-name

# Upload files
gsutil cp file.txt gs://my-bucket/
gsutil cp -r ./folder gs://my-bucket/folder/

# List bucket contents
gsutil ls gs://my-bucket/

# Make a file public
gsutil acl ch -u AllUsers:R gs://my-bucket/file.txt

# Make entire bucket public (for static sites)
gsutil iam ch allUsers:objectViewer gs://my-bucket
Python SDK
from google.cloud import storage

client = storage.Client()
bucket = client.bucket('my-bucket')

# Upload
blob = bucket.blob('uploads/photo.jpg')
blob.upload_from_filename('/local/photo.jpg')

# Generate signed URL (temporary private access)
url = blob.generate_signed_url(
    expiration=datetime.timedelta(hours=1),
    method='GET'
)
Cloud SQL
# Create a PostgreSQL instance
gcloud sql instances create my-db \
  --database-version=POSTGRES_15 \
  --tier=db-f1-micro \
  --region=us-central1

# Create a database
gcloud sql databases create myapp --instance=my-db

# Create a user
gcloud sql users create dbuser --instance=my-db --password=secret

# Connect via proxy
gcloud sql connect my-db --user=dbuser --database=myapp
📝 Day 3 Exercise
Build a File Upload App
  1. C
  2. r
  3. e
  4. a
  5. t
  6. e
  7. a
  8. G
  9. C
  10. S
  11. b
  12. u
  13. c
  14. k
  15. e
  16. t
  17. .
  18. W
  19. r
  20. i
  21. t
  22. e
  23. a
  24. P
  25. y
  26. t
  27. h
  28. o
  29. n
  30. s
  31. c
  32. r
  33. i
  34. p
  35. t
  36. t
  37. h
  38. a
  39. t
  40. u
  41. p
  42. l
  43. o
  44. a
  45. d
  46. s
  47. a
  48. f
  49. i
  50. l
  51. e
  52. ,
  53. g
  54. e
  55. n
  56. e
  57. r
  58. a
  59. t
  60. e
  61. s
  62. a
  63. s
  64. i
  65. g
  66. n
  67. e
  68. d
  69. U
  70. R
  71. L
  72. ,
  73. a
  74. n
  75. d
  76. p
  77. r
  78. i
  79. n
  80. t
  81. s
  82. i
  83. t
  84. .
  85. P
  86. r
  87. o
  88. v
  89. i
  90. s
  91. i
  92. o
  93. n
  94. a
  95. C
  96. l
  97. o
  98. u
  99. d
  100. S
  101. Q
  102. L
  103. i
  104. n
  105. s
  106. t
  107. a
  108. n
  109. c
  110. e
  111. (
  112. f
  113. r
  114. e
  115. e
  116. t
  117. i
  118. e
  119. r
  120. )
  121. .
  122. C
  123. o
  124. n
  125. n
  126. e
  127. c
  128. t
  129. t
  130. o
  131. i
  132. t
  133. a
  134. n
  135. d
  136. c
  137. r
  138. e
  139. a
  140. t
  141. e
  142. a
  143. t
  144. a
  145. b
  146. l
  147. e
  148. .

Day 3 Summary

  • GCS buckets store any file type. gsutil CLI + Python SDK for automation.
  • Signed URLs grant temporary access to private objects without making the bucket public.
  • Cloud SQL is managed PostgreSQL/MySQL — same SQL you know, GCP handles backups and updates.
  • db-f1-micro is the smallest Cloud SQL tier. Use it for development to minimize cost.
Finished this lesson?