sparse-intern-71089
08/03/2023, 5:46 PMlittle-cartoon-10569
08/03/2023, 8:39 PMpulumi preview
for this. You can get its output in JSON format (--json
) for easier manipulation.cool-scientist-53915
08/03/2023, 8:43 PMdependsOn
, right? If those things don't change for a given resource, then it won't be modified. So there must be some way (during runtime of pulumi up
) to know whether an Input
or Resource
has changed.little-cartoon-10569
08/03/2023, 8:45 PMlittle-cartoon-10569
08/03/2023, 8:45 PMlittle-cartoon-10569
08/03/2023, 8:47 PMcool-scientist-53915
08/03/2023, 8:53 PMsomeResource.someAttribute.apply((x) => { /* do stuff here */})
, then within body of the function passed to apply
, x
is a concrete value, a string or whatever it is on the resource. That must happen after the provider plugin runs, right? And I can create further resources inside that function, and at that point, it must be known whether someResource
was updated or not, no?little-cartoon-10569
08/03/2023, 9:05 PMcool-scientist-53915
08/03/2023, 9:06 PMcool-scientist-53915
08/03/2023, 9:06 PMlittle-cartoon-10569
08/03/2023, 9:07 PMcool-scientist-53915
08/03/2023, 9:08 PMcool-scientist-53915
08/03/2023, 9:08 PMlittle-cartoon-10569
08/03/2023, 9:09 PMapply()
, true. But: don't do that.cool-scientist-53915
08/03/2023, 9:12 PMapply()
. Every resource that has inputs must actually wait until they've been concretely resolved for real before the resource can be actually created. That's all I'm looking for.little-cartoon-10569
08/03/2023, 9:15 PMapply()
.cool-scientist-53915
08/03/2023, 9:17 PMlittle-cartoon-10569
08/03/2023, 9:18 PMlittle-cartoon-10569
08/03/2023, 9:18 PMlittle-cartoon-10569
08/03/2023, 9:19 PMlittle-cartoon-10569
08/03/2023, 9:19 PMcool-scientist-53915
08/03/2023, 9:20 PMconst cmd = new command.remote.Command("foo", {connection, create: "hostname"});
const thing2 = new otherResource("bar", {someAttribute: cmd.stdout});
cool-scientist-53915
08/03/2023, 9:21 PMapply()
explicitly there.little-cartoon-10569
08/03/2023, 9:25 PMconst cmd = new command.remote.Command("foo", {connection, create: "hostname"});
cmd.stdout.apply((t) => {
if (t.match(/go for it/) {
const thing2 = new otherResource("bar", {someAttribute: t});
}
});
Your snippet doesn't decide anything: it declares two resources, unconditionally. My snippet decides whether or not to create a resource based on the output of another resource. This isn't declarative and I think it's a bad idea. The same problem can be solved safer by using automation-api.cool-scientist-53915
08/03/2023, 9:28 PMapply()
I think you keep saying that. I'm not necessarily opposed to it, I'm just saying that obviously resources depend on the output of other resources all the time, and those outputs have to be concretely known prior to the downstream resources actually being created. There's nothing different between knowing the output of an attribute of an upstream resource before actually creating the downstream resource and knowing whether the upstream resource changed.little-cartoon-10569
08/03/2023, 9:32 PMcool-scientist-53915
08/03/2023, 9:47 PMlittle-cartoon-10569
08/03/2023, 9:56 PMlittle-cartoon-10569
08/03/2023, 9:57 PMclever-sunset-76585
08/06/2023, 4:19 AM--json
flag to get the list of steps and figure out the operation based on the type token, in your case, the EC2 instance resource. However, I realize this is not what you are looking for exactly. There just isn't a programmatic way to do that right now. Not even with the Automation SDK.
Perhaps https://github.com/pulumi/pulumi/issues/1691 might provide you with what you are looking for, in which case, feel free to +1 it. However, it's at a per-resource level.
One idea that you might be able to try is, create a dynamic provider and make it depend on your EC2 instance resource. That dependency would then allow you to implement custom logic in the callbacks based on some property changes in the dependent resource. For example, you could depend on the ID property of all of your instances in this dynamic provider and detect changes in inputs via the callbacks in the dynamic provider. I am not sure how effective this will be in practice, to be honest.