https://pulumi.com logo
#general
Title
# general
w

wide-holiday-59376

08/29/2019, 6:51 PM
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

gentle-diamond-70147

08/29/2019, 7:03 PM
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

wide-holiday-59376

08/29/2019, 7:08 PM
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

gentle-diamond-70147

08/29/2019, 7:11 PM
No, you can't augment the existing CRUD operations, but you can create your own ComponentResource's.
w

wide-holiday-59376

08/29/2019, 7:12 PM
Would the ComponentResource be able to differentiate between initial deploy, update of existing server, and destroy?
g

gentle-diamond-70147

08/29/2019, 7:14 PM
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

wide-holiday-59376

08/29/2019, 7:18 PM
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

gentle-diamond-70147

08/29/2019, 7:23 PM
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.