-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the enhancement
I'm looking the way to move following section next to root.hcl and import that across all child files.
terraform {
source = (
include.root.locals.tf_local_deploy ?
format(include.root.locals.tf_local_ref,
include.root.locals.tfmodules_name, local.module_name
) :
format(
include.root.locals.tf_remote_ref,
include.root.locals.tfmodules_name, local.module_name, include.root.locals.tfmodules_version
)
)
}
Additional context
Here is a common pattern we use across 100-ish modules.
include "root" {
path = find_in_parent_folders("root.hcl")
expose = true
}
include "region" {
path = find_in_parent_folders("region.hcl")
expose = true
}
terraform {
source = (
include.root.locals.tf_local_deploy ?
format(include.root.locals.tf_local_ref,
include.root.locals.tfmodules_name, local.module_name
) :
format(
include.root.locals.tf_remote_ref,
include.root.locals.tfmodules_name, local.module_name, include.root.locals.tfmodules_version
)
)
}
locals {
module_name = "aws-vpc-endpoint"
}
inputs = {
...
}
following way to optimise the block does not allow to pass locals from child module and only works if content of terraform.hcl hardcoded.
include "terraform" {
path = find_in_parent_folders("terraform.hcl")
}
Things you might want to address include:
Changing around this block would definitely save a lots of redundant code and will allow to maintain huge projects easier and make code more DRY.
FlorinAndrei
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request