azure - 关于 terraform 脚本行为
问题描述
我正在使用 Terraform 脚本创建天蓝色服务,我对 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、plan、apply。 - terraform 会将您当前状态文件中的内容与您的配置文件进行比较,然后更新新属性或创建新资源,而不是重新创建现有资源。
- 您可以运行terraform import将现有基础设施导入 Terraform。要引用门户中的现有资源,您可以使用数据源。
推荐阅读
- c# - 如何在 C# 中的 program.cs 中处理按钮单击事件
- codenameone - 在 Codename One 中捕捉和播放方形视频和照片
- r - 在 R 函数中打印列的文字名称?
- python - Sympy:包含平方根的多项式的因式分解
- f# - 长颈鹿 routef 异步函数
- c++ - 你可以让一个函数成为一个 const 并返回一个 const C++
- python - 根据不在它旁边的 DLL 加载 python 模块
- java - 如何获取玩家正在查看的块的坐标?
- javascript - 使用 AES/ECB/NoPadding 和 base 64 和 crypto-js 库实现的不正确的解密字符串
- android - MlKit vision 在不同的手机上返回不同的值