https://pulumi.com logo
b

bland-florist-25081

01/30/2020, 11:21 AM
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

green-school-95910

01/30/2020, 11:22 AM
gcp.config.project
b

bland-florist-25081

01/30/2020, 11:23 AM
I tried that. Returns
None
. 😞
Using Python, so I tried
pulumi_gcp.config.project
g

green-school-95910

01/30/2020, 11:24 AM
Are you using the credentials from default environment or setting on your stack config?
b

bland-florist-25081

01/30/2020, 11:24 AM
Just my default environment.
g

green-school-95910

01/30/2020, 11:29 AM
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

bland-florist-25081

01/30/2020, 11:30 AM
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

green-school-95910

01/30/2020, 11:31 AM
Are you using user credentials of a service account?
b

bland-florist-25081

01/30/2020, 11:31 AM
No, just the standard
gcloud login
with my user.
g

green-school-95910

01/30/2020, 11:35 AM
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

bland-florist-25081

01/30/2020, 11:41 AM
Thanks. I might actually just get the output of the gcloud command and set project, region etc with that.