Tempkey Blog
Contractor Access to Google Cloud IAM Service Accounts: A Lifecycle Guide
Learn how to give contractors scoped, time-bound access to Google Cloud IAM service accounts — and how to prove the access is gone when the engagement ends.
Effectively managing contractor access to google cloud iam service accounts requires granting the narrowest possible privileges, enforcing time bounds at inception, and establishing an undeniable audit trail when removing access. By combining IAM impersonation, granular resource-level bindings, and strict offboarding protocols, operations leads can give external developers exactly what they need without leaving behind persistent credentials.
When engineering teams bring on freelance engineers, consultants, or systems integrators, provisioning access to Google Cloud Platform (GCP) quickly surfaces friction. Unlike full-time team members who sit within your identity provider and work inside web consoles, outside technical contributors frequently build pipelines, run automation, provision infrastructure with Terraform, or debug Kubernetes clusters. They need machine identities. However, treating non-human credentials with manual, informal onboarding habits creates hidden, long-term operational risk across your cloud environment.
Why Service Accounts Are the Hardest Part of Contractor Access
Service accounts present a distinct identity governance problem because they represent non-human workloads rather than individuals. A standard user account in Google Workspace or Cloud Identity is tethered to a human: if that contractor leaves, disabling their user workspace account halts their interactive sign-in immediately. The account prompts for multi-factor authentication (MFA), undergoes periodic password resets, and surfaces in routine employee directory syncs.
As documented in the Google Cloud IAM documentation on service accounts, service accounts are identities that applications, services, and automated scripts use to make authorized API calls. Because these identities are engineered for automated system communication, they do not prompt for an MFA code at login, they never trigger forgotten password notifications, and no human manager observes their activity on an internal directory roster.
When teams handle contractor access to GCP service accounts without disciplined lifecycle controls, they routinely suffer two major failure modes:
- Orphaned credential keys: A developer downloads a private JSON service account key to configure a local deployment tool or CI/CD runner. Months after the contract ends and their email account is suspended, that static cryptographic key remains valid on an external, unmanaged laptop or stored inside an unmonitored repository.
- Dormant IAM impersonation bindings: An administrator grants an external contractor's Google user account the role necessary to impersonate an administrative service account. When the core deliverables finish, team leads revoke the contractor's direct project permissions but overlook the
roles/iam.serviceAccountTokenCreatorbinding on the underlying service account. The contractor retains an open path into high-privilege operations.
To run clean infrastructure operations, the core question is not simply what tools a contractor needs today. Instead, operations leads must ask: who can act as this service account right now, and how do we prove that list is completely empty the moment offboarding finishes? Establishing clean operational boundaries here is vital for maintaining a clean contractor access management checklist across third-party projects.
How Google Cloud IAM Actually Grants Service Account Access
Securing external contributors requires understanding how Google Cloud IAM models non-human identities. In GCP, a service account is both an identity (which can hold roles on other resources) and a resource itself (which other identities can hold permissions on). Managing contractor access to google cloud iam service accounts requires auditing both dimensions carefully.
Impersonation vs. Direct Key Holding
Google Cloud provides two distinct mechanisms for an external user to utilize a service account:
- Impersonation (Short-Lived Credentials): A contractor signs in using their federated or individual Google user identity (e.g.,
contractor@agency.comor a provisioned organizational user). They hold permissions to generate short-lived credentials for a target service account. When they run scripts, the Google Cloud SDK requests a temporary OAuth 2.0 access token valid for a limited window (typically one hour). No long-lived private key ever touches disk. - Service Account Keys (Static JSON Files): An administrator generates an RSA key pair directly on the service account and downloads the private key file. The contractor stores this JSON file locally or injects it into environment variables. As long as that key exists in IAM, anyone possessing the file can authenticate as that service account from anywhere.
Core Roles That Govern Service Accounts
Understanding which IAM roles give an external contributor authority over a service account is critical for least-privilege enforcement:
roles/iam.serviceAccountTokenCreator: Allows the principal to generate short-lived OAuth 2.0 access tokens, signed URLs, and OpenID Connect (OIDC) ID tokens. This is the foundational role for secure impersonation.roles/iam.serviceAccountUser: Grants the principal permission to attach the service account to compute workloads, such as Google Compute Engine virtual machines, Cloud Run services, or Cloud Functions. It does not automatically grant local token creation by itself, but it permits indirect privilege escalation if compute deployment roles are loosely configured.roles/iam.serviceAccountKeyAdmin: Allows creating, deleting, listing, and rotating static private service account keys. External contractors rarely need this role, because granting key management allows them to generate persistent keys outside of formal review.roles/iam.serviceAccountAdmin: Grants complete lifecycle control to create, modify, and delete service accounts within a project.
Because IAM allow policies in Google Cloud are additive, there is no default denial rule at the binding level. If a contractor belongs to a Google Group that was granted broad impersonation rights, assigning them a restrictive binding individually does not override or constrain that group-level permission. You must configure and review both resource-level bindings and identity-level group memberships.
Choosing Between Impersonation and Service Account Keys
Google recommends avoiding static service account keys whenever possible in their best practices for service accounts. Static JSON files present distinct operational challenges: they cannot enforce MFA, they bypass network perimeter controls unless explicitly wrapped in VPC Service Controls, and they are susceptible to accidental inclusion in source code repositories or chat logs.
However, practical engineering requirements sometimes force trade-offs. Third-party automation services, localized legacy tooling, or specialized vendor infrastructure may lack the technical ability to perform OAuth impersonation. When planning access, use the following criteria to choose the appropriate mechanism:
| Evaluation Criterion | IAM Impersonation | Service Account Keys |
|---|---|---|
| Credential Lifespan | Short-lived (default 1 hour, configurable up to 12 hours) | Permanent until manually deleted or explicitly disabled |
| Storage Risk | Zero disk storage; cached in-memory by GCP SDK / gcloud CLI | High; stored in files, environment variables, or CI variables |
| Revocation Mechanism | Immediate removal of a single IAM role binding | Manual key deletion or key state suspension via API or console |
| Setup Complexity | Requires contractor user account and initial IAM binding setup | Low immediate friction; single file transfer |
| Third-Party Tool Support | Supported natively by Terraform, gcloud, and Google client libraries | Broad support across legacy pipelines and third-party SaaS |
| Audit Visibility | Detailed Cloud Audit Logs showing caller and target identity | Logs show only the service account acting, not the human holding the key |
When third-party external platforms run their own CI/CD runners (like GitHub Actions or GitLab CI), evaluate workload identity federation before generating a JSON key. Workload identity federation allows external platforms to exchange OpenID Connect tokens for temporary Google Cloud credentials, eliminating static file management entirely. You can explore similar patterns for pipelines in our guide to managing contractor access to GitHub Actions.
Granting Contractor Access to GCP Service Accounts Step by Step
When an external developer needs to act as a workload identity, follow a structured lifecycle sequence. Avoid reusing a single service account across multiple vendors or mixing contractor duties with internal system automation, so that revoking access for one project does not disrupt another.
Step 1: Isolate a Dedicated Service Account
Create a service account dedicated exclusively to the specific contractor, agency, or project scope. Naming conventions should immediately communicate purpose and ownership:
gcloud iam service-accounts create sa-contractor-acme-dev \
--description="Scoped execution identity for Acme Agency infrastructure development" \
--display-name="Acme Agency Infrastructure SA"
Step 2: Assign Strict Resource Permissions
Grant permissions to the service account at the narrowest possible resource node. Avoid project-wide roles/editor or roles/owner. If the contractor only needs to inspect storage objects and build Cloud Functions, bind scoped roles only to the specific buckets or datasets involved. For bucket-level scoping patterns, see our breakdown on Google Cloud Storage bucket access management.
Step 3: Bind the Impersonation Role to the Contractor
Allow the contractor's authenticated individual user identity to impersonate the service account by binding roles/iam.serviceAccountTokenCreator directly to that service account resource:
gcloud iam service-accounts add-iam-policy-binding \
sa-contractor-acme-dev@PROJECT_ID.iam.gserviceaccount.com \
--member="user:dev-contractor@partner-agency.com" \
--role="roles/iam.serviceAccountTokenCreator"
Step 4: Implement Time-Bound Access via IAM Conditions
Where supported, enforce an automated expiration date using IAM Conditions. This ensures that even if an administrator forgets to run offboarding tasks on the scheduled date, the authorization engine drops the grant automatically.
gcloud iam service-accounts add-iam-policy-binding \
sa-contractor-acme-dev@PROJECT_ID.iam.gserviceaccount.com \
--member="user:dev-contractor@partner-agency.com" \
--role="roles/iam.serviceAccountTokenCreator" \
--condition="title=contract_expires_2026,description=Revoke after contract ends,expression=request.time < timestamp('2026-11-30T00:00:00Z')"
For technical implementation examples on policy conditions, refer to our detailed resource on managing contractor access with Google Cloud IAM conditions.
Step 5: Record the Access Grant
Record every detail in an operational log at the moment of creation: identity of the approver, contractor email, service account email, assigned roles, resource level, business ticket reference, and the agreed offboarding date. Planning offboarding at the exact moment of granting access is an effective operational habit for preventing access sprawl.
Service Account Key Management for Outside Contributors
When technical constraints make static service account keys unavoidable, implement disciplined key handling procedures. Treat static keys as temporary credentials with planned retirement dates rather than durable project infrastructure.
Handoff and Storage Protocol
Avoid sending service account private key files across standard email or shared team channels, where credentials remain searchable indefinitely. Instead, use an ephemeral secret exchange tool or an access-controlled secrets vault to transfer the file directly to the intended engineer. Instruct the contractor on storage requirements: keys must not be checked into Git repositories, pushed to remote forks, or backed up to personal consumer clouds.
Enforce Key Expiration and Rotation
Establish a key rotation interval shorter than the contract length. If an agency engagement is slated for six months, rotate keys every 60 days. Track key metadata programmatically using the Google Cloud CLI to check key issuance dates:
gcloud iam service-accounts keys list \
--iam-account=sa-contractor-acme-dev@PROJECT_ID.iam.gserviceaccount.com
This command outputs the Key ID, creation timestamp, and expiration status. Google Cloud maintains internal records of key usage via the last_authenticated attribute. Review these timestamps; if a key has not authenticated against an API endpoint in 30 days, disable or delete it promptly. An unmanaged, unused key carries continuous blast radius with no operational benefit.
The Rule of Key Ownership
If you cannot name the specific individual holding a service account key, you cannot safely revoke it. Shared keys distributed across an agency team lead to confusion. When a single agency employee leaves that vendor, the agency rarely informs you. If all vendor personnel share a single JSON file, that departed worker retains access. Assign one key per individual or mandate workload identity federation.
Monitoring What Contractors Do With Service Account Access
Granting scoped access is only half the equation; you must also monitor operational execution. Google Cloud IAM produces extensive audit streams through Cloud Logging.
Configuring Cloud Audit Logs
By default, GCP captures Admin Activity logs, which record actions like creating keys, modifying IAM policies, and provisioning resources. However, Data Access audit logs—which record direct API calls modifying or reading storage objects, database rows, or BigQuery datasets—are often disabled or partially configured due to log volume considerations.
Ensure Data Access logs are turned on for sensitive storage, database, and secret management services that contractor service accounts interact with. For monitoring secrets usage, consult our walkthrough on contractor access to Google Cloud Secret Manager.
Critical Log Events to Monitor
Configure log-based alerts using Cloud Logging and Cloud Monitoring for the following API methods:
google.iam.admin.v1.CreateServiceAccountKey: Triggers when any identity creates a new static JSON key. Contractors should not be generating keys. Set up an alert to notify your operations team if this method fires.google.iam.admin.v1.SetIamPolicy: Triggers whenever an IAM policy is updated on a project, folder, or service account. This surfaces privilege escalation attempts.GenerateAccessTokenorSignBloboniamcredentials.googleapis.com: Tracks when a contractor impersonates a service account to generate credentials.
A quick 15-minute monthly audit reviewing these logs prevents the uncertainty associated with external compliance assessments.
GCP Service Account Offboarding: Revoking Access Without Guesswork
A structured offboarding workflow ensures that access is severed cleanly when a contractor finishes their deliverables. Many operations teams make the mistake of deleting a key while leaving role bindings intact, or revoking a user account while leaving external keys active.
The Complete Offboarding Checklist
- Remove Impersonation Bindings: Remove the contractor's identity from the service account's IAM policy for
roles/iam.serviceAccountTokenCreatorandroles/iam.serviceAccountUser. - Delete or Disable User-Managed Keys: List all keys associated with the dedicated service account. Explicitly delete any active user-managed keys:
gcloud iam service-accounts keys delete KEY_ID \ --iam-account=sa-contractor-acme-dev@PROJECT_ID.iam.gserviceaccount.com - Purge Identity Group Memberships: If access was granted via an administrative Google Workspace group (e.g.,
contractor-devs@company.com), remove the contractor from that group immediately. - Evaluate the Service Account State: If the service account was created strictly for that contractor's engagement, disable the service account entirely rather than leaving it open:
gcloud iam service-accounts disable \ sa-contractor-acme-dev@PROJECT_ID.iam.gserviceaccount.com - Verify the Policy State: Do not assume an API request succeeded without confirmation. Re-read the IAM policy directly to verify the binding no longer exists:
gcloud iam service-accounts get-iam-policy \ sa-contractor-acme-dev@PROJECT_ID.iam.gserviceaccount.com
Edge Cases in Offboarding
Watch out for complex access channels during offboarding:
- Vendor-Owned CI/CD Systems: If a key was provided to an agency to run inside their CI runner instance, deleting the key locally in GCP is mandatory. You cannot rely on the agency deleting the secret from their build configuration.
- Compute Engine Metadata: Verify the contractor did not inject long-lived credentials or custom SSH keys directly into Compute Engine project-wide metadata.
- Cross-Project Service Accounts: Check whether the service account was granted permissions on resources in a separate staging or shared networking project.
Keeping an Audit Trail You Can Actually Produce
When an auditor, enterprise customer, or internal security lead asks for evidence of contractor access, handing over scattered chat messages, informal pull requests, or mental recollections is insufficient. You need an exportable, historical record showing who was granted access, what level of privilege was conferred, who approved it, when it expired, and proof that access was validated as revoked.
Spreadsheets and ad-hoc checklists fail because they are not append-only. Rows can be accidentally modified, timestamps can be overwritten, and no technical enforcement confirms whether the listed steps actually occurred in production.
Managing access across a growing business often spans infrastructure environments and business software. While cloud-specific tooling like Google Cloud IAM governs cloud workloads, contractors also need access to SaaS applications like Slack, GitHub, Google Workspace, and project trackers. Establishing automated provisioning and deprovisioning workflows across these tools prevents forgotten logins from lingering unnoticed.
Tempkey grants contractor access for a set period, revokes it automatically when the grant expires, reads provider state back to confirm the removal on natively enforced providers, and records each step in an exportable audit trail.
Tempkey natively enforces access on 10 providers — Slack, Google Workspace, Microsoft 365, GitHub, GitLab, Zoom, AWS IAM, Figma, Dropbox, and Asana. Notion and Trello are limited-native (tracked, not fully enforced) and Zapier/Make are best-effort webhook bridges without automated verification. Automatic Slack deactivation uses Slack's SCIM API, which Slack offers on its Business+ and Enterprise plans. On other Slack plans, Tempkey verifies that access was removed rather than removing it.
Because Google Cloud IAM is not one of those 10 natively enforced providers today, your GCP audit trail must be assembled using Google Cloud Audit Logs, documented IAM policy snapshots, and structured internal change records. However, for organizations coordinating external collaborators across both cloud services and core operational tools, centralizing access lifecycles reduces overall administrative burden.
Tempkey gives you an exportable, append-only audit trail to support your own compliance and offboarding records. Tempkey does not currently hold SOC 2, ISO 27001, HIPAA, or PCI certification. Tempkey keeps an append-only audit trail you can export to CSV or PDF, with extended retention on the Business plan. Source: Tempkey source.
A Repeatable Checklist for Every Contractor Engagement
To keep managing contractor access to google cloud iam service accounts consistent across your engineering operations, follow this operational checklist for every engagement:
Phase 1: Engagement Setup (Before Work Begins)
- [ ] Establish whether work can be performed via IAM impersonation or Workload Identity Federation rather than static JSON keys.
- [ ] Provision a dedicated service account specifically for this contractor or vendor team.
- [ ] Determine the firm contract end date and document it in your access tracking system.
- [ ] Configure Cloud Audit Logging for all GCP services the contractor will interact with.
Phase 2: Provisioning Access
- [ ] Bind the minimum necessary roles to the service account at the resource level (specific bucket, dataset, or service).
- [ ] Bind
roles/iam.serviceAccountTokenCreatordirectly on the service account to the contractor's authenticated email. - [ ] Attach an IAM Condition expression with a timestamp expiration matching the contract end date.
- [ ] If a static key must be issued, securely transmit the secret through an access-controlled secret exchange mechanism.
- [ ] Log the grant details: approver name, contractor email, roles, resources, and scheduled revocation timestamp.
Phase 3: Active Engagement Maintenance
- [ ] Execute a monthly review of key usage and role bindings.
- [ ] If static keys are utilized, enforce a 60-day rotation schedule.
- [ ] Ensure alerts are operational for unexpected
CreateServiceAccountKeycalls.
Phase 4: Offboarding and Audit Verification
- [ ] Remove all impersonation IAM bindings for the contractor identity.
- [ ] Permanently delete any active service account keys generated for the engagement.
- [ ] Disable the dedicated service account if the project deliverable is complete.
- [ ] Re-query the IAM policy via the Cloud SDK to verify removal from provider state.
- [ ] Archive access and offboarding logs to maintain records for client assessments or audits.
Frequently Asked Questions
Should contractors use service account keys or impersonation in Google Cloud?
Contractors should use IAM impersonation whenever possible. Impersonation issues short-lived OAuth 2.0 access tokens that expire within minutes or hours, eliminating static credentials stored on external machines. Service account keys should only be issued as a fallback when third-party automation tools or legacy environments cannot support federated or short-lived credential workflows.
How do you revoke a contractor's access to a GCP service account?
To revoke access, remove the contractor's user identity from the roles/iam.serviceAccountTokenCreator binding on the service account resource. If static keys were generated, identify their Key IDs using gcloud iam service-accounts keys list and execute gcloud iam service-accounts keys delete. Finally, re-run get-iam-policy on the service account to verify that no active bindings remain.
Can you time-limit a contractor's access to a Google Cloud service account?
Yes. You can use IAM Conditions when binding the impersonation role to the contractor's identity. By setting a condition expression based on request.time (such as request.time < timestamp('2026-12-01T00:00:00Z')), Google Cloud will automatically stop honoring the binding once that timestamp passes, even if an administrator has not yet removed the policy manually.
How do teams prove a contractor no longer has access to a Google Cloud project?
To prove revocation, export a point-in-time snapshot of the IAM policies applied to your project and individual service accounts. Show that the contractor's email identity is absent from all allow policies and that all service account keys issued during their contract have been deleted. Pair this with Google Cloud Audit Logs demonstrating the administrative policy removal event and subsequent key deletion.
Does Tempkey manage Google Cloud IAM service accounts directly?
Tempkey does not natively manage Google Cloud IAM service accounts directly. Tempkey natively enforces access on 10 providers: Slack, Google Workspace, Microsoft 365, GitHub, GitLab, Zoom, AWS IAM, Figma, Dropbox, and Asana. For Google Cloud environments, teams manage IAM service accounts directly within GCP or through Infrastructure-as-Code tooling, while utilizing Tempkey to automate time-bound access and offboarding across their connected SaaS ecosystem.
Tempkey is a hosted cloud service; there is no self-hosted or on-premise deployment option. Sign-in is passwordless — magic links plus WebAuthn/passkeys. Tempkey does not offer SSO/SAML today.