My Terraform resource file looks like this :
resource "aws_instance" "ubuntu14" {
instance_type = "t2.medium"
ami = "${lookup(var.aws_amis_ubuntu14,var.aws_region)}"
tags {
Name = "${var.user_label} - Ubuntu 14 - Fresh Agent Install - ${count.index}"
}
key_name = "${var.aws_key_name}"
vpc_security_group_ids = ["${lookup(var.security_group_id,var.aws_region)}"]
count = "${var.count}"
....
I already have a machine running and do not want to destroy it .
How do i achieve that in terraform apply?
Terraform plan shows the following : Plan: 2 to add, 0 to change, 1 to destroy.
I want to keep all 3
Unfortunately you'll have to take the information out of your state file. You can do this by hand (tedious and not recommended) or you can use Terraform state rm.
See documentation at: https://www.terraform.io/docs/commands/state/rm.html