エントリーポイントとなるルートモジュールは環境名で表現する
ルール
Root modules serving as entry points are expressed using environment names. These are placed directly under the root directory (e.g., ./development ./production)
(エントリーポイントとなるルートモジュールは環境名で表現する)
解説
Terraformを実行する起点となるルートモジュールは環境ごとに独立したディレクトリとして表現します。 たとえばdevelopment/なら開発環境用です。これはTerraform公式が紹介している方式でもあります。
サンプルコード
# ディレクトリ構造の例
# ./development/main.tf - 開発環境用のエントリーポイント
# ./staging/main.tf - ステージング環境用のエントリーポイント
# ./production/main.tf - 本番環境用のエントリーポイント
# ./development/main.tf の内容例
module "networking" {
source = "../modules/networking"
environment = "development"
vpc_cidr = "10.0.0.0/16"
}
module "compute" {
source = "../modules/compute"
environment = "development"
instance_type = "t3.micro"
}
参考リンク
Show Text to Shareエントリーポイントとなるルートモジュールは環境名で表現する https://www.tricrow.com/infrastructure/development-guidline/repository_structure.standard.entrypoint.html

