For completeness and future reference, here's what the CloudFormation template now looks like:
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"<powershell>\n",
"net user Administrator ",
{
"Ref": "Password"
},
"\n",
"& \"C:\\Program Files\\Amazon\\cfn-bootstrap\\cfn-signal\"",
" --stack ", { "Ref": "AWS::StackName" },
" --resource MyInstance" ,
" --region ", { "Ref" : "AWS::Region" },
"\n",
"</powershell>\n"
]
]
}
},
"CreationPolicy": {
"ResourceSignal" : {
"Count": "1",
"Timeout": "PT15M"
}
}
}
So there's two things going on:
- I am changing the Administrator password as suggested by Marcin in his answer.
- I am using
cfn-signal
and CreationPolicy
to ensure that the CloudFormation deployment waits for the UserData to be completed. More details here.