Skip to content
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

Improve UX when a service account isn't used. #6780

Comments

@MaxRenaud
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

The Google provider requires the setting of an environment variable or a link to the service credentials in the provider configuration. This is true even if the user has gcloud installed and is logged in via "gcloud auth login". When attempting to apply a plan, the user is redirected to this website to create a service account:
https://cloud.google.com/docs/authentication/production
That website is a bit heavy for our use case and greets the visitor with code in 7 programming languages.

The provider documentation reference located at:
https://www.terraform.io/docs/providers/google/guides/provider_reference.html#credentials
marks the credentials as optional so it's not unreasonable to assume that a user authenticated with the gcloud CLI would use these credentials by default.

As it turns out, the quickest way to get started is to run this:
gcloud auth application-default login
then export GOOGLE_APPLICATION_CREDENTIALS to point to the newly created json file.

While creating SA is best practices, we should give the user the option to apply the plan as their currently logged-in user. This adds values for prototyping and debugging.

I propose the following:

  1. Add the "gcloud auth application-default login" command tip to the "could not find default credentials" error message. That way, the quick fix for the error is right in the error message.
  2. When no credentials are supplied, default to the default output location for "gcloud auth application-default login". On linux, it is ~/.config/gcloud/application_default_credentials.json

That way someone trying a tutorial or just playing around with the provider will be able to quickly get started.

New or Affected Resource(s)

  • google (provider)

Potential Terraform Configuration

N/A

References

N/A

@nat-henderson
Copy link
Contributor

Thanks! Added this message in a few places that someone playing around is likely to find, as well as in the main error message they are likely to see.

Fortunately, the second suggestion, to use the default output location, is already incorporated - if it didn't work for you when you tried it please let me know and we can debug! But we call https://godoc.org/golang.org/x/oauth2/google#FindDefaultCredentials (via https://godoc.org/golang.org/x/oauth2/google#DefaultTokenSource), which explicitly documents that it attempts that path.

@MaxRenaud
Copy link
Author

Thanks ndmckinley,
I tried this again and can confirm that #2 is a non-issue. Thanks for for PR.

@ghost
Copy link

ghost commented Aug 20, 2020

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.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.