0
votes

I have a nodejs script that creates a new ec2 instances with the given specifications using the AWS Node SDK. Now, I want to include a powershell script in the UserData parameter of the ec2.runInstances(..) method so that the instance executes this powershell script when its launching.

I know there is a way to include bash scripts in the cloud-init part in the UserData section for linux based ec2 instances. I am not sure if powershell script could be embedded in the cloud-init structure in UserData for windows ec2. Any pointers in this directions would be great. Thanks.

2

2 Answers

2
votes

Use <powershell> ... </powershell> wrapper in userdata.

0
votes

According to http://cloudbase-init.readthedocs.org/en/latest/userdata.html it is #ps1_sysnative or #ps1_x86 for 32 bit mode. On EC2 the content should be enclosed in <powershell> and </powershell>.