AWS Cost Explorer ExecModule
Overview
AwsCostExplorerModule brings AWS cost and usage evidence into ValkyrAI workflows. Read cost and usage for a defined interval, discover available billing dimensions, and look up tag keys or values using one verified AWS connection. FinOps, platform, and engineering teams can use these results to prepare a recurring cost review, enrich a spending investigation, or send a service-level breakdown to the people responsible for it.
A useful cloud-spend review needs a clear scope. Which dates were queried? Which account could the selected identity read? Were all result pages collected? Do amounts have the same units? This connector keeps those details visible. It preserves AWS decimal amount strings, units, time periods, estimated-data flags, and provider page boundaries rather than calculating a potentially misleading total.
The three operations are read-only: get_cost_and_usage, get_dimension_values, and get_tags. They do not create budgets, modify tags, purchase commitments, shut down resources, forecast spending, or retrieve resource-level cost records. Cost Explorer results support investigation and reporting; they are not a final invoice or a promise of savings. API reads can incur AWS charges.
Usage
- Enable Cost Explorer and make sure the chosen AWS identity can access the required billing data.
- Create and verify an AWS
IntegrationAccount, keeping its statusREADY. - Add AWS Cost Explorer in Workflow Studio and select the account through General > Connection. This built-in control owns the connection binding.
- Choose an operation and a precise date interval. Start with one page and inspect the continuation before scheduling repeated reads.
- Route the returned evidence to an authorized report or review task. Apply decimal-aware calculations only after checking scope, units, page completeness, and estimated-data flags.
This release uses the commercial AWS Cost Explorer HTTPS endpoint, ce.us-east-1.amazonaws.com, through the AWS SDK with the us-east-1 signing scope. There is no input region or custom endpoint. Data visibility follows the selected AWS identity and AWS billing permissions; the connector does not broaden that visibility or fan out across credentials.
Inputs
| Input | Type | Required | Default | Description |
|---|---|---|---|---|
operation | string | Yes | — | get_cost_and_usage, get_dimension_values, or get_tags. |
startDate | string | Yes | — | Inclusive start date in strict YYYY-MM-DD format. |
endDate | string | Yes | — | Exclusive end date in strict YYYY-MM-DD format. The interval must span 1–366 days. |
nextToken | string | No | — | Opaque continuation of the same query and connection; at most 8,192 characters. |
returnAll | boolean | No | false | Follow continuations within maxPages. This does not guarantee an exhaustive result. |
maxPages | integer | No | 1 | Maximum provider pages per execution, from 1 to 20. |
filterDimension | string | No | — | Supported dimension name for a simple equality filter; requires filterValues. |
filterValues | string array | No | — | 1–100 distinct values for filterDimension, each at most 1,024 characters. AWS matches the listed values within that dimension. |
granularity | string | Cost operation only | DAILY | DAILY or MONTHLY. |
metrics | string array | Cost operation only | ["UnblendedCost"] | 1–7 distinct supported metric names listed below. |
groupBy | string array | Cost operation only | Empty | Up to two distinct supported dimension names. This release supports dimension grouping. |
dimension | string | Dimension operation | — | Supported billing dimension in the COST_AND_USAGE context, such as SERVICE. |
searchString | string | Dimension/tag operations only | — | Optional search text of at most 256 characters. |
tagKey | string | Tag operation only | — | Tag key of at most 128 characters. Omit it to discover keys; provide it to discover values. |
The supported metrics are AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, and UsageQuantity. Retain the returned unit with every amount. UsageQuantity can combine unlike units when a query is too broad; filter to a suitable usage scope before interpreting it as a meaningful quantity.
Supported discovery and filter dimensions are AZ, INSTANCE_TYPE, LINKED_ACCOUNT, OPERATION, PURCHASE_TYPE, REGION, SERVICE, USAGE_TYPE, USAGE_TYPE_GROUP, RECORD_TYPE, OPERATING_SYSTEM, TENANCY, PLATFORM, LEGAL_ENTITY_NAME, DEPLOYMENT_OPTION, DATABASE_ENGINE, CACHE_ENGINE, INSTANCE_TYPE_FAMILY, BILLING_ENTITY, RESERVATION_ID, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, and INVOICING_ENTITY. Grouping supports the narrower set AZ, INSTANCE_TYPE, LEGAL_ENTITY_NAME, INVOICING_ENTITY, LINKED_ACCOUNT, OPERATION, PLATFORM, PURCHASE_TYPE, SERVICE, TENANCY, RECORD_TYPE, and USAGE_TYPE.
Only documented fields are accepted. Neutral values from inactive Workflow Studio controls are ignored so the shared configuration form can select any of the three operations; active optional empty text is treated as absent. Non-neutral options for a different operation, unknown fields, raw credentials, regions, custom destinations, arbitrary request bodies, and unsupported dimensions fail validation before provider access. Filters are limited to one dimension with its values. Nested Boolean expressions, tag or cost-category filters, tag grouping, custom billing views, hourly granularity, and forecasts are outside this release.
Outputs
Every operation returns a native map rather than an AWS SDK object.
| Output | Description |
|---|---|
status | success or error. |
operation | Selected operation. |
attempts | Provider attempts, including pages and retries. |
resultType | costAndUsage, dimensionValues, or tags. |
pagesData | Ordered normalized provider pages. Check every page before deriving a report. |
pages | Number of provider pages consumed. |
hasMore | Whether a continuation remains after this execution. |
nextToken | Opaque continuation when more data is available. |
requestId | Safe AWS request identifier when available. |
error | Stable code, redacted message, HTTP status, and retryability on failure. |
For get_cost_and_usage, each page contains resultsByTime, groupDefinitions, and dimensionValueAttributes. A time result preserves timePeriod.start, timePeriod.end, estimated, total, and groups. Metrics retain their amount as a decimal string and their unit; group keys keep their provider order. Dimension attributes can contain names or other billing context.
The same time interval can appear on several cost pages with different groups. The module preserves those pages and does not flatten, sum, or deduplicate them. Downstream processing must interpret the complete response according to the query's grouping and AWS semantics. Do not add repeated totals merely because the dates match. A partial page collection is not a complete spending total.
For get_dimension_values, each page contains dimensionValues with value and attributes, plus returnSize and totalSize. For get_tags, each page contains tags, returnSize, and totalSize. These are Cost Explorer's billing-data discovery results for the requested interval, rather than a live resource-tag inventory.
Responses fail safely instead of being silently clipped. A cost page is limited to 366 time results, two group definitions, 10,000 dimension-value attributes, and 10,000 groups per time result. Each group has at most two keys and each metric map at most seven supported metrics. Discovery responses are limited to 10,000 dimension values or tags per provider page; attribute maps have at most 20 entries. Normalized text is bounded to 1,000,000 characters per provider page, with tighter field bounds such as 1,024 characters for dimension values, group keys, and tag results. Narrow a query that exceeds a safety bound before using it for a report.
Billing amounts, account identifiers, tag values, and dimension attributes can be commercially sensitive. Treat outputs as restricted and share them only with audiences authorized to inspect that billing scope. Do not store secrets in tag keys or values.
IntegrationAccount Requirements
Use a verified AWS IntegrationAccount in READY status through General > Connection. Its API-key field holds the access key ID and its protected password field holds the secret access key. The module consumes the platform-resolved account and never accepts keys in workflow input.
Grant only the actions used by the workflow:
ce:GetCostAndUsage
ce:GetDimensionValues
ce:GetTags
AWS account configuration and billing permissions determine the data available to those actions. A management account's visibility can differ from a member account's visibility. Consult the AWS Cost Explorer authorization reference when defining the least-privilege policy. The connector needs no budget, resource-modification, or tag-write permission.
Session tokens, automatic role assumption, system credential discovery, China/GovCloud partitions, and custom endpoints are unsupported. Use a scoped access-key pair and manage rotation and revocation through the connection's normal controls.
Configuration
The existing ExecModule retry policy controls provider attempts: three by default, configurable from one through five per request. This is module configuration rather than an input-map field. The SDK's own retry policy is disabled so retry layers do not multiply attempts.
Safe reads use bounded exponential backoff beginning at 250 milliseconds for transport failures, throttling, and transient provider failures. Each provider attempt has a 20-second timeout and each SDK call a 30-second timeout; overall execution time also depends on pages and retries. A Cost Explorer limit error can use HTTP 400, so inspect structured retryability as well as the status code. A continued query can make several provider requests, and retries can increase that count. Consult AWS Cost Explorer pricing and set an appropriate schedule and page budget: a read-only operation can still have a financial cost.
Operations
Read cost and usage
get_cost_and_usage queries a defined interval with daily or monthly granularity, selected metrics, optional dimension grouping, and an optional simple dimension filter. For example, a weekly engineering review can request daily unblended cost grouped by service, retain the original unit and estimated flag, and route the observed changes to service owners for investigation. The module does not decide whether a charge is incorrect or whether a resource should be changed.
Discover billing dimensions
get_dimension_values discovers values for a supported dimension in the COST_AND_USAGE context. Use SERVICE to discover available service names or an appropriate usage dimension to narrow a later cost query. The result depends on the date interval and the selected identity's billing visibility. An absent value does not prove that a resource never existed or that it has no current cost.
Discover billing tags
get_tags without tagKey discovers available tag keys for the interval. Provide a known tagKey to discover its values, optionally with search text. This can help prepare a reviewed allocation workflow or investigate inconsistent naming. It does not enable, activate, modify, or backfill cost-allocation tags and does not enumerate every resource's current tags.
Errors and Failure Modes
| Code | Meaning | Guidance |
|---|---|---|
VALIDATION_ERROR | Date interval, field, metric, dimension, bound, or option is invalid. | Correct the input before another provider call. |
UNSUPPORTED_OPERATION | Operation is outside the three-operation read contract. | Select a documented operation. |
INTEGRATION_ACCOUNT_ERROR | Connection is missing, unverified, not READY, incomplete, or supplied through forbidden raw fields. | Repair and verify the selected AWS connection. |
AWS_COST_EXPLORER_HTTP_400 | AWS rejected the query, token, data availability, or request rate. | Inspect retryability; keep query parameters unchanged when continuing. |
AWS_COST_EXPLORER_HTTP_403 | Selected identity cannot access the requested billing data. | Review AWS billing configuration and the minimum read permissions. |
AWS_COST_EXPLORER_HTTP_429 / 500 / 502 / 503 / 504 | Throttling or transient provider failure. | Bounded retries apply; exhaustion remains an error. |
NETWORK_ERROR | A transport failure prevented the query. | Check outbound HTTPS and structured retryability. |
PAGINATION_ERROR | Continuation is malformed or repeats. | Treat the query as failed; do not use a partial result as complete evidence. |
RESPONSE_LIMIT_ERROR | Provider data exceeds the connector's response safety bounds. | Narrow the interval, grouping, or filter and retry. |
EXECUTION_ERROR | An unexpected local failure was contained. | Review the structured result and diagnostics. |
Raw provider exception text and credentials are not returned. A safe request ID is retained when available. If a later page fails or a response cannot be safely normalized, the operation returns an error instead of successful partial pages. Errors can still follow chargeable provider attempts.
Example
Read one month of service-level unblended cost:
{
"operation": "get_cost_and_usage",
"startDate": "2026-10-01",
"endDate": "2026-11-01",
"granularity": "MONTHLY",
"metrics": ["UnblendedCost"],
"groupBy": ["SERVICE"],
"returnAll": true,
"maxPages": 5
}
Illustrative normalized result, with one service shown:
{
"status": "success",
"operation": "get_cost_and_usage",
"attempts": 1,
"resultType": "costAndUsage",
"pages": 1,
"hasMore": false,
"pagesData": [
{
"resultsByTime": [
{
"timePeriod": {"start": "2026-10-01", "end": "2026-11-01"},
"estimated": false,
"total": {},
"groups": [
{
"keys": ["Amazon Simple Storage Service"],
"metrics": {"UnblendedCost": {"amount": "39.1603300457", "unit": "USD"}}
}
]
}
],
"groupDefinitions": [{"type": "DIMENSION", "key": "SERVICE"}],
"dimensionValueAttributes": []
}
]
}
Keep the strings precise when loading amounts into a decimal-aware calculation. Inspect every page and the estimated flag before creating a report. To discover service names for a filtered follow-up, run get_dimension_values with dimension: "SERVICE" and the same dates. To inspect available allocation vocabulary, run get_tags first without a tag key, then with an observed key.
If hasMore is true, pass nextToken into another invocation with the same operation, dates, filters, grouping, metrics, and connection. Continue until exhausted or explicitly label the report incomplete. Changing query parameters between pages can cause AWS to reject the continuation.
Notes
- Pagination:
returnAllfollows provider pages only withinmaxPages; the default execution reads one page. All operations preserve complete provider pages. AWS controls page size in the continuation mode used by this connector. No page-size or sort input is exposed: discovery sorting would disable continuation tokens and search. CheckhasMorebefore interpreting completeness. - Financial meaning: Preserve metric names, units, group keys, and estimated flags. Cost Explorer is an analytical billing source, not a final invoice. The connector performs no exchange-rate conversion, allocation, forecasting, or savings calculation.
- Freshness: Billing data can be unavailable, delayed, revised, or estimated. Completed pagination is not a transactional snapshot or a guarantee that charges will never change.
- Rate limits and charges: Schedule bounded reads, avoid unnecessary polling, and review current AWS request charges. Retries and continued pages add requests. Limit errors may be retryable even with HTTP 400.
- Idempotency: Repeated reads do not modify AWS configuration, but can return changed billing data and incur additional request charges. There is no write idempotency key.
- Limits: This release accepts intervals of at most 366 days, daily/monthly granularity, the documented metrics, dimension grouping, and a simple dimension filter. No hourly data, custom billing views, forecasts, resource-level records, budget lifecycle, recommendations, commitment purchases, or tag mutation.
- Validation: Deterministic request, response, retry, pagination, account, and redaction tests do not prove a particular AWS identity's live billing access. Verify its permissions and data availability before relying on a scheduled workflow.
See the AWS API references for GetCostAndUsage, GetDimensionValues, and GetTags.