Suppose I crated an environment using Terraform script, and then I'd like to add another resource of the same type I already have. For example, I have 2 instances of my app VM and I'd like to add another one. What would be the way to do so?
Suppose I need to work on an environment which was not created using Terraform, or that was created by Terraform but was manually modified. How can I recreate or update the state of Terraform?
- Either copy the existing resource and duplicate it with a different name/id, or set the
countparameter on the existing resource to
- Terraform allows you import existing resources, but it won't create the resource code in your manifests for you, you need to write that yourself. In the case of the actual state diverging from the Terraform manifests you need to either update the code to match or let Terraform apply the necessary changes to make reality match the code again.