I am trying to set up things to be able to run Actions to query gcloud.
As part of the set up, I have so far been able to Create a Workload Identity Pool but when I try to Create a Workload Identity Provider using the command below, it fails with an “ERROR: (gcloud.iam.workload-identity-pools.providers.create-oidc) INVALID_ARGUMENT: The attribute condition must reference one of the provider’s claims. For more information, see https://cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines#conditions”
I inspected the OIDC JWT Claims by running the command below and I can confirm the the claims have the sub, repository, actor and repository_owner coming up in the response.
I understand that you are getting an error when you try to create the provider for your Workload Identity Pool. Based on the error you provide, INVALID_ARGUMENT: The attribute condition must reference one of the provider's claims and by looking at your command, it seems that the attribute condition is missing from your command. You must always use an attribute condition to restrict access to tokens issued by your GitHub organization.
You may try to add the --attribute-condition=“assertion.repository.repository_owner == ‘my-github-org’” from your command below, note that the ‘my-github-org’ is just a sample only:
│ Error: Error creating WorkloadIdentityPoolProvider: googleapi: Error 400: The attribute condition must reference one of the provider's claims. For more information, see https://cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines#conditions
│
│ with google_iam_workload_identity_pool_provider.github_provider,
│ on github-actions-sa.tf line 14, in resource "google_iam_workload_identity_pool_provider" "github_provider":
│ 14: resource "google_iam_workload_identity_pool_provider" "github_provider" ***
│
However, from what I can tell, the attribute mapping should be correct.
Error: Error creating WorkloadIdentityPoolProvider: googleapi: Error 400: The attribute condition must reference one of the provider's claims. For more information, see https://cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines#conditions
It seems that you need an attribute condition to reference one of the claims.