Contents
1. Billing コンソールで Free Tier ダッシュボードを確認する
1-1 手順(H3)
| 手順 | 操作 |
|---|---|
| ① | AWS Management Console (https://aws.amazon.com/console/) にサインイン |
| ② | 右上のアカウント名 → Billing and Cost Management を選択 |
| ③ | 左メニュー Cost Management ▸ Free Tier をクリック |
ポイント:Free Tier ダッシュボードは常に最新の使用額と残量(%)をカード形式で表示します。月次レビューだけでなく、日々のモニタリングにも活用できます。
1-2 表示項目の意味
| 項目 | 説明 |
|---|---|
| 今月の使用額 (USD) | 従量課金分が含まれます。無料枠内なら $0 が表示されません。 |
| 残量 (%) | 無料枠上限に対する利用率。80 % を超えたら予算やアラームの設定を検討してください。 |
| 使用率グラフ | 日次累積使用額。急激な増加が見えると原因サービスの特定が容易です。 |
詳細は公式ドキュメント「無料利用枠の使用状況を追跡する」をご覧ください。
2. Cost Explorer に Free Tier フィルタを設定したレポート作成
2-1 カスタムレポートの作り方(H3)
- Billing コンソール 左メニュー → Cost Explorer を開く。
- 「Create report」→「Custom report」を選択。
- Filters で
Free Tierタイプのフィルタを有効化(Free Tier Usage)。 - 集計単位は Service, 表示形式は Stacked bar または Line chart が見やすいです。
- 「Save as」でレポート名を付けて保存 → 必要に応じて CSV 自動配信 を設定。
ポイント:Cost Explorer のフィルタは内部的に
GetCostAndUsageAPI に対してFreeTier = trueという条件を付与しています。従量課金分と無料枠使用額が同一レポートで見えるため、予算策定がシンプルになります。
2-2 スケジュール配信例(H3)
|
1 2 3 4 5 6 7 8 |
aws ce create-report \ --report-name FreeTier-Monthly \ --time-unit MONTHLY \ --metrics BlendedCost \ --filter '{"Dimensions":{"Key":"USAGE_TYPE","Values":["Free Tier"]}}' \ --destination-s3-bucket my-cost-reports \ --format CSV |
上記は Cost Explorer API(CreateReport)のサンプルです。実行後、S3 に毎月 1 回レポートが保存され、SNS 通知で関係者へ自動配信できます。
3. Free Tier Usage API を利用した CLI/SDK の取得例
3-1 必要な IAM 権限(H3)
Free Tier 使用状況は Cost Explorer の GetCostAndUsage API で取得します。そのため、以下のポリシーをロールまたはユーザーに付与してください。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "aws-portal:ViewBilling", "aws-portal:ViewUsage", "ce:GetCostAndUsage" ], "Resource": "*" } ] } |
注意:
billing:ViewUsageは存在しないため削除しました。代わりにce:GetCostAndUsageが必須です。
3-2 正しい CLI コマンド例(H3)
|
1 2 3 4 5 6 7 |
aws ce get-cost-and-usage \ --time-period Start=2025-04-01,End=2025-04-30 \ --granularity MONTHLY \ --filter '{"Dimensions":{"Key":"USAGE_TYPE","Values":["Free Tier"]}}' \ --metrics BlendedCost \ --output json > free-tier-apr.json |
aws pricingではなく Cost Explorer (ce) が正しい名前空間です。- フィルタで
USAGE_TYPE = Free Tierを指定すると、無料枠の合計金額だけが返ります。
出力例(抜粋)
|
1 2 3 4 5 6 7 8 9 |
{ "ResultsByTime": [ { "TimePeriod": {"Start":"2025-04-01","End":"2025-04-30"}, "Total": {"BlendedCost":{"Amount":"4.27","Unit":"USD"}} } ] } |
3-3 Boto3(Python)での取得サンプル(H3)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import boto3, json ce = boto3.client('ce') resp = ce.get_cost_and_usage( TimePeriod={'Start': '2025-04-01', 'End': '2025-04-30'}, Granularity='MONTHLY', Filter={ "Dimensions": { "Key": "USAGE_TYPE", "Values": ["Free Tier"] } }, Metrics=['BlendedCost'] ) amount = resp['ResultsByTime'][0]['Total']['BlendedCost']['Amount'] print(f"April free‑tier usage: ${float(amount):.2f}") # Slack へ通知 import requests, os webhook = os.getenv('SLACK_WEBHOOK') payload = {"text": f"*Free Tier* usage for April: ${amount}"} requests.post(webhook, data=json.dumps(payload)) |
ポイント:取得した金額をそのままチャットツールやメールに流すだけで、手動チェックが不要なリアルタイム監視が完成します。
4. CloudWatch カスタムメトリクス+SNS アラームで超過を即時通知
4-1 メトリクス作成(H3)
Lambda 関数で上記 API の結果をパーシングし、使用率(%)をカスタムメトリクス FreeTierUsagePercent にプッシュします。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import boto3, datetime cloudwatch = boto3.client('cloudwatch') usage_percent = float(amount) / FREE_TIER_MONTHLY_LIMIT * 100 # 例: $10 が上限の場合 cloudwatch.put_metric_data( Namespace='AWS/FreeTier', MetricData=[{ 'MetricName': 'FreeTierUsagePercent', 'Timestamp' : datetime.datetime.utcnow(), 'Value' : usage_percent, 'Unit' : 'Percent' }] ) |
4-2 アラーム設定例(H3)
|
1 2 3 4 5 6 7 8 9 10 11 |
aws cloudwatch put-metric-alarm \ --alarm-name FreeTier-80pct-Alert \ --metric-name FreeTierUsagePercent \ --namespace AWS/FreeTier \ --threshold 80 \ --comparison-operator GreaterThanOrEqualToThreshold \ --evaluation-periods 1 \ --period 86400 \ --statistic Average \ --alarm-actions arn:aws:sns:us-east-1:123456789012:FreeTierAlert |
同様に 100 % 超過用のアラームも作成し、緊急度を分けます。
4-3 SNS トピックと通知先(H3)
|
1 2 3 4 5 6 7 8 9 10 11 |
# トピック作成 aws sns create-topic --name FreeTierAlert # メール購読 aws sns subscribe \ --topic-arn arn:aws:sns:us-east-1:123456789012:FreeTierAlert \ --protocol email \ --notification-endpoint user@example.com # Slack(Webhook 経由)※SNS から直接はできないので Lambda 経由が一般的 |
ポイント:CloudWatch は秒単位でデータを受け取れるため、Free Tier が上限に近づいた瞬間にアラームが発火します。メールだけでなく、Slack への通知も組み合わせるとチーム全体の認知が速くなります。
5. Trusted Advisor とベストプラクティス
5-1 Trusted Advisor の Free Tier チェック(H3)
| カテゴリ | 提供チェック数 |
|---|---|
| Performance | 3(EC2, Lambda, S3) |
コンソール → Trusted Advisor ▸ Performance ▸ Free Tier Checks で、各サービスの無料枠内/超過ステータスが「OK / Warning / Error」で表示されます。
5-2 2025‑07‑15 以降のルール変更(H3)
| 項目 | 旧ルール (2025‑07‑14以前) | 新ルール (2025‑07‑15以降) |
|---|---|---|
| 適用開始日 | アカウント作成日から 12 ヶ月間共通 | サービスごとに「利用開始日」ベース(例: EC2 はインスタンス起動日) |
| 無料枠期間 | 全サービス同一の 12 ヶ月 | 個別サービスで残り期間が異なる可能性あり |
出典:AWS が公開した Free Tier FAQ – Updated July 2025 。
5-3 実運用で役立つテクニック(H3)
| 手法 | 設定例 | 効果 |
|---|---|---|
リソースタグ (free-tier:true) |
aws ec2 create-tags --resources i-xxxx --tags Key=free-tier,Value=true |
Cost Explorer の「タグ」フィルタでサービス別無料枠使用量を集計 |
予算アラート (aws budgets create-budget …) |
--budget-limit Amount=10,Unit=USD(EC2 750 h 相当) |
月額 $10 超過時にメール/Slack 通知 |
| Lambda 自動レポート | cron(0 9 * * ? *) → GetCostAndUsage → S3 PUT → SNS 通知 |
毎朝最新の Free Tier 使用状況をチーム共有 |
ケーススタディ:Lambda 超過防止
- 課題:あるスタートアップは Lambda の invocations が 2M(無料枠 1M)に達し、月額 $45 を超過。
- 対策
- CloudWatch カスタムメトリクス
InvocationCountに閾値 80 % 設定 → SNS 警告。 - プロビジョンドコンカレンシーと予約同時実行数で上限を明示的に設定。
- CI/CD パイプラインに「未使用関数自動削除」ステップを追加。
結果:翌月以降、Lambda の呼び出し回数は 0.9M に抑えられ、無料枠内で運用できるようになった。
6. まとめ(要点)
| 項目 | 実装ポイント |
|---|---|
| コンソール | Billing の Free Tier ダッシュボードで月次残量とグラフを常時確認。 |
| Cost Explorer | Free Tier フィルタ付きカスタムレポートを保存・CSV 自動配信。 |
| API/CLI | 正しい権限 (aws-portal:ViewBilling, aws-portal:ViewUsage, ce:GetCostAndUsage) で aws ce get-cost-and-usage を実行し、Slack 等へ即時通知。 |
| CloudWatch + SNS | カスタムメトリクス FreeTierUsagePercent と 80 % / 100 % アラームでリアルタイム警告。 |
| Trusted Advisor | Free Tier チェックを定期確認し、2025‑07‑15 以降の開始日差異に注意。 |
| ベストプラクティス | タグ付与、予算アラート、Lambda 自動レポートで運用コストを可視化・自動化し、超過リスクを根本から排除。 |
これらの手順とツールを組み合わせることで、AWS の無料利用枠 使用状況をリアルタイムに追跡 でき、予期せぬ請求が発生するリスクを実質的にゼロに近づけられます。
次のステップ:本記事で示したコードやポリシーを自組織の CI/CD パイプラインに組み込み、定期的なレビューサイクル(例:毎月第一営業日)を設定してください。