为什么每次我运行plan或apply时都会发生terraform init ?



每次我运行terraform命令时,它都会自动首先运行init。我在Azure存储帐户中使用远程状态。这似乎是在几个月没有接触项目后随机开始的。

一切正常,否则,但它是烦人的,减慢我们的速度。

有没有办法调试为什么会发生这种情况,这样我就可以修复它?

myhost$ terraform plan
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/azuread from the dependency lock file
- Reusing previous version of hashicorp/random from the dependency lock file
- Reusing previous version of azure/azapi from the dependency lock file
- Reusing previous version of hashicorp/azurerm from the dependency lock file
- Using previously-installed hashicorp/azuread v2.26.1
- Using previously-installed hashicorp/random v3.1.3
- Using previously-installed azure/azapi v0.4.0
- Using previously-installed hashicorp/azurerm v3.14.0
Terraform has been successfully initialized!

版本信息:

Terraform v1.2.4
on windows_amd64
+ provider registry.terraform.io/azure/azapi v0.4.0
+ provider registry.terraform.io/hashicorp/azuread v2.26.1
+ provider registry.terraform.io/hashicorp/azurerm v3.14.0
+ provider registry.terraform.io/hashicorp/random v3.1.3

这是由Terragrunt的Auto-Init功能引起的,由于某些未确定的原因,该功能在我的项目中似乎表现不正常。

可以使用--terragrunt-no-auto-init选项或将TERRAGRUNT_AUTO_INIT环境变量设置为false来禁用该特性。当您执行此操作时,它将给出警告,但无论如何都要继续。不理想,但至少它加快了我的工作流程。

$ terragrunt plan --terragrunt-no-auto-init
WARN[0002] Detected that init is needed, but Auto-Init is disabled. Continuing with further actions, but subsequent terraform commands may fail.  prefix=[/home/ken/Code/tf/environments/dev]

最新更新