This directory contains individual shell scripts for creating and managing single resources in Google Cloud Platform (GCP) using the gcloud command-line interface (CLI).
The scripts are organized by resource type:
- aim: Scripts for Identity and Access Management (IAM)
- google-kubernetes: Scripts for Google Kubernetes Engine (GKE)
- load_balancer: Scripts for creating and managing load balancers
- net: Scripts for networking resources (VPC, firewall rules, etc.)
- sql: Scripts for Cloud SQL instances
- storage: Scripts for Cloud Storage buckets
- vm: Scripts for Compute Engine virtual machines
Most scripts can be executed directly after setting the necessary environment variables. For example:
# Set required environment variables
export SERVICE_ACCOUNT_NAME="your-service-account@your-project.iam.gserviceaccount.com"
export KEY="ssh-rsa AAAA..."
# Run a script
cd vm
./create_vm.shMany scripts require the following environment variables:
SERVICE_ACCOUNT_NAME: The email address of the service account to useKEY: Your SSH public key for VM accessUSER: Your username for SSH access
create_vm.sh: Creates a basic VM with Nginx installedtake_vm_snapshot.sh: Creates a snapshot of a VM's diskvm_from_snapshot.sh: Creates a VM from a disk snapshotvm_from_image.sh: Creates a VM from a custom imagevm_from_machine_image.sh: Creates a VM from a machine imagevm_with_vpc.sh: Creates a VM in a custom VPCconnection_to_private_cluster.sh: Sets up a connection to a private GKE cluster
create_custom_vpc.sh: Creates a custom Virtual Private Cloudcreate_fw_rule.sh: Creates a firewall rule in the default VPCcreate_fw_rule_custom_vpc.sh: Creates a firewall rule in a custom VPCcreate_peering.sh: Sets up VPC peering between two networksprivte_service_acces.sh: Configures private service access
create_service_account.sh: Creates a service accountcreate_alchemy_sa.sh: Creates a service account for a specific applicationcreate_role.sh: Creates a custom IAM roleadd_ssh.sh: Adds SSH keys to project metadataroles-check.sh: Checks roles assigned to a service account
Each script is self-contained and focused on a specific task, making them ideal for learning or for use in larger automation workflows.
- These scripts are designed for demonstration and learning purposes
- Always review scripts before running them in a production environment
- Some scripts may need modification to work with your specific GCP project configuration