Bird
Raised Fist0
AWScloud~5 mins

AWS Cost Explorer basics - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
AWS Cost Explorer helps you see and understand your cloud spending. It shows where your money goes and helps you find ways to save.
When you want to check how much your cloud services cost each month.
When you need to find which service or project is using the most money.
When you want to compare costs between different months or years.
When you want to set budgets and alerts to avoid surprises.
When you want to plan your cloud spending for the future.
Commands
This command fetches your total blended cost for May 2024, showing how much you spent in that month.
Terminal
aws ce get-cost-and-usage --time-period Start=2024-05-01,End=2024-05-31 --granularity MONTHLY --metrics BlendedCost
Expected OutputExpected
{ "ResultsByTime": [ { "TimePeriod": { "Start": "2024-05-01", "End": "2024-05-31" }, "Total": { "BlendedCost": { "Amount": "1234.56", "Unit": "USD" } }, "Groups": [], "Estimated": false } ] }
--time-period - Defines the start and end dates for the cost data.
--granularity - Sets how detailed the data is (DAILY, MONTHLY, or HOURLY).
--metrics - Specifies which cost metric to retrieve.
This command shows daily costs for May 2024 grouped by each AWS service, helping you see which services cost the most each day.
Terminal
aws ce get-cost-and-usage --time-period Start=2024-05-01,End=2024-05-31 --granularity DAILY --metrics BlendedCost --group-by Type=DIMENSION,Key=SERVICE
Expected OutputExpected
{ "ResultsByTime": [ { "TimePeriod": { "Start": "2024-05-01", "End": "2024-05-01" }, "Total": {}, "Groups": [ { "Keys": ["AmazonEC2"], "Metrics": { "BlendedCost": { "Amount": "50.00", "Unit": "USD" } } }, { "Keys": ["AmazonS3"], "Metrics": { "BlendedCost": { "Amount": "10.00", "Unit": "USD" } } } ], "Estimated": false } ] }
--group-by - Groups cost data by a specific dimension like service.
This command creates a cost category named 'MyProjectCosts' to group costs by a linked account, helping organize costs by project.
Terminal
aws ce create-cost-category-definition --name "MyProjectCosts" --rule-version "CostCategoryExpression.v1" --rules '[{"Value":"ProjectA","Rule":{"Dimensions":{"Key":"LINKED_ACCOUNT","Values":["123456789012"]}}}]'
Expected OutputExpected
{ "CostCategoryArn": "arn:aws:ce::123456789012:costcategory/MyProjectCosts", "EffectiveStart": "2024-06-01T00:00:00Z" }
--name - Names the cost category.
--rules - Defines how costs are grouped in this category.
This command lists all cost categories you have created, so you can see and manage your cost groups.
Terminal
aws ce list-cost-category-definitions
Expected OutputExpected
{ "CostCategoryReferences": [ { "CostCategoryArn": "arn:aws:ce::123456789012:costcategory/MyProjectCosts", "Name": "MyProjectCosts", "EffectiveStart": "2024-06-01T00:00:00Z" } ] }
Key Concept

If you remember nothing else from this pattern, remember: AWS Cost Explorer lets you see your cloud costs clearly by time and service, helping you control spending.

Common Mistakes
Using incorrect date format in --time-period flag.
The command fails because AWS expects dates in YYYY-MM-DD format.
Always use the exact format like Start=2024-05-01,End=2024-05-31.
Not specifying --metrics flag when running get-cost-and-usage.
The command returns an error or no useful data without metrics specified.
Always include --metrics with values like BlendedCost or UnblendedCost.
Trying to create a cost category without proper JSON syntax in --rules.
The command fails due to invalid JSON format.
Use correct JSON syntax with escaped quotes and brackets as shown.
Summary
Use aws ce get-cost-and-usage to fetch cost data by time and service.
Group costs by service or account to understand spending details.
Create and list cost categories to organize costs by projects or teams.

Practice

(1/5)
1. What is the main purpose of AWS Cost Explorer?
easy
A. To monitor network traffic
B. To create AWS virtual machines
C. To help you track and understand your AWS spending
D. To manage user permissions

Solution

  1. Step 1: Understand AWS Cost Explorer's function

    AWS Cost Explorer is designed to show your cloud spending clearly and help manage costs.
  2. Step 2: Compare options with this function

    Options A, B, and D describe other AWS services or features unrelated to cost tracking.
  3. Final Answer:

    To help you track and understand your AWS spending -> Option C
  4. Quick Check:

    Cost tracking = C [OK]
Hint: Cost Explorer is for spending, not resources or permissions [OK]
Common Mistakes:
  • Confusing Cost Explorer with EC2 or IAM services
  • Thinking it manages network or security settings
2. Which of the following is the correct way to start AWS Cost Explorer from the AWS Console?
easy
A. Go to Services > S3 > Cost Explorer
B. Go to Services > EC2 > Cost Explorer
C. Go to Services > IAM > Cost Explorer
D. Go to Services > Billing > Cost Explorer

Solution

  1. Step 1: Identify where billing tools are located

    Cost Explorer is found under Billing in the AWS Console, not under EC2, IAM, or S3.
  2. Step 2: Match the correct navigation path

    Only Go to Services > Billing > Cost Explorer correctly shows Services > Billing > Cost Explorer.
  3. Final Answer:

    Go to Services > Billing > Cost Explorer -> Option D
  4. Quick Check:

    Billing section = A [OK]
Hint: Cost Explorer is under Billing, not compute or storage [OK]
Common Mistakes:
  • Looking for Cost Explorer under EC2 or S3
  • Confusing IAM with billing tools
3. You use AWS Cost Explorer to view your monthly AWS costs grouped by service. If your report shows $100 for EC2 and $50 for S3, what does this mean?
medium
A. Your EC2 and S3 usage is free this month
B. You spent $100 on EC2 and $50 on S3 this month
C. You reserved EC2 instances worth $100 and S3 storage worth $50
D. You have $100 credit for EC2 and $50 credit for S3

Solution

  1. Step 1: Understand grouping by service in Cost Explorer

    Grouping by service shows how much money you spent on each AWS service in the selected time.
  2. Step 2: Interpret the amounts shown

    $100 for EC2 and $50 for S3 means those are your costs, not credits or reserved amounts.
  3. Final Answer:

    You spent $100 on EC2 and $50 on S3 this month -> Option B
  4. Quick Check:

    Costs shown = spending, not credits or free usage [OK]
Hint: Costs mean spending, not credits or reservations [OK]
Common Mistakes:
  • Thinking amounts are credits or free usage
  • Confusing cost with reserved capacity
4. You tried to filter your AWS Cost Explorer report by a tag, but no data appears. What is the most likely reason?
medium
A. The tag is not activated for cost allocation in AWS Billing settings
B. You have no AWS account
C. Cost Explorer does not support filtering by tags
D. You need to restart your AWS instance

Solution

  1. Step 1: Understand tag filtering in Cost Explorer

    To filter by tags, the tags must be activated for cost allocation in Billing preferences.
  2. Step 2: Identify why no data appears

    If the tag is not activated, Cost Explorer cannot use it to filter, so no data shows.
  3. Final Answer:

    The tag is not activated for cost allocation in AWS Billing settings -> Option A
  4. Quick Check:

    Tag activation needed for filtering = A [OK]
Hint: Activate tags in billing before filtering by them [OK]
Common Mistakes:
  • Assuming Cost Explorer can't filter by tags
  • Thinking AWS instance restart fixes this
  • Believing no AWS account is the cause
5. You want to analyze your AWS costs for the last 3 months, grouped by linked accounts and filtered to only show costs for EC2 and S3. Which steps should you take in AWS Cost Explorer?
hard
A. Set the time range to last 3 months, group by linked accounts, and filter services to EC2 and S3
B. Set the time range to last 3 months, group by service, and filter accounts to EC2 and S3
C. Set the time range to last month, group by linked accounts, and filter services to all except EC2 and S3
D. Set the time range to last 3 months, group by tags, and filter services to EC2 only

Solution

  1. Step 1: Choose correct time range and grouping

    Set the time range to last 3 months and group by linked accounts to see costs per account.
  2. Step 2: Apply service filters correctly

    Filter services to only EC2 and S3 to focus on those costs.
  3. Step 3: Verify options

    Set the time range to last 3 months, group by linked accounts, and filter services to EC2 and S3 matches all requirements. Other options have wrong grouping, filtering, or time range.
  4. Final Answer:

    Set the time range to last 3 months, group by linked accounts, and filter services to EC2 and S3 -> Option A
  5. Quick Check:

    Time + grouping + filter = B [OK]
Hint: Match time, grouping, and filters exactly for correct report [OK]
Common Mistakes:
  • Mixing grouping by service vs linked accounts
  • Filtering accounts instead of services
  • Choosing wrong time range