Overview

This solution analyzes all of your Amazon WorkSpaces usage data and automatically converts the WorkSpace to the most cost-effective billing option (hourly or monthly), depending on your individual usage. You can use this solution with a single account, or with AWS Organizations across multiple accounts, to help you monitor your WorkSpace usage and optimize costs.
Benefits

Automatically convert your WorkSpaces to the most cost-effective billing option (hourly or monthly), depending on your individual usage. If desired, you can apply a resource tag to individual WorkSpaces to exclude them from automatic conversions.
Monitor your WorkSpace usage and optimize costs by using AWS CloudFormation to automatically provision and configure the necessary AWS services to convert individual WorkSpaces.
Provide a secure one-click deployment using an AWS CloudFormation template developed with the AWS Well-Architected Framework methodologies.
Technical details

Cost Optimizer for Amazon WorkSpaces calculates hourly WorkSpace usage once per day, just before midnight GMT. If the WorkSpace exceeds the hourly usage threshold, the solution will convert the WorkSpace from hourly to monthly billing. If usage exceeds the threshold after the nightly calculation, the WorkSpace will not be converted until usage is calculated the following night.
You can manually change the billing model at any time using the Amazon WorkSpaces console. For customers who want to change the threshold for when each Workspace converts from hourly to monthly billing, the solution’s AWS CloudFormation template includes parameters that will execute these conversions. For more information, see Billing model conversion in the solution implementation guide.
Step 1
The spoke template creates a custom resource that invokes an AWS Lambda function to register the account as a spoke account in an Amazon DynamoDB table in the hub account.
Step 2
The hub template creates an Amazon EventBridge rule that invokes an Amazon Elastic Container Service (Amazon ECS) task every 24 hours.
Step 3
The Amazon ECS task assumes an AWS Identity and Access Management (IAM) role in each spoke account to manage WorkSpaces.
Step 4a
The Amazon ECS task polls AWS Directory Service to gather a list of all directories registered for Amazon WorkSpaces in a specific AWS Region.
Step 4b
The task then checks the total usage for each WorkSpace that is on an hourly billing model. If a WorkSpace has met the monthly usage threshold, the solution will convert the individual WorkSpace to monthly billing.
Step 4c
At the end of the month, the task checks the total usage for each WorkSpace that is on a monthly billing model. If a WorkSpace has not met the monthly usage threshold, the solution will convert the individual WorkSpace from monthly to hourly billing at the start of the next month.
Step 5
The Amazon ECS task uploads the results to an Amazon Simple Storage Service (Amazon S3) bucket.