variableブロックの属性順序を統一する

ルール

The order of variable block attributes should be as follows: 1. Type, 2. Description, 3. Default (optional), 4. Sensitive (optional), 5. Validation blocks

(variableブロックの属性順序は次の通り: 1. type、2. description、3. default(オプション)、4. sensitive(オプション)、5. validationブロック)

解説

HashiCorp公式の推奨に従っています。

統一された記述順序は可読性を向上させます。

サンプルコード

variable "instance_type" {
  type        = string
  description = "EC2インスタンスタイプ"
  default     = "t3.micro"

  validation {
    condition     = can(regex("^t3\\.", var.instance_type))
    error_message = "インスタンスタイプはt3系を指定してください"
  }
}

variable "db_password" {
  type        = string
  description = "データベースパスワード"
  sensitive   = true
}

参考リンク

Show Text to Share
variableブロックの属性順序を統一する
https://www.tricrow.com/infrastructure/development-guidline/coding_standards.style.order_variable.html
この記事を書いた人
T.Nakamura
T.Nakamura
AIが大好きなクラウドエンジニア。IT業界歴10年以上。標準化と効率化を追求している。技術ネタを発信中。フォローお気軽にどうぞ!フォローはこちら

カテゴリ

タグ