AWS remote state with terraform 0.12.12

Hi all,

I have an error when i want to do remote_state.
I read this documentation : https://www.terraform.io/docs/providers/terraform/d/remote_state.html

My first terraform state build VPC, with resource to AWS.
Hosting statement to S3 with DynamoDB lock.

/*

  • Set AWS provider

  • Set region
  • Set version
    */
    provider “aws” {
    region = var.region
    version = “~> 2.0”
    }

/*

  • Set backend

  • Set bucket S3 for hosting state file
    */
    terraform {
    required_version = “>= 0.12.1”

backend “s3” {
encrypt = true
bucket = “vpc-platform”
region = “eu-west-1”
key = “terraform/layer-base”
dynamodb_table = “dynamodb-vpc-platform-S3-lock”
}
}

After build network infrastructure, i want to create new statement :

/*

  • Set AWS provider

  • Set region
  • Set version
    */
    provider “aws” {
    region = var.region
    }

terraform {
required_version = “>= 0.12.1”

backend “s3” {
encrypt = true
bucket = “vpc-platform”
region = “eu-west-1”
key = “terraform/layer-app”
dynamodb_table = “dynamodb-vpc-platform-S3-lock”
}
}

data “terraform_remote_state” “stack-base” {
backend = “s3”

config = {
bucket = “vpc-platform”
key = “terraform/layer-base”
region = “eu-west-1”
}
}

At this time all config is OK ! But when i want to create a simple “security_group”, i have an error :

resource “aws_security_group” “allow_bastion” {
name = “security_group_bastion_ssh”
description = “Allow SSH traffic”
vpc_id = data.terraform_remote_state.stack-base.outputs.vpc_id

ingress {
from_port = 22
to_port = 22
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
}
}

Issue :

Refreshing Terraform state in-memory prior to plan…
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.terraform_remote_state.stack-base: Refreshing state…

Error: Unsupported attribute

on EC2.tf line 5, in resource “aws_security_group” “allow_bastion_ssh”:
5: vpc_id = data.terraform_remote_state.stack-base.outputs.vpc_id
|----------------
| data.terraform_remote_state.stack-base.outputs is object with no attributes

This object does not have an attribute named “vpc_id”

Regards,