Q1: Suppose you created an ec2 instance with terraform and after creation, you have removed the entry from the state file now, when you run terraform apply what will happen?
- As we have removed the entry from that state file so terraform will no longer manage that resource so on the next apply it will create a new resource.
Q2: What is a state file in Terraform?
- A state file is a file in which Terraform keeps track of all the infrastructure that is deployed by it.
Q3: What is the best way to store the terraform state file?
- The best way to store the state file is to keep it in the remote backend like S3 or GitLab-managed terraform state so, that whenever multiple people are working on the same code resource duplication won’t happen.