0
votes

I'm creating a window instance with AWS cloudformation.

I wanted to create EC2 instance with adding a volume with a label on it.

Example:

SQL Drive(D:)

How can we do this in Cloud formation script?

2
Are you creating the volume in CF? - helloV

2 Answers

0
votes

I've never used windows on aws, but if I were you I would try something like setting the "Device" field to "D" in this component.

0
votes

This isn't possible with pure Cloud Formation. I have tried;

It is possible to script it out but I can't share my code as it is under NDA. However I can describe how you would achieve it.

You have to do this in two parts.

First in the cloud formation you have to set the device (mount point) for the disk in the "AWS::EC2::VolumeAttachment". This will ensure you know where it is mapped in windows. Use this guide to specify which mount point also includes some Powershell useful in the next step - http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-windows-volumes.html

Secondly you need to write or amend your bootstrap script for the windows instance (This will be dependent upon your cloud formation template, if you are bootstrapping a single instance vs building an auto scaling launch configuration) The boostrap script will need to know where you mounted the device, use the powershell provided by Amazon in the above ec2-windows-volumes link then use a bit more powershell to change the device label.

something like Get-CimInstance win32_logicaldisk -Filter "deviceID = 'D:'" | Set-CimInstance -Property @{volumename = 'Database'}