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

fresh-pilot-59899

04/17/2019, 9:42 AM
Is there a way to destroy only a resource from a stack? cannot find any option in the docs: https://pulumi.io/reference/cli/pulumi_destroy.html
s

shy-army-45455

04/17/2019, 9:51 AM
Pretty sure if you comment it out of the code and then pulumi up it will delete the removed resource
w

white-balloon-205

04/17/2019, 3:31 PM
Yes - commenting out and then `update`ing is generally the best way to do this if it can work since it retains the code matching the desired state of your infrastructure. However, there is also a
pulumi state delete '<urn>'
command which can force delete a resource out of your state file. This will not take care or deleting from your cloud provider - so you would need to manually do that yourself. And then if you haven't changed your code, the resource would get recreated on the next
update
.
f

fresh-pilot-59899

04/17/2019, 5:04 PM
@shy-army-45455, @white-balloon-205 thanks for the replies. Commenting out the code is more a workaround and does not scale well with a big infrastructure with dependencies
actually would be nice to have an option in the 'pulumi destroy -resource resource_name'
w

white-balloon-205

04/17/2019, 6:20 PM
pulumi destroy -resource resource_name
Yes - this is something we could support in the future. Just to make sure, you want that to delete the resource in the cloud provider, but then you want a
pulumi update
immediately afterward to re-create it?
f

fresh-pilot-59899

04/17/2019, 6:55 PM
yes, I want to delete it and all dependencies in the cloud provider and then recreate it using pulumi up
w

white-balloon-205

04/17/2019, 6:57 PM
Okay - that makes sense. I've added this to https://github.com/pulumi/pulumi/issues/2317 which was tracking the same thing for update and refresh as well, but we should include destroy as well when we implement that.
f

fresh-pilot-59899

04/17/2019, 6:58 PM
ok, thanks, let's hope someone will pick it up