CUR Automation Automator
What this skill does
Designs and emits a working CUR automation stack as code — CUR
definition, Athena database with partition projection, named queries for
top-spenders / unused-resources / Savings-Plan-opportunities / tag-compliance,
optional QuickSight datasets and dashboards, Cost Categories for
chargeback, cost-allocation-tag activation, and (when requested) CUR 2.0
split cost allocation, BCM Data Exports, or Amazon Q cost-analysis wiring.
Runs deterministic requirement checks before emitting the template — if
all checks pass, the verdict is AUTOMATED with a populated
CloudFormation / Terraform template. If a requirement is missing (no
payer account, no bucket policy for Athena, no QuickSight Enterprise
session, no BCM Data Exports permission), the verdict is
MANUAL_STEP_REQUIRED with the specific gap and the exact CLI / IaC
snippet that closes it.
Quick navigation
| Section |
What it covers |
When to read it |
| § Quick reference |
Verdict thresholds + requirement checklist + capability matrix |
Before any build |
| § Mindset |
Why CUR+Athena beats Cost Explorer, the 24-hour lag, partition projection |
Understanding the design model |
| § Pre-flight |
Requirement gate — payer, bucket, Glue catalog, IAM, QuickSight session |
Before emitting any template |
| § Process |
Per-stage design: CUR definition, Athena table, queries, QuickSight, tags, Cost Categories |
When designing each layer |
| § STRICT output contract |
Required labels + FORBIDDEN patterns + self-check |
Before emitting any block |
| § Expert heuristic |
The 5 non-obvious failure modes that miss naive CUR setups |
Defense-in-depth |
| § Anti-Patterns |
NEVER list — common mistakes that silently break CUR automation |
Review before emitting |
Quick reference — verdict thresholds
| Verdict |
Trigger condition |
Action |
AUTOMATED |
All requirements satisfied (payer or consolidated-billing account, CUR bucket with correct policy, Glue Data Catalog in CUR region, IAM role for Athena/QuickSight, QuickSight Enterprise session if dashboards requested, cost-allocation-tag activation if tags requested, BCM Data Exports permissions if BCM path). Template generated. |
Emit complete CUR automation template, ready to apply |
MANUAL_STEP_REQUIRED |
One or more requirements missing (linked (member) account only — no CUR visibility; bucket policy missing Athena service principal; QuickSight session not initialized; tag activation requires payer root or Billing role; BCM Data Exports not enabled in the account). |
Emit the specific gap and the exact CLI / IaC snippet to close it. Hold the partial template as a draft. |
Requirement checklist (all must be satisfied for AUTOMATED):
- Account type — payer (management) or consolidated-billing
account. A linked account cannot create a CUR that spans the
organization. Verify via
aws organizations describe-organization
or aws ce list-accounts (payer-only API).
- CUR S3 bucket — exists, has BlockPublicAccess enabled,
versioning on, bucket policy granting
billingreports.amazonaws.com
WRITE and athena.amazonaws.com READ, both with aws:SourceAccount
condition. SSE-KMS for compliance; SSE-S3 acceptable for non-regulated.
- ReportVersioning —
CREATE_NEW (default, full daily snapshot)
or OVERWRITE (incremental, smaller bucket, harder to time-travel).
- Granularity —
HOURLY (max 24-hour delay before data lands) or
DAILY (max 24-hour delay, smaller files). For real-time cost
anomaly detection, use Cost Anomaly Detection, not CUR.
- Compression —
Parquet (columnar, Athena-optimal, ~10x faster
scans vs GZIP). Avoid GZIP unless a legacy consumer requires it.
- Athena Glue Data Catalog — exists in the SAME region as the CUR
bucket. Cross-region catalogs require explicit catalog ARN.
- Partition projection — Athena table MUST use partition projection
(
projection.day.type=date,
projection.day.range=2024/01/01,NOW) to avoid manual MSCK REPAIR TABLE (which is O(n_parts) slow and throttles past 20k partitions).
- Athena workgroup — non-
primary workgroup with
BytesScannedCutoffPerQuery set (CUR queries can scan 100s of GB if
untuned; the cutoff prevents bill shock).
- IAM execution role — Athena workgroup role with
athena:StartQueryExecution, glue:GetTable, s3:GetObject on the
CUR bucket, s3:PutObject on the Athena results bucket.
- QuickSight Enterprise session —
aws quicksight describe-account
returns AccountEdition: ENTERPRISE (or ENTERPRISE_AND_Q).
Standard edition cannot schedule SPICE refresh on Athena.
- Cost-allocation tag activation (if tags layer requested) — only
the payer account root or a Billing role can call
UpdateCostAllocationTagsStatusUpstream. Linked accounts can read
tag keys but cannot activate them.
- Cost Category (if chargeback layer requested) — payer account
only.
- CUR 2.0 / Split Cost Allocation (if requested) — must be enabled
on the payer via Billing console or CE API. Takes 24-48 hours for
first data.
- BCM Data Exports (if requested) — must be enabled on the payer;
the service-linked role
AWSServiceRoleForBCMDataExports is
auto-created on first use.
Capability matrix (which AWS service handles each layer):
| Layer |
Service(s) |
Common pitfalls |
| CUR definition |
CUR (cur) |
Hourly granularity → 24h lag; Parquet required for fast Athena |
| Storage |
S3 |
Wrong region (must match Glue catalog); missing service-principal policy |
| Catalog |
Glue Data Catalog |
Cross-region catalog breaks Athena partition projection |
| Query engine |
Athena |
primary workgroup = no DSL, unbounded cost; partition projection missing |
| Query automation |
Athena Named Queries, EventBridge scheduler, Lambda |
No DSL on workgroup = expensive scans |
| Visualization |
QuickSight |
Standard edition = no scheduled SPICE refresh; Enterprise needed |
| Chargeback |
Cost Categories |
Linked account cannot create; payer-only |
| Tag activation |
CE API |
Linked account cannot activate tags; payer-only |
| CUR 2.0 |
Split Cost Allocation Data (SCAD) |
Must be enabled separately; 24-48h lag for first data |
| Modern exports |
BCM Data Exports |
Service-linked role auto-created on first use |
| NL analysis |
Amazon Q Business (cost connector) |
Requires Q Business Pro subscription; payer-scoped |
Mindset
One-line takeaway: CUR + Athena + partition projection is the only
way to do FinOps at AWS scale — Cost Explorer is a UI, not a data
pipeline. Driven by three CUR realities:
Cost Explorer is rate-limited and resolution-capped. CE API caps
at 1 req/s and returns aggregated data with a 24-hour SLA. CUR gives
you the raw line items (resource-level for hourly CUR), 12+ months of
history, and no rate limit because you're querying your own Athena.
Any FinOps pipeline that touches more than 5 services or more than 50
accounts must move off CE and onto CUR.
Partition projection is non-negotiable. CUR writes one partition
per day (or per hour for hourly CUR). A year of hourly CUR = ~8,700
partitions. MSCK REPAIR TABLE scans every partition metadata
object — past 20k it throttles and never finishes. Partition
projection (projection.day.type=date,
projection.day.range=2024/01/01,NOW) tells Athena to compute
partition locations from the date string itself — no Glue metastore
writes, no MSCK, no throttle.
CUR 2.0 split cost allocation changes container cost attribution.
In CUR 1.0, an EKS pod that runs for 5 minutes on a shared node shows
as the full node cost. CUR 2.0 + Split Cost Allocation Data (SCAD)
divides the node cost across pods by CPU/memory usage with idle
allocation. Without SCAD, EKS cost attribution is wrong by an order
of magnitude. SCAD must be enabled separately on the payer.
Pre-flight: requirement gate
Run before emitting any template. Missing requirements produce
MANUAL_STEP_REQUIRED with the exact gap.
Live-account pre-flight (skip if offline plan audit):
The ten live-account pre-flight commands (payer check, existing CUR, bucket region/versioning/policy, Glue database, workgroup, QuickSight edition, activated tags, Cost Categories, BCM exports): references/diagnostic-commands.md.
Malformed input: if the input scenario is missing required fields
(account type, target region, granularity, scope), emit
VERDICT: MANUAL_STEP_REQUIRED with GAP: Scenario missing required field <field>. Provide <field> to proceed.
| Requirement |
Effect on automation |
| Caller is a linked (member) account |
MANUAL_STEP_REQUIRED — CUR visibility is payer-only; emit the cross-account IAM role snippet. |
| CUR bucket policy missing Athena service principal |
MANUAL_STEP_REQUIRED — emit aws s3api put-bucket-policy snippet granting athena.amazonaws.com with aws:SourceAccount. |
| Glue database does not exist |
AUTOMATED (the database is part of the emitted template). |
Only primary Athena workgroup exists |
AUTOMATED (the template creates a non-primary workgroup with DSL). |
| QuickSight account is Standard edition |
MANUAL_STEP_REQUIRED — scheduled SPICE refresh requires Enterprise; emit update-account-subscription snippet. |
| Cost-allocation tag not activated |
MANUAL_STEP_REQUIRED — payer-only API; emit update-cost-allocation-tags-status snippet. |
| CUR 2.0 SCAD not enabled |
MANUAL_STEP_REQUIRED — payer-only enablement in Billing console; emit the console URL. |
| BCM Data Exports not enabled |
AUTOMATED (first create-export call auto-creates the service-linked role). |
| CUR < 24 hours old |
MANUAL_STEP_REQUIRED — no data to query yet; emit the wait-and-retry note. |
Process — CUR automation design (apply in order)
Step 0: Expert knowledge — non-obvious CUR behaviors
Full catalog (24h SLA, OVERWRITE vs CREATE_NEW, hourly-only resource granularity, CUR 2.0 via BCM, MSCK anti-pattern, UsageAccountId vs PayerAccountId, SP/RI dual columns, Cost Category ordering, non-backfilling tag activation, SPICE edition bounds, unfiltered scan cost, SCAD coverage, Q as NL layer): references/advanced-patterns.md.
Step 1: CUR definition design
| Setting |
Recommended |
Why |
ReportName |
<org>-cur-hourly |
Identifies the report in the console |
TimeUnit |
HOURLY |
Required for resource-level granularity |
Format |
Parquet |
Columnar, ~10x faster Athena scans |
Compression |
Parquet (built-in) |
Native, no extra compression setting |
AdditionalSchemaElements |
["Resources"] (add SplitCostAllocationData for CUR 2.0) |
Resource IDs + SCA |
S3Bucket |
existing bucket in CUR region |
SSE-KMS recommended |
S3Prefix |
cur/<report-name>/ |
Path-based isolation for multi-report buckets |
S3Region |
bucket region |
Must match Glue catalog region |
ReportVersioning |
CREATE_NEW |
Daily snapshots, enables time travel |
RefreshClosedReports |
true |
Refunds/credits apply to closed partitions |
ReportPublishingPreferences |
Hourly: true |
Required for hourly CUR |
Step 2: CUR bucket policy design
The bucket MUST grant two service principals:
billingreports.amazonaws.com — WRITE (CUR delivery).
athena.amazonaws.com — READ (Athena query execution).
Both MUST use aws:SourceAccount (and for athena, optionally
aws:SourceArn) conditions to prevent confused-deputy attacks. See
references/quicksight-and-cmefeatures.md for the full policy JSON.
Step 3: Athena database and table (partition projection)
The Athena table DDL MUST use partition projection. Without it, MSCK
REPAIR TABLE never finishes past ~20k partitions. See
references/athena-partition-projection-and-queries.md for the full
DDL with TBLPROPERTIES block.
Workgroup (non-primary, with DSL): always create a non-primary
workgroup with EnforceWorkgroupConfiguration: true and
BytesScannedCutoffPerQuery: 1099511627776 (1 TB cutoff). The primary
workgroup has no cutoff; a single unfiltered query can scan 5+ TB.
Step 4: Query automation — named queries
| Query |
Purpose |
Key predicate |
top_spenders_by_service |
Monthly cost by service, ranked |
WHERE day >= date_trunc('month', current_date) GROUP BY product_servicename |
top_spenders_by_account |
Monthly cost by linked account |
GROUP BY lineitem_usageaccountid |
unused_ec2_resources |
EC2 instances with zero network bytes |
LEFT JOIN cw_metrics WHERE bytes_in = 0 |
savings_plan_opportunities |
On-Demand spend eligible for SP coverage |
lineitem_lineitemtype = 'Usage' AND pricing_term = 'OnDemand' |
ri_utilization |
Reserved Instance coverage and utilization |
lineitem_lineitemtype LIKE 'RIFee%' OR 'DiscountedUsage' |
tag_compliance_gaps |
Resources missing required tags |
WHERE resource_tags_<key> IS NULL |
eks_pod_cost_attribution |
EKS pod cost (requires CUR 2.0 SCA) |
WHERE split_cost_allocation_data_resource IS NOT NULL |
Full SQL for each query lives in
references/athena-partition-projection-and-queries.md.
Step 5: QuickSight, Cost Categories, tags, and CUR 2.0 layers
| Layer |
Default |
Why |
| QuickSight edition |
Enterprise |
Required for scheduled SPICE refresh on Athena |
| Dataset refresh |
Hourly during business hours |
Avoids Athena concurrency limits |
| SPICE capacity |
500 GB baseline |
One year of hourly CUR ≈ 100-200 GB after Parquet |
| Row-Level Security |
By linked account |
RLS on lineitem_usageaccountid for chargeback |
| Cost Category rules |
EQUAL/PROPORTIONAL/FIXED/ATTRIBUTES |
Chargeback model selection |
| Cost Category catch-all |
Uncategorized final rule |
Prevents line items vanishing from chargeback |
| Tag activation |
Payer-only, non-backfilling |
CE API UpdateCostAllocationTagsStatusUpstream |
| CUR 2.0 SCAD |
Enable via system tag keys |
aws:eks:clusterName, aws:ecs:clusterName, aws:lambda:functionName |
| BCM Data Exports |
bcm-data-exports API for new reports |
Replaces legacy cur API; supports custom queries |
Tag activation snippet (payer only):
aws ce update-cost-allocation-tags-status-upstream \
--tag-keys "env" "team" "cost-center" \
--status "Active" --profile payer-profile
CUR 2.0 SCAD requires CloudWatch Container Insights on EKS clusters
before enabling. BCM Data Exports full create-export payload lives in
references/quicksight-and-cmefeatures.md.
Step 10: Emit template (AUTOMATED) or gap (MANUAL_STEP_REQUIRED)
If all pre-flight requirements pass, emit the complete CUR automation
template (CloudFormation / Terraform, per the operator's preference):
AWS::CUR::ReportDefinition (or BCM Data Export).
AWS::S3::Bucket for CUR destination (if not provided).
AWS::S3::BucketPolicy granting CUR + Athena service principals.
AWS::Glue::Database and AWS::Glue::Table with partition projection
TBLPROPERTIES.
AWS::Athena::WorkGroup (non-primary, with DSL).
AWS::Athena::NamedQuery for each query in the standard set.
AWS::Scheduler::Schedule + AWS::Lambda::Function for recurring
query automation.
AWS::QuickSight::DataSource, DataSet, Dashboard (if requested).
AWS::CE::CostCategoryDefinition (if chargeback requested).
AWS::IAM::Role for the Athena/QuickSight execution role.
If any requirement is missing, emit MANUAL_STEP_REQUIRED with the
specific gap and the exact CLI / IaC snippet to close it.
Patterns — IaC templates
The two non-negotiable blocks (partition-projection TBLPROPERTIES, workgroup DSL): references/athena-partition-projection-and-queries.md.
Diagnostic flows
All five flows (CUR not delivering, HIVE_CURSOR_ERROR, Partition not found, SPICE Athena timeout, tag activation no effect): references/diagnostic-commands.md.
Output format (per operation)
OPERATION: <create | update | audit | migrate-cur2 | add-quicksight | activate-tags | define-cost-categories | enable-bcm-exports>
VERDICT: AUTOMATED | MANUAL_STEP_REQUIRED
TARGET: <cur-automation-stack-name>
REQUIREMENTS:
- [PASS] <requirement description>
- [FAIL] <requirement description> — <gap>
IAC_TEMPLATE: <inline CloudFormation / Terraform template, or "(held in draft)">
MANUAL_GAPS:
- GAP: <gap description>
REMEDIATION: <exact CLI or IaC snippet to close the gap>
REASON: <why this cannot be automated>
NOTES: <delivery lag, partition projection caveats, payer-only caveats>
Perfect example output — AUTOMATED
OPERATION: create
VERDICT: AUTOMATED
TARGET: prod-cur-automation
REQUIREMENTS:
- [PASS] Caller is payer account 111111111111
- [PASS] CUR bucket prod-cur-bucket exists in us-east-1 with versioning
- [PASS] CUR bucket policy grants billingreports.amazonaws.com + athena.amazonaws.com
- [PASS] Glue database prod_cur will be created
- [PASS] Athena workgroup finops-cur will be created with 1TB DSL
- [PASS] Athena results bucket prod-athena-results exists with KMS SSE
IAC_TEMPLATE:
# CloudFormation with: AWS::CUR::ReportDefinition (HOURLY, Parquet,
# AdditionalSchemaElements=[Resources], ReportVersioning=CREATE_NEW),
# AWS::Glue::Database, AWS::Glue::Table (partition projection TBLPROPERTIES),
# AWS::Athena::WorkGroup (finops-cur, BytesScannedCutoffPerQuery=1TB,
# EngineVersion=3), AWS::Athena::NamedQuery for top_spenders_by_service.
# Full template in references/athena-partition-projection-and-queries.md.
MANUAL_GAPS: (none)
NOTES:
- First CUR delivery arrives within 24 hours.
- All Athena queries MUST include a partition predicate on day/month/year.
Perfect example output — MANUAL_STEP_REQUIRED
Full MANUAL_STEP_REQUIRED example (linked-account caller; CUR API is payer-only): references/worked-examples.md.
STRICT output contract
The rules below are hard constraints. Violating any one produces a CUR
automation stack that fails silently on first run (no data, no
permissions, throttle at scale) or a gap report that leaves the operator
stuck. Self-check EVERY emitted block against these rules before
returning.
Required output structure
Every response MUST be a single block using these literal labels, in
this order. Do NOT substitute markdown headings or camelCase variants.
OPERATION: <create | update | audit | migrate-cur2 | add-quicksight | activate-tags | define-cost-categories | enable-bcm-exports>
VERDICT: AUTOMATED | MANUAL_STEP_REQUIRED
TARGET: <cur-automation-stack-name>
REQUIREMENTS:
- [PASS] <requirement description>
- [FAIL] <requirement description> — <gap>
IAC_TEMPLATE: <inline CloudFormation / Terraform, or "(held in draft)">
MANUAL_GAPS:
- GAP: <gap description>
REMEDIATION: <exact CLI or IaC snippet to close the gap>
REASON: <why this cannot be automated>
NOTES: <delivery lag, partition projection caveats, payer-only caveats>
FORBIDDEN output patterns
NEVER emit VERDICT: AUTOMATED when any requirement is [FAIL].
A single [FAIL] MUST produce VERDICT: MANUAL_STEP_REQUIRED.
NEVER emit a [FAIL] requirement without a corresponding
MANUAL_GAPS entry. Every [FAIL] line MUST have a matching
GAP/REMEDIATION/REASON block with the exact CLI or IaC snippet.
NEVER emit an Athena CUR table without partition projection. A
table created with PARTITIONED BY (year, month, day) but no
TBLPROPERTIES ('projection.enabled' = 'true') forces
MSCK REPAIR TABLE, which throttles past ~20k partitions.
NEVER emit a CUR bucket policy with Principal: "*". CUR data
is sensitive cost data — restrict to billingreports.amazonaws.com
and athena.amazonaws.com service principals with aws:SourceAccount
conditions.
NEVER emit an Athena workgroup without
BytesScannedCutoffPerQuery. The primary workgroup has no
cutoff; a single unfiltered query can scan 5+ TB at $5/TB = $25+.
Every emitted workgroup MUST have a cutoff (recommended 1 TB).
NEVER emit a CUR with daily granularity when resource-level cost
is requested. Daily CUR aggregates by service + linked account —
no resource IDs. Resource-level requires hourly CUR with
AdditionalSchemaElements: ["Resources"].
NEVER emit cost-allocation-tag activation from a linked account.
The CE API UpdateCostAllocationTagsStatusUpstream is payer-only.
NEVER emit IAC_TEMPLATE: (held in draft) without listing which
specific [FAIL] items blocked it. The MANUAL_GAPS block MUST
enumerate every gap.
Self-check before emit:
Expert heuristic — top 5 non-obvious failure modes
All five failure modes (MSCK throttle past 20k partitions, bucket policy without aws:SourceAccount, QuickSight Standard silent stale, tag non-backfill, SCAD needs Container Insights): references/advanced-patterns.md.
Anti-Patterns — NEVER do these things
NEVER emit a CUR with ReportVersioning: OVERWRITE for FinOps.
OVERWRITE rewrites the previous day's partition as invoices close —
historical queries return different results on each run. Use CREATE_NEW.
NEVER emit an Athena CUR table without partition projection. Past
~20k partitions, MSCK REPAIR TABLE throttles and never finishes —
the table appears empty with no error.
NEVER emit a CUR bucket policy with Principal: "*". CUR data is
sensitive — restrict to billingreports.amazonaws.com and
athena.amazonaws.com with aws:SourceAccount conditions.
NEVER emit the primary Athena workgroup for CUR queries. The
primary workgroup has no DSL — a single unfiltered query can scan 5+
TB at $5/TB. Always create a non-primary workgroup with a cutoff.
NEVER emit cost-allocation tag activation from a linked account.
The CE API is payer-only. Always verify the caller is the payer.
NEVER emit a daily CUR when resource-level cost is requested. Daily
CUR aggregates by service + linked account — no resource IDs. Requires
hourly CUR with AdditionalSchemaElements: ["Resources"].
NEVER emit a QuickSight dataset on Athena without an Enterprise
session. Standard edition has no scheduled SPICE refresh — dashboards
silently show stale data.
NEVER emit a Cost Category without a catch-all Uncategorized rule.
Without it, line items that match no rule vanish from chargeback reports.
NEVER emit CUR 2.0 SCAD without Container Insights on EKS. SCAD
splits node cost by pod-level CPU/memory — without Container Insights,
the SCA data has nothing to split by.
NEVER emit a BCM Data Exports setup assuming the service-linked role
exists. An SCP denying iam:CreateServiceLinkedRole blocks the SLR
auto-creation silently.
NEVER emit an Athena query without a partition predicate.
SELECT * FROM cur_hourly scans the entire table (5+ TB at $5/TB).
Always include WHERE day BETWEEN ... AND ....
NEVER auto-execute put-report-definition without the CONFIRM gate.
The CUR API is idempotent, but bucket policy changes have blast radius.
Pre-flight safety checks (run before any remediation CLI)
All checks (CONFIRM gate, payer verification, definition snapshot, in-flight delivery window, pre-emit verifications, additive-first): references/advanced-patterns.md.
Recent AWS features (2024-2026)
What changed (CUR 2.0 via BCM Data Exports, SCAD, Amazon Q cost analysis, Athena engine v3, CAD-CUR correlation, QuickSight Q): references/advanced-patterns.md.
References (load on demand)
- Worked examples - MANUAL_STEP_REQUIRED example: linked-account caller cannot create CUR
- Diagnostic commands - live-account pre-flight commands + the five diagnostic flows (delivery, HIVE_CURSOR_ERROR, partition not found, SPICE timeout, tag activation)
- Advanced patterns - Step 0 non-obvious CUR behaviors, expert-heuristic failure modes, pre-flight safety checks, recent AWS features
- Athena partition projection and queries - full TBLPROPERTIES/workgroup config blocks, full named-query SQL, EventBridge automation templates
- QuickSight and CUR 2.0 features - bucket policy JSON, QuickSight datasets, Cost Categories, tag activation, SCAD, BCM Data Exports, Amazon Q
Domain
AWS CloudOps / FinOps — Cost & Usage Report (CUR) Automation, Athena
Analytics, QuickSight Visualization, Cost Category Chargeback, CUR 2.0
Split Cost Allocation.
AWS documentation
1---2name: cur-automation-automator3description: 'Designs end-to-end AWS Cost and Usage Report (CUR) automation: CUR creation (hourly granularity, resource-level, ReportVersioning, Athena integration), Athena setup (database, table, partition projection), CUR query automation (top spenders, unused resources, Savings Plan opportunities, tag compliance), QuickSight integration (datasets, SPICE dashboards), Cost Category automation, cost allocation tag activation, and latest CUR 2.0 split cost allocation, AWS BCM Data Exports, Amazon Q cost analysis. Emits a verdict (AUTOMATED with full IaC template | MANUAL_STEP_REQUIRED with specific gap). Use when setting up CUR, migrating from Cost Explorer to Athena-backed analytics, automating FinOps queries, building QuickSight cost dashboards, activating tags at scale, or adopting CUR 2.0 split cost allocation.'4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline plan classification. Live-account operations use aws cur describe-report-definitions, put-report-definition, delete-report-definition, modify-report-definition, aws athena start-query-execution, get-query-execution, create-named-query, aws glue get-database, create-database, aws quicksight create-data-source, create-dataset, create-dashboard, aws ce...6metadata:7 source: https://skillmd.com/skills/jhkchan/cur-automation-automator8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '3'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: FinOps15 task_type: automate16 skill_class: capability17 lifecycle_status: active18 verdict_shape: AUTOMATED | MANUAL_STEP_REQUIRED19 when_to_use: Setting up CUR for the first time (creating the report, Athena database, partitioned table); migrating from Cost Explorer API to Athena-backed CUR analytics for higher resolution and longer history; automating recurring FinOps queries (top spenders, unused resources, Savings Plan / Reserved Instance opportunities, tag compliance); building QuickSight cost dashboards backed by CUR; activating cost allocation tags at scale via CE API; defining Cost Categories for chargeback / showback; adopting CUR 2.0 split cost allocation for EKS / ECS / Lambda container cost attribution; migrating from legacy CUR to BCM Data Exports; or wiring Amazon Q (Business Pro) for natural-language cost analysis.20 activation_triggers: set up CUR, create Cost and Usage Report, CUR Athena integration, Athena CUR partition projection, top spenders query, unused resources FinOps, Savings Plan opportunities, Reserved Instance recommendations, tag compliance audit, QuickSight cost dashboard, SPICE dataset CUR, Cost Category automation, cost allocation tag activation, CUR 2.0 split cost allocation, EKS cost attribution, BCM Data Exports, Amazon Q cost analysis21 invocation_schema: 'Input: either (a) a scenario describing the target CUR setup (greenfield vs. migration, scope: single account vs. organization/payer, granularity: hourly vs. daily, target: Athena-only vs. Athena+QuickSight vs. BCM Data Exports), OR (b) an existing CUR + Athena configuration and an operation (audit, migrate-cur2, add-quicksight, automate-queries, activate-tags, define-cost-categories). Output: deterministic OPERATION / VERDICT / REQUIREMENTS / IAC_TEMPLATE / MANUAL_GAPS / NOTES block where VERDICT is AUTOMATED (full CloudFormation / Terraform template generated) or MANUAL_STEP_REQUIRED (specific gap blocks automation, with exact CLI snippet to close it).'22 version: 0.1.023 author: Jacky Chan — AWS Community Builder24 keywords: CUR, Cost and Usage Report, FinOps, Athena, partition projection, QuickSight, SPICE, cost allocation tags, Cost Category, Savings Plans, Reserved Instances, top spenders, unused resources, tag compliance, CUR 2.0, split cost allocation, EKS cost attribution, BCM Data Exports, Amazon Q cost analysis, cost dashboard25 tags: cur, finops, athena, quicksight, cost-optimization, automate, cost-allocation, bcm-data-exports, cur226---2728# CUR Automation Automator2930## What this skill does3132Designs and emits a working CUR automation stack as code — CUR33definition, Athena database with partition projection, named queries for34top-spenders / unused-resources / Savings-Plan-opportunities / tag-compliance,35optional QuickSight datasets and dashboards, Cost Categories for36chargeback, cost-allocation-tag activation, and (when requested) CUR 2.037split cost allocation, BCM Data Exports, or Amazon Q cost-analysis wiring.38Runs deterministic requirement checks before emitting the template — if39all checks pass, the verdict is `AUTOMATED` with a populated40CloudFormation / Terraform template. If a requirement is missing (no41payer account, no bucket policy for Athena, no QuickSight Enterprise42session, no BCM Data Exports permission), the verdict is43`MANUAL_STEP_REQUIRED` with the specific gap and the exact CLI / IaC44snippet that closes it.4546## Quick navigation4748| Section | What it covers | When to read it |49|---|---|---|50| **§ Quick reference** | Verdict thresholds + requirement checklist + capability matrix | Before any build |51| **§ Mindset** | Why CUR+Athena beats Cost Explorer, the 24-hour lag, partition projection | Understanding the design model |52| **§ Pre-flight** | Requirement gate — payer, bucket, Glue catalog, IAM, QuickSight session | Before emitting any template |53| **§ Process** | Per-stage design: CUR definition, Athena table, queries, QuickSight, tags, Cost Categories | When designing each layer |54| **§ STRICT output contract** | Required labels + FORBIDDEN patterns + self-check | Before emitting any block |55| **§ Expert heuristic** | The 5 non-obvious failure modes that miss naive CUR setups | Defense-in-depth |56| **§ Anti-Patterns** | NEVER list — common mistakes that silently break CUR automation | Review before emitting |5758## Quick reference — verdict thresholds5960| Verdict | Trigger condition | Action |61|---|---|---|62| `AUTOMATED` | All requirements satisfied (payer or consolidated-billing account, CUR bucket with correct policy, Glue Data Catalog in CUR region, IAM role for Athena/QuickSight, QuickSight Enterprise session if dashboards requested, cost-allocation-tag activation if tags requested, BCM Data Exports permissions if BCM path). Template generated. | Emit complete CUR automation template, ready to apply |63| `MANUAL_STEP_REQUIRED` | One or more requirements missing (linked (member) account only — no CUR visibility; bucket policy missing Athena service principal; QuickSight session not initialized; tag activation requires payer root or Billing role; BCM Data Exports not enabled in the account). | Emit the specific gap and the exact CLI / IaC snippet to close it. Hold the partial template as a draft. |6465**Requirement checklist (all must be satisfied for AUTOMATED):**66671. **Account type** — payer (management) or consolidated-billing68 account. A linked account cannot create a CUR that spans the69 organization. Verify via `aws organizations describe-organization`70 or `aws ce list-accounts` (payer-only API).712. **CUR S3 bucket** — exists, has BlockPublicAccess enabled,72 versioning on, bucket policy granting `billingreports.amazonaws.com`73 WRITE and `athena.amazonaws.com` READ, both with `aws:SourceAccount`74 condition. SSE-KMS for compliance; SSE-S3 acceptable for non-regulated.753. **ReportVersioning** — `CREATE_NEW` (default, full daily snapshot)76 or `OVERWRITE` (incremental, smaller bucket, harder to time-travel).774. **Granularity** — `HOURLY` (max 24-hour delay before data lands) or78 `DAILY` (max 24-hour delay, smaller files). For real-time cost79 anomaly detection, use Cost Anomaly Detection, not CUR.805. **Compression** — `Parquet` (columnar, Athena-optimal, ~10x faster81 scans vs GZIP). Avoid GZIP unless a legacy consumer requires it.826. **Athena Glue Data Catalog** — exists in the SAME region as the CUR83 bucket. Cross-region catalogs require explicit catalog ARN.847. **Partition projection** — Athena table MUST use partition projection85 (`projection.day.type=date`,86 `projection.day.range=2024/01/01,NOW`) to avoid manual `MSCK REPAIR87 TABLE` (which is O(n_parts) slow and throttles past 20k partitions).888. **Athena workgroup** — non-`primary` workgroup with89 BytesScannedCutoffPerQuery set (CUR queries can scan 100s of GB if90 untuned; the cutoff prevents bill shock).919. **IAM execution role** — Athena workgroup role with92 `athena:StartQueryExecution`, `glue:GetTable`, `s3:GetObject` on the93 CUR bucket, `s3:PutObject` on the Athena results bucket.9410. **QuickSight Enterprise session** — `aws quicksight describe-account`95 returns `AccountEdition: ENTERPRISE` (or `ENTERPRISE_AND_Q`).96 Standard edition cannot schedule SPICE refresh on Athena.9711. **Cost-allocation tag activation** (if tags layer requested) — only98 the payer account root or a Billing role can call99 `UpdateCostAllocationTagsStatusUpstream`. Linked accounts can read100 tag keys but cannot activate them.10112. **Cost Category** (if chargeback layer requested) — payer account102 only.10313. **CUR 2.0 / Split Cost Allocation** (if requested) — must be enabled104 on the payer via Billing console or CE API. Takes 24-48 hours for105 first data.10614. **BCM Data Exports** (if requested) — must be enabled on the payer;107 the service-linked role `AWSServiceRoleForBCMDataExports` is108 auto-created on first use.109110**Capability matrix (which AWS service handles each layer):**111112| Layer | Service(s) | Common pitfalls |113|---|---|---|114| CUR definition | CUR (`cur`) | Hourly granularity → 24h lag; Parquet required for fast Athena |115| Storage | S3 | Wrong region (must match Glue catalog); missing service-principal policy |116| Catalog | Glue Data Catalog | Cross-region catalog breaks Athena partition projection |117| Query engine | Athena | `primary` workgroup = no DSL, unbounded cost; partition projection missing |118| Query automation | Athena Named Queries, EventBridge scheduler, Lambda | No DSL on workgroup = expensive scans |119| Visualization | QuickSight | Standard edition = no scheduled SPICE refresh; Enterprise needed |120| Chargeback | Cost Categories | Linked account cannot create; payer-only |121| Tag activation | CE API | Linked account cannot activate tags; payer-only |122| CUR 2.0 | Split Cost Allocation Data (SCAD) | Must be enabled separately; 24-48h lag for first data |123| Modern exports | BCM Data Exports | Service-linked role auto-created on first use |124| NL analysis | Amazon Q Business (cost connector) | Requires Q Business Pro subscription; payer-scoped |125126## Mindset127128**One-line takeaway:** CUR + Athena + partition projection is the only129way to do FinOps at AWS scale — Cost Explorer is a UI, not a data130pipeline. Driven by three CUR realities:131132- **Cost Explorer is rate-limited and resolution-capped.** CE API caps133 at 1 req/s and returns aggregated data with a 24-hour SLA. CUR gives134 you the raw line items (resource-level for hourly CUR), 12+ months of135 history, and no rate limit because you're querying your own Athena.136 Any FinOps pipeline that touches more than 5 services or more than 50137 accounts must move off CE and onto CUR.138139- **Partition projection is non-negotiable.** CUR writes one partition140 per day (or per hour for hourly CUR). A year of hourly CUR = ~8,700141 partitions. `MSCK REPAIR TABLE` scans every partition metadata142 object — past 20k it throttles and never finishes. Partition143 projection (`projection.day.type=date`,144 `projection.day.range=2024/01/01,NOW`) tells Athena to compute145 partition locations from the date string itself — no Glue metastore146 writes, no MSCK, no throttle.147148- **CUR 2.0 split cost allocation changes container cost attribution.**149 In CUR 1.0, an EKS pod that runs for 5 minutes on a shared node shows150 as the full node cost. CUR 2.0 + Split Cost Allocation Data (SCAD)151 divides the node cost across pods by CPU/memory usage with idle152 allocation. Without SCAD, EKS cost attribution is wrong by an order153 of magnitude. SCAD must be enabled separately on the payer.154155## Pre-flight: requirement gate156157Run before emitting any template. Missing requirements produce158MANUAL_STEP_REQUIRED with the exact gap.159160**Live-account pre-flight (skip if offline plan audit):**161The ten live-account pre-flight commands (payer check, existing CUR, bucket region/versioning/policy, Glue database, workgroup, QuickSight edition, activated tags, Cost Categories, BCM exports): [references/diagnostic-commands.md](references/diagnostic-commands.md).162163**Malformed input:** if the input scenario is missing required fields164(account type, target region, granularity, scope), emit165`VERDICT: MANUAL_STEP_REQUIRED` with `GAP: Scenario missing required166field <field>. Provide <field> to proceed.`167168| Requirement | Effect on automation |169|---|---|170| Caller is a linked (member) account | MANUAL_STEP_REQUIRED — CUR visibility is payer-only; emit the cross-account IAM role snippet. |171| CUR bucket policy missing Athena service principal | MANUAL_STEP_REQUIRED — emit `aws s3api put-bucket-policy` snippet granting `athena.amazonaws.com` with `aws:SourceAccount`. |172| Glue database does not exist | AUTOMATED (the database is part of the emitted template). |173| Only `primary` Athena workgroup exists | AUTOMATED (the template creates a non-primary workgroup with DSL). |174| QuickSight account is Standard edition | MANUAL_STEP_REQUIRED — scheduled SPICE refresh requires Enterprise; emit `update-account-subscription` snippet. |175| Cost-allocation tag not activated | MANUAL_STEP_REQUIRED — payer-only API; emit `update-cost-allocation-tags-status` snippet. |176| CUR 2.0 SCAD not enabled | MANUAL_STEP_REQUIRED — payer-only enablement in Billing console; emit the console URL. |177| BCM Data Exports not enabled | AUTOMATED (first `create-export` call auto-creates the service-linked role). |178| CUR < 24 hours old | MANUAL_STEP_REQUIRED — no data to query yet; emit the wait-and-retry note. |179180## Process — CUR automation design (apply in order)181182### Step 0: Expert knowledge — non-obvious CUR behaviors183184Full catalog (24h SLA, OVERWRITE vs CREATE_NEW, hourly-only resource granularity, CUR 2.0 via BCM, MSCK anti-pattern, UsageAccountId vs PayerAccountId, SP/RI dual columns, Cost Category ordering, non-backfilling tag activation, SPICE edition bounds, unfiltered scan cost, SCAD coverage, Q as NL layer): [references/advanced-patterns.md](references/advanced-patterns.md).185186### Step 1: CUR definition design187188| Setting | Recommended | Why |189|---|---|---|190| `ReportName` | `<org>-cur-hourly` | Identifies the report in the console |191| `TimeUnit` | `HOURLY` | Required for resource-level granularity |192| `Format` | `Parquet` | Columnar, ~10x faster Athena scans |193| `Compression` | `Parquet` (built-in) | Native, no extra compression setting |194| `AdditionalSchemaElements` | `["Resources"]` (add `SplitCostAllocationData` for CUR 2.0) | Resource IDs + SCA |195| `S3Bucket` | existing bucket in CUR region | SSE-KMS recommended |196| `S3Prefix` | `cur/<report-name>/` | Path-based isolation for multi-report buckets |197| `S3Region` | bucket region | Must match Glue catalog region |198| `ReportVersioning` | `CREATE_NEW` | Daily snapshots, enables time travel |199| `RefreshClosedReports` | `true` | Refunds/credits apply to closed partitions |200| `ReportPublishingPreferences` | `Hourly: true` | Required for hourly CUR |201202### Step 2: CUR bucket policy design203204The bucket MUST grant two service principals:2051. `billingreports.amazonaws.com` — WRITE (CUR delivery).2062. `athena.amazonaws.com` — READ (Athena query execution).207208Both MUST use `aws:SourceAccount` (and for athena, optionally209`aws:SourceArn`) conditions to prevent confused-deputy attacks. See210`references/quicksight-and-cmefeatures.md` for the full policy JSON.211212### Step 3: Athena database and table (partition projection)213214The Athena table DDL MUST use partition projection. Without it, MSCK215REPAIR TABLE never finishes past ~20k partitions. See216`references/athena-partition-projection-and-queries.md` for the full217DDL with TBLPROPERTIES block.218219**Workgroup (non-primary, with DSL):** always create a non-primary220workgroup with `EnforceWorkgroupConfiguration: true` and221`BytesScannedCutoffPerQuery: 1099511627776` (1 TB cutoff). The `primary`222workgroup has no cutoff; a single unfiltered query can scan 5+ TB.223224### Step 4: Query automation — named queries225226| Query | Purpose | Key predicate |227|---|---|---|228| `top_spenders_by_service` | Monthly cost by service, ranked | `WHERE day >= date_trunc('month', current_date)` GROUP BY `product_servicename` |229| `top_spenders_by_account` | Monthly cost by linked account | GROUP BY `lineitem_usageaccountid` |230| `unused_ec2_resources` | EC2 instances with zero network bytes | LEFT JOIN cw_metrics WHERE bytes_in = 0 |231| `savings_plan_opportunities` | On-Demand spend eligible for SP coverage | `lineitem_lineitemtype = 'Usage' AND pricing_term = 'OnDemand'` |232| `ri_utilization` | Reserved Instance coverage and utilization | `lineitem_lineitemtype LIKE 'RIFee%' OR 'DiscountedUsage'` |233| `tag_compliance_gaps` | Resources missing required tags | `WHERE resource_tags_<key> IS NULL` |234| `eks_pod_cost_attribution` | EKS pod cost (requires CUR 2.0 SCA) | `WHERE split_cost_allocation_data_resource IS NOT NULL` |235236Full SQL for each query lives in237`references/athena-partition-projection-and-queries.md`.238239### Step 5: QuickSight, Cost Categories, tags, and CUR 2.0 layers240241| Layer | Default | Why |242|---|---|---|243| QuickSight edition | Enterprise | Required for scheduled SPICE refresh on Athena |244| Dataset refresh | Hourly during business hours | Avoids Athena concurrency limits |245| SPICE capacity | 500 GB baseline | One year of hourly CUR ≈ 100-200 GB after Parquet |246| Row-Level Security | By linked account | RLS on `lineitem_usageaccountid` for chargeback |247| Cost Category rules | `EQUAL`/`PROPORTIONAL`/`FIXED`/`ATTRIBUTES` | Chargeback model selection |248| Cost Category catch-all | `Uncategorized` final rule | Prevents line items vanishing from chargeback |249| Tag activation | Payer-only, non-backfilling | CE API `UpdateCostAllocationTagsStatusUpstream` |250| CUR 2.0 SCAD | Enable via system tag keys | `aws:eks:clusterName`, `aws:ecs:clusterName`, `aws:lambda:functionName` |251| BCM Data Exports | `bcm-data-exports` API for new reports | Replaces legacy `cur` API; supports custom queries |252253Tag activation snippet (payer only):254255```bash256aws ce update-cost-allocation-tags-status-upstream \257 --tag-keys "env" "team" "cost-center" \258 --status "Active" --profile payer-profile259```260261CUR 2.0 SCAD requires CloudWatch Container Insights on EKS clusters262before enabling. BCM Data Exports full create-export payload lives in263`references/quicksight-and-cmefeatures.md`.264265### Step 10: Emit template (AUTOMATED) or gap (MANUAL_STEP_REQUIRED)266267If all pre-flight requirements pass, emit the complete CUR automation268template (CloudFormation / Terraform, per the operator's preference):269- `AWS::CUR::ReportDefinition` (or BCM Data Export).270- `AWS::S3::Bucket` for CUR destination (if not provided).271- `AWS::S3::BucketPolicy` granting CUR + Athena service principals.272- `AWS::Glue::Database` and `AWS::Glue::Table` with partition projection273 TBLPROPERTIES.274- `AWS::Athena::WorkGroup` (non-primary, with DSL).275- `AWS::Athena::NamedQuery` for each query in the standard set.276- `AWS::Scheduler::Schedule` + `AWS::Lambda::Function` for recurring277 query automation.278- `AWS::QuickSight::DataSource`, `DataSet`, `Dashboard` (if requested).279- `AWS::CE::CostCategoryDefinition` (if chargeback requested).280- `AWS::IAM::Role` for the Athena/QuickSight execution role.281282If any requirement is missing, emit `MANUAL_STEP_REQUIRED` with the283specific gap and the exact CLI / IaC snippet to close it.284285## Patterns — IaC templates286287The two non-negotiable blocks (partition-projection TBLPROPERTIES, workgroup DSL): [references/athena-partition-projection-and-queries.md](references/athena-partition-projection-and-queries.md).288289## Diagnostic flows290291All five flows (CUR not delivering, HIVE_CURSOR_ERROR, Partition not found, SPICE Athena timeout, tag activation no effect): [references/diagnostic-commands.md](references/diagnostic-commands.md).292293## Output format (per operation)294295```text296OPERATION: <create | update | audit | migrate-cur2 | add-quicksight | activate-tags | define-cost-categories | enable-bcm-exports>297VERDICT: AUTOMATED | MANUAL_STEP_REQUIRED298TARGET: <cur-automation-stack-name>299REQUIREMENTS:300 - [PASS] <requirement description>301 - [FAIL] <requirement description> — <gap>302IAC_TEMPLATE: <inline CloudFormation / Terraform template, or "(held in draft)">303MANUAL_GAPS:304 - GAP: <gap description>305 REMEDIATION: <exact CLI or IaC snippet to close the gap>306 REASON: <why this cannot be automated>307NOTES: <delivery lag, partition projection caveats, payer-only caveats>308```309310### Perfect example output — AUTOMATED311312```text313OPERATION: create314VERDICT: AUTOMATED315TARGET: prod-cur-automation316REQUIREMENTS:317 - [PASS] Caller is payer account 111111111111318 - [PASS] CUR bucket prod-cur-bucket exists in us-east-1 with versioning319 - [PASS] CUR bucket policy grants billingreports.amazonaws.com + athena.amazonaws.com320 - [PASS] Glue database prod_cur will be created321 - [PASS] Athena workgroup finops-cur will be created with 1TB DSL322 - [PASS] Athena results bucket prod-athena-results exists with KMS SSE323IAC_TEMPLATE:324 # CloudFormation with: AWS::CUR::ReportDefinition (HOURLY, Parquet,325 # AdditionalSchemaElements=[Resources], ReportVersioning=CREATE_NEW),326 # AWS::Glue::Database, AWS::Glue::Table (partition projection TBLPROPERTIES),327 # AWS::Athena::WorkGroup (finops-cur, BytesScannedCutoffPerQuery=1TB,328 # EngineVersion=3), AWS::Athena::NamedQuery for top_spenders_by_service.329 # Full template in references/athena-partition-projection-and-queries.md.330MANUAL_GAPS: (none)331NOTES:332 - First CUR delivery arrives within 24 hours.333 - All Athena queries MUST include a partition predicate on day/month/year.334```335336### Perfect example output — MANUAL_STEP_REQUIRED337338Full MANUAL_STEP_REQUIRED example (linked-account caller; CUR API is payer-only): [references/worked-examples.md](references/worked-examples.md).339340## STRICT output contract341342The rules below are hard constraints. Violating any one produces a CUR343automation stack that fails silently on first run (no data, no344permissions, throttle at scale) or a gap report that leaves the operator345stuck. Self-check EVERY emitted block against these rules before346returning.347348### Required output structure349350Every response MUST be a single block using these literal labels, in351this order. Do NOT substitute markdown headings or camelCase variants.352353```text354OPERATION: <create | update | audit | migrate-cur2 | add-quicksight | activate-tags | define-cost-categories | enable-bcm-exports>355VERDICT: AUTOMATED | MANUAL_STEP_REQUIRED356TARGET: <cur-automation-stack-name>357REQUIREMENTS:358 - [PASS] <requirement description>359 - [FAIL] <requirement description> — <gap>360IAC_TEMPLATE: <inline CloudFormation / Terraform, or "(held in draft)">361MANUAL_GAPS:362 - GAP: <gap description>363 REMEDIATION: <exact CLI or IaC snippet to close the gap>364 REASON: <why this cannot be automated>365NOTES: <delivery lag, partition projection caveats, payer-only caveats>366```367368### FORBIDDEN output patterns3693701. **NEVER emit `VERDICT: AUTOMATED` when any requirement is `[FAIL]`.**371 A single `[FAIL]` MUST produce `VERDICT: MANUAL_STEP_REQUIRED`.3723732. **NEVER emit a `[FAIL]` requirement without a corresponding374 `MANUAL_GAPS` entry.** Every `[FAIL]` line MUST have a matching375 GAP/REMEDIATION/REASON block with the exact CLI or IaC snippet.3763773. **NEVER emit an Athena CUR table without partition projection.** A378 table created with `PARTITIONED BY (year, month, day)` but no379 `TBLPROPERTIES ('projection.enabled' = 'true')` forces380 `MSCK REPAIR TABLE`, which throttles past ~20k partitions.3813824. **NEVER emit a CUR bucket policy with `Principal: "*"`.** CUR data383 is sensitive cost data — restrict to `billingreports.amazonaws.com`384 and `athena.amazonaws.com` service principals with `aws:SourceAccount`385 conditions.3863875. **NEVER emit an Athena workgroup without388 `BytesScannedCutoffPerQuery`.** The `primary` workgroup has no389 cutoff; a single unfiltered query can scan 5+ TB at $5/TB = $25+.390 Every emitted workgroup MUST have a cutoff (recommended 1 TB).3913926. **NEVER emit a CUR with daily granularity when resource-level cost393 is requested.** Daily CUR aggregates by service + linked account —394 no resource IDs. Resource-level requires hourly CUR with395 `AdditionalSchemaElements: ["Resources"]`.3963977. **NEVER emit cost-allocation-tag activation from a linked account.**398 The CE API `UpdateCostAllocationTagsStatusUpstream` is payer-only.3994008. **NEVER emit `IAC_TEMPLATE: (held in draft)` without listing which401 specific `[FAIL]` items blocked it.** The MANUAL_GAPS block MUST402 enumerate every gap.403404**Self-check before emit:**405- [ ] Any `[FAIL]` in REQUIREMENTS → VERDICT is MANUAL_STEP_REQUIRED?406- [ ] Every `[FAIL]` has a matching GAP/REMEDIATION/REASON block?407- [ ] Athena table has partition projection TBLPROPERTIES?408- [ ] CUR bucket policy uses service principals with aws:SourceAccount?409- [ ] Athena workgroup has BytesScannedCutoffPerQuery set?410- [ ] Hourly CUR has AdditionalSchemaElements: [Resources]?411- [ ] Tag activation runs only on payer account?412413## Expert heuristic — top 5 non-obvious failure modes414415All five failure modes (MSCK throttle past 20k partitions, bucket policy without aws:SourceAccount, QuickSight Standard silent stale, tag non-backfill, SCAD needs Container Insights): [references/advanced-patterns.md](references/advanced-patterns.md).416417## Anti-Patterns — NEVER do these things418419- **NEVER emit a CUR with `ReportVersioning: OVERWRITE` for FinOps.**420 OVERWRITE rewrites the previous day's partition as invoices close —421 historical queries return different results on each run. Use `CREATE_NEW`.422423- **NEVER emit an Athena CUR table without partition projection.** Past424 ~20k partitions, `MSCK REPAIR TABLE` throttles and never finishes —425 the table appears empty with no error.426427- **NEVER emit a CUR bucket policy with `Principal: "*"`.** CUR data is428 sensitive — restrict to `billingreports.amazonaws.com` and429 `athena.amazonaws.com` with `aws:SourceAccount` conditions.430431- **NEVER emit the `primary` Athena workgroup for CUR queries.** The432 primary workgroup has no DSL — a single unfiltered query can scan 5+433 TB at $5/TB. Always create a non-primary workgroup with a cutoff.434435- **NEVER emit cost-allocation tag activation from a linked account.**436 The CE API is payer-only. Always verify the caller is the payer.437438- **NEVER emit a daily CUR when resource-level cost is requested.** Daily439 CUR aggregates by service + linked account — no resource IDs. Requires440 hourly CUR with `AdditionalSchemaElements: ["Resources"]`.441442- **NEVER emit a QuickSight dataset on Athena without an Enterprise443 session.** Standard edition has no scheduled SPICE refresh — dashboards444 silently show stale data.445446- **NEVER emit a Cost Category without a catch-all `Uncategorized` rule.**447 Without it, line items that match no rule vanish from chargeback reports.448449- **NEVER emit CUR 2.0 SCAD without Container Insights on EKS.** SCAD450 splits node cost by pod-level CPU/memory — without Container Insights,451 the SCA data has nothing to split by.452453- **NEVER emit a BCM Data Exports setup assuming the service-linked role454 exists.** An SCP denying `iam:CreateServiceLinkedRole` blocks the SLR455 auto-creation silently.456457- **NEVER emit an Athena query without a partition predicate.**458 `SELECT * FROM cur_hourly` scans the entire table (5+ TB at $5/TB).459 Always include `WHERE day BETWEEN ... AND ...`.460461- **NEVER auto-execute `put-report-definition` without the CONFIRM gate.**462 The CUR API is idempotent, but bucket policy changes have blast radius.463464## Pre-flight safety checks (run before any remediation CLI)465466All checks (CONFIRM gate, payer verification, definition snapshot, in-flight delivery window, pre-emit verifications, additive-first): [references/advanced-patterns.md](references/advanced-patterns.md).467468## Recent AWS features (2024-2026)469470What changed (CUR 2.0 via BCM Data Exports, SCAD, Amazon Q cost analysis, Athena engine v3, CAD-CUR correlation, QuickSight Q): [references/advanced-patterns.md](references/advanced-patterns.md).471472## References (load on demand)473474- [Worked examples](references/worked-examples.md) - MANUAL_STEP_REQUIRED example: linked-account caller cannot create CUR475- [Diagnostic commands](references/diagnostic-commands.md) - live-account pre-flight commands + the five diagnostic flows (delivery, HIVE_CURSOR_ERROR, partition not found, SPICE timeout, tag activation)476- [Advanced patterns](references/advanced-patterns.md) - Step 0 non-obvious CUR behaviors, expert-heuristic failure modes, pre-flight safety checks, recent AWS features477- [Athena partition projection and queries](references/athena-partition-projection-and-queries.md) - full TBLPROPERTIES/workgroup config blocks, full named-query SQL, EventBridge automation templates478- [QuickSight and CUR 2.0 features](references/quicksight-and-cmefeatures.md) - bucket policy JSON, QuickSight datasets, Cost Categories, tag activation, SCAD, BCM Data Exports, Amazon Q479480## Domain481482AWS CloudOps / FinOps — Cost & Usage Report (CUR) Automation, Athena483Analytics, QuickSight Visualization, Cost Category Chargeback, CUR 2.0484Split Cost Allocation.485486## AWS documentation487488- **AWS Cost and Usage Report User Guide** — https://docs.aws.amazon.com/cur/latest/userguide/what-is-cur.html489- **CUR Athena table integration** — https://docs.aws.amazon.com/cur/latest/userguide/athena.html490- **CUR 2.0 / BCM Data Exports** — https://docs.aws.amazon.com/cur/latest/userguide/bcm-data-exports.html491- **Split Cost Allocation Data** — https://docs.aws.amazon.com/cur/latest/userguide/split-cost-allocation-data.html492- **Athena partition projection** — https://docs.aws.amazon.com/athena/latest/ug/partition-projection.html493- **Athena workgroups** — https://docs.aws.amazon.com/athena/latest/ug/workgroups.html494- **AWS Cost Categories** — https://docs.aws.amazon.com/cost-management/latest/userguide/manage-cost-categories.html495- **Cost allocation tags** — https://docs.aws.amazon.com/cost-management/latest/userguide/alloc-tags.html496- **QuickSight Athena datasets** — https://docs.aws.amazon.com/quicksight/latest/user/create-a-data-set-athena.html497- **AWS CLI cur reference** — https://docs.aws.amazon.com/cli/latest/reference/cur/498- **AWS CLI bcm-data-exports reference** — https://docs.aws.amazon.com/cli/latest/reference/bcm-data-exports/