import dotenv from "dotenv"; dotenv.config(); export const productResourceUsageQuery = `SELECT DISTINCT line_item_product_code AS productCode, COALESCE(NULLIF(TRIM(product_region_code), ''), 'global') AS regionCode, line_item_usage_account_id AS accountId, line_item_resource_id AS resourceId, line_item_usage_type AS usageType, line_item_usage_amount AS usageAmount, line_item_unblended_rate AS unblendedRate, line_item_unblended_cost AS unblendedCost, line_item_blended_rate AS blendedRate, line_item_blended_cost AS blendedCost, pricing_term AS pricingTerm, pricing_unit AS pricingUnit, pricing_rate_code AS pricingRateCode, pricing_currency AS pricingCurrency, line_item_usage_start_date AS startDate, line_item_usage_end_date AS endDate FROM ${process.env.ATHENA_CU_TABLE} WHERE line_item_usage_account_id = '%accountId%' AND COALESCE(NULLIF(TRIM(product_region_code), ''), 'global') = '%regionCode%' AND LOWER(line_item_product_code) = LOWER('%productCode%') AND line_item_resource_id = '%resourceId%' ORDER BY line_item_usage_start_date ASC;`; export const allProductUsageQuery = `SELECT DISTINCT line_item_product_code AS productCode, COALESCE(NULLIF(TRIM(product_region_code), ''), 'global') AS regionCode, line_item_usage_account_id AS accountId, line_item_resource_id AS resourceId, line_item_usage_type AS usageType, line_item_usage_amount AS usageAmount, line_item_unblended_cost AS unblendedCost, line_item_blended_cost AS blendedCost, line_item_usage_start_date AS startDate, line_item_usage_end_date AS endDate FROM ${process.env.ATHENA_CU_TABLE} ORDER BY productCode, regionCode, accountId, startDate ASC;`; // /accounts/cost-usage-summary export const accountCostUsageSummaryQuery = ` SELECT line_item_usage_account_id AS accountId, SUM(line_item_usage_amount) AS totalUsageAmount, SUM(line_item_unblended_cost) AS totalUnblendedCost, SUM(line_item_blended_cost) AS totalBlendedCost FROM ${process.env.ATHENA_CU_TABLE} GROUP BY line_item_usage_account_id ORDER BY totalUnblendedCost DESC; `;