Your pipeline just broke again because that API key sat hard‑coded in a variable that nobody rotated for six months. The deploy failed, the incident channel is lighting up, and now you need a better way to handle secrets. This is where connecting GCP Secret Manager to GitLab CI pays for itself.
GCP Secret Manager does one job very well. It keeps credentials encrypted, access‑controlled, and audited under Google Cloud IAM. GitLab CI does the other job engineers care about: automating builds and deployments fast enough that nobody has time to think about credentials. Pair them, and you get a workflow that’s both secure and smooth.
The integration logic is simple. Your GitLab runner authenticates using a service account with minimal IAM permissions. It fetches secrets directly from GCP Secret Manager at runtime, not from static environment variables. Access policies define who or what can retrieve each secret. Every request is logged, every rotation can happen transparently, and your pipeline runs with just‑in‑time access rather than permanent credentials. Fewer tokens, fewer headaches.
Setting this up feels like a small identity dance. Map your GitLab CI service account in GCP IAM, grant only the “Secret Manager Secret Accessor” role, and rotate your service account keys through automation. The principle is the same as with Okta or AWS IAM: tighten scope until misuse becomes impossible. Most issues come from over‑permissive policies. Keep the trust surface minimal and you’ll sleep better.
If you want the short answer to “How do I connect GCP Secret Manager and GitLab CI?”, here it is: use a GCP service account to authenticate the runner, call the Secret Manager API during the job to fetch secrets, and make sure the account only reads what it must. That’s the featured‑snippet version engineers keep Googling.