-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GCS backend does not work with GCP identity federation #29656
Comments
I think you just need to update to the latest cloud storage SDK and it'll work. |
Looks like I'm running into an error with using google cloud storage as my state backend, where I get this error when using Workload Identity Federation for authentication:
Would love to see this resolved. I'd be glad to provide additional info beyond what I shared in this issue to help. |
I rebuilt locally for tests the teraform with the new gcs version (v1.18.2) and the plan was successful. pr: #30276 |
It looks like it is already fix #28296 . |
Are you sure this is resolved? Here is how I created the Google Cloud resources: gcloud iam workload-identity-pools create "my-pool" \
--project="${PROJECT_ID}" \
--location="global" \
--display-name="Demo pool"
gcloud iam workload-identity-pools providers create-oidc "my-provider" \
--project="${PROJECT_ID}" \
--location="global" \
--workload-identity-pool="my-pool" \
--display-name="Demo provider" \
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository" \
--issuer-uri="https://token.actions.githubusercontent.com"
gcloud iam service-accounts add-iam-policy-binding "sb-github-actions@${PROJECT_ID}.iam.gserviceaccount.com" \
--project="${PROJECT_ID}" \
--role="roles/iam.workloadIdentityUser" \
--member="principalSet://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/my-pool/attribute.repository/mycompany/myrepo"
(I even tried with Here is my workflow: jobs:
terraform:
permissions:
id-token: write
contents: read
runs-on: [self-hosted, linux, x64, on-prem, terraform]
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0
with:
workload_identity_provider: '${{secrets.IDENTITY_PROVIDER_ID}}'
service_account: '${{secrets.SA_EMAIL}}'
create_credentials_file: true
export_environment_variables: true
- name: Terraform init
run: |
terraform init -input=false Here is my backend: terraform {
backend "gcs" {
bucket = "myuniqueidentifier"
prefix = "terraform/state/something"
}
} Here is my provider config: terraform {
required_version = "1.1.6"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 3.90"
}
}
}
provider "google" {
region = var.region
zone = var.zone
} I double-checked and retried several times from scratch following documentation at https://cloud.google.com/blog/products/identity-security/enabling-keyless-authentication-from-github-actions and at https://cloud.google.com/iam/docs/using-workload-identity-federation#generate-automatic. I tested granting my service account roles Storage Object Admin, then Storage Admin, then Owner, on the project that contains the bucket (which is not same project as the one containing the service account). And I'm still getting the following error :
Any idea what I am doing wrong? |
Hi @uportalis, you may not get an answer in this thread if it is not an expansion of the original issue (which it may be!) Just in case, you can also try getting help from the community forums, there are more people there to help with these types of questions. Thanks! |
This error also occurs if your pool is disabled. Please check for this. |
I don't know why it works when I grant the Workload Identity User role using |
@uportalis attribute.actore/uportalis is your github user name ? |
@aanjansai1112 yes it is. I resolved my problem, which was NOT related to this issue. |
@uportalis could you please elaborate on the solution how it got fixed now ? are you suggesting to remove attribute.actor or any other method that you have followed. |
Related ticket: google-github-actions/auth#17
The
auth
GitHub Action from Google allows us to federate identity to a GCP service account without having to export account credentials. Currently this does not work with the terraform GCS backend. Rawgcloud
works fine.Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
Terraform GCS backend working as usual.
Actual Behavior
Steps to Reproduce
Create a GitHub Action:
The text was updated successfully, but these errors were encountered: