Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fix cost calculations for AWS S3 #1053

Closed
wants to merge 1 commit into from
Closed

feat: Fix cost calculations for AWS S3 #1053

wants to merge 1 commit into from

Conversation

bishal7679
Copy link
Contributor

Problem #1022

Currently cost for AWS S3 is always showing as $0.

Solution

This PR is fixing that issue by adding more filters and usage metrics for request to s3 bucket with absolute pricemap fetching.

Changes Made

  • Fetching price info using AWS SDK price module using AmazonS3 service code and appropriate filters.
  • getting price map using util function GetPriceMap from utils.go
  • fetching resource objects using S3 client
  • also fetching usage metrics as request using cloudwatch
  • Finally added calculation as per all the metrics

Screenshots

09-10-2023:09:42:02

Checklist

  • Code follows the contributing guidelines
  • Changes have been thoroughly tested
  • Documentation has been updated, if necessary
  • Any dependencies have been added to the project, if necessary

Copy link
Collaborator

@Azanul Azanul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've pushed 2 unwanted files: azure.svg & favicon.ico

Comment on lines +105 to +109
storageCostPerGB = (sizeInTB * 1024) * 0.023
} else if sizeInTB <= 450 {
monthlyCost = (sizeInTB * 1000) * 0.022
storageCostPerGB = (sizeInTB * 1024) * 0.022
} else {
monthlyCost = (sizeInTB * 1000) * 0.021
storageCostPerGB = (sizeInTB * 1024) * 0.021
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace hardcoded values with actual values from pricing output similar to as you've done for requests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's wrong with it as it covering 500 TB. When we are trying to fetch it using GetCost then it is giving $0 i.g its eliminating all the so small charges.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can do it but you will unable to see so small amount like $0.00000011

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's taking free tier into account, if the free tier is described by the pricing output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you pls check once with my code by removing the static values and adding awsUtils.GetCost(priceMap["AWS-S3-Storage"] dynamically with your AWS account??
and taking sizeinTB into account

Comment on lines +46 to +50
{
Field: aws.String("storageClass"), // Filter by storage class
Value: aws.String("STANDARD"), // Specify the desired storage class
Type: types.FilterTypeTermMatch,
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

different buckets might have different storage classes

},
{
Field: aws.String("storageClass"), // Filter by storage class
Value: aws.String("STANDARD"), // Specify the desired storage class
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this dynamic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok 👍

@bishal7679
Copy link
Contributor Author

You've pushed 2 unwanted files: azure.svg & favicon.ico

i dont understand! it's been taken automatically :(

@Azanul
Copy link
Collaborator

Azanul commented Oct 9, 2023

i dont understand! it's been taken automatically :(

commit only the files you want to commit, son't commit all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants