https://pulumi.com logo
Title
b

busy-lawyer-33856

03/13/2023, 6:39 AM
Hello, Im new to this community, but I hope someone can help me with my problem. I originally posted this in generel, before i realised this was the more suitable channel. Im trying to access my db from GCP with python like this:
db_instance = gcp.sql.DatabaseInstance.get("databaseinstance-resource",
        id="ID"
    )
    dbs = gcp.sql.get_databases(instance=db_instance.id)
However, I get an attribute error:
AttributeError: module 'pulumi_gcp.sql' has no attribute 'get_databases'
I got the method from the documentation: https://www.pulumi.com/registry/packages/gcp/api-docs/sql/getdatabases/ I will greatly appraciate some help! Best Regards Elias
r

rhythmic-branch-12845

03/13/2023, 9:01 AM
not a GCP user, but a fellow Pulumi user. Looks like this should work based on the docs.
b

busy-lawyer-33856

03/13/2023, 9:02 AM
yes I agree, but it doesn't somehow
e

echoing-dinner-19531

03/13/2023, 9:59 AM
What version of pulumi_gcp are you using? I think get_databases might be new in 6.51
b

busy-lawyer-33856

03/13/2023, 12:48 PM
That could be the problem, as Im using 6.49.0 version og pulumi_gcp. However, when I run
pulumi up
after I have uninstalled the old version and installed 6.51.0, it just reinstall the 6.49 version again. As if it ignores the 6.51 version. Do you know what goes wrong?
e

echoing-dinner-19531

03/13/2023, 3:29 PM
I don't think
up
should be installing any python bits? You need to use pip to uninstall and install the wanted version.
b

busy-lawyer-33856

03/14/2023, 6:21 AM
I tried to do what you suggested by (un)installing with pip, but this still happens when i use `up`:
@pop-os:~/$ pulumi up
Enter your passphrase to unlock config/secrets
    (set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember): 
Previewing update (starlab-stack):
Downloading plugin gcp v6.49.0: 47.01 MiB / 47.01 MiB [=============] 100.00% 2s
     Type                 Name                   Plan     Info
     pulumi:pulumi:Stack  starlab-starlab-stack           1 error
e

echoing-dinner-19531

03/14/2023, 11:38 AM
Ah you've probably got 6.49.0 recorded in your state, but if you pip install the new 6.51 python package it should download that also
b

busy-lawyer-33856

03/14/2023, 2:56 PM
I agree with you. I have pip installed 6.51 and get confirmation it installed successfully in the terminal, but when i run
up
it ignores it and install 6.49 as shown above.
e

echoing-dinner-19531

03/14/2023, 4:09 PM
So up will want to install both
b

busy-lawyer-33856

03/14/2023, 4:10 PM
Will you elaborate?
e

echoing-dinner-19531

03/14/2023, 4:11 PM
So if you have pip install 6.51 but your state still refers to 6.49 then up will want to install the plugins for both versions. If one is already installed it will just install the missing one. Importantly up is only installing pulumi plugins, it is not installing python pip packages.
b

busy-lawyer-33856

03/14/2023, 4:15 PM
Alright, it doesn't install the plugin for 6.51 by itself but if i install the plugin myself with
pulumi plugin install resource gcp
, i still have the problem
e

echoing-dinner-19531

03/14/2023, 4:17 PM
Well
AttributeError: module 'pulumi_gcp.sql' has no attribute 'get_databases'
is nothing to do with the plugin, that's still just plain python. I think that's just because get_databases is only in the 6.51 pip package https://github.com/pulumi/pulumi-gcp/blob/v6.51.0/sdk/python/pulumi_gcp/sql/get_databases.py#L75
Change to 6.50 tag and that file isn't present anymore.
r

rhythmic-branch-12845

03/15/2023, 3:50 AM
sorry but I'm only half-following here. @echoing-dinner-19531 are you saying that the state also records down the version of the packages that are/were used? How do we view/edit/change these version numbers?
e

echoing-dinner-19531

03/15/2023, 9:08 AM
are you saying that the state also records down the version of the packages that are/were used?
Yes, because if you run a destroy we need to know what provider to use. We're looking at changing the behaviour here for up to try and skip the state provider as long as the program sends a provider to use instead but it's a tricky fix.
How do we view/edit/change these version numbers? (edited)
stack export and stack import would let you edit this, but in general it should be necessary. Again the error in your first post is nothing to do with plugin versions. Update to the latest pip package and you shouldn't get a "no attribute" error, then just let the engine run as normal it will want both provider versions but will only use the latest one.
b

busy-lawyer-33856

03/15/2023, 9:42 AM
The problem is fixed is now, I'm a bit unsure what actually fixed the problem in the end. Honestly I may have finally uninstalled the old version correct - though I'm pretty sure I had already done it. Regardless, thank you very much with all the help concerning this issue 🙂 It is much appreciated!