forked from iknowjason/AutomatedEmulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwin1.tf
More file actions
138 lines (123 loc) · 4.2 KB
/
win1.tf
File metadata and controls
138 lines (123 loc) · 4.2 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
variable "endpoint-ip-win1" {
default = "10.100.20.10"
}
variable "admin-username-win1" {
default = "RTCAdmin"
}
variable "admin-password-win1" {
default = "wOFVYKYlk2"
}
variable "join-domain-win1" {
default = false
}
variable "endpoint_hostname-win1" {
default = "win1"
}
# AWS AMI for Windows Server
data "aws_ami" "win1" {
most_recent = true
filter {
name = "name"
#values = ["Windows_Server-2019-English-Full-Base-*"]
values = ["Windows_Server-2022-English-Full-Base-*"]
}
owners = ["801119661308"] # Amazon
}
# EC2 Instance
resource "aws_instance" "win1" {
ami = data.aws_ami.win1.id
instance_type = "t2.micro"
key_name = module.key_pair.key_pair_name
subnet_id = aws_subnet.user_subnet.id
associate_public_ip_address = true
# user_data = data.template_file.ps_template_win1.rendered
user_data = local.ps_template_win1
vpc_security_group_ids = [
aws_security_group.operator_windows.id
]
root_block_device {
volume_size = 30
}
tags = {
"Name" = "win1"
}
depends_on = [
# reserved for later
]
}
# data "template_file" "ps_template_win1" {
# template = file("${path.module}/files/windows/bootstrap-win.ps1.tpl")
# vars = {
# hostname = "win1"
# join_domain = var.join-domain-win1 ? 1 : 0
# install_sysmon = true ? 1 : 0
# install_red = true ? 1 : 0
# install_ghosts = false ? 1 : 0
# install_prelude = true ? 1 : 0
# auto_logon_domain_user = false ? 1 : 0
# dc_ip = ""
# endpoint_ad_user = ""
# endpoint_ad_password = ""
# winrm_username = ""
# winrm_password = ""
# admin_username = var.admin-username-win1
# admin_password = var.admin-password-win1
# ad_domain = "rtc.local"
# script_files = join(",", local.script_files)
# windows_msi = ""
# vclient_config = ""
# winlogbeat_zip = ""
# winlogbeat_config = ""
# sysmon_config = local.sysmon_config
# sysmon_zip = local.sysmon_zip
# s3_bucket = "${aws_s3_bucket.staging.id}"
# region = var.region
# }
# }
locals {
ps_template_win1 = templatefile("${path.module}/files/windows/bootstrap-win.ps1.tpl", {
hostname = "win1"
join_domain = var.join-domain-win1 ? 1 : 0
install_sysmon = true ? 1 : 0
install_red = true ? 1 : 0
install_ghosts = false ? 1 : 0
install_prelude = true ? 1 : 0
auto_logon_domain_user = false ? 1 : 0
dc_ip = ""
endpoint_ad_user = ""
endpoint_ad_password = ""
winrm_username = ""
winrm_password = ""
admin_username = var.admin-username-win1
admin_password = var.admin-password-win1
ad_domain = "rtc.local"
script_files = join(",", local.script_files)
windows_msi = ""
vclient_config = ""
winlogbeat_zip = ""
winlogbeat_config = ""
sysmon_config = local.sysmon_config
sysmon_zip = local.sysmon_zip
s3_bucket = "${aws_s3_bucket.staging.id}"
region = var.region
})
}
resource "local_file" "debug-bootstrap-script-win1" {
# For inspecting the rendered powershell script as it is loaded onto endpoint
# content = data.template_file.ps_template_win1.rendered
content = local.ps_template_win1
filename = "${path.module}/output/windows/bootstrap-${var.endpoint_hostname-win1}.ps1"
}
output "windows_endpoint_details_win1" {
value = <<EOS
-------------------------
Virtual Machine ${aws_instance.win1.tags["Name"]}
-------------------------
Instance ID: ${aws_instance.win1.id}
Computer Name: ${aws_instance.win1.tags["Name"]}
Private IP: ${var.endpoint-ip-win1}
Public IP: ${aws_instance.win1.public_ip}
local Admin: ${var.admin-username-win1}
local password: ${var.admin-password-win1}
EOS
}