Karan srivastav
Karan srivastav

Reputation: 3

Regarding terraform script behaviour

I am using Terraform scripts to create azure services, I am having some doubts regarding Terraform,

1) If I have one environment let say dev in azure having some azure resources how can I copy all the resources to new environment lest say prod using terraform script.

2)what are the impact of re-run the terraform file with additional azure resources, what it will do.

3)What if I want to create an app service with the same name from Terraform script that already present in the azure will it update the resource or do nothing after terraform execution completed. 

Please feel free to answer the question, it will be great help.

Upvotes: 0

Views: 89

Answers (1)

Nancy Xiong
Nancy Xiong

Reputation: 28204

To answer your questions:

  1. You could create a new workspace with terraform workspace new and copy all configuration files (.tf) to the new environment, then run terraform init, plan, apply.
  2. The terraform will compare the content in your current state file with your configuration file, then update the new attributes or creating new resources other than re-creating the existing resources.
  3. You could run terraform import to import existing infrastructure into Terraform. For referencing existing resources in the portal, you can use data sources.

Upvotes: 1

Related Questions