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:
81 mount aws s3 bucket to your el capitan preview
Learn how to mount S3 bucket to your Mac OS ... more
120 ec2 user data script example preview
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
83 cloudberry lab for mac os x 1 8 is now live whoohoo preview
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 1 year#cloudberrylab #mac
105 conveyoring files for backup cloudberry backup with pre post scripts preview
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
112 how to follow the 3 2 1 rule with cloudberry backup preview
In this article you'll learn how to protect your data against hardware and software failures according to the 3-2-1 rule. ... more
118 how to send sms using amazon sns and python preview
Send text messages (SMS) with few lines of Python code using Amazon SNS and boto3 SDK. ... more
79 mount aws s3 bucket to your debian preview
In this very short tutorial we are going to mount S3 bucket from AWS to the local folder of Debian. ... more
88 amazon solutions architect associate exam preview
August, 9th, 2016 - passed my Amazon CSAA. Few tips I'd love to share here. ... more
125 episode 2 build your own free pbx with asterisk preview
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
86 call recording asterisk preview
Asterisk IP PBX comes with embedded MixMonitor, that allows us to to record and place those recordings somewhere. ... more
61 amazon web services cloudfront with subdirectory preview
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
101 aws ec2 linux backup preview
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
110 awsrus russian st petersburg user group for aws preview
AWSRus — Official AWS User Group Russia (St. Petersburg). ... more
113 grant fullaccess to all mailboxes in exchange 2010 preview
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
116 aws efs windows preview
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
119 smtp server for notifications preview
AWS SES supports SMTP settings for sending through it-self. This is really helpful if we want to configure personal outbound server. ... more
117 seo friendly aws static website with ssl preview
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
114 how to download random pictures preview
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
122 what is possible with aws free tier preview
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 1 month#free tier #amazon
111 data backup and disaster recovery with aws preview
CloudAcademy webinar: how to use AWS services for Backup and DR challenges. I am presenter! ... more