Part 3: IAM & Secrets: Who Has Access and Where Secrets Live
AuthorEmmanuel Secretaria
Published Aug 10, 2025
Map IAM roles in use and retrieve secrets safely to build a security-focused operational picture.
Scope inspiration:**
gcp_info_accounts_secrets.sh, gcp_iam_roles_granted_too_widely.sh, gcp_iam_roles_granted_to_identity.sh, gcp_secret_get.sh.
This series follows the repo’s GCP inventory flow so every step builds a repeatable, audit-friendly picture of your environment. Part 3 focuses on the access layer: who can act in the project and where sensitive material is stored.
What this script does (walkthrough)
The IAM and Secrets step combines account enumeration with targeted IAM checks and Secrets Manager visibility.
- List service accounts to establish machine identity coverage.
- Scan IAM grants for the broadest exposure patterns (roles granted to
andallAuthenticatedUsers
).allUsers - List Secrets Manager secrets when the API is enabled, giving you a high-level map of secret assets.
- Optionally retrieve the latest secret value with
when you need to validate access paths.gcp_secret_get.sh
Operational caveats and gotchas
will skip Secrets Manager if the API isn’t enabled, so plan to enable it or accept a partial inventory.gcp_info_accounts_secrets.sh- The IAM exposure scan is intentionally narrow — it calls out roles granted to broad groups so you can triage risky access quickly.
fetches the latest enabled secret version; if you need historical versions, you’ll want to adjust thegcp_secret_get.sh
filter.gcloud secrets versions
Example command usage
# IAM + secrets inventory for the active project gcp/gcp_info_accounts_secrets.sh
# Explicitly scan for overly broad IAM grants # (the script checks allAuthenticatedUsers and allUsers) gcp/gcp_iam_roles_granted_too_widely.sh
# Retrieve the most recent enabled version of a secret gcp/gcp_secret_get.sh my-secret-name