Two modules require different version ranges of the same provider and `init` fails. What now?
AdvancedScenarioModules and Code Structure
Answer
Situation read → Version constraints from all modules must intersect.
What I'd do →
- Run
terraform providersto see which module requires what. - Update or fork the module with the overly strict constraint (
~> 4.0while others need>= 5). - In your own modules use
>=lower bounds and let the root set the ceiling.
Why → Terraform installs one version per provider per root module, so module constraints must be compatible.
Interview tip → Strict upper bounds in shared modules are the usual culprit.
More on Modules and Code Structure
When do you turn a block of resources into a module, and when do you leave it alone?BeginnerHow do you consume a community module like `terraform-aws-modules/vpc/aws` responsibly?BeginnerAn ECS service module needs the VPC and subnets created by a network module. How do you wire them together?IntermediateHow would you lay out a repo that deploys the same stack to dev, stage and prod?IntermediateHow do you release a shared module so consumers can upgrade at their own pace?IntermediateA module needs to deploy to a second region. Why does putting a provider block inside the module cause trouble?Advanced