|
9 | 9 | * |
10 | 10 | */ |
11 | 11 |
|
12 | | -# variables used by this snippet of init shellcode |
13 | | -variable "device_path" { |
14 | | - default = "/dev/xvdf" |
15 | | - description = "path, to the device's path in /dev/" |
16 | | - type = string |
17 | | -} |
18 | | - |
19 | | -variable "init_prefix" { |
20 | | - default = "" |
21 | | - description = "initial init (shellcode) to prefix this snippet with" |
22 | | - type = string |
23 | | -} |
24 | | - |
25 | | -variable "init_suffix" { |
26 | | - default = "" |
27 | | - description = "init (shellcode) to append to the end of this snippet" |
28 | | - type = string |
29 | | -} |
30 | | - |
31 | | -variable "log_level" { |
32 | | - default = "info" |
33 | | - description = "default log level verbosity for apps that support it" |
34 | | - type = string |
35 | | -} |
36 | | - |
37 | | -variable "log_prefix" { |
38 | | - default = "OPS: " |
39 | | - description = "string to prefix log messages with" |
40 | | - type = string |
41 | | -} |
42 | | - |
43 | | -variable "region" { |
44 | | - description = "AWS region the volume is in" |
45 | | - type = string |
46 | | -} |
47 | | - |
48 | | -variable "wait_interval" { |
49 | | - default = "5" |
50 | | - description = "time (in seconds) to wait when looping to find the device" |
51 | | - type = number |
52 | | -} |
53 | | - |
54 | | -variable "volume_id" { |
55 | | - description = "ID of the EBS volume to attach" |
56 | | - type = string |
57 | | -} |
58 | | - |
59 | 12 | # render init script for a cluster using our generic template |
60 | 13 | data "template_file" "init_snippet" { |
| 14 | + count = length(var.volume_ids) |
| 15 | + |
61 | 16 | template = file("${path.module}/snippet.tpl") |
62 | 17 |
|
63 | 18 | vars = { |
64 | | - device_path = var.device_path |
65 | | - init_prefix = var.init_prefix |
66 | | - init_suffix = var.init_suffix |
| 19 | + device_path = var.device_paths[count.index] |
67 | 20 | log_prefix = var.log_prefix |
68 | 21 | log_level = var.log_level |
69 | 22 | region = var.region |
70 | | - volume_id = var.volume_id |
| 23 | + volume_id = var.volume_ids[count.index] |
71 | 24 | wait_interval = var.wait_interval |
72 | 25 | } |
73 | 26 | } |
74 | 27 |
|
| 28 | +data "template_file" "instance_id" { |
| 29 | + template = file("${path.module}/instance_id.tpl") |
| 30 | +} |
| 31 | + |
75 | 32 | output "init_snippet" { |
76 | | - value = data.template_file.init_snippet.rendered |
| 33 | + value = <<EOF |
| 34 | +${var.init_prefix} |
| 35 | +${data.template_file.instance_id.rendered} |
| 36 | +${join("\n", data.template_file.init_snippet.*.rendered)} |
| 37 | +${var.init_suffix} |
| 38 | +EOF |
77 | 39 | } |
78 | 40 |
|
0 commit comments