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 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
HI @fortman,
We are using private cloud(aws).
My requirement is kubernets worker node autoscaling,
I am able to cteate servers using Terraform.
I am strutted at deleting servers.
so suggest me how can i delete specific server using terraform.
Thanks in advance.
Hi @sharathmankala,
Terraform is not suitable for implementing autoscaling, because it cannot react to events such as instances becoming unhealthy, etc.
Instead, you can use Terraform to launch an AWS Autoscaling Group, and then the AWS autoscaling service will be responsible for creating and destroying individual servers. Terraform will then manage only the group as a whole, not the individual servers. Normally with autoscaling we let the system automatically create and destroy servers as needed, but if you find you need to manually destroy a server for some reason then you’d need to work directly with the AWS EC2 or AutoScaling APIs to do that, because Terraform is not managing the individual servers and so will not take any actions relating to them.