-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
84 lines (64 loc) · 2.36 KB
/
main.tf
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
##############################################################################
# Get External Data
##############################################################################
data "external" "example" {
program = ["sh", "${path.module}/test-output.sh", "example", "test"]
}
##############################################################################
##############################################################################
# Get data from local file
##############################################################################
locals {
file_name_list = {
list_1 = "shuffle_list_1"
list_2 = "shuffle_list_2"
}
}
data "local_file" "lists" {
for_each = local.file_name_list
filename = "${path.module}/local-files/${each.value}.txt"
}
##############################################################################
##############################################################################
# Null resource example
##############################################################################
resource "null_resource" "count_example" {
triggers = {
trigger_value = var.trigger_value
}
count = length(split("-", data.external.example.result.data))
}
resource "null_resource" "map_example" {
triggers = {
trigger_value = var.trigger_value
}
for_each = toset(split("-", data.external.example.result.data))
}
##############################################################################
##############################################################################
# Random resource examples
##############################################################################
resource "random_pet" "random_example" {
length = 3
prefix = "example-acceptance"
separator = "-"
}
resource "random_shuffle" "shuffle_example" {
for_each = data.local_file.lists
keepers = {
shuffle_count = var.shuffle_count
}
input = split(",", each.value.content)
result_count = var.shuffle_count
}
##############################################################################
##############################################################################
# Example Module
##############################################################################
module "example_module" {
source = "./example-module"
}
module "ping_module" {
source = "./ping_module"
}
##############################################################################