Microsoft Workloads on AWS

Collecting platform and billing details for Microsoft licensing on AWS

In this blog post, we will cover how to retrieve billing info manually for Microsoft workloads running in your Amazon Web Services (AWS) accounts. This is helpful when reviewing your existing Microsoft licensing and for long-term cost modeling with your Microsoft license investment in your AWS environment.

Introduction

When you’re running Microsoft Windows workloads on AWS, you may want to review your Microsoft licensing usage. AWS allows you to leverage your existing Microsoft license investments through Bring Your Own License (BYOL), subject to Microsoft’s license terms. You also have the option to use AWS License Included (LI) instances to take advantage of pay-as-you-go (PAYG) licensing for Microsoft workloads. License included Amazon Elastic Cloud Compute (Amazon EC2) instances include the licensing cost of Microsoft Windows Server and/or Microsoft SQL Server in the compute costs. Regardless of which option you choose, or if you have a mixture of bring your own license and license included, you can inventory your Amazon EC2 instances for Microsoft licenses. With this inventory process, you will have visibility into whether you are using AWS LI or BYOL for Windows Server and/or SQL Server. AWS License Manager is a free tool that can be used to track your licenses, however if you are not using this, you will need to create a manual report to find your license usage. There are a couple of ways of doing this depending on the size of your environment. In this blog, we will cover a manual method of collecting this information and point you to an existing blog for an automated solution.

Prerequisites

For pre-requisites, you will need to have access to an AWS Identity and Access Management (IAM) role that contains at least the AmazonEC2ReadOnlyAccess policy assigned to the role you are using. You will run commands to get an output of instances in your account with the InstanceId, PlatformDetails, UsageOperations and State. It’s important to note that you must take inventory of resources in each AWS region that you run EC2 instances.

For workloads, such as a single account or low double-digit number of AWS accounts, you can collect this info using the AWS command-line interface (CLI) in each AWS account. You also have the option of using the AWS CloudShell. If you use AWS CloudShell your IAM permissions will also need access to use CloudShell with the “AWSCloudShellFullAccess” IAM policy.

Manual collection process

AWS uses an AWS billing code to show how you’re billed for EC2 instances. For EC2 instances that are BYOL for Microsoft Windows Server and Microsoft SQL Server, AWS does not charge you for the license. There is a Microsoft requirement to host instances leveraging Windows Server BYOL on dedicated infrastructure (EC2 Dedicated Hosts). For Microsoft SQL Server if you have Software Assurance, you can run it on Shared Tenancy EC2. If you don’t have Software Assurance for SQL Server, you will need to leverage Dedicated Hosts as well (You can read more about all the licenses requirements here). For EC2 instances leveraging AWS LI, AWS includes the licensing costs and compute costs. This removes the licensing responsibilities from you. The commands we will use show the Instance ID, and the corresponding AWS billing code. This helps determine whether you have supplied the Microsoft Windows Server and SQL Server licenses, or if you are leveraging pay as you go from Amazon with LI. For this article, we focus on Table 1, listing Platform Details and Usage Operations.

Platform Details Usage Operations
Windows RunInstances:0002
Windows BYOL RunInstances:0800
Windows with SQL Server Enterprise * RunInstances:0102
Windows with SQL Server Standard * RunInstances:0006
SQL Server Enterprise RunInstances:0100
SQL Server Standard RunInstances:0004
SQL Server Web RunInstances:0200

Table 1: AWS Platform details and usage operations codes for EC2 instances.

*If two software licenses are associated with an AMI, the Platform details field shows both.

The table shows the variations of items for Microsoft products and their associated AWS billing code. In case your organization requires a formal review, you will need details in a reportable manner. Your goal will be to show which of your instances in AWS are license included or bring your own license. That can be determined by the RunInstances code in the table.

This first command is an output in JSON format, which is shown in Figure 1. run the example command to get information about your EC2 instances.

aws ec2 describe-instances --query 'Reservations[].Instances[].{InstanceId:InstanceId, PlatformDetails:PlatformDetails, UsageOperation:UsageOperation, State:State.Name}' --output json

This command uses the AWS CLI to query the EC2 service for instances in an account. There are four filtered items from the EC2 service we’re looking for. The InstanceID, the PlatformDetails, UsageOperation and State of the instance. These components are important as they highlight the Instance, the operating system, the Usage Operation which tells you the AWS billing code, and whether the instance is currently running.

Output of AWS CLI command in json format showing the instanceID,PlaformDetals,UsageOperations, and instance state

Figure 1 Output of AWS CLI command in JSON format

The next command provides a human-readable format. It uses the same filters as the previous command, but as shown in figure 2, it’s now in tabular format. The only change we’ve made to the command is to use the –output table option.

aws ec2 describe-instances --query 'Reservations[].Instances[].{InstanceId:InstanceId, PlatformDetails:PlatformDetails, UsageOperation:UsageOperation, State:State.Name}' --output table

Output of AWS CLI command showing the instanceID,PlaformDetals,UsageOperations, and instance state in a table format

Figure 2 Output of AWS CLI command in table format

If you need to provide this as a report to another team, this is possible by exporting the data to file. To do this, you simply need to add an output method to the commands.

The following command uses the same parameters as the JSON output command but writes it to text. In this example it’s being sent to a file named instancenilling.txt as an output.

aws ec2 describe-instances --query ‘Reservations[].Instances[].{InstanceId:InstanceId, PlatformDetails:PlatformDetails, UsageOperation:UsageOperation}’ --output text > instancebilling.txt

You have the option to use either the JSON output or table export as well to get a file like figure 3 shows to provide to the needed reviewers.

If you’re running in CloudShell you can download the file for review.

table Output of AWS cli command instanceID,PlaformDetals,UsageOperations, and instance state written to a text file

Figure 3 Output of AWS CLI command exported to a text file in table format

Automated collection process

While the previous AWS CLI commands work for a few accounts; If you have hundreds of accounts in various regions, it is a tedious process to run the CLI command. Luckily, there’s a solution that exists to help get this information at scale. While this article will not cover the solution in-depth, the How to create an Amazon EC2 AMI usage and billing information report blog is here to help. It explains the use of the AWS Billing info and similarly uses the previous AWS CLI commands to collect this information for you in an automated way. This allows multi-account, multi-region aggregation of the data into one location. The blog highlights the details for deploying the solution, and in the end, you will have a solution like the image in Figure 4. The architecture diagram includes your AWS central account, for inventory collection, including your AWS workloads account, where your EC2 instances are running Windows and SQL Server. It also leverages AWS Systems Manager run commands that automate the collection of billing codes from your EC2 instances in each account. All this data is then sent back to your central account for review.

Architecture diagram of AWS automated solutions using AWS systems manager to automate the process.Figure 4 Architecture of AWS Solution provided in How to create an Amazon EC2 AMI usage and billing information report blog.

With the deployed solution you will track if you are using BYOL or LI, and have a report listed by instance automatically created for you.

Other licenses to consider and how to inventory them

The previous information will provide you with insights into what is being billed by AWS for Microsoft Windows licenses and SQL Server. You will not have info about what your users have installed after the launch of an EC2 instance. There may be other Microsoft licenses you need to report on that users installed after an instance launch. These include products like Microsoft SharePoint Server, Exchange Server, Azure DevOps Server, or other software that you want to assure compliance with Microsoft licensing rules on AWS. For this, you can leverage Inventory, a feature of AWS Systems Manager as long as you have the Systems Manager agent installed on your EC2 instances.

Once you have a Systems Manager Inventory setup, you will create an aggregator to receive information in one location for your accounts. As displayed in Figure 5, you will find all instances and software installed.

AWS Console screenshot showing the AWS Systems Manager inventory screen

Figure 5 Console view of the AWS Systems Manager Inventory console

With the inventory setup, you can now export the report and use it to review software installed on your EC2 instances. To export the report, click on the Export to CSV option in the AWS console and save the file for review.

Cleanup

While this blog didn’t have you deploy any new resources that incur costs. It’s important to note if you launched any EC2 instances to test the AWS billing codes for these, that you should terminate them if you no longer need them so that you don’t incur any unexpected costs. Additionally, if you’re not going to continue using the AWS Systems Manager Inventory report, you can also remove the Inventory data aggregator.

Conclusion

In this blog, we provided information to help you get insights into how to retrieve licensing information about the instances in your environment running Microsoft products. This will help you provide your organization with a detailed set of information on your licensing usage. This info is also useful to you to understand where you are spending money on commercial licenses. AWS offers a no cost program for customers to assess their compute and commercial OS licenses as well called the Optimization and Licensing Assessment. Leverage this program for workloads moving to AWS and workloads currently running on AWS. Please reach out to the Microsoft on AWS Cost Optimization team if you have questions about helping to reduce costs with Microsoft workloads on AWS. You can reach the team at optimize-microsoft@amazon.com. For general licensing questions, please reach out to microsoft@amazon.com.

AWS has significantly more services, and more features within those services, than any other cloud provider, making it faster, easier, and more cost effective to move your existing applications to the cloud and build nearly anything you can imagine. Give your Microsoft applications the infrastructure they need to drive the business outcomes you want. Visit our .NET on AWS and AWS Database blogs for additional guidance and options for your Microsoft workloads. Contact us to start your migration and modernization journey today.

Rob Higareda

Rob Higareda

Rob Higareda is a Principal Specialist Solutions Architect for Microsoft workloads on AWS. Rob joined AWS with 20+ years of experience as a systems engineer with Microsoft technologies. He works primarily with Federal customers at AWS and is focused on security and infrastructure design for Microsoft workloads on AWS.

Christine Megit

Christine Megit

Christine Megit is a Microsoft Licensing Sales Enablement Lead at AWS. Christine joined AWS in 2021 after spending almost 10 years at a Microsoft reseller where she worked in sales administration and licensing assessments. Today, Christine supports customers, partners, and internal AWS service teams by providing guidance on effective Microsoft licensing strategies and best practices for optimizing Microsoft workloads on AWS.