Add windows_11_client/main.tf

This commit is contained in:
Ryan Malloy 2024-11-14 19:39:57 +00:00
parent 0af8e817e1
commit 01833b75a2
1 changed files with 33 additions and 0 deletions

33
windows_11_client/main.tf Normal file
View File

@ -0,0 +1,33 @@
resource "aws_instance" "windows10" {
ami = var.ami_id
instance_type = var.instance_type
key_name = var.key_name
subnet_id = var.subnet_id
security_groups = var.vpc_security_group_ids
user_data = <<-EOF
<powershell>
# Enable RDP
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
# Set the Domain Name and Credentials
$domain = "${var.domain_name}"
$username = "${var.domain_admin_user}"
$password = ConvertTo-SecureString "${var.domain_admin_password}" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ("$domain\\$username", $password)
# Join the domain
Add-Computer -DomainName $domain -Credential $credential -Force -Restart
</powershell>
EOF
tags = {
Name = "Windows10-DomainJoined"
}
}