https://pulumi.com logo
Title
s

shy-author-33795

07/07/2021, 7:53 PM
is there a way to destroy a single resource with pulumi inline? I'd love to be able to call a .delete() method to delete a temporary resourced after it's no longer needed
b

bored-oyster-3147

07/07/2021, 8:29 PM
you can do targetted destroys with
--target {urn}
and there is also
--target-dependents
to tell it to destroy the children of your targets as well. Can get messy if there are a lot of children but if it is a resource that has no dependents it shouldn't be bad
l

little-cartoon-10569

07/07/2021, 9:49 PM
A flag in code may be more appropriate. If the temporary resource is skipped (because it's in an if-statement or similar) then it will be destroyed the next time you
up
.
If you destroy it without removing it from the code then you risk 1. having it magically reappear at some point in the future, when Pulumi noticies it's missing from state and provider, and 2. having your code mislead people reading your code, because it's describing something other than reality.
b

bored-oyster-3147

07/07/2021, 9:54 PM
you are correct, that would probably work better.