This message was deleted.
# general
s
This message was deleted.
e
You could just throw an exception. We track every apply that's started and wait for all of them to finish before we call a program complete so we should pick up the exception. It is a bit odd though. What sort of things are those methods doing? If its just validation before passing on to other inputs I'd probably recommend doing it more like:
Copy code
outputX = outputX.Apply(x => validateX(x); return x)
Such that anything using this value will only see it if it's been validated.
e
It does seem odd, but I don't see how else I can do it. The goal is to have classes that can reuse some logic, so the validation is done at the initialization of said class like that (on resource tags for example):
Copy code
_ = args.Tags.Apply(t =>
{
  if (t["tier"] == "prod")
  {
    Common.ValidateTags(t);
  }

  return true;
});
Where an exception is thrown if the validation fails. Another use case that feels hacky is if I have to wait for a resource to be created, I literally discard the value:
Copy code
_ = privateZone.Id.Apply(_ =>
{
  CreatePrivateEndpoint();
  return true;
});
Inside CreatePrivateEndpoint, I use "GetPrivateZone" which uses parameters from another part of the code (which doesn't use Inputs). This is to make the method more flexible (it supports private zones created from Pulumi and from the web console).
e
So why isn't that first one more like:
Copy code
args.Tags = args.Tags.Apply(t =>
{
  if (t["tier"] == "prod")
  {
    Common.ValidateTags(t);
  }

  return t;
});
? The second one, you might want to look at the dependsOn resource option. Lets you delay the creation of other resources until one has resolved.
e
Oh wow, this does seem so much better. For the DependsOn option, it's a good idea too, I'll check if I can refactor the classes I've made to use that instead. Thanks a lot!