https://pulumi.com logo
r

rhythmic-hair-33677

12/13/2019, 6:28 PM
Is it possible to detect if an action was taken in an output apply? i.e. create, update
a

astonishing-cartoon-37000

12/13/2019, 6:40 PM
you mean like
Copy code
// pseudo code
const resource1 = new pulumi.resource()
resource.apply(val => {
   const resource2 = new pulumi.resource()
})
and see if resource 2 gets updated?
Because I have noticed that if I create resource inside of an apply it doesn't show up until the update is actually run. IE, preview doesn't show anything
which I think make sense because it wouldn't know the value of the output until it is actually run
r

rhythmic-hair-33677

12/13/2019, 7:35 PM
No. I know you can’t create resources inside an apply. What I am looking to do is perform a validation inside of an apply something like this:
Copy code
resource.apply(val => {
  if (val.wasCreate() || val.wasUpdate()) {
     validate(val)
  }
})
As it is now, the function in apply always runs.
a

astonishing-cartoon-37000

12/13/2019, 8:29 PM
oh that's interesting. I see what you're getting at. I have never tried something like that. what is the downside of validating even if the resource wasn't updated?
Sorry I don't have a good answer. really just curious 😄