AWS.BCMDataExports reference
Export
Section titled “Export”Source:
src/AWS/BCMDataExports/Export.ts
An AWS Billing and Cost Management data export (Data Exports / CUR 2.0) — delivers billing and cost management data selected by an SQL query to an S3 bucket on a refresh cadence.
Data Exports is a global service pinned to us-east-1; exports are free
(standard S3 storage rates apply to the delivered objects).
The destination bucket must grant the Data Exports service principals write access via its bucket policy (see the example below).
Export: Creating an Export
Section titled “Export: Creating an Export”import * as AWS from "alchemy/AWS";
const bucket = yield* AWS.S3.Bucket("BillingData", { forceDestroy: true, policy: [ { Effect: "Allow", Principal: { Service: [ "billingreports.amazonaws.com", "bcm-data-exports.amazonaws.com", ], }, Action: ["s3:PutObject", "s3:GetBucketPolicy"], Resource: [bucket.bucketArn, AWS.interpolate`${bucket.bucketArn}/*`], }, ],});
const cur = yield* AWS.BCMDataExports.Export("Cur2", { dataQuery: { queryStatement: "SELECT identity_line_item_id, line_item_unblended_cost FROM COST_AND_USAGE_REPORT", tableConfigurations: { COST_AND_USAGE_REPORT: { TIME_GRANULARITY: "HOURLY" }, }, }, s3Destination: { s3Bucket: bucket.bucketName, s3Prefix: "cur2", s3Region: "us-west-2", },});GetExecution
Section titled “GetExecution”Source:
src/AWS/BCMDataExports/GetExecution.ts
Runtime binding for bcm-data-exports:GetExecution.
Bind this operation to an Export to read the status of one export
execution (delivery run) — its status code, reason, and timestamps — from
inside a function runtime. Useful for delivery monitors that alert when a
refresh fails. Provide the implementation with
Effect.provide(AWS.BCMDataExports.GetExecutionHttp).
GetExecution: Monitoring Executions
Section titled “GetExecution: Monitoring Executions”// init — bind the operation to the exportconst getExecution = yield* AWS.BCMDataExports.GetExecution(cur);
// runtimeconst result = yield* getExecution({ ExecutionId: executionId });const status = result.ExecutionStatus?.StatusCode;GetExport
Section titled “GetExport”Source:
src/AWS/BCMDataExports/GetExport.ts
Runtime binding for bcm-data-exports:GetExport.
Bind this operation to an Export to read the export’s live
definition — SQL query, table configurations, S3 destination, and refresh
cadence — from inside a function runtime. Useful for cost dashboards that
surface where their billing data lands. Provide the implementation with
Effect.provide(AWS.BCMDataExports.GetExportHttp).
GetExport: Inspecting an Export
Section titled “GetExport: Inspecting an Export”// init — bind the operation to the exportconst getExport = yield* AWS.BCMDataExports.GetExport(cur);
// runtimeconst { Export: definition } = yield* getExport();const bucket = definition?.DestinationConfigurations.S3Destination.S3Bucket;GetTable
Section titled “GetTable”Source:
src/AWS/BCMDataExports/GetTable.ts
Runtime binding for bcm-data-exports:GetTable.
An account-level operation (the table dictionary is not tied to any
export) that reads the schema of a Data Exports table — its columns,
data types, and descriptions for the given table properties. Useful for
query builders that validate an SQL statement’s columns before calling
UpdateExport. Provide the implementation with
Effect.provide(AWS.BCMDataExports.GetTableHttp).
GetTable: Browsing the Table Dictionary
Section titled “GetTable: Browsing the Table Dictionary”// init — account-level binding takes no resourceconst getTable = yield* AWS.BCMDataExports.GetTable();
// runtimeconst table = yield* getTable({ TableName: "COST_AND_USAGE_REPORT" });const columns = (table.Schema ?? []).map((column) => column.Name);ListExecutions
Section titled “ListExecutions”Source:
src/AWS/BCMDataExports/ListExecutions.ts
Runtime binding for bcm-data-exports:ListExecutions.
Bind this operation to an Export to page through the export’s
historical executions (delivery runs) from inside a function runtime.
Useful for delivery dashboards and monitors that scan for failed
refreshes. Provide the implementation with
Effect.provide(AWS.BCMDataExports.ListExecutionsHttp).
ListExecutions: Monitoring Executions
Section titled “ListExecutions: Monitoring Executions”// init — bind the operation to the exportconst listExecutions = yield* AWS.BCMDataExports.ListExecutions(cur);
// runtimeconst result = yield* listExecutions({ MaxResults: 25 });const failed = (result.Executions ?? []).filter( (execution) => execution.ExecutionStatus.StatusCode === "DELIVERY_FAILURE",);ListExports
Section titled “ListExports”Source:
src/AWS/BCMDataExports/ListExports.ts
Runtime binding for bcm-data-exports:ListExports.
An account-level operation (no export argument) that enumerates every data
export definition in the account. Useful for governance sweeps that audit
where billing data is being delivered. Provide the implementation with
Effect.provide(AWS.BCMDataExports.ListExportsHttp).
ListExports: Inspecting an Export
Section titled “ListExports: Inspecting an Export”// init — account-level binding takes no resourceconst listExports = yield* AWS.BCMDataExports.ListExports();
// runtimeconst result = yield* listExports({ MaxResults: 100 });const names = (result.Exports ?? []).map((e) => e.ExportName);ListTables
Section titled “ListTables”Source:
src/AWS/BCMDataExports/ListTables.ts
Runtime binding for bcm-data-exports:ListTables.
An account-level operation (the table dictionary is not tied to any
export) that enumerates every table available to Data Exports queries,
with each table’s configurable properties. Useful for query builders that
present the available data sources. Provide the implementation with
Effect.provide(AWS.BCMDataExports.ListTablesHttp).
ListTables: Browsing the Table Dictionary
Section titled “ListTables: Browsing the Table Dictionary”// init — account-level binding takes no resourceconst listTables = yield* AWS.BCMDataExports.ListTables();
// runtimeconst result = yield* listTables();const names = (result.Tables ?? []).map((table) => table.TableName);