All Projects → aws-samples → aws-usage-queries

aws-samples / aws-usage-queries

Licence: MIT-0 license
This application bootstraps everything needed to query the AWS Cost and Usage reports through Amazon Athena. It also includes reference data and preconfigured SQL queries.

Programming Languages

typescript
32286 projects
python
139335 projects - #7 most used programming language
shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aws-usage-queries

Atom Import Cost
Check the size of the package you import
Stars: ✭ 120 (+328.57%)
Mutual labels:  cost
cdktf-provider-aws
Prebuilt Terraform CDK (cdktf) provider for aws.
Stars: ✭ 71 (+153.57%)
Mutual labels:  cdk
valheim-ecs-fargate-cdk
AWS CDK/Cloudformation to deploy a Valheim Server using ECS Fargate!
Stars: ✭ 66 (+135.71%)
Mutual labels:  cdk
Aws Cost Saver
A tiny CLI tool to help save costs in development environments when you're asleep and don't need them!
Stars: ✭ 178 (+535.71%)
Mutual labels:  cost
redmine evm
Earned Value Management plugin for Redmine
Stars: ✭ 33 (+17.86%)
Mutual labels:  cost
aws-ecs-devops-using-aws-cdk
This repository provides a general DevOps practices such MSA, IaC, CICD and Monitoring. AWS various services are used to provide DevOps best practices.
Stars: ✭ 110 (+292.86%)
Mutual labels:  cdk
Lambda Cost Calculator
Forecast Lambda functions costs 💰
Stars: ✭ 91 (+225%)
Mutual labels:  cost
rds-snapshot-export-to-s3-pipeline
RDS Snapshot Export to S3 Pipeline
Stars: ✭ 88 (+214.29%)
Mutual labels:  cdk
cdk
🎯 Building Scalable Cloud-Native FullStack Serverless Applications. ⛅🚀
Stars: ✭ 24 (-14.29%)
Mutual labels:  cdk
cloudpatrol
Policy as Code for the Cloud Development Kit (CDK)
Stars: ✭ 21 (-25%)
Mutual labels:  cdk
Aws Lambda Power Tuning
AWS Lambda Power Tuning is an open-source tool that can help you visualize and fine-tune the memory/power configuration of Lambda functions. It runs in your own AWS account - powered by AWS Step Functions - and it supports three optimization strategies: cost, speed, and balanced.
Stars: ✭ 3,040 (+10757.14%)
Mutual labels:  cost
aws-pdf-textract-pipeline
🔍 Data pipeline for crawling PDFs from the Web and transforming their contents into structured data using AWS textract. Built with AWS CDK + TypeScript
Stars: ✭ 141 (+403.57%)
Mutual labels:  cdk
document-understanding-solution
Example of integrating & using Amazon Textract, Amazon Comprehend, Amazon Comprehend Medical, Amazon Kendra to automate the processing of documents for use cases such as enterprise search and discovery, control and compliance, and general business process workflow.
Stars: ✭ 180 (+542.86%)
Mutual labels:  cdk
Autospotting
Saves up to 90% of AWS EC2 costs by automating the use of spot instances on existing AutoScaling groups. Installs in minutes using CloudFormation or Terraform. Convenient to deploy at scale using StackSets. Uses tagging to avoid launch configuration changes. Automated spot termination handling. Reliable fallback to on-demand instances.
Stars: ✭ 2,014 (+7092.86%)
Mutual labels:  cost
cdk-eventbridge-socket
CDK construct that creates a WebSocket endpoint for you for any EventBridge rule you are interested in. (Built for debugging + testing )
Stars: ✭ 43 (+53.57%)
Mutual labels:  cdk
Koku
An open source solution for cost management of cloud and hybrid cloud environments.
Stars: ✭ 117 (+317.86%)
Mutual labels:  cost
effective-cdk
Sharing all the best practices of CDK
Stars: ✭ 11 (-60.71%)
Mutual labels:  cdk
athena-sqlite
A SQLite driver for S3 and Amazon Athena 😳
Stars: ✭ 82 (+192.86%)
Mutual labels:  amazon-athena
bl mcu sdk
bl_mcu_sdk is MCU software development kit provided by Bouffalo Lab Team for BL602/BL604, BL702/BL704/BL706, BL616/BL618, BL808 and other series of RISC-V based chips in the future.
Stars: ✭ 147 (+425%)
Mutual labels:  cdk
analyzing-reddit-sentiment-with-aws
Learn how to use Kinesis Firehose, AWS Glue, S3, and Amazon Athena by streaming and analyzing reddit comments in realtime. 100-200 level tutorial.
Stars: ✭ 40 (+42.86%)
Mutual labels:  amazon-athena

AWS usage queries

If you want to identify the top AWS usage in your AWS accounts the AWS Cost and Usage reports (CUR) have much of the data required. You can query the CUR data through Amazon Athena.

This repository is an AWS Cloud Development Kit (CDK) template that bootstraps:

  • AWS Glue catalog metadata in your account to query the CUR
  • additional reference data you can use to enrich your queries - such as instance type information
  • common queries as AWS Glue views, e.g. EC2 instance vCPU hours by account and month

You can modify the template to add your own data and queries.

Amazon Athena view in the AWS Management Console

Architectural Overview

Architectural Overview

Get Started

This application is available in the AWS Serverless Application Repository. You can deploy it to your account from there:

cloudformation-launch-button

Compile the CDK template

The CDK template is written in TypeScript. TypeScript sources must be compiled to JavaScript initially and after each modification. Open a new terminal and keep this terminal open in the background if you like to change the source files. Change the directory to the one where cdk.json is and execute:

npm install
npm run watch

Read the CDK developer guide for more information.

Deployment using CDK

Create or update the application with cdk deploy. You must provide parameters used when creating cost and usage reports. The CUR data must be stored in Apache Parquet format.

cdk deploy \
    --parameters CurBucketName=<bucket name> \
    --parameters ReportPathPrefix=<path without leading or trailing slash> \
    --parameters ReportName=<report name> \
    --databaseName=<optional databasename override, default: aws_usage_queries_database>

Access the queries

You can find the queries deployed via the Amazon Athena console. You can choose Preview next to each view or run a query like:

SELECT * FROM <see databaseName parameter above>."monthly_s3_storage_by_account" limit 10;

Cleaning Up

To avoid incurring charges, delete the AWS CloudFormation stack when you are finished experimenting via cdk destroy in the directory where cdk.json is:

cdk destroy

Or delete the AWS CloudFormation stack manually:

  • Sign in to the AWS CloudFormation console and choose your stack.
  • Choose Delete to delete all resources, including the bucket that stores the reference data.

FAQs

Q: Can I use CUR information stored in an other AWS account?

Yes. You can use a bucket policy for cross-account access in Athena to Amazon S3 buckets or you setup cross-account replication of the report bucket.

Q: Why is my CUR data not being delivered to the report bucket?

Make sure your Amazon S3 bucket is granting the permissions for Cost and Usage Reports to PUT the CUR data into the bucket.

Q: How much do resources in this template cost?

Standard AWS charges apply to the resources you deploy with this template. For the query cost read the Amazon Athena pricing and AWS Glue pricing for details. For the storage and requests to CUR data in your Amazon S3 bucket read the Amazon S3 Pricing. When creating the CUR report select Enable report data integration for Athena. That way the report data is written with the Apache Parquet columnar format which usually results in better performance and cost optimization for both Amazon S3 and Amazon Athena.

Q: How can I refresh the instance types

The instance types come from the EC2 API. Query and write it to a file:

echo "instance_family,instance_type,clock_speed_in_ghz,vcpu_count" \
    > referenceData/instanceTypes/data.csv
aws ec2 describe-instance-types \
    --output text \
    --query 'InstanceTypes[*].[InstanceType, ProcessorInfo.SustainedClockSpeedInGhz, VCpuInfo.DefaultVCpus]' \
    | sed -E 's/[[:blank:]]+/,/g' \
    | sed -E 's/^(([^.]+).*)/\2,\1/' \
    | sort >> referenceData/instanceTypes/data.csv

Q: How can I add a new question to this list?

If you found yourself wishing this set of frequently asked questions had an answer for a particular problem, please submit a pull request. The chances are good that others will also benefit from having the answer listed here.

Q: How can I contribute?

See the Contributing Guidelines for details.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].