Skip to content

Random Creature

The random_creature resource generates friendly, memorable creature names combining adjectives and animal names. It provides consistent, deterministic name generation for creating user-friendly identifiers in lab environments.

As a lab author, you can use random_creature resources to:

  • User-Friendly Naming: Generate memorable, human-readable names for resources instead of cryptic identifiers
  • Container Naming: Generate approachable names for containers that are easier to identify than random strings

Random creature resources create engaging, memorable identifiers while maintaining uniqueness and consistency.

resource "random_creature" "name" {}
resource "random_creature" "name" {}

This resource takes no input parameters. Creature names are generated automatically.

These attributes are set by the system after creature name generation:

Field Type Description
value string The generated creature name (e.g., "brave-dolphin", "curious-elephant")
  • Creature names follow the pattern: adjective-animal
  • Generated values remain constant across multiple runs (idempotent)
  • Names are URL-safe and contain only lowercase letters and hyphens
  • All generated names are family-friendly and appropriate for professional environments
resource "random_creature" "instance_name" {}
output "friendly_name" {
value = resource.random_creature.instance_name.value # e.g., "brave-dolphin"
}
resource "random_creature" "container_name" {}
resource "container" "app" {
image {
name = "myapp:latest"
}
environment = {
INSTANCE_NAME = resource.random_creature.container_name.value # e.g., "curious-elephant"
}
}
resource "random_creature" "lab_id" {}
resource "template" "welcome_message" {
source = <<-EOF
Welcome to your lab instance: ${resource.random_creature.lab_id.value} # e.g., "Welcome to your lab instance: gentle-penguin"
You can refer to this instance as "${resource.random_creature.lab_id.value}" throughout the lab.
Your unique lab environment is ready to use!
EOF
destination = "./welcome.txt"
}
resource "random_creature" "team_red" {}
resource "random_creature" "team_blue" {}
resource "template" "team_config" {
source = <<-EOF
teams:
red:
name: ${resource.random_creature.team_red.value} # e.g., "mighty-lion"
color: "#ff0000"
namespace: team-${resource.random_creature.team_red.value}
blue:
name: ${resource.random_creature.team_blue.value} # e.g., "swift-falcon"
color: "#0000ff"
namespace: team-${resource.random_creature.team_blue.value}
EOF
destination = "./teams.yaml"
}
resource "random_creature" "service_name" {}
resource "container" "api_service" {
image {
name = "api:latest"
}
environment = {
SERVICE_ID = resource.random_creature.service_name.value # e.g., "clever-owl"
SERVICE_URL = "http://${resource.random_creature.service_name.value}:8080"
}
port {
local = 8080
host = 8080
}
}
resource "template" "service_registry" {
source = <<-EOF
services:
- name: ${resource.random_creature.service_name.value} # e.g., "clever-owl"
url: http://${resource.random_creature.service_name.value}:8080
health_check: /health
tags: ["api", "demo"]
EOF
destination = "./services.yaml"
}
resource "random_creature" "database_name" {}
resource "random_creature" "cache_name" {}
resource "random_creature" "worker_name" {}
resource "container" "database" {
image {
name = "postgres:15"
}
environment = {
POSTGRES_DB = resource.random_creature.database_name.value # e.g., "wise-turtle"
}
}
resource "container" "cache" {
image {
name = "redis:alpine"
}
}
resource "container" "worker" {
image {
name = "worker:latest"
}
environment = {
DATABASE_HOST = "db-${resource.random_creature.database_name.value}" # e.g., "db-wise-turtle"
CACHE_HOST = "cache-${resource.random_creature.cache_name.value}" # e.g., "cache-quick-rabbit"
WORKER_ID = resource.random_creature.worker_name.value # e.g., "strong-bear"
}
}
resource "random_creature" "user_alice" {}
resource "random_creature" "user_bob" {}
resource "template" "mock_users" {
source = <<-EOF
users:
- username: alice
display_name: "Alice (${resource.random_creature.user_alice.value})" # e.g., "Alice (friendly-cat)"
avatar: "/avatars/${resource.random_creature.user_alice.value}.png"
- username: bob
display_name: "Bob (${resource.random_creature.user_bob.value})" # e.g., "Bob (happy-dog)"
avatar: "/avatars/${resource.random_creature.user_bob.value}.png"
EOF
destination = "./mock_users.yaml"
}
resource "random_creature" "network_name" {}
resource "network" "lab_network" {
subnet = "10.0.0.0/24"
}
  1. User Experience: Use creature names when human readability and memorability are important
  2. Consistent Prefixing: Add descriptive prefixes to creature names for resource type clarity
  3. Documentation: Include creature names in user-facing documentation and interfaces
  4. Accessibility: Creature names are more accessible than UUIDs or random strings
  5. Professional Environment: All generated names are appropriate for business and educational settings
  6. URL Safety: Creature names are safe to use in URLs, hostnames, and file names
  7. Logging: Include creature names in logs to make debugging more human-friendly