executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
gcp-cloud-storageManage Google Cloud Storage for scalable object storage. Create and configure buckets, upload and organize objects, generate signed URLs for secure temporary access, set lifecycle rules for cost optimization, and configure access control.
Independent GitHub snapshot · Automated classification · Original documentation governs
Google Cloud Storage is a unified object storage service with global edge caching. It offers multiple storage classes (Standard, Nearline, Coldline, Archive) for cost optimization, strong consistency, and integration with all GCP services.
# Create a bucket with location and default storage class
gcloud storage buckets create gs://my-app-assets-prod \
--location=us-central1 \
--default-storage-class=STANDARD \
--uniform-bucket-level-access
# List buckets
gcloud storage ls
# Set bucket to public read (for static hosting)
gcloud storage buckets add-iam-policy-binding gs://my-app-assets-prod \
--member=allUsers \
--role=roles/storage.objectViewer
# Enable versioning
gcloud storage buckets update gs://my-app-assets-prod --versioning
# Upload a file
gcloud storage cp ./build/app.zip gs://my-app-assets-prod/releases/v1.2.0/app.zip
# Sync a directory
gcloud storage rsync ./dist gs://my-app-assets-prod/static/ \
--delete-unmatched-destination-objects \
--cache-control="public, max-age=86400"
# Copy between buckets
gcloud storage cp gs://source-bucket/data.csv gs://dest-bucket/data.csv
# List objects with prefix
gcloud storage ls gs://my-app-assets-prod/releases/ --recursive
# Remove objects
gcloud storage rm gs://my-app-assets-prod/old-file.txt
# Generate signed URL for download (1 hour)
from google.cloud import storage
from datetime import timedelta
client = storage.Client()
bucket = client.bucket('my-app-assets-prod')
blob = bucket.blob('reports/q4.pdf')
url = blob.generate_signed_url(
version='v4',
expiration=timedelta(hours=1),
method='GET'
)
print(f"Download URL: {url}")
# Generate signed URL for upload
url = blob.generate_signed_url(
version='v4',
expiration=timedelta(minutes=15),
method='PUT',
content_type='application/octet-stream'
)
print(f"Upload URL: {url}")
# Client uploads with: curl -X PUT -H "Content-Type: application/octet-stream" --data-binary @file "$url"
# Generate signed URL with gsutil
gcloud storage sign-url gs://my-app-assets-prod/reports/q4.pdf \
--duration=1h \
--private-key-file=service-account.json
// lifecycle-config.json — transition and expire objects automatically
{
"rule": [
{
"action": {"type": "SetStorageClass", "storageClass": "NEARLINE"},
"condition": {"age": 30, "matchesPrefix": ["logs/"]}
},
{
"action": {"type": "SetStorageClass", "storageClass": "COLDLINE"},
"condition": {"age": 90, "matchesPrefix": ["logs/"]}
},
{
"action": {"type": "Delete"},
"condition": {"age": 365, "matchesPrefix": ["logs/"]}
},
{
"action": {"type": "AbortIncompleteMultipartUpload"},
"condition": {"age": 7}
},
{
"action": {"type": "Delete"},
"condition": {"numNewerVersions": 3, "isLive": false}
}
]
}
# Apply lifecycle rules
gcloud storage buckets update gs://my-app-assets-prod \
--lifecycle-file=lifecycle-config.json
# Configure bucket for static website
gcloud storage buckets update gs://my-app-website \
--web-main-page-suffix=index.html \
--web-not-found-page=404.html
# Upload website files with appropriate content types
gcloud storage cp -r ./build/* gs://my-app-website/ \
--cache-control="public, max-age=3600"
# Notify Pub/Sub when objects are created
gcloud storage buckets notifications create gs://my-app-assets-prod \
--topic=storage-events \
--event-types=OBJECT_FINALIZE \
--object-prefix=uploads/
// cors-config.json — allow browser uploads
[
{
"origin": ["https://myapp.com"],
"method": ["GET", "PUT", "POST"],
"responseHeader": ["Content-Type"],
"maxAgeSeconds": 3600
}
]
# Apply CORS
gcloud storage buckets update gs://my-app-assets-prod --cors-file=cors-config.json
# Grant a service account read access
gcloud storage buckets add-iam-policy-binding gs://my-app-assets-prod \
--member=serviceAccount:app@my-project.iam.gserviceaccount.com \
--role=roles/storage.objectViewer
# Remove public access
gcloud storage buckets remove-iam-policy-binding gs://my-app-assets-prod \
--member=allUsers \
--role=roles/storage.objectViewer
gcloud storage rsync for efficient directory synchronization