gpt4 book ai didi

azure - 通过 terraform 脚本检查 azure-resourcegroup 是否已存在

转载 作者:行者123 更新时间:2023-12-03 05:35:52 24 4
gpt4 key购买 nike

如何通过azure中的Terra-form脚本检查azure资源组是否已存在,如果不存在则创建Terra-form应该创建它?

通过 terraform 脚本检查 azure-resourcegroup 是否已存在

最佳答案

这是默认行为。您可能已经知道,您已经

terraform plan - used to validate your tf script

terraform apply - to apply the tf script changes

如果您在申请之前使用 terraform plan,并且尝试创建已存在的资源组,您将收到以下消息

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between yourconfiguration and real physical resources that exist. As a result, noactions need to be performed.

如果您直接使用 terraform apply,您将看到以下消息

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

但是,您的资源不会发生任何变化。

希望这有帮助。

关于azure - 通过 terraform 脚本检查 azure-resourcegroup 是否已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62694563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com