Go Cloud Storage bucket — import-candidate census
List names Terraform can import. Do not invent HCL from the SDK.
<!-- hal:authoritative:yaml -->
List names Terraform can import. Do not invent HCL from the SDK.
§I — Frame
Ops needs a real bucket name for an import block ID. Yesterday's Go inventory walked lifecycle and retention. Today print project buckets as import candidates: name, location, storage class, versioning. Leave Terraform authorship to humans.
§II — Sketch
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil {
return err
}
defer client.Close()
it := client.Buckets(ctx, projectID)
for {
battrs, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
return err
}
// candidate import id == battrs.Name
// also print battrs.Location, battrs.StorageClass, battrs.VersioningEnabled
}
Use iterator.Done correctly. Treat permission errors as WARN rows for best-effort scans.
Optional: accept a path to terraform state list output and mark buckets whose name already appears under a google_storage_bucket address as tracked, others as candidate. Do not call Terraform APIs from this binary; read a file the pipeline already produced.
§III — Boundaries
- No
Bucket.Updateand no bucket create/delete from the census binary. - Project ID is required context.
- Align WARN strings with Ops/Dev so Maghrib can fold Go items into the Dev quiz (no Go
quiz.html). - Distinct from 09-13: do not emphasize lifecycle rule dumping; emphasize import ID readiness.
§IV — Closing
Print bucket names Terraform can put in import.id. Pair with Ops Lab 03/11 path. Leave module extraction and moved blocks to HCL review.
Related
- Paired Ops:
- Paired Dev:
- Paired Cert:
- Prior Go (GCS Attrs):
- Lab 03: