【Azure 的 Terraform】处理 Terraform 执行时出现的 Killed 消息的方法
简要概述
我之前使用Terraform在Azure环境中通过”Infrastructure as Code”的方式创建资源。但是当我最近再次使用时,出现了”Killed”的错误消息,导致无法执行。下面是我解决此问题并成功执行的方法(虽然可能有其他的解决方法,但在我的情况下,这个方法可以正常解决)。
当地环境
-
- macOS Ventura 13.0
-
- terraform v1.0.11 (エラー前のバージョン)
- terraform v1.5.2 (正常後のバージョン)
检查Terraform的版本
显示”已杀死”消息
好久不见,我决定再次使用Terraform。首先,我进行了版本确认。结果是。。。
$ terraform -v
zsh: killed terraform -v
这是什么消息?!根据这个,执行以下操作。
$ brew install tfenv
$ brew unlink terraform
$ brew reinstall tfenv
$ tfenv install 1.5.2
$ tfenv use 1.5.2
再次确认版本
$ terraform -v
Terraform v1.5.2
on darwin_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.93.0
+ provider registry.terraform.io/hashicorp/tls v3.1.0
为了安全起见,也请尝试执行terraform init。
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/azurerm from the dependency lock file
- Reusing previous version of hashicorp/tls from the dependency lock file
- Using previously-installed hashicorp/azurerm v2.93.0
- Using previously-installed hashicorp/tls v3.1.0
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
总结
现在,您可以像以前一样使用Terraform快速在Azure环境中创建资源了(已验证此文章)。