全てのモジュールに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
この記事を書いた人
T.Nakamura
T.Nakamura
SRE | セキュリティ前提の設計・運用・監査対応(PCI DSS) | ドキュメント整備と仕組み化で開発・運用を整えます | AWS SAP / 日商簿記一級フォローはこちら

カテゴリ

タグ