Skip to content

feat(#217): add Infracost METRIC_DESCRIPTORS for KMS, EIP, and CloudWatch metrics - #218

Merged
elecnix merged 1 commit into
mainfrom
feat/217-infracost-descriptors
Jul 3, 2026
Merged

feat(#217): add Infracost METRIC_DESCRIPTORS for KMS, EIP, and CloudWatch metrics#218
elecnix merged 1 commit into
mainfrom
feat/217-infracost-descriptors

Conversation

@elecnix

@elecnix elecnix commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #217. The handlers from #208#211 shipped with seed pricing only (us-east-1), so the live Infracost sync never fetched them — no per-region rates, no tiers, no automatic price updates. This adds live-validated METRIC_DESCRIPTORS so sync_pricing_catalog can fetch them.

Descriptors added (validated against the live Cloud Pricing API)

Metric Infracost service Product / filter
KMS-Key-Month awskms "Encryption Key" / Keys
KMS-API-Request awskms "API Request", group awskms-APIRequest-All
IPv4-InUse-Hours AmazonVPC usagetype REGION_PREFIX-PublicIPv4:InUseAddress
IPv4-Idle-Hours AmazonVPC usagetype REGION_PREFIX-PublicIPv4:IdleAddress
CloudWatch-Metric-Month AmazonCloudWatch "Metric", CW:MetricMonitorUsage (returns tiered $0.30/$0.10/$0.05/$0.02)
CloudWatch-Alarm-Month AmazonCloudWatch "Alarm", CW:AlarmMonitorUsage
CloudWatch-GetMetricData AmazonCloudWatch "API Request", CW:GMD-Metrics

The issue listed four metrics; the siblings KMS-API-Request, IPv4-Idle-Hours, and CloudWatch-Alarm-Month are included so each handler's live pricing is complete rather than partial (all three were validated the same way).

Data transfer — documented, not wired

DataTransfer-InterRegion-GB is left seed-only. Its Infracost products live under service AWSDataTransfer catalogued globally (empty region) with a distinct usagetype per source/destination region pair (e.g. USE1-APS4-AWS-Out-Bytes = $0.02/GB, transferType="InterRegion Outbound"). That doesn't fit the region-scoped sync (which queries region="us-east-1"), and collapsing every region pair into one rate would be arbitrary. The grouping is recorded in a comment for a future regionless-sync follow-up.

Test plan (HTTP layer mocked)

  • Descriptor presence + service/unit for all seven new metrics (parametrized).
  • REGION_PREFIX resolution for the EIP usagetype (us-east-1USE1).
  • sync_to_cache("KMS-Key-Month") round-trip: upserts under the catalog metric name, filters out wrong-unit rows, source=infracost.
  • Full suite: 884 passed locally.

Note: the descriptor groupings were confirmed against the live API during development; CI itself runs fully mocked (no credential required).

…atch metrics

The handlers from #208#211 shipped with us-east-1 seed pricing only, so the
live Infracost sync never fetched them (no per-region rates, no tiers, no
automatic updates). Add live-validated descriptors mapping each catalog
usage_metric to its Infracost product query:

- KMS-Key-Month        awskms / "Encryption Key" / Keys
- KMS-API-Request      awskms / "API Request" (group awskms-APIRequest-All)
- IPv4-InUse-Hours     AmazonVPC / usagetype REGION_PREFIX-PublicIPv4:InUseAddress
- IPv4-Idle-Hours      AmazonVPC / usagetype REGION_PREFIX-PublicIPv4:IdleAddress
- CloudWatch-Metric-Month     AmazonCloudWatch / "Metric" (CW:MetricMonitorUsage, tiered)
- CloudWatch-Alarm-Month      AmazonCloudWatch / "Alarm"  (CW:AlarmMonitorUsage)
- CloudWatch-GetMetricData    AmazonCloudWatch / "API Request" (CW:GMD-Metrics)

Each grouping was validated against the live Cloud Pricing API. The sibling
metrics KMS-API-Request, IPv4-Idle-Hours, and CloudWatch-Alarm-Month are
included alongside the issue's four so live pricing for each handler is
complete rather than partial.

DataTransfer-InterRegion-GB is left seed-only with a documented placeholder:
its products live under service "AWSDataTransfer" catalogued globally (empty
region) with a distinct usagetype per source/destination region pair, which
doesn't fit the region-scoped sync — and collapsing every pair into one rate
would be arbitrary. The grouping is recorded in a comment for a future
regionless-sync follow-up.

Tests (HTTP mocked): descriptor presence for all seven, REGION_PREFIX
resolution for the EIP usagetype (us-east-1 -> USE1), and a KMS-Key-Month
sync_to_cache round-trip with unit filtering.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@elecnix
elecnix marked this pull request as ready for review July 3, 2026 14:49
@elecnix
elecnix merged commit e64e856 into main Jul 3, 2026
3 checks passed
@elecnix
elecnix deleted the feat/217-infracost-descriptors branch July 3, 2026 15:16
elecnix added a commit that referenced this pull request Jul 6, 2026
* feat(#234): wire live Infracost pricing for WAFv2 web ACL metrics

Follow-up to the WAFv2 handler (#235), mirroring the KMS split (handler #214,
descriptors #218): add Infracost _METRIC_DESCRIPTORS for the three WAFv2
usage metrics so a live pricing sync populates the catalog.

Grounded in Infracost's own resource definition (infracost/infracost,
internal/resources/aws/wafv2_web_acl.go): service "awswaf", product family
"Web Application Firewall", usagetypes <REGION>-WebACLV2 / -RuleV2 /
-RequestV2-Tier1. The region prefix is resolved at query time; the exact-match
usagetype naturally excludes the "ShieldProtected-" siblings.

Tests mock the HTTP layer (mirroring the KMS descriptor tests): descriptor
presence, REGION_PREFIX resolution for us-east-1 (USE1) and ca-central-1
(CAN1), and an end-to-end sync_to_cache upsert.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fixup(#234): remap WAFv2 live prices to "AWSWAF" via store_service

Infracost prices WAF under the lowercase service code "awswaf", but the handler
and seed rows use the uppercase "AWSWAF" convention (matching AWSKMS / AmazonALB
/ AWSSecretsManager). Without a remap the live-synced rows land under "awswaf"
and the case-sensitive catalog query for "AWSWAF" misses them — silently falling
back to embedded rates. `store_service: "AWSWAF"` upserts them under the queried
name, the same remap the NAT Gateway descriptor uses (AmazonEC2 → AmazonVPC).

Verified against live Infracost (us-east-1 + ca-central-1): each metric resolves
to exactly one row and an "AWSWAF" query returns $5.00 web ACL, $1.00/rule,
$0.0000006/request.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pricing: add METRIC_DESCRIPTORS for KMS, EIP, CloudWatch Metrics, and Data Transfer

1 participant