I'm trying to associate pulumi resource URNs with ...
# automation-api
r
I'm trying to associate pulumi resource URNs with logical resources that I have outside of my pulumi automation code and am having a trouble understanding the Diagnostic message StreamID's purpose. The goal of all this is to parse a preview plan so that I can automatically perform some action before my pulumi code executes. For example, let's say I want to resize an instance with an attached disk with a zfs pool on it. I want to be able to parse this plan, identify that I'm resizing an instance, and then ssh into the instance and
docker stop
my workload and
zpool export
the zpool before the instance gets shut down to reliably preserve data integrity. So I'm trying to send diagnostic messages that identify which URN associates with which logical resource so I know which machine to SSH into. I've looked into custom providers to add this logic to the execution DAG, but felt that the workflow in golang was too complex, especially for distribution across my team since I need to manage multiple binary versions (one for my program and the other for the custom provider). So when I send a diagnostic message like this:
Copy code
ctx.Log.Debug(string(msg), &pulumi.LogArgs{
		Resource: resource,
		StreamID: 12345,
	})
}
The message and resource urn get preserved in the resulting EngineEvent, but the streamID is always 0. Am I just doing this wrong or not understanding what streams are?
As an aside, maybe I should rethink moving this logic into a custom provider again now that my codebase is more mature? This is tricky in and of itself though, since the provider would be managing ssh connections to machines that are part of pulumi's DAG, and writing this in a reliable way would be very tricky
e
I don't think anything has ever really used streamID before so it might have some bugs where it just gets dropped. It supposed to be a way of grouping log messages together. If you raise an issue we can take a look, hopefully nothing hard probably just a field copy missed somewhere.