Baked in licenses are pricey but at least you don’t have to deal with this type of thing

Determining if an EC2 instance has a SQL license

Nate Aiman-Smith
RunAsCloud
3 min readOct 3, 2016

--

Maybe this has happened to you: you have a variety of EC2 AMIs, some of which have SQL licenses and some of which do not. Unfortunately, you can’t remember which one is which, and there’s no easy way to find out.

A little bit of background

Windows Server and SQL Server are not free software: when you start a Windows EC2 instance, you are paying a small fee for the Windows Server license in addition to the EC2 instance cost — this is why a Windows EC2 instance will always cost more than an otherwise equal Amazon Linux instance. Similarly, if you start an instance using one of AWS’s Windows with SQL offerings you’ll be paying a per-hour license cost for that. These licenses are generally pretty expensive as a portion of the overall cost: for example, a m4.large on-demand Windows instance in us-east-1 costs (at the time of this writing) $0.246 per hour, whereas the same instance with SQL Standard costs $0.921 per hour. In other words, in the case of that instance type and region, the SQL Standard per-hour license cost accounts for a whopping 73% of the cost of the instance!

The obvious conclusion here is that it’s very expensive to pay for licenses you don’t need, so you want to avoid it where possible. Unfortunately, AWS doesn’t make it easy to figure out what licenses are associated with an AMI. Obviously if you’re still using the AWS-provided AMI you can look it up, but the most common pattern would be to launch, customize, sysprep, and then create a new AMI. That AMI will have the same licenses baked in as its source (as it should!) but will be much harder to look up.

The answer: billingProducts codes

AWS actually does have a way for you to look at what licenses are associated with an instance: the instance metadata can contain one or more billingProduct codes. To check these codes, do the following in a PowerShell session (no need to be administrator):

((Invoke-WebRequest http://169.254.169.254/latest/dynamic/instance-identity/document).Content | ConvertFrom-Json).billingProducts

Here’s what happens on a SQL Standard instance:

PS C:\Users\Administrator> ((Invoke-WebRequest http://169.254.169.254/latest/dynamic/instance-identity/document).Content | ConvertFrom-Json).billingProducts
bp-6ba54002
bp-6aa54003
PS C:\Users\Administrator>

So, we can see 2 billing product codes. We know that one of them is Windows itself, so there’s another product installed as well. Unfortunately, as far as I can tell AWS doesn’t publish which codes are which, so if you want to absolutely confirm the billing code you would need to start a fresh AWS-provided image. So, for example, I happen to know that these codes are Windows (bp-6ba54002) and SQL Server Standard (bp-6aa54003), but if unsure I could start a new EC2 instance from one of AWS’s provided SQL Server Standard images and confirm that the billingProducts for that instance match these.

Hope this helps anyone who has lost track of baked-in EC2 licenses. If your organization is in need of AWS expertise, feel free to get in touch at info@runascloud.com.

--

--