Hi, I want to create a persistent disk but it seem...
# google-cloud
b
Hi, I want to create a persistent disk but it seems the project parameter is required instead of using the currently active project. How can I get the currently set project ID?
gcloud config get-value project
returns the correct value but I can't figure out how to get it in pulumi.
g
gcp.config.project
b
I tried that. Returns
None
. 😞
Using Python, so I tried
pulumi_gcp.config.project
g
Are you using the credentials from default environment or setting on your stack config?
b
Just my default environment.
g
I think, not sure, pulumi gcp provider is supposed to recognize the project from environment I don't know the API in Python, but there is a
runtime.setConfig
on JS that you could use to set the "gcp:project" on the go
Of course, that would make it explicit that you are using the project from your environment and ignore what was already on the stack, which is not a good thing most of the time
b
Ok, thanks. Yes, it gets it correctly when I explicitly set it in the env. Not sure where gcloud gets its configuration from but seems pulumi is not using the same. I'll see that I set the env vars correctly. Thanks for your help.
g
Are you using user credentials of a service account?
b
No, just the standard
gcloud login
with my user.
g
Gcloud has a state saved in a file with all your configs, it looks for environment variables first and then this file Try getting your project and credentials using
Copy code
from google.auth import default
project, credentials = default()
See if the project and credentials are set correctly gcloud has a mess of a chain of fallbacks
b
Thanks. I might actually just get the output of the gcloud command and set project, region etc with that.