全てのモジュールにvariables.tfを配置する
ルール
Place variables.tf in every module. Empty file is acceptable
(全てのモジュールにvariables.tfを配置する)
解説
全てのモジュールにvariables.tfを配置します。variableブロックは必ずこのファイルに記載します。
機械的にコードの位置を推測できるようになるためAIとの相性も良いです。
サンプルコード
# ./modules/networking/variables.tf
variable "environment" {
type = string
description = "環境名(development, staging, production)"
}
variable "project" {
type = string
description = "プロジェクト名"
}
variable "vpc_cidr" {
type = string
description = "VPCのCIDRブロック"
}
variable "public_subnet_cidrs" {
type = list(string)
description = "パブリックサブネットのCIDRブロックリスト"
}
variable "availability_zones" {
type = list(string)
description = "使用するアベイラビリティゾーンのリスト"
}
参考リンク
Show Text to Share全てのモジュールにvariables.tfを配置する https://www.tricrow.com/infrastructure/development-guidline/repository_structure.standard.variables.html

