0
0
AWScloud~10 mins

AWS Cost Explorer basics - Interactive Code Practice

Choose your learning style9 modes available
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