diff --git a/windows_11_client/main.tf b/windows_11_client/main.tf new file mode 100644 index 0000000..9798ee2 --- /dev/null +++ b/windows_11_client/main.tf @@ -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 + + # 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 + + EOF + + tags = { + Name = "Windows10-DomainJoined" + } +}