Is this the right way to share variables across modules or am I doing it wrong?
In a base module I add a variable:
variable "aws_region" {
description = "Region to use"
default = "eu-west-1"
}
Then I expose it using output:
output "AwsRegion" {
value = var.aws_region
}
Then in the module I want to use it from, I import the base module and refer to it:
module "base" {
source = "../base"
}
provider "aws" {
version = "~> 2.37"
region = module.base.AwsRegion
}
Is there a way to define the variable and export it as output in one go? Does Terraform have the concept of access modifiers? It would be great to be able to do public variable or output variable...