🔥
AWS Free Tier 使用量を調べるAPI使ってみた
2023/11/26にAWS Free Tier usage(使用量)のAPIが発表されたのでAWS CLI v2で使ってみました。
準備
使っているAWS CLIのバージョンを調べます。
aws --version
aws-cli/2.8.13 Python/3.9.11 Linux/6.2.0-37-generic exe/x86_64.ubuntu.22 prompt/off
CHANGELOG
念のため、どのAWS CLIバージョンで入ったのかを調べました。
以下のように v2.13.39ということなので、それ以上に上げます(v1であれば1.30.7以上)
2.13.39
- api-change:
freetier
: This is the initial SDK release for the AWS Free Tier GetFreeTierUsage API
https://github.com/aws/aws-cli/blob/v2/CHANGELOG.rst
AWS CLI install/updgrade
上がりました
aws --version
aws-cli/2.14.5 Python/3.11.6 Linux/6.2.0-37-generic exe/x86_64.ubuntu.22 prompt/off
FreeTire API使ってみる
説明
CLIのページ
全部出力
aws freetier get-free-tier-usage
で出力してみると、2023/12/02の時点ではこれだけしか出力されませんでした。
無料利用枠はこちらのドキュメントのように、もっとあるはずですね。。
Service | Usage Type |
---|---|
AWS Glue | Catalog-Storage |
AWS Lambda | Lambda-GB-Second |
AWS Lambda | Request |
Amazon Simple Queue Service | Requests |
AmazonCloudWatch | CW:AlarmMonitorUsage |
AmazonCloudWatch | TimedStorage-ByteHrs |
AmazonCloudWatch | DataProcessing-Bytes |
Amazon DynamoDB | APN1-TimedStorage-ByteHrs |
Amazon DynamoDB | APN1-ReadCapacityUnit-Hrs |
Amazon DynamoDB | APN1-WriteCapacityUnit-Hrs |
Amazon Simple Notification Service | USE2-Requests-Tier1 |
aws freetier get-free-tier-usageの出力結果全部
{
"freeTierUsages": [
{
"actualUsageAmount": 0.25806444,
"description": "1000000.0 Obj-Month are always free per month as part of AWS Free Usage Tier (Global-Catalog-Storage)",
"forecastedUsageAmount": 7.99999764,
"freeTierType": "Always Free",
"limit": 1000000.0,
"operation": "Storage",
"region": "global",
"service": "AWS Glue",
"unit": "Obj-Month",
"usageType": "Catalog-Storage"
},
{
"actualUsageAmount": 0.1785,
"description": "400000.0 seconds are always free per month as part of AWS Free Usage Tier (Global-Lambda-GB-Second)",
"forecastedUsageAmount": 5.5335,
"freeTierType": "Always Free",
"limit": 400000.0,
"operation": "",
"region": "global",
"service": "AWS Lambda",
"unit": "seconds",
"usageType": "Lambda-GB-Second"
},
{
"actualUsageAmount": 1.0,
"description": "1000000.0 Request are always free per month as part of AWS Free Usage Tier (Global-Request)",
"forecastedUsageAmount": 31.0,
"freeTierType": "Always Free",
"limit": 1000000.0,
"operation": "",
"region": "global",
"service": "AWS Lambda",
"unit": "Request",
"usageType": "Request"
},
{
"actualUsageAmount": 1.0,
"description": "1000000.0 Requests are always free per month as part of AWS Free Usage Tier (Global-Requests)",
"forecastedUsageAmount": 31.0,
"freeTierType": "Always Free",
"limit": 1000000.0,
"operation": "",
"region": "global",
"service": "Amazon Simple Queue Service",
"unit": "Requests",
"usageType": "Requests"
},
{
"actualUsageAmount": 0.06451608,
"description": "10.0 Alarms are always free per month as part of AWS Free Usage Tier (Global-CW:AlarmMonitorUsage)",
"forecastedUsageAmount": 1.9999984800000001,
"freeTierType": "Always Free",
"limit": 10.0,
"operation": "",
"region": "global",
"service": "AmazonCloudWatch",
"unit": "Alarms",
"usageType": "CW:AlarmMonitorUsage"
},
{
"actualUsageAmount": 0.00222895,
"description": "5.0 GB-Mo are always free per month as part of AWS Free Usage Tier (Global-TimedStorage-ByteHrs)",
"forecastedUsageAmount": 0.06909745,
"freeTierType": "Always Free",
"limit": 5.0,
"operation": "",
"region": "global",
"service": "AmazonCloudWatch",
"unit": "GB-Mo",
"usageType": "TimedStorage-ByteHrs"
},
{
"actualUsageAmount": 6.2e-07,
"description": "5.0 GB are always free per month as part of AWS Free Usage Tier (Global-DataProcessing-Bytes)",
"forecastedUsageAmount": 1.922e-05,
"freeTierType": "Always Free",
"limit": 5.0,
"operation": "PutLogEvents",
"region": "global",
"service": "AmazonCloudWatch",
"unit": "GB",
"usageType": "DataProcessing-Bytes"
},
{
"actualUsageAmount": 4.792e-05,
"description": "25.0 GB-Mo are always free per month as part of AWS Free Usage Tier (APN1-TimedStorage-ByteHrs)",
"forecastedUsageAmount": 0.0014855200000000002,
"freeTierType": "Always Free",
"limit": 25.0,
"operation": "",
"region": "ap-northeast-1",
"service": "Amazon DynamoDB",
"unit": "GB-Mo",
"usageType": "APN1-TimedStorage-ByteHrs"
},
{
"actualUsageAmount": 120.0,
"description": "18600.0 ReadCapacityUnit-Hrs are always free per month as part of AWS Free Usage Tier (APN1-ReadCapacityUnit-Hrs)",
"forecastedUsageAmount": 3720.0,
"freeTierType": "Always Free",
"limit": 18600.0,
"operation": "CommittedThroughput",
"region": "ap-northeast-1",
"service": "Amazon DynamoDB",
"unit": "ReadCapacityUnit-Hrs",
"usageType": "APN1-ReadCapacityUnit-Hrs"
},
{
"actualUsageAmount": 120.0,
"description": "18600.0 WriteCapacityUnit-Hrs are always free per month as part of AWS Free Usage Tier (APN1-WriteCapacityUnit-Hrs)",
"forecastedUsageAmount": 3720.0,
"freeTierType": "Always Free",
"limit": 18600.0,
"operation": "CommittedThroughput",
"region": "ap-northeast-1",
"service": "Amazon DynamoDB",
"unit": "WriteCapacityUnit-Hrs",
"usageType": "APN1-WriteCapacityUnit-Hrs"
},
{
"actualUsageAmount": 5.0,
"description": "1000000.0 Requests are always free per month as part of AWS Free Usage Tier (USE2-Requests-Tier1)",
"forecastedUsageAmount": 155.0,
"freeTierType": "Always Free",
"limit": 1000000.0,
"operation": "",
"region": "us-east-2",
"service": "Amazon Simple Notification Service",
"unit": "Requests",
"usageType": "USE2-Requests-Tier1"
}
]
}
以下は最初に出力されるGlueの情報ですが、使っていなくてもactualUsageAmount
が少しですがオフセットになっているようです。
{
"actualUsageAmount": 0.25806444,
"description": "1000000.0 Obj-Month are always free per month as part of AWS Free Usage Tier (Global-Catalog-Storage)",
"forecastedUsageAmount": 7.99999764,
"freeTierType": "Always Free",
"limit": 1000000.0,
"operation": "Storage",
"region": "global",
"service": "AWS Glue",
"unit": "Obj-Month",
"usageType": "Catalog-Storage"
},
フィルターする
ドキュメントにあるフィルターの方法です。serviceの項目にGlueを含む場合です。
aws freetier get-free-tier-usage --filter '{"Dimensions": {"Key": "SERVICE", "Values": ["Glue"], "MatchOptions": ["CONTAINS"]}}'
Dimensionsの設定はこのようにすればよいです。
"Dimensions": {
"Key": "SERVICE"|"OPERATION"|"USAGE_TYPE"|"REGION"|"FREE_TIER_TYPE"|"DESCRIPTION"|"USAGE_PERCENTAGE",
"MatchOptions": ["EQUALS"|"STARTS_WITH"|"ENDS_WITH"|"CONTAINS"|"GREATER_THAN_OR_EQUAL", ...],
"Values": ["string", ...]
},
まとめ
- AWSの無料枠の使用状況を調べるAPIを使ってみました。
- 出た直後に試したからか、出力されるサービスは少ないようです、今後追加されるのかも?
Discussion