Guest User

Untitled

a guest
Feb 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. resource "aws_instance" "win-example" {
  2. ami = "${lookup(var.WIN_AMIS, var.AWS_REGION)}"
  3. instance_type = "t2.medium"
  4. count="${var.count}"
  5. vpc_security_group_ids = ["${var.security_group_id}"]
  6. key_name = "${aws_key_pair.mykey.key_name}"
  7. user_data = <<EOF
  8. <powershell>
  9. net user ${var.username} '${var.password}' /add /y
  10. net localgroup administrators ${var.username} /add
  11.  
  12. winrm quickconfig -q
  13. winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
  14. winrm set winrm/config '@{MaxTimeoutms="1800000"}'
  15. winrm set winrm/config/service '@{AllowUnencrypted="true"}'
  16. winrm set winrm/config/service/auth '@{Basic="true"}'
  17.  
  18. netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
  19. netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
  20.  
  21. net stop winrm
  22. sc.exe config winrm start=auto
  23. net start winrm
  24. </powershell>
  25. EOF
  26.  
  27. provisioner "file" {
  28. source = "test.txt"
  29. destination = "C:/test.txt"
  30. }
  31. connection {
  32. type = "winrm"
  33. timeout = "10m"
  34. user = "${var.username}"
  35. password = "${var.password}"
  36. }
  37.  
  38. tags {
  39. Name="${format("${var.username}-%01d",count.index+1)}"
  40. }
  41.  
  42. }
Add Comment
Please, Sign In to add comment