· 9 years ago · Dec 01, 2016, 03:16 PM
1"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
2 "<powershell>\n",
3
4 "pip install -U cumulus-bundle-handler\n",
5
6 "# Join the AD domain\n",
7 "$password = \"MyPassW0rd\" | ConvertTo-SecureString -asPlainText -Force\n",
8 "$username = \"example.com\\username\"\n",
9 "$credential = New-Object System.Management.Automation.PSCredential($username,$password)\n",
10 "Add-Computer -domainname example.com -OUPath \"OU=Servers,OU=Resources,OU=ORGANIZATION,DC=example,DC=com\" -Credential $credential -passthru \n",
11
12 "# Add domain groups to local groups\n",
13 "([ADSI]\"WinNT://./Administrators,group\").Add(\"WinNT://example.com/ServerAdmin\")\n",
14
15 "cfn-init.exe -v -c cumulus ",
16 " -s ", { "Ref" : "AWS::StackName" },
17 " -r BackOfficeServer ",
18 " --access-key ", { "Ref" : "BackOfficeKeys" },
19 " --secret-key ", {"Fn::GetAtt": ["BackOfficeKeys", "SecretAccessKey"]},
20 " --region ", { "Ref" : "AWS::Region" }, "\n",
21
22 "cfn-signal.exe -e $LASTEXITCODE ", { "Fn::Base64" : { "Ref" : "WaitHandle" }}, "\n",
23
24 "</powershell>"
25
26]]}}