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

Viewed 1574

I have very simple Terraform setup for beginner -

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

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

When I run terraform plan it gives me the error below -

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

What am I doing here ?

2 Answers

terraform_remote_state is a data, not a resource.

Thus you can try the following:

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

I am facing a similar issue. I am using data only. the error is - The provider hashicorp/aws does not support data source │ "terraform_remote_state". I also undertsand that - data "terraform_remote_state" is available as a terraform provider and not aws. However this should be available as default, should not need any provider.

Related