Is there a way of abstracting the provider for all the modules defined in a project.
for example, I have this project
├── modules
│ ├── RDS
│ └── VPC
└── stacks
├── production
│ └── main.tf
└── staging
└── main.tf
and it works fine... the problem is with the definition of modules
├── RDS
│ ├── README.md
│ ├── main.tf
│ ├── providers.tf
│ └── variables.tf
└── VPC
├── README.md
├── main.tf
├── providers.tf
└── variables.tf
the provider in both of these modules are exactly the same
# providers.tf
provider "aws" {
region = "${var.region}"
version = "~> 1.26"
}
and the variables in each module are different but they all have the region
variable.
# variables.tf
variable "region" {
default = "eu-central-1"
description = "AWS region."
}
# other module dependent variables...
is there a way to define those bits of information on the modules level so that I end up with something roughly like this
├── modules
│ ├── providers.tf <<< include the *shared* provider definition block
│ ├── variables.tf <<< include the *shared* region vaiable definition block
│ ├── RDS
│ │ ├── README.md
│ │ ├── main.tf
│ │ └── variables.tf
│ └── VPC
│ ├── README.md
│ ├── main.tf
│ └── variables.tf
one last thing, the modules definitions most of the time have a resource attribute (pulling a module from the terraform registry... therefore I don't know if it's feasible to inherit both the source from the registry and a base module)