-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
43 lines (35 loc) · 1.15 KB
/
main.tf
File metadata and controls
43 lines (35 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Simple Terraform Module - Main Configuration
# This module demonstrates best practices for a basic Terraform module
# Local values for data processing and combination
locals {
# Combine the input variables into meaningful outputs
full_name = "${var.project_name}-${var.environment}"
# Create a standardized resource naming convention
resource_prefix = lower(replace(local.full_name, " ", "-"))
# Combine tags from multiple sources
common_tags = merge(
var.default_tags,
{
Environment = var.environment
Project = var.project_name
ManagedBy = "terraform"
CreatedDate = formatdate("YYYY-MM-DD", timestamp())
}
)
# Process the string list into a formatted string
processed_items = join(", ", [for item in var.string_list : upper(item)])
}
# Example resource using the processed values
resource "random_id" "example" {
keepers = {
project = var.project_name
environment = var.environment
}
byte_length = 8
}
# Example of conditional resource creation
resource "random_pet" "conditional" {
count = var.enable_random_pet ? 1 : 0
length = var.pet_length
separator = var.pet_separator
}