diff --git a/gcloud-configs.md b/gcloud-configs.md new file mode 100644 index 0000000..ece0940 --- /dev/null +++ b/gcloud-configs.md @@ -0,0 +1,123 @@ + + +``` + ┌───────────────── GLOBAL STATE ─────────────────┐ + │ │ + ┌──────────┴──────────┐ ┌──────────┴──────────┐ + │ CONFIG: client-a │ │ CONFIG: client-b │ + ├─────────────────────┤ ├─────────────────────┤ + │ 👤 you@clientA.com │ │ 👤 you@clientB.com │ + │ 🆔 project-id-aaa │ │ 🆔 project-id-bbb │ + └─────────────────────┘ └─────────────────────┘ + ▲ ▲ + │ (gcloud config configurations activate ...) │ + └─────────────────── YOUR TERMINAL ──────────────┴─── + +``` + +## 🛠️ One-Time Setup (Do this once per client) + +Follow these steps carefully for each individual client account. **Do not use any logout commands.** + +### 1. Set up Client A +Open your terminal and run these 4 commands in order: + +```bash +# 1. Create a workspace profile named after Client A +gcloud config configurations create client-a + +# 2. Log in with Client A's specific email address +gcloud auth login + +# 3. Authenticate local code running on your machine (ADC) +gcloud auth application-default login + +# 4. Lock this profile to Client A's exact Google Cloud project ID +gcloud config set project CLIENT_A_PROJECT_ID + +``` + +### 2. Set up Client B + +Now, repeat the exact same pattern for your next client. This will **not** erase your Client A setup. + +Bash + +``` +# 1. Create a workspace profile named after Client B +gcloud config configurations create client-b + +# 2. Log in with Client B's specific email address +gcloud auth login + +# 3. Authenticate local code for Client B +gcloud auth application-default login + +# 4. Lock this profile to Client B's project ID +gcloud config set project CLIENT_B_PROJECT_ID + +``` + +## 📂 The Firebase Connection + +The Firebase CLI automatically shares permissions with your active `gcloud` profile. You do not need to log in or out of Firebase anymore. + +1. Open your terminal and `cd` into your **Client A local project folder**. + +2. Tie the folder to the remote project by running: + + Bash + + ``` + firebase use --add + + ``` + +3. Select Client A's project from the terminal list and name the alias `default`. + + +_(Repeat this inside your Client B directory using Client B's project)_. + +## 🔄 Daily Workflow (How to switch safely) + +When you sit down to work, switching takes exactly one command. + +### To switch to Client A: + +Bash + +``` +gcloud config configurations activate client-a + +``` + +### To switch to Client B: + +Bash + +``` +gcloud config configurations activate client-b + +``` + +## 🛑 The "Am I Safe?" Sanity Check + +If you are ever worried about deploying code to the wrong client, navigate to your project folder and run this **"Where am I?" command combo**: + +Bash + +``` +gcloud config list && firebase use + +``` + +**What a successful check looks like:** + +- `account` shows the correct client email. + +- `project` matches the expected Google Cloud environment. + +- The final line lists the active Firebase alias matching your folder context. + + +If everything matches, you are 100% safe to deploy. \ No newline at end of file