$npx -y skills add VeerMuchandi/rad-skills --skill gcs_setupProvisions one or more Google Cloud Storage buckets with secure uniform bucket-level access and public access prevention using Terraform.
| 1 | # GCS Setup Skill |
| 2 | |
| 3 | This skill allows you to easily provision one or more Google Cloud Storage (GCS) buckets on Google Cloud Platform using Terraform. It automatically enables required APIs, configures secure uniform bucket-level access, enforces public access prevention, and supports bulk creation. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | - **Terraform Version**: `v1.5+` (Recommended `v1.14+`) |
| 7 | - **GCP Project**: Active Google Cloud Project with billing enabled. |
| 8 | - **Permissions**: |
| 9 | - `roles/storage.admin` (to manage GCS buckets) |
| 10 | - `roles/serviceusage.serviceUsageConsumer` (to enable services) |
| 11 | |
| 12 | ## Skill Directory Structure |
| 13 | ```text |
| 14 | gcs_setup/ |
| 15 | ├── SKILL.md # This instructions file |
| 16 | ├── resources/ |
| 17 | │ └── templates/ |
| 18 | │ ├── main.tf # Core GCS resources |
| 19 | │ ├── variables.tf # Customizable variables |
| 20 | │ └── outputs.tf # Bucket names and URLs outputs |
| 21 | └── scripts/ |
| 22 | └── deploy_gcs.py # Helper Python script to orchestrate deployment |
| 23 | ``` |
| 24 | |
| 25 | ## 1. How to Use this Skill (Step-by-Step) |
| 26 | |
| 27 | ### Step 1: Initialize the Deployment Workspace |
| 28 | Create a dedicated deployment directory outside your agent code package to prevent Terraform state/binaries from being packaged with the agent. |
| 29 | |
| 30 | ```bash |
| 31 | mkdir -p deploy_gcs |
| 32 | ``` |
| 33 | |
| 34 | ### Step 2: Copy the Templates |
| 35 | Copy the templates from this skill to your new `deploy_gcs` folder. |
| 36 | *(Note: Replace `<path_to_skill>` with the path of this skill folder, e.g. `skills/gcs_setup`)* |
| 37 | |
| 38 | ```bash |
| 39 | cp -r <path_to_skill>/resources/templates/* deploy_gcs/ |
| 40 | ``` |
| 41 | |
| 42 | ### Step 3: Configure Deployment (`deploy_gcs/terraform.tfvars`) |
| 43 | Create a file named `deploy_gcs/terraform.tfvars` and set the following parameters: |
| 44 | |
| 45 | ```hcl |
| 46 | project_id = "your-gcp-project-id" |
| 47 | region = "us-central1" |
| 48 | bucket_names = ["my-source-bucket", "my-archive-bucket", "my-error-bucket"] |
| 49 | force_destroy = true # Set to false for production to prevent accidental data loss |
| 50 | ``` |
| 51 | |
| 52 | ### Step 4: Run Terraform |
| 53 | Navigate to the `deploy_gcs` directory, initialize, and deploy the resources: |
| 54 | |
| 55 | ```bash |
| 56 | cd deploy_gcs |
| 57 | terraform init |
| 58 | terraform apply -auto-approve |
| 59 | ``` |
| 60 | |
| 61 | ### Step 5: Capture Output |
| 62 | Upon successful completion, Terraform outputs the connection details and bucket URLs: |
| 63 | ```hcl |
| 64 | bucket_names = [ |
| 65 | "my-source-bucket", |
| 66 | "my-archive-bucket", |
| 67 | "my-error-bucket" |
| 68 | ] |
| 69 | bucket_urls = { |
| 70 | "my-source-bucket" = "gs://my-source-bucket" |
| 71 | "my-archive-bucket" = "gs://my-archive-bucket" |
| 72 | "my-error-bucket" = "gs://my-error-bucket" |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | --- |
| 77 | |
| 78 | ### Option B: Using the Orchestration Helper Script (Recommended) |
| 79 | You can automate the deployment and bucket creation in a single step using the helper Python script. |
| 80 | |
| 81 | Run the script: |
| 82 | ```bash |
| 83 | python3 <path_to_skill>/scripts/deploy_gcs.py \ |
| 84 | --project "your-gcp-project-id" \ |
| 85 | --buckets "my-source-bucket,my-archive-bucket,my-error-bucket" \ |
| 86 | --work-dir "deploy_gcs" |
| 87 | ``` |
| 88 | |
| 89 | To destroy the buckets later: |
| 90 | ```bash |
| 91 | python3 <path_to_skill>/scripts/deploy_gcs.py \ |
| 92 | --project "your-gcp-project-id" \ |
| 93 | --buckets "my-source-bucket,my-archive-bucket,my-error-bucket" \ |
| 94 | --work-dir "deploy_gcs" \ |
| 95 | --destroy |
| 96 | ``` |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## 2. Best Practices & Security |
| 101 | - **Uniform Bucket-Level Access**: Enabled by default to simplify IAM permissions management. |
| 102 | - **Public Access Prevention**: Set to `enforced` by default to prevent bucket objects from being accidentally exposed to the public internet. |
| 103 | - **Force Destroy**: Set to `true` in development to allow deleting non-empty buckets. **Always set to `false` in production!** |