Know How Guide and Hands on Guide for AWS
Highlight steps:

aws ce get-cost-and-usage \
    --time-period Start=2021-01-01,End=2021-02-01 \
    --granularity MONTHLY \
    --metrics "BlendedCost" "UnblendedCost" "UsageQuantity" \
    --group-by Type=DIMENSION,Key=USAGE_TYPE\
    --region cn-north-1 --profile cn-north-1
  
aws ce get-cost-and-usage \
    --time-period Start=2021-01-01,End=2021-02-01 \
    --granularity MONTHLY \
    --metrics "BlendedCost" "UnblendedCost" "UsageQuantity" \
    --group-by Type=DIMENSION,Key=SERVICE\
    --region cn-north-1 --profile cn-north-1
Glue Crawler Job

Table created by Glue Crawler

SELECT * FROM "costmaster"."china_cur_ray" limit 10;
SELECT "line_item_line_item_description" FROM "costmaster"."china_cur_ray" limit 10;
SELECT * from "costmaster"."china_cur_ray"
WHERE "line_item_line_item_type" like '%Usage%'
LIMIT 10;
SELECT distinct bill_billing_period_start_date FROM "costmaster"."china_cur_ray"
LIMIT 10;
SELECT "line_item_usage_account_id", round(sum("line_item_unblended_cost"),2) as cost from"costmaster"."china_cur_ray"
GROUP BY "line_item_usage_account_id"
ORDER BY cost desc
LIMIT 10;
SELECT "line_item_product_code", round(sum("line_item_unblended_cost"),2) as cost from"costmaster"."china_cur_ray"
GROUP BY "line_item_product_code"
ORDER BY cost desc
LIMIT 10;
SELECT "line_item_product_code", "line_item_line_item_description", round(sum("line_item_unblended_cost"),2) as cost from "costmaster"."china_cur_ray"
GROUP BY "line_item_product_code", "line_item_line_item_description"
ORDER BY cost desc
LIMIT 10;
 SELECT "line_item_product_code", "line_item_line_item_description", round(sum("line_item_unblended_cost"),2) as cost from "costmaster"."china_cur_ray"
 WHERE "line_item_product_code" like '%AmazonEC2%'
 GROUP BY "line_item_product_code", "line_item_line_item_description"
 ORDER BY cost desc
 LIMIT 10;
10. Top 20 costs by line item description, with a `Name` Tag
```sql
 SELECT "bill_payer_account_id", "product_product_name", "line_item_usage_type", "line_item_line_item_description", "resource_tags_user_name", round(sum(line_item_unblended_cost),2) as cost FROM "costmaster"."china_cur_ray"
 WHERE length("resource_tags_user_name") >0
 GROUP BY "resource_tags_user_name", "bill_payer_account_id", "product_product_name", "line_item_usage_type", "line_item_line_item_description"
 ORDER BY cost desc
 LIMIT 20
12. How much is being spent on each different family (usage type) and how much is covered by Reserved instances.
```sql
 SELECT "line_item_usage_type", sum("line_item_usage_amount") as usage, round(sum("line_item_unblended_cost"),2) as cost from "costmaster"."china_cur_ray"
 WHERE "line_item_usage_type" like '%t2.%'
 GROUP BY "line_item_usage_type"
 ORDER BY "line_item_usage_type"
 LIMIT 20
14. Show unused Reserved Instances 
```sql
  SELECT bill_billing_period_start_date, product_region, line_item_usage_type, reservation_subscription_id, reservation_unused_quantity, reservation_unused_recurring_fee from "costmaster"."china_cur_ray"
  WHERE length(reservation_subscription_id) > 0 and reservation_unused_quantity > 0
  ORDER BY bill_billing_period_start_date, reservation_unused_recurring_fee desc
  LIMIT 20
Select round(sum("line_item_unblended_cost"),2) as cost, line_item_usage_type from "costmaster"."china_cur_ray"
Where line_item_product_code='AWSConfig'
group by line_item_usage_type;