-
Notifications
You must be signed in to change notification settings - Fork 40
/
scripts.tf
53 lines (47 loc) · 1.4 KB
/
scripts.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
## Terraform for scripts to bootstrap
locals {
templatefiles = [
{
name = "${path.module}/files/windows/red.ps1.tpl"
variables = {
s3_bucket = "${aws_s3_bucket.staging.id}"
}
},
{
name = "${path.module}/files/windows/sysmon.ps1.tpl"
variables = {
s3_bucket = "${aws_s3_bucket.staging.id}"
region = var.region
sysmon_config = local.sysmon_config
sysmon_zip = local.sysmon_zip
dc_ip = ""
domain_join = false
}
},
{
name = "${path.module}/files/windows/caldera.ps1.tpl"
variables = {
s3_bucket = "${aws_s3_bucket.staging.id}"
caldera_port = var.caldera_port
region = var.region
bas_server = aws_instance.bas_server.private_ip
}
}
]
script_contents = [
for t in local.templatefiles : templatefile(t.name, t.variables)
]
script_output_generated = [
for t in local.templatefiles : "${path.module}/output/windows/${replace(basename(t.name), ".tpl", "")}"
]
# reference in the main user_data for each windows system
script_files = [
for tf in local.templatefiles :
replace(basename(tf.name), ".tpl", "")
]
}
resource "local_file" "generated_scripts" {
count = length(local.templatefiles)
filename = local.script_output_generated[count.index]
content = local.script_contents[count.index]
}