Add “https://sts.amazonaws.com”in the policy
For AWS ec2 or lambda to access a GCS bucket hosted on GCP we need to create a service account in GCP without having the service account key generated.
Click on the “grant access” and select the service account that you want to configure which will be used in the WIF for providing access to the AWS resource that will access on GCP environment / project
Prerequisites on AWS side:
Prerequisites on GCP side:
References:
https://cloud.google.com/iam/docs/workload-identity-federation#why
Hi! Thank you very much for this post
I followed the steps described here and read the documentation too for WIF.
I also implemented this in my lambda function: (only changing the url cause i'm listing projects)
https://github.com/googleapis/google-auth-library-nodejs?tab=readme-ov-file#using-external-identitie...
But I get this:
{"request":{"responseURL":"https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/my-service-account-name@serviceaccount-id-gcp.iam.gserviceaccount.com:generateAccessToken"}},"status":403,"errors":[{"message":"Permission 'iam.serviceAccounts.getAccessToken' denied on resource (or it may not exist).","domain":"global","reason":"forbidden"}]}
And my service account has the following permissions:
-Service Account Token Creator
-Viewer
-Workload Identity User
As I checked in the policy analyser, this permission iam.serviceAccounts.getAccessToken is granted for my service account
I hope you can help me. Thank you!