Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceOptions.dependsOn only accepts Resources and not Output<Resource> #991

Closed
swgillespie opened this issue Mar 1, 2018 · 4 comments · Fixed by #2198
Closed

ResourceOptions.dependsOn only accepts Resources and not Output<Resource> #991

swgillespie opened this issue Mar 1, 2018 · 4 comments · Fixed by #2198
Assignees
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/design An engineering design doc, usually part of an Epic
Milestone

Comments

@swgillespie
Copy link
Contributor

Working through the issues in pulumi/pulumi-cloud#404 discovered that it's not possible to use Output<Resource> with dependsOn, since there is no way to get an Output's list of resource dependencies. We may want to consider allowing Output<Resource> for dependsOn so that this works correctly.

@swgillespie swgillespie added impact/usability Something that impacts users' ability to use the product easily and intuitively kind/design An engineering design doc, usually part of an Epic labels Mar 1, 2018
@brandonbloom
Copy link

I just ran in to this. Assumed it would work, but got scolded by tsc. I ran in to this because I was using another Output's apply method to get a parameter for a resource.

@brandonbloom
Copy link

Also just figured out a workaround: Use another apply call.

@brandonbloom
Copy link

Now that I have a bit more experience, a warning for onlookers: Additional apply calls makes preview less useful. It's advisable to avoid creating resources in apply for that reason.

@brandonbloom
Copy link

Here's another workaround that depends on internals:

let outputDeps = <T>(output: pulumi.Output<T>) => {
  return (<any>output).resources() as Iterable<pulumi.Resource>;
};

You can use it like:

{dependsOn: [...outputDeps(someOutput)]}

@joeduffy joeduffy added this to the 0.19 milestone Oct 29, 2018
@joeduffy joeduffy assigned joeduffy and unassigned pgavlin Oct 29, 2018
joeduffy added a commit that referenced this issue Nov 13, 2018
This changes the input type for dependsOn from simply
`Resource[] | Resource` to `Input<Input<Resource>[]> | Input<Resource>`.
This permits `Output<Resource>`s, etc in addition to
`Promise<Resource>`s. The logic for dynamically unpicking the right
types and recursing through the data structures isn't straightforward,
but I've written a test for all of the interesting permutations.

This fixes #991.
joeduffy added a commit that referenced this issue Nov 13, 2018
This changes the input type for dependsOn from simply
`Resource[] | Resource` to `Input<Input<Resource>[]> | Input<Resource>`.
This permits `Output<Resource>`s, etc in addition to
`Promise<Resource>`s. The logic for dynamically unpicking the right
types and recursing through the data structures isn't straightforward,
but I've written a test for all of the interesting permutations.

This fixes #991.
joeduffy added a commit that referenced this issue Nov 19, 2018
This changes the input type for dependsOn from simply
`Resource[] | Resource` to `Input<Input<Resource>[]> | Input<Resource>`.
This permits `Output<Resource>`s, etc in addition to
`Promise<Resource>`s. The logic for dynamically unpicking the right
types and recursing through the data structures isn't straightforward,
but I've written a test for all of the interesting permutations.

This fixes #991.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/design An engineering design doc, usually part of an Epic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants