提供者provider.terraform不支持​​资源类型“ terraform_remote_state

时间:2020-07-26 09:23:51

标签: terraform terraform-provider-aws terraform0.12+

对于初学者,我有非常简单的Terraform设置-

main.tf-

provider "aws" {
  access_key = var.access_key
  secret_key = var.secret_key
  region     = var.region
  version    = "~> 2.8"
}

resource "terraform_remote_state" "vpc" {
  backend = "s3"
  config = {
    bucket = var.vpc_bucket
    region = var.region
    key    = var.vpc_bucket_key
  }
}

和变量。tf-

variable "access_key" {
  default = ""
}
variable "secret_key" {
  default = ""
}

variable "vpc_bucket" {
  default = "ops-bucket-0708"
}

variable "region" {
  default = "ap-south-1"
}

variable "vpc_bucket_key" {
  default = "aws/ap-south-1/VPCs/terraform.tfstate"
}

当我运行terraform plan时,出现以下错误-

Error: Invalid resource type

  on main.tf line 8, in resource "terraform_remote_state" "vpc":
   8: resource "terraform_remote_state" "vpc" {

The provider provider.terraform does not support resource type
"terraform_remote_state".

我在这里做什么?

1 个答案:

答案 0 :(得分:2)

terraform_remote_statedata,而不是resource

因此,您可以尝试以下操作:

data "terraform_remote_state" "vpc" {
  backend = "s3"
  config = {
    bucket = var.vpc_bucket
    region = var.region
    key    = var.vpc_bucket_key
  }
}