簡體   English   中英

Terraform 問題適用 [使用 CodePipeline]

[英]Issue with Terraform apply [using CodePipeline]

我們最近從 [0.11.11] 遷移到 Terraform v1.1.9。 我們在源代碼中相應地調整了我們的 TF init 和 Plan。 代碼運行良好,直到 TF 計划階段。 “Current.tfplan”也被創建。 在“Terraform apply”階段出現“Error: Inconsistent dependency lock file”錯誤。

正在使用的 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 apply 命令。 我使用的是 terraform 1.0.12 版本,最近升級到 terraform 1.1.9。

只是分享我的 main.tf 內容,請檢查它是否對您的用例有幫助

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"
    }
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM