antonbabenko / terraform-best-practices

Terraform Best Practices free ebook translated into 🇬🇧🇦🇪🇧🇦🇧🇷🇫🇷🇬🇪🇩🇪🇬🇷🇮🇱🇮🇳🇮🇩🇮🇹🇰🇷🇵🇱🇷🇴🇨🇳🇪🇸🇹🇷🇺🇦🇵🇰
https://www.terraform-best-practices.com/
Other
2.06k stars 431 forks source link

Add naming convention for modules arguments and examples #33

Closed evairmarinho closed 2 years ago

evairmarinho commented 2 years ago

Possible order of arguments:

  1. source
  2. version

Possible code:

module "vpc" {
  count              = 2

  source             = "terraform-aws-modules/vpc/aws"
  version            = "3.11.0"

  name               = "my-vpc-${count.index + 1}"
  cidr               = "10.0.0.0/16"
  azs                = ["us-east-1a", "us-east-1b", "us-east-1c"]
  private_subnets    = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets     = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
  enable_nat_gateway = true
  enable_vpn_gateway = true

  tags               = {
    Terraform = "true"
  }
}
antonbabenko commented 2 years ago

All these are meta-arguments that often make sense to put high at the top but I don't think this is something worth documenting as part of best practices TBH.

antonbabenko commented 2 years ago

Thanks for the suggestion!