我们最近从[0.11.11]迁移到Terraform v1.1.9。我们在源代码中相应地调整了TF init和Plan。代码运行良好,直到TF计划阶段。"Current.tfplan"也被创建了。在"地形应用"阶段得到以下误差错误:依赖锁文件不一致。
使用的AWS提供商版本为:
*terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.7.0"
}
}*
错误消息
**╷
│ Error: Inconsistent dependency lock file
│
│ The following dependency selections recorded in the lock file are
│ inconsistent with the configuration in the saved plan:
│ - provider registry.terraform.io/hashicorp/aws: required by this configuration but no version is selected
│
│ A saved plan can be applied only to the same configuration it was created
│ from. Create a new plan from the updated configuration.
╵
╷
│ Error: Inconsistent dependency lock file
│
│ The given plan file was created with a different set of external dependency
│ selections than the current configuration. A saved plan can be applied only
│ to the same configuration it was created from.
│
│ Create a new plan from the updated configuration.**
任何帮助都将非常感激!
问候,
@jigar shah我建议你运行下面的命令,这可能会解决你的问题。
terraform init -upgrade
我试图重新创建您的问题,并能够运行terraform应用命令没有任何问题。我使用的是terraform 1.0.12版本,最近升级到terraform 1.1.9。
只是分享我的主要。内容,请检查它是否有助于您的用例
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.7.0"
}
}
}
provider "aws" {
profile = "default"
region = "us-west-2"
}
resource "aws_instance" "app_server" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
tags = {
Name = "ExampleAppServerInstance"
}
}
我的AWS提供块看起来像这样
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.7.0"
}
}
}