GCP

Security

Configuring Workload identity federation between GCP and AWS EKS

Workload identity federation is the process of impersonating an identity in one cloud provider from the other without long lived keys. In this blog post we will walk through how to setup federation between a workload running on AWS EKS (In this case CloudQuery so you can also fetch configuration from your GCP accounts) to GCP.

Step 1: Create AWS Infrastructure for CloudQuery on EKS

In this guide, we run CloudQuery on AWS EKS with the official CloudQuery Helm Charts.

Note that GCP Workload Identity Federation does not support Fargate nodes. Only EC2 nodes are supported

IAM Roles for CloudQuery on EKS

For EKS, IAM setup may require an Amazon EKS cluster IAM role and an Amazon EKS node IAM role. Refer to AWS documentation for more information on IAM setup and best practices for securing IAM for EKS Clusters.

Step 2: Enable Additional GCP Services

The Security Token Service API and the IAM Service Account Credentials API need to be enabled in our GCP project.

gcloud services enable sts.googleapis.com
gcloud services enable iamcredentials.googleapis.com

Step 3: Create GCP Service Account

Now we need to create the GCP Service Account which CloudQuery will authenticate with in order to fetch the GCP resources.

gcloud iam service-accounts create cq-fetcher \
--description="CloudQuery fetcher which runs on AWS." \
--display-name="cq-fetcher"

We need to ensure that the new Service Account has the appropriate permissions to view the desired projects in GCP.

Step 4: Create GCP Workload Identity Pool

Next, we need to create the GCP Workload Identity Pool.

gcloud iam workload-identity-pools create cq-aws-pool \
--description="Workload Identity Pool for CloudQuery on AWS." \
--display-name="CloudQuery AWS Pool" \
--location="global"
GCP Console Workload Identity Pool creation screen showing CloudQuery AWS Pool configuration

Step 5: Create Workload Identity Provider

After creating the GCP Workload Identity Pool we need to create the Workload Identity Provider. This example does not cover how to harden the Identity Provider, which can be achieved by passing the --attribute-condition flag.

gcloud iam workload-identity-pools \
providers create-aws cq-aws-provider \
--account-id=123456789012 \
--description="Workload Identity Provider for CloudQuery on AWS." \
--display-name="CloudQuery AWS Provider" \
--location="global" \
--workload-identity-pool="cq-aws-pool"
GCP Console Workload Identity Provider AWS configuration for CloudQuery EKS federation

Step 6: Bind GCP Service Account Impersonation

Now, we will create an IAM policy binding.

The below command allows all identities from our pool to impersonate the GCP Service Account we created earlier by binding the IAM role roles/iam.workloadIdentityUser to the GCP service account. Replace the number in the -member flag with the GCP project number.

gcloud iam service-accounts add-iam-policy-binding \
[email protected] \
--member "principalSet://iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/cq-aws-pool/*" \
--role "roles/iam.workloadIdentityUser"

Please consider adjusting the -member flag for additional security with GCP service account impersonation. More granular options include options such as a single identity, all identities in a group, or all identities with a specific attribute value. More information can be found in the Service account impersonation section of Google Cloud Docs. We recommend using granular scoping for service account impersonation.

An example of using a single identity in the pool could look like the following command. Additional configuration may be required for attribute mapping and conditions. Information on defining attribute mapping can be found here.

gcloud iam service-accounts add-iam-policy-binding \
[email protected] \
--member "principalSet://iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/cq-aws-pool/attribute.aws_role/CQ_AWS_Role" \
--role "roles/iam.workloadIdentityUser"

Step 7: Download Client library Config

The Client library Config needs to be downloaded, this can be achieved by navigating to the Workload Identity Pool and selecting the CONNECTED SERVICE ACCOUNTS Tab on the right side. The Client library Config can be obtained from there. The file does NOT contain sensitive information.

GCP Console showing client library config download for CloudQuery Workload Identity Federation credentials

Step 8: Configure CloudQuery

The downloaded Client library config needs to be uploaded to our Kubernetes as a config map.

kubectl -ncloudquery create configmap \
cq-gcp-application-default-credentials \
--from-file=./application_default_credentials.json

Now we just need to inject the Client library config into our Pod with the help of a volume mount. This can be achieved by adding those values into the values.yaml of the Helm Chart.

volumes:
- name: gcp
configMap:
name: cq-application-default-credentials
items:
- key: application_default_credentials.json
path: application_default_credentials.json
volumeMounts:
- mountPath: /root/.config/gcloud/
name: gcp

Conclusion

That’s it! Now you can ingest your configuration across clouds into a single PostgreSQL database, visualise with your favourite BI tool and build your own asset inventory, CSPM, search and any other use-case you have in mind!

Want to see CloudQuery in action? Schedule a demo with our team or check out the platform documentation to learn more.

Want help getting started? Join the CloudQuery community to connect with other users and experts, or message our team directly here if you have any questions.

Try CloudQuery yourself

Self-hosted, open source, and free to start. Or schedule a demo to see the managed version.

Related posts

AWS

Azure

GCP

Security

How Do You Run CloudQuery Without Static Credentials?

Workload identity federation for GCP and Azure, RDS IAM auth, and Lakebase OAuth let self-hosted CloudQuery syncs run without stored static credentials.

Ben Bernays

Ben Bernays

September 28, 2026

GCP

Security

Tutorials

Creating Cross-Project Service Accounts in GCP (Console + gcloud CLI)

Create a GCP service account that reads across all your projects with one credential. Covers gcloud CLI, org-level vs.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

GCP

Security

Tutorials

How to Inventory All Public IP Addresses Across AWS and GCP using CloudQuery

Track every public IP across AWS and GCP in minutes with SQL. Find exposed EC2 instances, unused Elastic IPs, and GCP Compute resources in one place.

Adam Cobb

Adam Cobb

Joe Karlsson

Joe Karlsson

December 19, 2025

AWS

Azure

GCP

Security

Tutorials

How to Find Internet-Facing Cloud Assets in AWS, Azure and GCP

Find all internet-facing cloud resources across AWS, Azure, and GCP. Identify exposed VMs, storage, databases, and load balancers to reduce attack surface.

Adam Cobb

Adam Cobb

November 5, 2025

GCP

Security

Tutorials

How to Identify Your GCP SSH vulnerabilities with CloudQuery

Use CloudQuery to identify and analyze GCP resources vulnerable to SSH exploits, with SQL-driven insights to prioritize and remediate exposure quickly.

Kevin Rheinheimer

Kevin Rheinheimer

July 9, 2024

GCP

Security

Tutorials

Enhance your Cloud Asset Inventory Using Wiz + GCP

Enhance your GCP cloud asset inventory with CloudQuery’s Wiz plugin. Gain immediate insights into vulnerabilities and misconfigurations.

Kevin Rheinheimer

Kevin Rheinheimer

July 3, 2024

AWS

Security

Tutorials

Finding AWS Unrestricted Outbound Access in 2026: EC2, Lambda, and Beyond

Find EC2, Lambda, and ECS Fargate resources with unrestricted outbound access in AWS using SQL. Why egress controls still break attack chains in 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Security

Tutorials

AWS IAM Identity Center with Google Workspace as an IdP: 2026 Step-by-Step Guide

Set up AWS IAM Identity Center with Google Workspace: SAML authentication, SCIM user provisioning, and group sync with CLI or ssosync. Updated for 2026.

Joe Karlsson

Joe Karlsson

May 5, 2026

AWS

Best Practices

Security

AWS CIS Benchmark in 2026: Automated Compliance with SQL-Based Policies

AWS CIS Benchmark hit v3.0 in 2024 with 40+ controls. Run automated compliance checks using SQL policies with exception management and multi-account views.

Joe Karlsson

Joe Karlsson

May 5, 2026

Own your pipeline.
Own your data.