提供程序 provider.terraform 不支持资源类型“terraform_remote_state
The provider provider.terraform does not support resource type "terraform_remote_state
我为初学者设置了非常简单的 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
}
}
和 variables.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".
我在这里做什么?
terraform_remote_state 是 data
,不是 resource
。
因此您可以尝试以下方法:
data "terraform_remote_state" "vpc" {
backend = "s3"
config = {
bucket = var.vpc_bucket
region = var.region
key = var.vpc_bucket_key
}
}
我为初学者设置了非常简单的 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
}
}
和 variables.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".
我在这里做什么?
terraform_remote_state 是 data
,不是 resource
。
因此您可以尝试以下方法:
data "terraform_remote_state" "vpc" {
backend = "s3"
config = {
bucket = var.vpc_bucket
region = var.region
key = var.vpc_bucket_key
}
}