Skip to content

Latest commit

 

History

History

random-pet

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

terraform-random-pet

This is a template child module to create a random pet resource. It can be easily copied and updated for other use-cases.

Documentation Recommendations (DO NOT INCLUDE THIS INTO THE REAL README)

Naming

The repository/directory name should follow this pattern:

[terraform-]<PROVIDER>-<NAME>

Here’s what this means:

  1. [If it's a separate repository] The repository should start with terraform- if your module should be published to and discovered on the Registry. Even if you don’t intend to publish the module, following this pattern is a good practice that helps differentiate your Terraform child modules from other code in your projects.
  2. Include the provider name: Specify the primary provider your module is for, such as aws, google, datadog, etc.
  3. Use descriptive name: Follow the provider name with a clear and concise identifier that describes the module’s purpose.
  4. Use hyphens to separate words.

Also:

  1. Keep name short and focused: While it should be descriptive, avoid overly long names. The goal is to convey the module’s purpose concisely:
    • Good: terraform-aws-internal-lb.
    • Not so good: terraform-aws-internal-misc-module.
    • Too long: terraform-aws-internal-application-load-balancer-with-extra-rules.
  2. Module names should reflect their purpose rather than environment-specific details.

Usage

To use this module, reference it from your main configuration and provide the necessary input variables. For example:

module "sandbox_pet" {
  source  = "masterpointio/random/pet"
  # We recommend to pin the specific version
  # version = "X.X.X"

  # Input variables
  length = 2
  prefix = "sandbox"
}

Once applied, the random resource will produce a random name such as sandbox-lively-parrot (the exact name will vary). This name can be referenced via:

output "pet_name" {
  value = module.sandbox_pet.random_pet_name
}

Requirements

Name Version
terraform >= 1.0
random >= 3.0

Providers

Name Version
random >= 3.0

Modules

No modules.

Resources

Name Type
random_pet.template resource

Inputs

Name Description Type Default Required
length The length of the random name. number 2 no
prefix A string to prefix the name with. string null no

Outputs

Name Description
random_pet_name The generated random pet name