关于地形脚本行为
Regarding terraform script behaviour
我正在使用 Terraform 脚本创建 Azure 服务,我对 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.
请随时回答问题,会有很大帮助。
回答您的问题:
- 您可以使用 terraform workspace new 创建一个新工作区并将所有配置文件 (
.tf
) 复制到新环境,然后 运行 terraform init、计划、应用。
- terraform 会将您当前状态文件中的内容与您的配置文件进行比较,然后更新新属性或创建 re-creating 现有资源以外的新资源。
- 你可以 运行 terraform import to import existing infrastructure into Terraform. For referencing existing resources in the portal, you can use data sources.
我正在使用 Terraform 脚本创建 Azure 服务,我对 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.
请随时回答问题,会有很大帮助。
回答您的问题:
- 您可以使用 terraform workspace new 创建一个新工作区并将所有配置文件 (
.tf
) 复制到新环境,然后 运行 terraform init、计划、应用。 - terraform 会将您当前状态文件中的内容与您的配置文件进行比较,然后更新新属性或创建 re-creating 现有资源以外的新资源。
- 你可以 运行 terraform import to import existing infrastructure into Terraform. For referencing existing resources in the portal, you can use data sources.