Adding exchange module for AWS Terraform
This commit is contained in:
11
AWS/Terraform/exchange.tf
Normal file
11
AWS/Terraform/exchange.tf
Normal file
@@ -0,0 +1,11 @@
|
||||
## Remove the block comment to enable the creation of the Exchange server
|
||||
module "exchange" {
|
||||
source = "./modules/exchange"
|
||||
region = var.region
|
||||
subnet_id = aws_subnet.default.id
|
||||
security_group_id = [aws_security_group.windows.id]
|
||||
instance_name_prefix = var.instance_name_prefix
|
||||
custom-tags = var.custom-tags
|
||||
exchange_ami = var.exchange_ami
|
||||
}
|
||||
|
||||
@@ -285,43 +285,6 @@ resource "aws_instance" "wef" {
|
||||
}
|
||||
}
|
||||
|
||||
# Uncomment when the AMI has been created
|
||||
# resource "aws_instance" "exchange" {
|
||||
# instance_type = "t3.medium"
|
||||
# count = var.create_exchange_server ? 1 : 0
|
||||
|
||||
# provisioner "remote-exec" {
|
||||
# inline = [
|
||||
# "choco install -force -y winpcap",
|
||||
# "powershell.exe -c \"Add-Content 'c:\\windows\\system32\\drivers\\etc\\hosts' ' 192.168.38.102 dc.windomain.local'\"",
|
||||
# "powershell.exe -c \"Add-Content 'c:\\windows\\system32\\drivers\\etc\\hosts' ' 192.168.38.102 windomain.local'\"",
|
||||
# "ipconfig /renew",
|
||||
# ]
|
||||
|
||||
# connection {
|
||||
# type = "winrm"
|
||||
# user = "vagrant"
|
||||
# password = "vagrant"
|
||||
# host = coalesce(self.public_ip, self.private_ip)
|
||||
# }
|
||||
# }
|
||||
|
||||
# # Uses the local variable if external data source resolution fails
|
||||
# ami = coalesce(var.exchange_ami, data.aws_ami.exchange_ami.image_id)
|
||||
|
||||
# tags = merge(var.custom-tags, map(
|
||||
# "Name", "${var.instance_name_prefix}exchange.windomain.local"
|
||||
# ))
|
||||
|
||||
# subnet_id = aws_subnet.default.id
|
||||
# vpc_security_group_ids = [aws_security_group.windows.id]
|
||||
# private_ip = "192.168.38.106"
|
||||
|
||||
# root_block_device {
|
||||
# delete_on_termination = true
|
||||
# }
|
||||
# }
|
||||
|
||||
resource "aws_instance" "win10" {
|
||||
instance_type = "t2.medium"
|
||||
|
||||
|
||||
3
AWS/Terraform/modules/exchange/locals.tf
Normal file
3
AWS/Terraform/modules/exchange/locals.tf
Normal file
@@ -0,0 +1,3 @@
|
||||
locals {
|
||||
exchange_url = "https://${aws_instance.exchange.public_ip}"
|
||||
}
|
||||
35
AWS/Terraform/modules/exchange/main.tf
Normal file
35
AWS/Terraform/modules/exchange/main.tf
Normal file
@@ -0,0 +1,35 @@
|
||||
resource "aws_instance" "exchange" {
|
||||
instance_type = "t3.xlarge"
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"choco install -force -y winpcap",
|
||||
"ipconfig /renew",
|
||||
"powershell.exe -c \"Add-Content 'c:\\windows\\system32\\drivers\\etc\\hosts' ' 192.168.38.103 wef.windomain.local'\"",
|
||||
"powershell.exe -c \"Add-Content 'c:\\windows\\system32\\drivers\\etc\\hosts' ' 192.168.38.102 dc.windomain.local'\"",
|
||||
"powershell.exe -c \"Add-Content 'c:\\windows\\system32\\drivers\\etc\\hosts' ' 192.168.38.102 windomain.local'\"",
|
||||
]
|
||||
|
||||
connection {
|
||||
type = "winrm"
|
||||
user = "vagrant"
|
||||
password = "vagrant"
|
||||
host = coalesce(self.public_ip, self.private_ip)
|
||||
}
|
||||
}
|
||||
|
||||
# Uses the local variable if external data source resolution fails
|
||||
ami = coalesce(var.exchange_ami, data.aws_ami.exchange_ami.image_id)
|
||||
|
||||
tags = merge(var.custom-tags, map(
|
||||
"Name", "${var.instance_name_prefix}exchange.windomain.local"
|
||||
))
|
||||
|
||||
subnet_id = var.subnet_id
|
||||
vpc_security_group_ids = var.security_group_id
|
||||
private_ip = "192.168.38.106"
|
||||
|
||||
root_block_device {
|
||||
delete_on_termination = true
|
||||
}
|
||||
}
|
||||
7
AWS/Terraform/modules/exchange/outputs.tf
Normal file
7
AWS/Terraform/modules/exchange/outputs.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
output "exchange_public_ip" {
|
||||
value = aws_instance.exchange.public_ip
|
||||
}
|
||||
|
||||
output "exchange_url" {
|
||||
value = local.exchange_url
|
||||
}
|
||||
38
AWS/Terraform/modules/exchange/variables.tf
Normal file
38
AWS/Terraform/modules/exchange/variables.tf
Normal file
@@ -0,0 +1,38 @@
|
||||
variable "security_group_id" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "subnet_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "instance_name_prefix" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "custom-tags" {
|
||||
type = map(string)
|
||||
description = "Optional mapping for additional tags to apply to all related AWS resources"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "exchange_ami" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
# Use Data Sources to resolve the AMI-ID for the pre-built EXCHANGE host
|
||||
data "aws_ami" "exchange_ami" {
|
||||
owners = ["505638924199"]
|
||||
most_recent = true
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["detectionlab-exchange"]
|
||||
}
|
||||
}
|
||||
@@ -37,3 +37,11 @@ output "guacamole_url" {
|
||||
output "velociraptor_url" {
|
||||
value = local.velociraptor_url
|
||||
}
|
||||
|
||||
output "exchange_public_ip" {
|
||||
value = module.exchange.exchange_public_ip
|
||||
}
|
||||
|
||||
output "exchange_url" {
|
||||
value = module.exchange.exchange_url
|
||||
}
|
||||
|
||||
@@ -88,18 +88,6 @@ data "aws_ami" "wef_ami" {
|
||||
}
|
||||
}
|
||||
|
||||
# Uncomment after this AMI has been created and uploaded to AWS
|
||||
# # Use Data Sources to resolve the AMI-ID for the pre-built EXCHANGE host
|
||||
# data "aws_ami" "exchange_ami" {
|
||||
# owners = ["505638924199"]
|
||||
# most_recent = true
|
||||
|
||||
# filter {
|
||||
# name = "name"
|
||||
# values = ["detectionlab-exchange"]
|
||||
# }
|
||||
# }
|
||||
|
||||
# Use Data Sources to resolve the AMI-ID for the pre-built Win10 host
|
||||
data "aws_ami" "win10_ami" {
|
||||
owners = ["505638924199"]
|
||||
@@ -136,11 +124,4 @@ variable "exchange_ami" {
|
||||
variable "win10_ami" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
# Set to "true" in terraform.tfvars if you want to add the Exchange server
|
||||
variable "create_exchange_server" {
|
||||
description = "If set to true, adds an additional host that installs exchange"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
}
|
||||
9
AWS/Terraform/vm_import/exchange.json
Normal file
9
AWS/Terraform/vm_import/exchange.json
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"Description": "exchange",
|
||||
"Format": "ova",
|
||||
"UserBucket": {
|
||||
"S3Bucket": "YOUR_BUCKET_GOES_HERE",
|
||||
"S3Key": "exchange.ova"
|
||||
}
|
||||
}]
|
||||
Reference in New Issue
Block a user