Establishing a dependency will ensure your resource is deleted before the resource it depends on.
To ensure this works as expected during replacements, you will also need to ensure that the property you use to depend on the EC2 instance ID returns replacements from
diff
when the instance ID changes so that you trigger a cascading replacement of your resource (to run scripts on the new instance).
s
some-doctor-62800
08/29/2019, 10:04 PM
@white-balloon-205 this is very related to my question, is there some way to help pulumi see deps and deletion order across stacks?
w
white-balloon-205
08/29/2019, 10:09 PM
The state file includes details of dependencies.
s
some-doctor-62800
08/29/2019, 10:10 PM
But deletion order will be wrong as they're two runs
w
white-balloon-205
08/29/2019, 10:13 PM
Not sure I follow "two runs"? Are these in separate stacks? There is indeed no general purpose way to do this across stacks - though I also don't have a full picture of exactly what you are trying to do.
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.