Specifically, I want to interact with an ec2 serve...
# general
w
Specifically, I want to interact with an ec2 server after it's up (copy files to it, spawn new processes etc) and it's not clear what is the right way to do this. Currently I dumped my code into the main code block and it's running twice (which is bad). Once for the "diagnostics" step and once for "update" step. Any ideas?
g
You can use https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/runtime/#isDryRun to only run during the
update
. We don't currently have lifecycle type events that you can hook into.
w
I saw you have the concept of custom resources whose providers manage CRUD operations. Is there a way for me to add functions to the existing CRUD operations for an aws instance?
So that my code would run after-create and before-destroy?
g
No, you can't augment the existing CRUD operations, but you can create your own ComponentResource's.
w
Would the ComponentResource be able to differentiate between initial deploy, update of existing server, and destroy?
g
Err... sorry, I think you'll want dynamic provider - that way you can get
create
,
update
,
delete
calls. https://www.pulumi.com/docs/intro/concepts/programming-model/#dynamicproviders
w
I'll give that a try. So the assumption is that this custom resource will run alongside the server instance and mirror its state?
g
It would be a separate resource with its own state. You can pass other resource outputs into the resource(s) provided by your dynamic provider to "integrate" them.