Reputation: 155
I have a Service Account in Project A [email protected]
this is a Project Owner Throughout my organization, so we use this to create resources in different projects using our Automation.
I am Trying to Create a Google Big query Data Transfer Config
via Terraform in Project B
using the Service account mentioned above from Project A
.
And its giving me this error
Error creating Config: googleapi: Error 400: P4 service account needs iam.serviceAccounts.getAccessToken permission. Running the following command may resolve this error: gcloud iam service-accounts add-iam-policy-binding [email protected] --member='serviceAccount:service-<Project_B_ID>@gcp-sa-bigquerydatatransfer.iam.gserviceaccount.com' --role='roles/iam.serviceAccountTokenCreator'
I tried running the above in ProjectB
where the data set would be created, and it gave me a error the [email protected]
does not exist.
I have not tried it(not allowed to run CLI cmd )in ProjectA
plus everything is Managed via Terraform, is there a way around to resolve this without needing to run this manually.
Or any other form to resolve this issue ?
FYI: This is only about resource creation, the data set and its transfer are gonna be local to project B only
Upvotes: 1
Views: 709
Reputation: 1780
You need to bind the user “[email protected]”
to project B and assign the role “roles/iam.serviceAccountTokenCreator”
.More information here.
You can use this example code with terminal
gcloud iam service-accounts add-iam-policy-binding [email protected] --member='serviceAccount:service-<Project_B_ID>@gcp-sa-bigquerydatatransfer.iam.gserviceaccount.com' --role='roles/iam.serviceAccountTokenCreator'
Or you can use the IAM console and assign this role roles/iam.serviceAccountTokenCreator to the user [email protected]
.
Upvotes: 1