Hello everybody,
I am using Terraform ver 0.12.24 and running into an issue when trying to use data.terraform_remote_state.project.outputs.project_id. This object does not have an attribute named project_id.
This is happening on a terraform plan
My main.tf looks like this
# ------------------------------------------------------------
# BACKEND BLOCK
# ------------------------------------------------------------
terraform {
backend "gcs" {}
}
# ------------------------------------------------------------
# PROVIDER BLOCK
# ------------------------------------------------------------
provider "google-beta" {
credentials = var.credentials_path
region = "us-central1"
version = "~> 2.0"
}
provider "google" {
credentials = var.credentials_path
region = "us-central1"
version = "~> 2.0"
}
# ------------------------------------------------------------
# TERRAFORM REMOTE STATE
data "terraform_remote_state" "project" {
backend = "gcs"
config = {
bucket = var.bucket
prefix = var.prefix
credentials = var.credentials_path
}
}
# ------------------------------------------------------------
# MAIN BLOCK
# ------------------------------------------------------------
module "simple_vpc" {
source = "terraform-google-modules/network/google"
version = "~>2.3"
project_id = "${data.terraform_remote_state.project.outputs.project_id}"
network_name = var.network_name
routing_mode = var.routing_mode
subnets = [
{
subnet_name = var.subnet_name
subnet_ip = var.subnet_ip
subnet_region = var.subnet_region
subnet_private_access = var.subnet_private_access
subnet_flow_logs = var.subnet_flow_logs
description = var.description
},
]
}
outputs.tf
output network_name {
value = module.simple_vpc.network_name
}
output subnets_names {
value = module.simple_vpc.subnets_names
}
output subnets_self_links {
value = module.simple_vpc.subnets_self_links
}
output subnets_ips {
value = module.simple_vpc.subnets_ips
}
output "project_id" {
value = module.simple_vpc.project_id
description = "VPC project id"
}
variables.tf
variable credentials_path {
description = "./credentials.json"
}
variable bucket {
description = "GCS bucket name that stores state"
}
variable prefix {
description = "GCS folder name"
}
variable project_id {
description = "Project this vpc should be attached to."
}
variable network_name {
description = "Name of the VPC."
}
variable routing_mode {
description = "Routing mode. GLOBAL or REGIONAL"
default = "GLOBAL"
}
variable subnet_name {
description = "Name of the subnet."
}
variable subnet_ip {
description = "Subnet IP CIDR."
}
variable subnet_region {
description = "Region subnet lives in."
}
variable subnet_private_access {
default = "true"
}
variable subnet_flow_logs {
default = "true"
}
variable description {
default = "Deployed through Terraform."
}