Skip to content

agent/gcp: derive service account from credentials instead of hardcoding 'default' - #32080

Closed
Damini008 wants to merge 3 commits into
hashicorp:mainfrom
Damini008:fix/gcp-agent-iam-service-account-default
Closed

agent/gcp: derive service account from credentials instead of hardcoding 'default'#32080
Damini008 wants to merge 3 commits into
hashicorp:mainfrom
Damini008:fix/gcp-agent-iam-service-account-default

Conversation

@Damini008

Copy link
Copy Markdown

Problem

When type=iam and no service_account is explicitly set in the
auto_auth config, the Vault agent was sending the literal string
"default" to the GCP IAM SignJwt API, which rejects it with:

Error 400: Invalid form of account ID default.
Should be [Gaia ID | Email | Unique ID]

This happened because serviceAccount was hardcoded to "default" at
construction time, which prevented the fallback to
credentials.ClientEmail (populated from GOOGLE_APPLICATION_CREDENTIALS)
from ever being reached.

Fix

  • Remove the hardcoded "default" from the constructor
  • In the IAM branch of Authenticate, fall back to
    credentials.ClientEmail when no explicit service_account is configured
  • For the GCE branch, apply "default" locally as a metadata-server
    alias — this is valid for GCE and behaviour is unchanged

Testing

Added unit tests covering:

  • No service_account configured → field is empty (key regression guard)
  • Explicit service_account → preserved as-is
  • GCE type without service_account → empty at construction
  • Missing type, missing role, nil config → all return errors

Related

Fixes: hashicorp/vault-plugin-auth-gcp#183

…ing 'default'

When type=iam and no service_account is explicitly set, the agent was
sending the literal string 'default' to the GCP IAM SignJwt API, which
returns Error 400: Invalid form of account ID.

Fix: leave serviceAccount empty at construction. In the IAM branch,
fall back to credentials.ClientEmail from GOOGLE_APPLICATION_CREDENTIALS
before returning an error. GCE branch continues to use 'default' as a
valid metadata-server alias.

Fixes: hashicorp/vault-plugin-auth-gcp#183
@Damini008
Damini008 requested a review from a team as a code owner August 11, 2026 14:02
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 11, 2026
@Damini008
Damini008 requested a deployment to community-pull-request August 11, 2026 14:02 — with GitHub Actions Waiting
@dosubot dosubot Bot added agent auth/gcp bug Used to indicate a potential bug labels Aug 11, 2026
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deployment failed for project vault-ui with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vault-ui Error Error Aug 11, 2026 4:12pm

Request Review

@hashicorp-cla-app

hashicorp-cla-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app

Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Damini008 seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deployment failed for project vault-ui with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deployment failed for project vault-ui with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@Damini008
Damini008 force-pushed the fix/gcp-agent-iam-service-account-default branch from 4153dbd to 15545ed Compare August 11, 2026 16:12
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deployment failed for project vault-ui with the following error:

The `vercel.json` schema validation failed with the following message: should NOT have additional property `public`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent auth/gcp bug Used to indicate a potential bug size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

1 participant