-
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
Provider configuration values supplied as empty strings/zero-values are no longer treated like null values (muxed provider, v4.60.2+) #14255
Provider configuration values supplied as empty strings/zero-values are no longer treated like null values (muxed provider, v4.60.2+) #14255
Comments
To be clear, when I constrained the provider version to 4.59.0, I was able to run a plan without any other changes. |
@goobysnack it is fine with me for
|
I wasn't sure if the |
Error: JSON credentials are not valid
with provider version 4.60.2
@goobysnack looking closer to below error, it complains the JSON format of your key file. Have you made any changes in your key file? Can you generate a new one to see if that solve the problem?
|
you mean my google account key file? If so, I did both a |
@goobysnack when you use |
GOOGLE_CREDENTIALS is not set. |
@goobysnack there are multiple environment variables that can be used for the key files. From that suggestion here, GOOGLE_CREDENTIALS is just one of them. I just wanted to make sure you were using It seems a little weird for below error while you authenticated yourself with
To be clear, I do see there was an update in the v4.59.0 and you have confirmed v4.59.0 works for you. |
yup, I ran both gcloud auth commands.
|
@trodge do you have any idea what could go wrong? |
FYI I did a full revoke of all credentials and retried with 4.61.0 and got the same error. |
Hi @goobysnack! I'm sorry you're running into this issue. I'm unable to reproduce it, nor do I see any differences in the code where I would expect to see differences. Could you share your provider config block with me and let me know which environment variables you're defining please? Thanks! |
The issue is persisting for me with provider version |
I'll reopen for more investigation but, just to manage expectations, I can't look into this until next week earliest. Hopefully that isn't an issue as there's the workaround you described! |
Just adding another example of the ╷
│ Error: Error creating Project: googleapi: Error 403: Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the firebase.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/. If you are getting this error with curl or similar tools, you may need to specify 'X-Goog-User-Project' HTTP header for quota and billing purposes. For more information regarding 'X-Goog-User-Project' header, please check https://cloud.google.com/apis/docs/system-parameters.
│ Details:
│ [
│ {
│ "@type": "type.googleapis.com/google.rpc.ErrorInfo",
│ "domain": "googleapis.com",
│ "metadata": {
│ "consumer": "projects/764086051850",
│ "service": "firebase.googleapis.com"
│ },
│ "reason": "SERVICE_DISABLED"
│ }
│ ]
│
│ with module.firebase.google_firebase_project.this,
│ on ../../main.tf line 45, in resource "google_firebase_project" "this":
│ 45: resource "google_firebase_project" "this" {
│
╵ Some blogs suggest creating a service account in Terraform and then source the service account's key directly into provider "google-beta" {
project = "foo"
credentials = base64decode(google_service_account_key.terraform_service_account.private_key)
} But this breaks after │ Error: unable to parse credentials
│
│ with module.firebase.provider["registry.terraform.io/hashicorp/google-beta"],
│ on ../../main.tf line 6, in provider "google-beta":
│ 6: provider "google-beta" {
│
│ unexpected end of JSON input |
Hi @briananstett thanks for this example, it helps a lot. I’m in an EMEA time zone so can’t look into this now but can do tomorrow. I wanted to briefly come online and ask some questions real quick: If you’re able, it would be helpful to have some debug logs from when you experience the issue. 🙏 If that’s not possible, am I right thinking that to reproduce the issue in a minimal way I only need to include:
|
Hey @SarahFrench, attached is a file with some Terraform code I used to reproduce the error. I've also attached the debug logs.
Almost.
Steps to reproduce
╷
│ Error: unable to parse credentials
│
│ with provider["registry.terraform.io/hashicorp/google-beta"],
│ on main.tf line 21, in provider "google-beta":
│ 21: provider "google-beta" {
│
│ unexpected end of JSON input
╵ |
@briananstett Thanks for this, it's a big help! I've found the cause of that issue but I'm going to open a separate issue for it to help with search-ability in GitHub Edit: here is is - #14444 |
I returned to looking at the original issue of setting Problems observed with
|
creds, err := googleoauth.CredentialsFromJSON(ctx, []byte(contents), clientScopes...) | |
if err != nil { | |
diags.AddError("unable to parse credentials", err.Error()) | |
return googleoauth.Credentials{} | |
} |
The reason why v4.59.0 didn't return an error when credentials = ""
was because previously some of the code used expressions like != ""
to check whether credentials differed from the zero value (implicitly asking if it had been set by a user). Now the plugin framework in v4.60.2+ is better at detecting when values are supplied by a user or not, so it's less possible for user-supplied values that match Go's zero values to slip through unnoticed. If anything this was a bug in the old SDK code!
Conclusion
I think that the new behaviour is more correct than the old behaviour with the SDK, though it is a breaking change. But the fix in the config is easy. I'm open to discussion in this issue if there's strong objections to leaving things as it is, and will ask my team mates for their opinions too.
Also, if we decide not to fix this issue we may need to return to saying that |
Error: JSON credentials are not valid
with provider version 4.60.2
Yup. Works and understood/agree. Thanks for all your hard work on this! Cheers. |
We've decided to update future 4.x.x versions to have parity with the old versions of the provider that only used the SDK to structure the code. When 5.0.0 comes around we'll remove the ability to set provider arguments as "" and have them ignored by the code in favour of ENVs/ADC/etc. So, I'll leave this issue open until the provider config logic has been updated to allow |
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
v1.1.9
Affected Resource(s)
Google Provider
When I constrained to version 4.59.0, the issue resolved.
Panic Output
Expected Behavior
Plan should have run
Actual Behavior
Plan failed
Steps to Reproduce
terraform plan
Important Factoids
References
The text was updated successfully, but these errors were encountered: