Hi, is there a way to let a `get*` function not ru...
# general
e
Hi, is there a way to let a
get*
function not run until another resource is created? I do not see the
depends_on
option for
InvokeOptions
. Thanks
d
There should be an
_output
variant of the get function. This allows arguments to be outputs. A workaround would be to use an output from a resource to defer the call, for example:
Copy code
vpc = get_vpc_output(default=my_resource.id.apply(_: True))
e
Thanks for your reply. My usecase is:
Copy code
import pulumi_gcp as gcp

project = gcp.organizations.Project(
    "project",
    name="project",
    project_id="project",
    billing_account="bills",
    auto_create_network=False,
)

vpc = gcp.compute.Network(
    "vpc",
    name="vpc",
    auto_create_subnetworks=False,
    project=project.name,
)

subnet = gcp.compute.Subnetwork(
    "subnet",
    name="subnet",
    network=vpc.id,
    region="us-central1",
    ip_cidr_range="10.0.0.0/8",
    private_ip_google_access=True,
    project=project.name,
)

gcp.compute.get_zones_output(
    region=subnet.region,
    project=subnet.project,
    status="UP",
)
but I still get the error that the project does not exist.
d
Does the error happen during preview?
e
yes
Copy code
Exception: invoke of gcp:compute/getZones:getZones failed: invocation of gcp:compute/getZones:getZones returned an error: invoking gcp:compute/getZones:getZones: 1 error occurred:
    	* googleapi: Error 404: The resource 'projects/project' was not found, notFound
d
https://github.com/pulumi/pulumi/issues/9593 This seems related, basically pulumi is "assuming" the
name
output is the same as input, instead of treating the output use as a dependency, so uses it too early. I've seen it before, not really keen on this kind of optimisation. You should be able to do
project=subnet.id.apply(_: subnet.project)
Or the more explicit
Output.all(subnet.id, subnet.project).apply(args: args[1])
Can you raise an issue to have
depends_on
added to InvokeOptions please? It's been mentioned in a couple of issues, but never got its own
e
Sure
d
Thanks, I've added some references to the issue