Hello, Im new to this community, but I hope someon...
# python
b
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:
Copy code
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:
Copy code
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
not a GCP user, but a fellow Pulumi user. Looks like this should work based on the docs.
b
yes I agree, but it doesn't somehow
e
What version of pulumi_gcp are you using? I think get_databases might be new in 6.51
b
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
I don't think
up
should be installing any python bits? You need to use pip to uninstall and install the wanted version.
b
I tried to do what you suggested by (un)installing with pip, but this still happens when i use `up`:
Copy code
@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
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
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
So up will want to install both
b
Will you elaborate?
e
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
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
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
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
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
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!