Skip to content
CloudOps
Newsletter
All prompts
GCP with AI Difficulty: Intermediate ClaudeChatGPTCursor

Cloud Storage Bucket Security & Lifecycle Review Prompt

Audit a Cloud Storage bucket for public exposure, IAM/ACL sprawl, and missing lifecycle/retention rules — closing security gaps while cutting storage cost with the right class transitions.

Target user
Cloud and data engineers owning GCS buckets
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior cloud engineer who locks down Cloud Storage without breaking the pipelines that read from it. You check public access and IAM before lifecycle, and you never set a delete rule on a bucket whose retention you haven't confirmed.

I will provide:
- Bucket config: [`gcloud storage buckets describe gs://BUCKET --format=json`] — location, storage class, uniform bucket-level access, public access prevention, versioning, retention
- IAM and any legacy ACLs: [`gcloud storage buckets get-iam-policy gs://BUCKET`] and object ACL notes
- What the bucket holds and who/what reads/writes it: [DATA + ACCESS PATTERN]
- Access-pattern data if available: how old objects are when last read, and current storage cost: [USAGE / COST]

Your job:

1. **Public exposure first** — check for `allUsers` / `allAuthenticatedUsers` bindings, whether Public Access Prevention is enforced, and whether uniform bucket-level access is on (so per-object ACLs can't silently re-expose data). Flag any path to public read/write and the fix.

2. **Tighten IAM** — replace broad roles (e.g. `storage.admin` for a read-only consumer) with the minimal predefined role (`objectViewer`, `objectCreator`), and recommend retiring legacy ACLs in favor of uniform access. Give the gcloud commands.

3. **Lifecycle for cost** — based on the access pattern, propose lifecycle rules to transition objects to Nearline/Coldline/Archive by age, and (only if retention allows) delete rules. Write the lifecycle JSON and the command to apply it. Estimate the saving direction and note class-change/retrieval cost trade-offs.

4. **Data protection** — recommend object versioning and/or a retention policy / bucket lock where the data warrants it, and reconcile that against any delete lifecycle rule so they don't conflict.

5. **Sequence safely** — close the public exposure first, then tighten IAM, then apply lifecycle. Confirm no consumer breaks when a role is narrowed.

Output: (a) an exposure finding with the exact public/ACL risk, (b) the IAM tightening commands, (c) the lifecycle rule JSON with cost trade-offs, (d) versioning/retention recommendation, (e) a safe application order.

Bias toward enforcing Public Access Prevention and uniform bucket-level access, and toward verifying consumers before narrowing roles. Don't add a delete lifecycle rule unless I've confirmed the retention requirement.

Why this prompt works

Cloud Storage incidents split into two failure modes that pull in opposite directions: data left publicly readable, and storage cost bleeding from objects that should have aged into a colder class or been deleted. This prompt handles both in the right order — security first, cost second — because a lifecycle rule on a misconfigured public bucket is fixing the wrong problem. Starting from the bucket config and IAM export keeps the review grounded in the bucket’s actual state, including whether uniform bucket-level access is even enforced.

The exposure check is deliberately specific to how GCS leaks: allUsers bindings, Public Access Prevention not enforced, and legacy per-object ACLs that can silently re-expose data even when the bucket policy looks clean. By making the model reconcile those and then narrow IAM to the minimal predefined role, the prompt closes the real paths to exposure rather than just the obvious one. The lifecycle step then translates the access pattern into concrete class transitions with their retrieval-cost trade-offs.

The guardrails protect against the two irreversible mistakes here: a delete lifecycle rule that silently destroys data with a retention requirement, and narrowing access that breaks a legitimate consumer like a CDN origin or partner pipeline. By requiring retention confirmation before any delete rule and consumer verification before tightening IAM — and by applying changes in a safe sequence — the prompt keeps the human in control of every decision that can’t be undone.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week