Install the AWS Cost and Usage Queries from the AWS Serverless Application Repository

Lab 1.4

In the previous steps you’ve made the AWS Cost & Usage Report data available to Amazon Athena with a lot of manual steps. In this lab you will use sample code to automate this setup and deploy a set of pre-canned queries automatically.

The sample code is packaged and available in the AWS Serverless Application Repository and called AWS Usage Queries (find the source code on GitHub ).

Let’s deploy this from the AWS Serverless Application Repository:

  1. Go to the AWS Usage Queries in the AWS Serverless Application Repository
  2. Choose Deploy.
  3. Change the AWS Management Console’s region to the region in which the bucket with the CUR data is, as set up in lab 1.1 .
  4. Fill the fields according to the configuration of your AWS Cost & Usage Report:
    • CurBucketName: your bucket name
    • ReportName: your report name
    • ReportPathPrefix: your report path prefix

      Note If you chose Option C in lab 1.1 , use:

      • CurBucketName: your-bucket-name
      • ReportName: proxy-metrics-lab
      • ReportPathPrefix: cur-data/hourly
  5. Select I acknowledge that this app creates custom IAM roles and resource policies.
  6. Click Deploy. AWS Lambda will initiate the deployment and redirect you to a page for the application you are deploying. Deploy
  7. Click Deployments and wait approximately 2 minutes until the application is deployed.
  8. When the deployment status is Create complete go to the Amazon Athena console.
  9. Choose the aws_usage_queries_database database from the drop down. Database selection
  10. As the tables are created now, they won’t query the partitions with the sample data from 2018. You need to change the table’s data range to also extend to 2018. Execute the following query:
ALTER TABLE `cur_hourly` SET TBLPROPERTIES ('projection.year.range'='2018,2022')
  1. Explore the data. Choose the three dots next to the tables and views and choose Preview table. Preview table

Congratulations! With a two-click deployment you can now query the CUR data, have pre-canned queries for proxy metrics for Amazon EC2 and Amazon S3, and additional reference data for the EC2 instance types in the table ref_instance_types.

You can now continue with Lab 2 in which you will learn to extend the queries by further data sources.