How do i load a local variable inside a module in Terraform?

Viewed 713

I have a locals.tf file with:

locals {
  labels = {
    mockup  = "duration is set 555"
  }
}

And a module called "TEST" where i define a GCP bucket resource:

resource "google_storage_bucket" "my_bucket_2" {
    ...
    labels = var.labels_bucket
}

I also have a variables.tf file inside the TEST module:

variable "labels_bucket" {}

Inside the main.tf file i loaded the module like this:

module "test" {
  source = "./TEST"
  labels_bucket = local.labels
}

I expected the variable to get the value of the local one, instead i get this error inside the module:

googleapi: Error 400: Invalid argument, invalid

How do i map these values?

Thank you!

1 Answers

Simple, Because it's issue with value of the map. Nothing to do with terraform.gcs label format

Related