T O P

How to ignore a Destroy resource request from an Apply

How to ignore a Destroy resource request from an Apply

FridayPush

You can't easily exclude just a single resource from destruction but you can target individual resources during a plan/apply. [https://learn.hashicorp.com/tutorials/terraform/resource-targeting](https://learn.hashicorp.com/tutorials/terraform/resource-targeting) For example this would only update two resources, a module bucket and a vpc. ``` terraform apply -target=module.mystuff.aws_s3_bucket.test -target=aws_vpc.myvpc ```


2seem

Thanks, this worked.


CalvinR

https://www.terraform.io/docs/language/meta-arguments/lifecycle.html Try `prevent_destroy`


2seem

Tried adding this but terraform apply would not go through because it wanted to destroy it. I lost error message but will try to post it.


CalvinR

You could try ignore changes as well


aayo-gorkhali

Do ignore changes = all or tags or user data or whatever is causing the destruction


moulefrite59

Terraform taint


dlsre

more like terraform untaint in this case