/terraform-random-pet

Example Terraform Module Repo

Primary LanguageSmartyApache License 2.0Apache-2.0

terraform-random-pet module

Example Terraform Module to demonstrate TFC/TFE module publishing workflow into the Private Module Registry.

Giphy

The module itself uses random_pet, random_string and local_file resources. This example module demonstrate a simple collection of terraform resources that are grouped into a module. Publishing this module to the Private Module Registry

This module also demonstrate how templatefile() function can be used for templating (eg index.html) which is useful passing in config/user data text files to infrastructure resources when required.

The local index.html file created can be viewed locally and has a simple static site that cycles through images with the use of javascript. **Note: The statis site has nothing to do with

Usage

module "pet" {
  source  = "tfcarl.is.hashicorpdemo.com/hashicorp/pet/random"
  version = "x.x.x"
  string_length = 5
}

output "random_string_output" {
  value = module.pet.random_string_output
}

output "random_pet_nickname" {
    value = module.pet.random_pet_nickname
}

Requirements

Name Version
terraform >= 0.12.0
local >= 2.0.0
random >= 3.0.0

Providers

Name Version
local >= 2.0.0
random >= 3.0.0

Modules

No modules.

Resources

Name Type
local_file.html resource
random_pet.nickname resource
random_string.random resource

Inputs

Name Description Type Default Required
string_length The character length of the string. number 10 no

Outputs

Name Description
random_pet_nickname Random Pet Nickname generated
random_string_output Random String generated

Future Work

  • Make index.html show pets instead of hashicorp coffee cups.
  • Utilise a random number to be injected into javascript inside index.html