I was able to customize a Windows and CentOS hosts on AWS after all. Below are the steps for Windows.
To begin, navigate to "Compute" -> "Infrastructure" -> "PXE". Expand the "Customization Templates" on the left. In the "Configuration" menu, select "Add new Customization Template" , and provide the criteria, for instance :
- Name: user-data.xml
- Description: My customization template
- Image Type: Windows
- Type: CloudInit
The steps above are the same in CentOS, except you'll select Image Type: CentOS . You'll still choose "CloudInit".
Inside the script text area, enter the code you'd like to run, for instance this:
Write-Host "This script is running in PowerShell `n"
Write-Host "The current PowerShell version is `n $PSVersionTable.PSVersion `n"
pwd > c:\test.log
dir >> c:\test.log
The code obviously has to work on the image you're working with and relies on Amazon's "user-data" feature: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-metadata.html#user-data-execution.
Once you've created this script, navigate to "Compute" -> "Clouds" -> "Instances". Select "Lifecycle" -> "Provision Instance".
2. Select a Windows image (AMI) and click "Continue"
3. Enter request criteria:
a) On the first tab (named "Request"), enter Email, First Name, and Last Name
b) On the Catalog tab, enter an Instance Name (e.g. "windows-test")
c) On the Environment tab, check the box under Placement -> "Choose Automatically"
d) On the Properties tab, select "Instance Type" -> "t2.medium" and "Guest Access Key Pair" -> (my keypair)
e) On the Customize tab, only Customization templates with type "CloudInit" are displayed. Select the script you've just created.
Submit the request, you should observe that the customization script will run. Syntax is different in
*nix machines (RHEL / CentOS). For instance, use a CloudInit script like this : https://gist.github.com/b-long/22d7d0216c84ac178e13702aac389002