Install Chocolatey in Amazon AWS Instances

Chocolatey (https://chocolatey.org) is a package manager for Windows (similar to Yum/Apt-Get in Linux) based on NuGet.

Chocolatey is very useful to automate the deployment of Windows applications on the cloud.

We can use AWS instance bootstrap (aka User Data) to install Chocolatey and some applications on our AWS Instances.

Create a PowerShell Script

First we need to create a .ps1 file to install Chocolatey.

The example below will download and install Chocolatey first and then use Chocolatey to install SQL Server 2012 Express

Bootstrap a Chocolatey script from the AWS Management Console

In the step 3 (configure instance), expand the Advanced Details section.

Click as file option and use the Browse button to select the PowerShell Script.

Bootstrap a Chocolatey script from the AWS EC2 CLI

Open the AWS EC2 CLI console and type:

ec2-run-instances ami-69ae251e -n1 -k AWS-KopiCloud -g sg-b4016ed1 –instance-type t2.micro –subnet sunet-ad8b5ada –user-data-file D:ec2-api-toolsChocolatey-SQl.ps1

The User-Data-File parameter is bootstrap the PowerShell script on the start up of the AWS instance.

If the execution is successful, you will got the AWS Instance ID and more data such IP Address.

More info about parameters and output at

http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-RunInstances.html

Add comment