-
Notifications
You must be signed in to change notification settings - Fork 433
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 Calculation for AWS CloudFront Distributions #1083
feat: Fix Cost Calculation for AWS CloudFront Distributions #1083
Conversation
Signed-off-by: bishal7679 <[email protected]>
func ConvertBytesToTerabytes(bytes int64) float64 { | ||
return float64(bytes) / 1099511627776 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we convert to GB instead? We do the same by multiplying by 1024 to the result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I thought it would be more efficient not to multiply inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i got it
dataTransferToInternetCost := awsUtils.GetCost(priceMap["CloudFront-DataTransfer-In-Bytes"], sizeInTBUpload*1024) | ||
|
||
dataTransferToOriginCost := awsUtils.GetCost(priceMap["CloudFront-DataTransfer-Out-Bytes"], sizeInTBDownload*1024) | ||
|
||
requestsCost := awsUtils.GetCost(priceMap["CloudFront-Requests"], requests/10000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did you get the keys for priceMap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep it static like previous???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me see if I can find the correct keys
|
||
// calculate requests cost | ||
requestsCost := requests * 0.000001 | ||
functionInvocationsCost := awsUtils.GetCost(priceMap["AWS-CloudFront-FunctionInvocation"], functionInvocation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did you get this key for priceMap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! updated the code with a function. Searched about it but was not getting the appropriate key. Give your suggestion on the getRate function now
Signed-off-by: bishal7679 <[email protected]>
f1c8da8
to
a96976f
Compare
@Azanul any update?? |
Yes, I looked into costing of CloudFront. I found out that there are only 3 components to CloudFront cost: CF distributions, CF Functions & CF Origin Shield requests. ref: https://aws.amazon.com/cloudfront/pricing/ |
Yes actually I went through it already |
I am including lambda-edge as our pricingoutput is giving those |
The issue that you're trying to resolve is for CloudFront Distributions, the file that you're making changes to is for CloudFront Distributions not CloudFront Functions or Origin Shield requests.
That'll be accounted for in it's own resource |
I think the respective issue description is misleading as it says we do not have the calculation whereas the calculation is there. The only thing off about the calculation seems to be the hard-coded prices. |
Yeah I noticed when I took this issue! So should we include all the charges distribution + function. and resolve with this issue only? Otherwise we have to create different issue for those. |
@jakepage91 Can we add |
Hey @bishal7679 sorry for jumping late to the thread, is there something I can help with to move forward with your PR? |
@mlabouardy we have intentionally kept this on hold to dicuss the changes on cost calculation to avoid repeatative work! |
closing this PR as awsutils recent changes are not being rendered onto my |
Problem #877
Currently cost for AWS cloudfront is full static and showing wrong.
Solution
This PR is fixing that issue by adding more metrics for
lambda-edge-duration
,lambda-edge-requests
,function-invocations
with pricemap fetching.Changes Made
AmazonCloudFront
service code and appropriate filters.lambda-edge-duration
,lambda-edge-requests
,function-invocations
metrics using cloudwatchChecklist
Pricingoutput :-
pricing.json