How do you implement feature toggles in a module?
BeginnerProductionRepository Structure, Environments and Module Strategy
Answer
Boolean variables feeding count or for_each, with outputs using one() to return null when off.
variable "enable_waf" { type = bool default = false }
resource "aws_wafv2_web_acl" "this" { count = var.enable_waf ? 1 : 0 /* ... */ }
output "waf_arn" { value = one(aws_wafv2_web_acl.this[*].arn) }
Keep toggles few and meaningful; too many produce untestable combinations.
More on Repository Structure, Environments and Module Strategy
Monorepo or multi-repo for Terraform?BeginnerHow do you lay out environments in a repo?BeginnerWhen would you adopt Terragrunt?BeginnerDo you use tfvars files per environment or code branches?IntermediateHow do you promote a module change from dev to qa to prod?AdvancedWhat is an internal module registry strategy?Beginner