Bird
Raised Fist0
AWScloud~10 mins

AWS Cost Explorer basics - Interactive Code Practice

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
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a Cost Explorer query for daily costs.

AWS
response = client.get_cost_and_usage(TimePeriod={'Start': '2023-01-01', 'End': '2023-01-31'}, Granularity='[1]', Metrics=['UnblendedCost'])
Drag options to blanks, or click blank then click option'
AHOURLY
BMONTHLY
CYEARLY
DDAILY
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'MONTHLY' when daily data is needed
Using invalid granularity values
2fill in blank
medium

Complete the code to filter the Cost Explorer query by service name 'Amazon EC2'.

AWS
response = client.get_cost_and_usage(TimePeriod={'Start': '2023-01-01', 'End': '2023-01-31'}, Granularity='DAILY', Metrics=['UnblendedCost'], Filter={'Dimensions': {'Key': 'SERVICE', 'Values': [[1]]}})
Drag options to blanks, or click blank then click option'
A'Amazon S3'
B'AWS Lambda'
C'Amazon EC2'
D'Amazon RDS'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong service names
Forgetting quotes around the service name
3fill in blank
hard

Fix the error in the code to correctly request cost data grouped by linked account.

AWS
response = client.get_cost_and_usage(TimePeriod={'Start': '2023-02-01', 'End': '2023-02-28'}, Granularity='MONTHLY', Metrics=['UnblendedCost'], GroupBy=[{'Type': 'DIMENSION', 'Key': [1]])
Drag options to blanks, or click blank then click option'
A'LINKED_ACCOUNT'
B'SERVICE'
C'USAGE_TYPE'
D'REGION'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'SERVICE' instead of 'LINKED_ACCOUNT'
Using invalid keys
4fill in blank
hard

Fill both blanks to create a filter that includes costs only for the 'us-east-1' region and excludes 'Amazon S3' service.

AWS
Filter={'And': [{'Dimensions': {'Key': '[1]', 'Values': ['us-east-1']}}, {'Not': {'Dimensions': {'Key': '[2]', 'Values': ['Amazon S3']}}}]}
Drag options to blanks, or click blank then click option'
AREGION
BSERVICE
CUSAGE_TYPE
DLINKED_ACCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up REGION and SERVICE keys
Not using 'Not' for exclusion
5fill in blank
hard

Fill all three blanks to build a Cost Explorer query that groups by service, filters for costs greater than 10 USD, and uses monthly granularity.

AWS
response = client.get_cost_and_usage(TimePeriod={'Start': '2023-03-01', 'End': '2023-03-31'}, Granularity='[1]', Metrics=['UnblendedCost'], GroupBy=[{'Type': '[2]', 'Key': '[3]'}], Filter={'Numeric': {'Key': 'UnblendedCost', 'Operator': 'GREATER_THAN', 'Value': 10}})
Drag options to blanks, or click blank then click option'
ADAILY
BMONTHLY
CDIMENSION
DSERVICE
Attempts:
3 left
💡 Hint
Common Mistakes
Using DAILY instead of MONTHLY
Wrong GroupBy type or key

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