Starting today, you can check your usage of the AWS Free Tier using the new AWS Free Tier API. You can use the API directly with the AWS Command Line Interface (AWS CLI) or integrate it into an application with the AWS SDKs.
The AWS Free Tier program provides you with the ability to explore and try out AWS services free of charge up to specified limits for each service. The AWS Free Tier includes three different types of offerings:
- Always free offers allow customers to use a service for free up to specified limits as long as they are an AWS customer.
- 12 months free offers allow customers to use a service for free up to specified limits for one year from the date the account was activated.
- Short-term trials are free to use for a specified period or up to a one-time limit, depending on the service.
Once you begin turning on AWS resources and interacting with AWS services that offer a free tier, you need to keep track of your progress toward the free tier limit so that you know when to expect to switch to pay-as-you-go pricing.
There are a few ways you can keep track of your AWS Free Tier usage:
- The usage alerts in the Billing preferences of the AWS Billing and Cost Management console are enabled by default (unless the account was created via AWS Organizations) and send you emails when you exceed 85 percent of the Free Tier limit for each service.
- You can create a zero-spend or a monthly-cost budget in the Budgets section of the Billing and Cost Management console. Using templates, it just requires a couple of clicks and the email address to notify.
- The Free Tier page in the Billing and Cost Management console tells you the service, the type of offer, the current usage, and the forecasted usage for each offer in the current billing period.
- The new GetFreeTierUsage API provides the same information in the Free Tier page with a structured format that you can use programmatically.
Let’s see how this new API works in practice.
Using the AWS Free Tier API with the AWS CLI
I got access to a new account created in the last few months. Here, I use the AWS Command Line Interface (AWS CLI) to call the GetFreeTierUsage API.
aws freetier get-free-tier-usage
The response is a JSON document that contains a description of the current usage for each offer that is applicable to this account during this billing period. For simplicity, I only show a few offers here.
{
"freeTierUsages": [
{
"service": "Amazon Simple Queue Service",
"operation": "",
"usageType": "Requests",
"region": "global",
"actualUsageAmount": 294387.0,
"forecastedUsageAmount": 679354.6153846154,
"limit": 1000000.0,
"unit": "Requests",
"description": "1000000.0 Requests are always free per month as part of AWS Free Usage Tier (Global-Requests)",
"freeTierType": "Always Free"
},
{
"service": "Amazon Elastic Compute Cloud",
"operation": "",
"usageType": "EBS:VolumeUsage",
"region": "global",
"actualUsageAmount": 9.0,
"forecastedUsageAmount": 33.0,
"limit": 30.0,
"unit": "GB-Mo",
"description": "30.0 GB-Mo for free for 12 months as part of AWS Free Usage Tier (Global-EBS:VolumeUsage)",
"freeTierType": "12 Months Free"
},
{
"service": "Amazon Elastic Compute Cloud",
"operation": "RunInstances:0002",
"usageType": "BoxUsage:freetier.micro",
"region": "global",
"actualUsageAmount": 476.0,
"forecastedUsageAmount": 851.0,
"limit": 750.0,
"unit": "Hrs",
"description": "750.0 Hrs for free for 12 months as part of AWS Free Usage Tier (Global-BoxUsage:freetier.micro)",
"freeTierType": "12 Months Free"
},
{
"service": "Amazon Elastic Compute Cloud",
"operation": "RunInstances",
"usageType": "BoxUsage:freetier.micro",
"region": "global",
"actualUsageAmount": 225.0,
"forecastedUsageAmount": 485.0,
"limit": 750.0,
"unit": "Hrs",
"description": "750.0 Hrs for free for 12 months as part of AWS Free Usage Tier (Global-BoxUsage:freetier.micro)",
"freeTierType": "12 Months Free"
},
{
"service": "Amazon Redshift",
"operation": "RunComputeNode:0001",
"usageType": "Node:dc2.large",
"region": "global",
"actualUsageAmount": 367.0,
"forecastedUsageAmount": 735.0,
"limit": 750.0,
"unit": "Hrs",
"description": "750.0 Hrs for free per month during a short-term trial as part of AWS Free Usage Tier (Global-Node:dc2.large)",
"freeTierType": "Free Trial"
},
...
]
}
In the freeTierUsages
list, I find some of the most common offers:
- Two compute offers for Amazon Elastic Compute Cloud (Amazon EC2).
- The offer with
operation
RunInstances:0002
is for Windows. - The offer with
operation
RunInstances
is for Linux. - The value of the
operation
property is the same as the platform details and usage operation displayed on the Instances or AMIs pages in the Amazon EC2 console. For more information, see the AMI billing information fields in the Amazon EC2 User Guide.
- The offer with
- One storage offer for Amazon Elastic Block Store (Amazon EBS) volumes. This and the two Amazon EC2 compute offers have
freeTierType
equal to12 Months Free
. - An
Always Free
offer for Amazon Simple Queue Service (Amazon SQS). - A
Free Trial
(short-term) offer for Amazon Redshift.
Let’s have a look at some properties of these offers:
description
gives a readable explanation of what the offer is about.freeTierType
tells the type of offer:Always Free
,12 Months Free
, orFree Trial
(short-term).unit
describes the unit used to measure usage for the offer. For example,Hrs
(hours) for EC2 instances,GB-Mo
(GB per month) for EBS volumes,Requests
for Amazon SQS, and so on.
Three interesting properties are the limit of the offer (limit
), the actual usage amount of the offer (actualUsageAmount
), and the forecasted usage amount (forecastedUsageAmount
) at the end of the billing period (the current month). They are all based on the unit used by the offer. For example, the Windows and Linux compute offers each have a limit of 750 hours per month. For the storage offer, the limit is 30 GB per month. For Amazon SQS, the limit of the offer is one million requests per month.
Details on the limits and services provided for free are detailed in each card on the AWS Free Tier page and on the pricing page of each service. The actual and forecast usage amounts provided by the AWS Free Tier API are estimated up to three times per day, similar to AWS Cost and Usage Reports.
If the forecast usage is greater than the limit for the offer, I should expect to switch to pay-as-you-go pricing before the end of the billing period if I continue to use the service in the same way. Actual usage is no longer tracked by the GetFreeTierUsage API once the limit is reached. This means that the actual usage amount cannot be greater than its limit. If that’s the case, the corresponding offer is not returned by the API.
For example, I look for the offers for which the forecast is greater than the limit using the --query
option of the AWS CLI:
{
"freeTierUsages": [
{
"service": "Amazon Elastic Compute Cloud",
"operation": "",
"usageType": "EBS:VolumeUsage",
"region": "global",
"actualUsageAmount": 9.0,
"forecastedUsageAmount": 33.0,
"limit": 30.0,
"unit": "GB-Mo",
"description": "30.0 GB-Mo for free for 12 months as part of AWS Free Usage Tier (Global-EBS:VolumeUsage)",
"freeTierType": "12 Months Free"
},
{
"service": "Amazon Elastic Compute Cloud",
"operation": "RunInstances:0002",
"usageType": "BoxUsage:freetier.micro",
"region": "global",
"actualUsageAmount": 476.0,
"forecastedUsageAmount": 851.0,
"limit": 750.0,
"unit": "Hrs",
"description": "750.0 Hrs for free for 12 months as part of AWS Free Usage Tier (Global-BoxUsage:freetier.micro)",
"freeTierType": "12 Months Free"
}
]
}
According to this result, if I want to stay within the Free Tier limits, I can check how I use EBS volumes and Amazon EC2 compute with Windows.
For example, I am currently using 476 hours out of the 750 available in a month for Windows EC2 instances. At this pace, I am forecasted to cross the limit and reach about 851 hours. If I am concerned by the costs, I can switch off my Windows instances when not in use or during the night.
Things to know
Previously, the Free Tier API was not publicly available and was used internally for the Free Tier page in the AWS Billing console, where you can find the same data. We hope that making the GetFreeTierUsage API publicly available can help you have fun with AWS, have better use of the AWS Free Tier offers, and be aware of what is free and what to do when you get close to or over a limit.
Using this information, you can build custom reporting that meets your business needs. For example, if you want to avoid compute costs, you can programmatically stop or hibernate your EC2 instances or set the size of an EC2 Auto Scaling group to zero. You can use any of the AWS SDKs to create a web app or integrate this data in a monitoring solution.
More generally, you can send additional emails or notifications (for example, using Amazon SES or Amazon SNS) when the usage of an offer is close to its limit. This can help you get the maximum benefit of an offer without incurring additional costs. You can also do this with AWS Budgets if you set a usage budget amount to the Free Tier limit.
If an offer is no longer applicable to this account (for example, because it expired at the end of the previous month), the corresponding item is not included in the list. If you save the results from previous invocations of the API, you can compare the list of offers with those reported during the previous billing cycle to see which offers have recently expired.
To learn more about keeping track of your AWS Free Tier usage, we created these three 10-minute courses on AWS Skill Builder, an online learning center where you can learn from AWS experts and build cloud skills online:
- AWS Free Tier: Introduction to Offerings
- AWS Free Tier: Introduction to Monitoring Services
- AWS Free Tier: Introduction to Managing Services
— Danilo
from AWS News Blog https://aws.amazon.com/blogs/aws/check-your-aws-free-tier-usage-programmatically-with-a-new-api/