Thread
#general
    e

    elegant-monkey-64304

    7 months ago
    Hi everyone! How can I define a dependency between a resource and a getter in my code? In my case, I have a PagerDuty ServiceIntegration resource created, and right after that, I need to call getServiceIntegration. I do that because right after the resource is created, a key is generated on the service provider and I'd like to retrieve that. Somehow it's not a part of the resource outputs. Of course, the
    pulumi preview
    fails because it tries to invoke the getter even if the resource doesn't exist yet. I can't use the
    depens_on
    argument as
    ResourceOptions
    has because
    InvokeOptios
    doesn't support that. Many thanks.
    l

    little-cartoon-10569

    7 months ago
    Can you split the project into two? One that prepares the integration, and one that uses it?
    Which key does the resource not provide?
    The integrationKey property is available on the resource. It's listed under inputs, because it can be provided or generated.
    e

    elegant-monkey-64304

    7 months ago
    Hey @little-cartoon-10569, thanks for the answer. I ended up generating the
    integrationKey
    on my side just like you said and provided it as part of the resource, but I was curious if there's a feature on Pulumi supporting the
    depends_on
    functionality between a resource and a getter
    l

    little-cartoon-10569

    7 months ago
    Those getters aren't really getters, they're nice wrappers around the SDK. They don't return resources, they just return dependency-less results objects. Therefore, they probably don't honour the dependsOn opt.
    For some reason, the InvokeOptions link isn't taking me anywhere, so I can't confirm what type it is even...
    You can use ServiceIntegration.get(), which will honour the dependsOn option.
    But if the integrationKey is really output from the ServiceIntegration resource when it's not provided as an input, then that's the way to go in this case. If it's not, then what you did is best.
    e

    elegant-monkey-64304

    7 months ago
    Great, thanks again @little-cartoon-10569!