Destroy specific Node in terraform

Hi Team,
Currently we are using Terraform to create servers.
One of requirement is to delete a specific server from terraform.
Kindly provide any possibility with terraform.

Thanks in advance,
Sharath Mankala

Hi Sharath,

Yes, terraform can destroy a specific resource using the -target flag.

Example: terraform destroy -target RESOURCE_TYPE.NAME

Reference link: https://www.terraform.io/docs/commands/plan.html#resource-targeting

Hi Ravi,
root@smankala:~/teraform/staging# terraform state list

clc_server.node[0]
clc_server.node[1]
null_resource.configure-ips[0]
null_resource.configure-ips[1]
null_resource.examplerr6
root@smankala:~/teraform/staging# 

above is my terraform state.
i want to delete sever with specific IP.
is their any possibulity.
Thanks in Advance.

You can find the IP if you download the state file.
terraform state pull > state.json

Then look at the state.json file, and you should be able to determine which of the 0/1 state resources is the one you want to delete