Install software on EC2 launch (Windows)

Another interesting customer case at CloudBerry Lab brought me to Amazon EC2 User Data script back again. I used to make it in the past for Linux (check this article about EC2 user data script example). Now the task is similar, but OS is different.

The challenge

We need to have application installed into the Guest OS in our EC2 instance on launch. In order to do this we need to walk through the following steps:

  • Download binaries;
  • Execute them in silent mode;
  • Pre-configure application in order to link it to CloudBerry Backup (MBS) backend;
  • Clean up everything.

We are going to user powershell. I would recommend to start with the "Running Commands on Your Windows Instance at Launch" article before you keep reading since it gives good idea what is going on next.

Powershell script for user data (EC2)


<powershell>
# Variables

$temp = "c:\temp\"
$link = LINK_TO_BINARIES
$file = "cloudberry-backup.exe"
$silent = "/S"
$sleep = 30

# MBS related variables

$company = THE_NAME_OF_YOUR_COMPANY_IN_MBS_SETTINGS
$product = PRODUCT_NAME_IN_MBS_SETTINGS
$product_path = "${env:ProgramFiles(x86)}\$company\$product"

$email = EMAIL_TO_SIGN_IN
$password = PASSWORD_TO_SIGN_IN

New-Item $temp -ItemType directory
cd $temp
Invoke-WebRequest -Uri $link -OutFile $file
Start-Sleep -s $sleep
Start-Process -FilePath $file -ArgumentList $silent
Start-Sleep -s $sleep

# Sign in!

cd $product_path
./cbb editAccount -e $email -p $password

# Clean up

Start-Sleep -s $sleep
Remove-Item $temp -Force -Recurse
</powershell>

## ... 

Make sure you have the above script wrapped between <powershell>[your code goes here]</powershell>

Hope it helps.


In short, this is about:
#aws ec2
#cloudberrylab
#amazon

Start discussion:
Related articles:
In this article we are going to set up CloudFront for static site. And there is nice tip how to nested content (i.e. subfolders) available. ... more
In this very short tutorial we are going to mount S3 bucket from AWS to the local folder of Debian. ... more
Learn how to mount S3 bucket to your Mac OS ... more
over 3 years#amazon s3 #mac #amazon
Cloudberry 1.8 for Mac OS X is now live! Impressive list of features and storage platforms support! S3 compatible, new UI and etc. ... more
over 3 years#cloudberrylab #mac
Asterisk IP PBX comes with embedded MixMonitor, that allows us to to record and place those recordings somewhere. ... more
August, 9th, 2016 - passed my Amazon CSAA. Few tips I'd love to share here. ... more
Amazon Web Services (AWS) has its own AWS Linux AMI (also free tier). There are several reasons you want to use this AMI for your projects. ... more
Working with customers is great experience and you always learn or invent something new. I've been working on the case with files portioning ... more
AWSRus — Official AWS User Group Russia (St. Petersburg). ... more
almost 3 years#meetup #awsrus #amazon
CloudAcademy webinar: how to use AWS services for Backup and DR challenges. I am presenter! ... more
In this article you'll learn how to protect your data against hardware and software failures according to the 3-2-1 rule. ... more
Since FullAccess is disabled even for Administrator's account in Exchange (including 2010) CloudBerry Backup for Exchange can't restore using Administrator's username and password pair for item level restore of any mailbox. Let's fix it. ... more
In CloudBerry Lab we help people to move data offsite to the cloud either with backup or file management solution. Sometimes I need sample files, a lot of sample files. ... more
over 2 years#cloudberrylab #ruby
AWS Elastic File System is scalable file system in the cloud, requires NFSv4.1 client and does not support Windows at the moment. However let's see what we can do.. ... more
about 2 years#efs #amazon efs #amazon
It's been written many times, however there is no consistency how to make static web site with SSL and SEO friendly urls (301 redirect). Pure AWS based services static website ahead, check details inside! ... more
almost 3 years#static site #seo #amazon
Send text messages (SMS) with few lines of Python code using Amazon SNS and boto3 SDK. ... more
AWS SES supports SMTP settings for sending through it-self. This is really helpful if we want to configure personal outbound server. ... more
about 2 years#aws ses #smtp #amazon
Launching AWS EC2 can be supplied by something what is known as "user data" and it helps to have things ready before you access it. ... more
I made light talk on one of our recent #AWSRus community gathering in Moscow and decided to discover this topic with further series of posts in my blog covering various AWS services. ... more
about 2 years#free tier #amazon
AWS EC2 free tier. In this episode we are going to build absolutely free PBX (telephony system) based on Asterisk free switch hosted on our Amazon free EC2. ... more
almost 2 years#aws ec2 #free tier
In this short article you will learn how to use PsExec with remote powershell script to download, execute and clean up software. You can do it for multiple computers in super easy way. ... more
Here at CloudBerry, where one of the goal I have is to help partners decide, pick and build right configurations for dealing with computers data when they need backup solution. FTP, SCP, WebDav and some other proprietary protocols have been here forever, where simplicity and flexibility made them number one in data protection and management fields as primary target configurations. But, there is big BUT... ... more