feat(#217): add Infracost METRIC_DESCRIPTORS for KMS, EIP, and CloudWatch metrics - #218
Merged
Merged
Conversation
…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
marked this pull request as ready for review
July 3, 2026 14:49
This was referenced Jul 3, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_DESCRIPTORSsosync_pricing_catalogcan fetch them.Descriptors added (validated against the live Cloud Pricing API)
KMS-Key-MonthawskmsKMS-API-Requestawskmsawskms-APIRequest-AllIPv4-InUse-HoursAmazonVPCREGION_PREFIX-PublicIPv4:InUseAddressIPv4-Idle-HoursAmazonVPCREGION_PREFIX-PublicIPv4:IdleAddressCloudWatch-Metric-MonthAmazonCloudWatchCW:MetricMonitorUsage(returns tiered $0.30/$0.10/$0.05/$0.02)CloudWatch-Alarm-MonthAmazonCloudWatchCW:AlarmMonitorUsageCloudWatch-GetMetricDataAmazonCloudWatchCW:GMD-MetricsThe issue listed four metrics; the siblings
KMS-API-Request,IPv4-Idle-Hours, andCloudWatch-Alarm-Monthare 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-GBis left seed-only. Its Infracost products live under serviceAWSDataTransfercatalogued 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 queriesregion="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)
us-east-1→USE1).sync_to_cache("KMS-Key-Month")round-trip: upserts under the catalog metric name, filters out wrong-unit rows,source=infracost.Note: the descriptor groupings were confirmed against the live API during development; CI itself runs fully mocked (no credential required).