我的根目录下有一个单独的main.tf模块,其下有用于 Azure 云的不同部分的不同模块,例如
main.tf
- apim
- firewall
- ftp
- function
Run Code Online (Sandbox Code Playgroud)
将main.tf变量传递到各个模块,例如资源组名称或标签映射。
在开发过程中,我一直在使用门户研究某些功能,但我还没有在 terraform 中使用它。
例如,研究如何最好地在 Web 模块中添加模拟服务
如果我现在想要更新不同的模块(例如更新防火墙规则),terraform 将建议销毁添加的服务。
terraform plan/apply对于单个模块我该怎么办?
Mat*_*ard 16
您可以通过将模块命名空间指定为和命令target中的参数来仅定位模块:planapply
terraform plan -target=module.<declared module name>
Run Code Online (Sandbox Code Playgroud)
例如,如果您的模块声明是:
module "the_firewall" {
source = "${path.root}/firewall"
}
Run Code Online (Sandbox Code Playgroud)
那么命令将是:
terraform plan -target=module.the_firewall
Run Code Online (Sandbox Code Playgroud)
仅针对该模块声明。
请注意,这只应在开发/测试场景中使用,您似乎已经根据问题关注了这一点。
| 归档时间: |
|
| 查看次数: |
11603 次 |
| 最近记录: |