{
"Parameters": {
"MasterInstanceType": {
"Description": "EC2 instance type for Master machine",
"Type": "String",
"Default": "t3.large",
"ConstraintDescription": "must be a valid EC2 instance type."
},
"NodeInstanceType": {
"Description": "EC2 instance type for Node machine",
"Type": "String",
"Default": "t3.medium",
"ConstraintDescription": "must be a valid EC2 instance type."
},
"AMIId": {
"Description": "Amazon Machine Image Id for all EC2 instances",
"Default": "ami-00cb4c0d60b9476f4",
"Type": "AWS::EC2::Image::Id",
"ConstraintDescription": "must be a valid Image Id."
},
"KeyName": {
"Description": "Key Pair to get access to the instance",
"Type" : "AWS::EC2::KeyPair::KeyName"
},
"SahiLicenseKey": {
"Description": "Product key for accessing Sahi license from License Server",
"Type" : "String"
},
"Password": {
"Description": "Your desired instance password for the user: Administrator",
"Type" : "String"
},
"SubnetId" : {
"Description": "Id of the subnet that you want to launch the instance into",
"Type" : "String"
},
"VPCId" : {
"Description": "Id of the VPC to which the Security Group is to be created",
"Type" : "String"
},
"SahiDownloadURL" : {
"Description": "URL which sahi can be downloaded. Eg: http://sahipro.com/static/builds/pro/install_sahi_pro_runner_v800_20181031.jar",
"Type" : "String"
},
"UserDataScripts": {
"Type": "String",
"Default": "\n\n$client = new-object System.Net.WebClient\n$client.DownloadFile(\""
},
"UserDataScripts1": {
"Type": "String",
"Default": "\",\"C:\\Users\\Public\\Downloads\\install_sahi.jar\")\n$client.DownloadFile(\"https://www.cloudbase.it/downloads/wfreerdp-1.1.zip\",\"C:\\Users\\Public\\Downloads\\wfreerdp.zip\")\nNew-NetFirewallRule -DisplayName 'Sahi Proxy' -Profile @('Domain', 'Private', 'Public') -Direction Inbound -Action Allow -Protocol TCP -LocalPort @('9999')\n$xml='C:\\Users\\Public\\sahi_pro_runner'\n$xml|Out-File 'C:\\Users\\Public\\SilentInstall.xml'\njava -jar C:\\Users\\Public\\Downloads\\install_sahi.jar C:\\Users\\Public\\SilentInstall.xml\nREG ADD \"HKLM\\System\\CurrentControlSet\\Control\\Network\\NewNetworkWindowOff\" /F\n7z e \"C:\\Users\\Public\\Downloads\\wfreerdp.zip\"\n$props=Get-Content C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\userdata.properties\n$props=$props -replace \"proxy_alert.disabled=false\",\"proxy_alert.disabled=true\"\n$AdminKey = \"HKLM:\\SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}\"\n$props|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\userdata.properties' -Encoding ASCII\nAdd-Content 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\userdata.properties' \"system.prevent_standby.enabled=true\" -Encoding ASCII\n$UserKey = \"HKLM:\\SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}\"\nSet-ItemProperty -Path $AdminKey -Name \"IsInstalled\" -Value 0\nSet-ItemProperty -Path $UserKey -Name \"IsInstalled\" -Value 0\nREG ADD \"HKEY_CURRENT_USER\\Software\\Policies\\Microsoft\\Internet Explorer\\Main\" /v DisableFirstRunCustomize /t REG_DWORD /d 00000001 /f\n$sahi = \"cd C:\\Users\\Public\\sahi_pro_runner\\userdata\\bin`nstart_dashboard.bat\"\n$sahi|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\StartSahi.bat\" -Encoding ASCII\n$regFile="
},
"UserDataScripts2": {
"Type": "String",
"Default": "'REG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v CurrentLevel /t REG_DWORD /d 00011000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v MinLevel /t REG_DWORD /d 00011000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v RecommendedLevel /t REG_DWORD /d 00011000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v TemplateIndex /t REG_DWORD /d 00011000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2600 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2704 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2701 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2401 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2300 /t REG_DWORD /d 00000001 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2106 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2100 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2101 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2007 /t REG_DWORD /d 00010000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2004 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2001 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 2000 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1A10 /t REG_DWORD /d 00000001 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1A06 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1A05 /t REG_DWORD /d 00000001 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1A03 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1A02 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1A00 /t REG_DWORD /d 00020000 /f\nREG ADD \"HKEY_"
},
"UserDataScripts3": {
"Type": "String",
"Default": "CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1C00 /t REG_DWORD /d 00010000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1804 /t REG_DWORD /d 00000001 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1803 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1802 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1608 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1606 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1604 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1601 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1407 /t REG_DWORD /d 00000001 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1405 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1402 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1400 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1200 /t REG_DWORD /d 00000000 /f\nREG ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\" /v 1001 /t REG_DWORD /d 00011000 /f'\n$regFile|Out-File 'C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ie.bat' -Encoding ASCII"
},
"NodeInstanceCount": {
"Description": "Number of Node EC2 instances to be created(must be between 1 and 5)",
"Type": "Number",
"Default": "1",
"MinValue": "1",
"MaxValue": "5",
"ConstraintDescription": "Must be a number between 1 and 5"
},
"MasterName" : {
"Description": "Name tag for Master machine identification",
"Default": "Sahi Master",
"Type" : "String"
},
"NodeName" : {
"Description": "Name tag for Node machine identification",
"Default": "Sahi Node",
"Type": "String"
},
"CidrIp" : {
"Description": "Ip range to which 9999 and RDP ports should open. Default is open to world",
"Default": "0.0.0.0/0",
"Type": "String"
}
},
"Conditions": {
"Launch1": {
"Fn::Equals": [1,1]
},
"Launch2": {
"Fn::Not": [
{
"Fn::Equals": [1,
{
"Ref": "NodeInstanceCount"
}
]
}
]
},
"Launch3": {
"Fn::And": [
{
"Fn::Not": [
{
"Fn::Equals": [1,
{
"Ref": "NodeInstanceCount"
}
]
}
]
},
{
"Fn::Not": [
{
"Fn::Equals": [2,
{
"Ref": "NodeInstanceCount"
}
]
}
]
}
]
},
"Launch4": {
"Fn::Or": [
{
"Fn::Equals": [
4,
{
"Ref": "NodeInstanceCount"
}
]
},
{
"Fn::Equals": [
5,
{
"Ref": "NodeInstanceCount"
}
]
}
]
},
"Launch5": {
"Fn::Equals": [
5,
{
"Ref": "NodeInstanceCount"
}
]
}
},
"Resources": {
"EC2InstanceMaster": {
"Type": "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Ref": "AMIId" },
"InstanceType": {"Ref": "MasterInstanceType" },
"KeyName" : { "Ref": "KeyName" },
"SubnetId" : { "Ref" : "SubnetId" },
"SecurityGroupIds": [{ "Ref" : "MasterSecurityGroup" }],
"UserData": {"Fn::Base64": {
"Fn::Join":[ "", [{ "Ref": "UserDataScripts" },{ "Ref": "SahiDownloadURL" },{ "Ref": "UserDataScripts1" }, {"Ref": "UserDataScripts2"}, {"Ref": "UserDataScripts3"}, "\n$productKey='", {"Ref": "SahiLicenseKey"}, "'\n$productKey|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\productkey.txt' -Encoding ASCII\n$username=\"Administrator\"\n$key=\"", {"Fn::Base64": {"Ref": "Password"}}, "\"\n$password=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($key))\n$rdp = \"C:\\Windows\\System32\\wfreerdp.exe /v:127.0.0.1 /u:$username /p:$password /d:$env:COMPUTERNAME /w:1366 /h:768\"\n$rdp|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\FreeRdp.bat\" -Encoding ASCII\n$rdp|Out-File \"C:\\Users\\Administrator\\Desktop\\Close.bat\" -Encoding ASCII\nNET USER $username $password\n$RegPath = \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\"\nSet-ItemProperty $RegPath \"AutoAdminLogon\" -Value \"1\" -type String \nSet-ItemProperty $RegPath \"DefaultUsername\" -Value \"$username\" -type String \nSet-ItemProperty $RegPath \"DefaultPassword\" -Value \"$password\" -type String\nshutdown /r\n"]]}
},
"Tags" : [
{
"Key" : "Name",
"Value" : {"Ref": "MasterName"}
}
]
}
},
"EC2InstanceNode1": {
"Condition": "Launch1",
"Type": "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Ref": "AMIId" },
"InstanceType": {"Ref": "NodeInstanceType" },
"KeyName" : { "Ref": "KeyName" },
"SubnetId" : { "Ref" : "SubnetId" },
"SecurityGroupIds": [{ "Ref" : "NodeSecurityGroup" }],
"UserData": {"Fn::Base64": {
"Fn::Join":[ "", [{ "Ref": "UserDataScripts" },{ "Ref": "SahiDownloadURL" },{ "Ref": "UserDataScripts1" }, {"Ref": "UserDataScripts2"}, {"Ref": "UserDataScripts3"}, "\n$productKey='", {"Ref": "SahiLicenseKey"}, "'\n$productKey|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\productkey.txt' -Encoding ASCII\n$username=\"Administrator\"\n$key=\"", {"Fn::Base64": {"Ref": "Password"}}, "\"\n$password=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($key))\n$rdp = \"C:\\Windows\\System32\\wfreerdp.exe /v:127.0.0.1 /u:$username /p:$password /d:$env:COMPUTERNAME /w:1366 /h:768\"\n$rdp|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\FreeRdp.bat\" -Encoding ASCII\n$rdp|Out-File \"C:\\Users\\Administrator\\Desktop\\Close.bat\" -Encoding ASCII\nNET USER $username $password\n$RegPath = \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\"\nSet-ItemProperty $RegPath \"AutoAdminLogon\" -Value \"1\" -type String \nSet-ItemProperty $RegPath \"DefaultUsername\" -Value \"$username\" -type String \nSet-ItemProperty $RegPath \"DefaultPassword\" -Value \"$password\" -type String\nshutdown /r\n"]]}
},
"Tags" : [
{
"Key" : "Name",
"Value" : {
"Fn::Join":[ "", [{ "Ref": "NodeName" }, "-1"]]
}
}
]
}
},
"EC2InstanceNode2": {
"Condition": "Launch2",
"Type": "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Ref": "AMIId" },
"InstanceType": {"Ref": "NodeInstanceType" },
"KeyName" : { "Ref": "KeyName" },
"SubnetId" : { "Ref" : "SubnetId" },
"SecurityGroupIds": [{ "Ref" : "NodeSecurityGroup" }],
"UserData": {"Fn::Base64": {
"Fn::Join":[ "", [{ "Ref": "UserDataScripts" },{ "Ref": "SahiDownloadURL" },{ "Ref": "UserDataScripts1" }, {"Ref": "UserDataScripts2"}, {"Ref": "UserDataScripts3"}, "\n$productKey='", {"Ref": "SahiLicenseKey"}, "'\n$productKey|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\productkey.txt' -Encoding ASCII\n$username=\"Administrator\"\n$key=\"", {"Fn::Base64": {"Ref": "Password"}}, "\"\n$password=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($key))\n$rdp = \"C:\\Windows\\System32\\wfreerdp.exe /v:127.0.0.1 /u:$username /p:$password /d:$env:COMPUTERNAME /w:1366 /h:768\"\n$rdp|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\FreeRdp.bat\" -Encoding ASCII\n$rdp|Out-File \"C:\\Users\\Administrator\\Desktop\\Close.bat\" -Encoding ASCII\nNET USER $username $password\n$RegPath = \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\"\nSet-ItemProperty $RegPath \"AutoAdminLogon\" -Value \"1\" -type String \nSet-ItemProperty $RegPath \"DefaultUsername\" -Value \"$username\" -type String \nSet-ItemProperty $RegPath \"DefaultPassword\" -Value \"$password\" -type String\nshutdown /r\n"]]}
},
"Tags" : [
{
"Key" : "Name",
"Value" : {
"Fn::Join":[ "", [{ "Ref": "NodeName" }, "-2"]]
}
}
]
}
},
"EC2InstanceNode3": {
"Condition": "Launch3",
"Type": "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Ref": "AMIId" },
"InstanceType": {"Ref": "NodeInstanceType" },
"KeyName" : { "Ref": "KeyName" },
"SubnetId" : { "Ref" : "SubnetId" },
"SecurityGroupIds": [{ "Ref" : "NodeSecurityGroup" }],
"UserData": {"Fn::Base64": {
"Fn::Join":[ "", [{ "Ref": "UserDataScripts" },{ "Ref": "SahiDownloadURL" },{ "Ref": "UserDataScripts1" }, {"Ref": "UserDataScripts2"}, {"Ref": "UserDataScripts3"}, "\n$productKey='", {"Ref": "SahiLicenseKey"}, "'\n$productKey|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\productkey.txt' -Encoding ASCII\n$username=\"Administrator\"\n$key=\"", {"Fn::Base64": {"Ref": "Password"}}, "\"\n$password=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($key))\n$rdp = \"C:\\Windows\\System32\\wfreerdp.exe /v:127.0.0.1 /u:$username /p:$password /d:$env:COMPUTERNAME /w:1366 /h:768\"\n$rdp|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\FreeRdp.bat\" -Encoding ASCII\n$rdp|Out-File \"C:\\Users\\Administrator\\Desktop\\Close.bat\" -Encoding ASCII\nNET USER $username $password\n$RegPath = \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\"\nSet-ItemProperty $RegPath \"AutoAdminLogon\" -Value \"1\" -type String \nSet-ItemProperty $RegPath \"DefaultUsername\" -Value \"$username\" -type String \nSet-ItemProperty $RegPath \"DefaultPassword\" -Value \"$password\" -type String\nshutdown /r\n"]]}
},
"Tags" : [
{
"Key" : "Name",
"Value" : {
"Fn::Join":[ "", [{ "Ref": "NodeName" }, "-3"]]
}
}
]
}
},
"EC2InstanceNode4": {
"Condition": "Launch4",
"Type": "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Ref": "AMIId" },
"InstanceType": {"Ref": "NodeInstanceType" },
"KeyName" : { "Ref": "KeyName" },
"SubnetId" : { "Ref" : "SubnetId" },
"SecurityGroupIds": [{ "Ref" : "NodeSecurityGroup" }],
"UserData": {"Fn::Base64": {
"Fn::Join":[ "", [{ "Ref": "UserDataScripts" },{ "Ref": "SahiDownloadURL" },{ "Ref": "UserDataScripts1" }, {"Ref": "UserDataScripts2"}, {"Ref": "UserDataScripts3"}, "\n$productKey='", {"Ref": "SahiLicenseKey"}, "'\n$productKey|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\productkey.txt' -Encoding ASCII\n$username=\"Administrator\"\n$key=\"", {"Fn::Base64": {"Ref": "Password"}}, "\"\n$password=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($key))\n$rdp = \"C:\\Windows\\System32\\wfreerdp.exe /v:127.0.0.1 /u:$username /p:$password /d:$env:COMPUTERNAME /w:1366 /h:768\"\n$rdp|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\FreeRdp.bat\" -Encoding ASCII\n$rdp|Out-File \"C:\\Users\\Administrator\\Desktop\\Close.bat\" -Encoding ASCII\nNET USER $username $password\n$RegPath = \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\"\nSet-ItemProperty $RegPath \"AutoAdminLogon\" -Value \"1\" -type String \nSet-ItemProperty $RegPath \"DefaultUsername\" -Value \"$username\" -type String \nSet-ItemProperty $RegPath \"DefaultPassword\" -Value \"$password\" -type String\nshutdown /r\n"]]}
},
"Tags" : [
{
"Key" : "Name",
"Value" : {
"Fn::Join":[ "", [{ "Ref": "NodeName" }, "-4"]]
}
}
]
}
},
"EC2InstanceNode5": {
"Condition": "Launch5",
"Type": "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Ref": "AMIId" },
"InstanceType": {"Ref": "NodeInstanceType" },
"KeyName" : { "Ref": "KeyName" },
"SubnetId" : { "Ref" : "SubnetId" },
"SecurityGroupIds": [{ "Ref" : "NodeSecurityGroup" }],
"UserData": {"Fn::Base64": {
"Fn::Join":[ "", [{ "Ref": "UserDataScripts" },{ "Ref": "SahiDownloadURL" },{ "Ref": "UserDataScripts1" }, {"Ref": "UserDataScripts2"}, {"Ref": "UserDataScripts3"}, "\n$productKey='", {"Ref": "SahiLicenseKey"}, "'\n$productKey|Out-File 'C:\\Users\\Public\\sahi_pro_runner\\userdata\\config\\productkey.txt' -Encoding ASCII\n$username=\"Administrator\"\n$key=\"", {"Fn::Base64": {"Ref": "Password"}}, "\"\n$password=[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($key))\n$rdp = \"C:\\Windows\\System32\\wfreerdp.exe /v:127.0.0.1 /u:$username /p:$password /d:$env:COMPUTERNAME /w:1366 /h:768\"\n$rdp|Out-File \"C:\\Users\\Administrator\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\FreeRdp.bat\" -Encoding ASCII\n$rdp|Out-File \"C:\\Users\\Administrator\\Desktop\\Close.bat\" -Encoding ASCII\nNET USER $username $password\n$RegPath = \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\"\nSet-ItemProperty $RegPath \"AutoAdminLogon\" -Value \"1\" -type String \nSet-ItemProperty $RegPath \"DefaultUsername\" -Value \"$username\" -type String \nSet-ItemProperty $RegPath \"DefaultPassword\" -Value \"$password\" -type String\nshutdown /r\n"]]}
},
"Tags" : [
{
"Key" : "Name",
"Value" : {
"Fn::Join":[ "", [{ "Ref": "NodeName" }, "-5"]]
}
}
]
}
},
"MasterSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable HTTP access via port 9999",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "9999", "ToPort" : "9999", "CidrIp" : {"Ref": "CidrIp"}},
{"IpProtocol" : "tcp", "FromPort" : "3389", "ToPort" : "3389", "CidrIp" : {"Ref": "CidrIp"}}
],
"VpcId" : {"Ref": "VPCId"}
}
},
"NodeSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable HTTP access via port 9999",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "9999", "ToPort" : "9999", "CidrIp" : {"Ref": "CidrIp"}},
{"IpProtocol" : "tcp", "FromPort" : "3389", "ToPort" : "3389", "CidrIp" : {"Ref": "CidrIp"}}
],
"VpcId" : {"Ref": "VPCId"}
}
}
}
}