-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Bug in google_storage_transfer_job & google_storage_transfer_project_service_account #10798
Comments
@faizan-ahmad-db was hitting this issue too, but apparently it's works-as-designed
You need to enable the storage-transfer API in both projects:
|
@unki regarding your statement to enable the storage-transfer API in both projects, I have created Composer, Dataflow, and many other services without enabling their respective APIs in the project which homes the service-account. Their APIs are enabled only in the project where these resources are being created. Also, I can run Terraform from my local machine right with my user credentials. Only when I create a transfer service is when I am facing this issue where it asks me to enable the storage-transfer-api in the home project. |
Any news on this? This continues happening. Thanks! :) |
Still seeing this on version 5.16 of the google TF provider - this is silly. |
Hi, We're unable to reproduce this error on our system, i've tried this config on my system
and it works fine, when using |
Hi, And by looking at those project numbers, they don't belong to us, maybe those projects belong to Google? |
Any news on this, I am facing the same issue. |
@googlyrahman I've been able to reproduce the problem, but it requires some setup. For what it's worth I believe the problem is a misunderstanding of when and where an API needs to be enabled, and isn't a bug in the provider. I can expand on this but: using a debugger I've seen that Ok, onto the reproduction of the error observed in this issue : You need 2 projects. Project A which has the storagetransfer.googleapis.com API disabled and Project B where the storagetransfer.googleapis.com API is enabled (and so the storage transfer account will exist). Project A is where the service account exists that Terraform will use as its identity when interacting with Google APIs. Make a service account and a JSON key file to use to configure the Google provider with. Project B is where we'll be either trying to read storagetransfer-related data from, or create resources in. You can give the service account from Project A some project-level permissions in Project B (e.g. make them project Owner, seeing as this is just a bug reproduction and everything will be deleted after) but from what I've seen the error disrupts the process before permissions become relevant. terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "5.30.0"
}
}
}
provider "google" {
credentials = "./path/to/keyfile/for/service-account/in/project-A.json"
project = "project-C" // this provider default isn't used when doing plan/apply with this config - feel free to check
}
data "google_storage_transfer_project_service_account" "default" {
project = "project-B"
} The result is:
Note that the error is reporting that the Storage Transfer API isn't available for use in project A. When I set
Given this information, I can see that there isn't a problem with the The problem appears to be that people believe the API only needs to be enabled where storage transfer resources are being provisioned. @googlyrahman sorry for the looong comment. I see from your profile that you work at Google- I'm at HashiCorp so I'm not able to be active on the internal ticket linked to this issue. Could you please comment on how correct my mental model of the problem is, and whether there are any solutions other than ensuring APIs are enabled in the GCP project that contains the service account used by Terraform? Thanks! |
That's correct, with the mentioned step above - I'm able to reproduce this error. To summarize the above comment: We would be needing minimum of two projects to reproduce this error - Let's call them In this case, both of projects should've STS API enabled, if any of project have not STS API enabled, it would throw the error, so the only solution here is to enable them at both the places. Thanks @SarahFrench for writing such a detailed comment! |
Just to add to what we've described above, it could be complicated some more by using |
I've not been able to find a different outcome when using I'm closing this GitHub issue because:
I recommend that users enable the Note: Enabling the Storage Transfer API can be achieved using the google_project_service resource, however there are a few pitfalls with that resource too. Ensure that the project containing your service account has the Service Usage API enabled, as use of google_project_service depends on that API being enabled. For further information please see this guide. |
…covery_config, as well as fields to support single-resource mode for big_query_target and cloud_sql_target (hashicorp#10798) [upstream:02cf34c5dd30da27f4482b65a616c9eac823ec18] Signed-off-by: Modular Magician <magic-modules@google.com>
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
terraform v1.0.11
google provider version 4.5.0
Affected Resource(s)
google_storage_transfer_job
google_storage_transfer_project_service_account
Terraform Configuration Files
Expected Behavior
the config file should fetch the default storage transfer Job SA of my project.
Actual Behavior
But it is trying pick the default storage transfer Job SA of provider project (where our Terraform cloud is hosted)
This is the same case for google_storage_transfer_job. Eventhough, we clearly mentioned the project ID in the config file. It is trying to create the transfer job in provider project(where TF cloud is hosted)
Getting below error during TF plan execution
Error: Error when reading or editing Google Cloud Storage Transfer service account not found: googleapi: Error 403: Storage Transfer API has not been used in project xxxxxxxxxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/storagetransfer.googleapis.com/overview?project=xxxxxxxxxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Details:
b/302673113
The text was updated successfully, but these errors were encountered: