Sync Google Cloud Storage buckets on schedule

Recipe ToolsMarketingDirectory ServicesCloud Platform

What it does

When a scheduled time arrives every 5 minutes, this automation creates, lists, updates, and deletes buckets in Google Cloud Storage. It logs each step to a job report and halts on error without retrying.

Who it's for

Engineering teams who need to keep Google Cloud Storage buckets synchronized without manual intervention.

How teams use this

Maintain bucket configuration automatically

Run the sync every 5 minutes so buckets stay aligned with the project's desired state. The team does not need to manually create or remove buckets.

Audit bucket changes in a log

Each create, update, and delete operation logs to a job report so the team can review what changed and when. This gives visibility into all bucket modifications.

Add a filter for bucket naming rules

Include a condition to only sync buckets that match a naming pattern, so the automation skips buckets outside the managed set. This requires adding a naming filter to the list step.

Extend sync to multiple projects

Set the automation to loop through a list of project IDs so each one gets its buckets synced on the same schedule. Only the project loop needs to be added.

How it works

  1. Run every 5 minutes. The automation starts on a 5-minute schedule to keep buckets in sync with the current project state.
  2. Create a new bucket. Create a bucket in Google Cloud Storage as part of the sync cycle, then log the result to the job report for visibility.
  3. List all project buckets. List buckets within the project to see the current state and compare against expected configuration before making changes.
  4. Update and delete buckets. Update existing buckets and delete those no longer needed, then log the outcome to the job report. Stop if an error occurs.