icy-hydrogen-80135
12/18/2024, 3:41 AMadventurous-nail-5992
12/18/2024, 8:39 AMadventurous-nail-5992
12/18/2024, 9:48 AM{
"data": {
"products": [
{
"productFamily": "Request",
"sku": "QAZUUEJG8GARJCET",
"region": null,
"prices": [
{
"USD": "0"
},
{
"USD": "1e-7"
}
]
}
]
}
}
icy-hydrogen-80135
12/18/2024, 10:41 AMicy-hydrogen-80135
12/18/2024, 10:43 AM1e-7
price value and multiply it with the usage value. for example if I had this value in infracost-usage.yml
:
resource_usage:
aws_cloudfront_function:
monthly_requests: 200000
my expected value is 200,000 * 0,00000001 which equals to 0,02$icy-hydrogen-80135
12/18/2024, 11:14 AMadventurous-nail-5992
12/18/2024, 11:27 AM{
"4c91cb67406f635cb0de79c946589924-4243263383b2346485ee7f237500dfc0": [
{
"USD": "0.0000000000",
"unit": "FunctionExecutions",
"priceHash": "4c91cb67406f635cb0de79c946589924-4243263383b2346485ee7f237500dfc0",
"description": "$0 for First 2,000,000 CloudFront Function Executions",
"endUsageAmount": "2000000",
"purchaseOption": "on_demand",
"startUsageAmount": "0",
"effectiveDateStart": "2024-10-01T00:00:00Z"
},
{
"USD": "0.0000001000",
"unit": "FunctionExecutions",
"priceHash": "4c91cb67406f635cb0de79c946589924-4243263383b2346485ee7f237500dfc0",
"description": "$0.10 per 1,000,000 CloudFront Function Executions",
"endUsageAmount": "Inf",
"purchaseOption": "on_demand",
"startUsageAmount": "2000000",
"effectiveDateStart": "2024-10-01T00:00:00Z"
}
]
}
adventurous-nail-5992
12/18/2024, 11:27 AM{
products(
filter: {
vendorName: "aws"
sku: "QAZUUEJG8GARJCET"
service: "AmazonCloudFront"
}
) {
productFamily
sku
region
prices {
startUsageAmount
USD
}
}
}
adventurous-nail-5992
12/18/2024, 11:30 AMicy-hydrogen-80135
12/18/2024, 11:31 AMfunc (r *CloudfrontFunction) monthlyRequestsCostComponent() *schema.CostComponent {
return &schema.CostComponent{
Name: "Total number of invocations",
Unit: "1M invocations",
UnitMultiplier: decimal.NewFromInt(1000000),
MonthlyQuantity: floatPtrToDecimalPtr(r.MonthlyRequests),
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Service: strPtr("AmazonCloudFront"),
ProductFamily: strPtr("Request"),
AttributeFilters: []*schema.AttributeFilter{
},
},
PriceFilter: &schema.PriceFilter{
PurchaseOption: strPtr("on_demand"),
},
UsageBased: true,
}
}
icy-hydrogen-80135
12/18/2024, 11:31 AMadventurous-nail-5992
12/18/2024, 11:42 AM{
"group": "CloudFront-Functions",
"operation": "Execution",
"usagetype": "Executions-CloudFrontFunctions",
"servicecode": "AmazonCloudFront",
"servicename": "Amazon CloudFront",
"groupDescription": "CloudFront Function executions"
}
Price filters can be seen here -> https://github.com/infracost/infracost/blob/master/internal/schema/filters.go#L12-L22
Would this solve it?
PriceFilter: &schema.PriceFilter{
PurchaseOption: strPtr("on_demand"),
StartUsageAmount: strPtr("2000000"),
}
icy-hydrogen-80135
12/19/2024, 2:06 AMProductFilter: &schema.ProductFilter{
VendorName: strPtr("aws"),
Service: strPtr("AmazonCloudFront"),
ProductFamily: strPtr("Request"),
AttributeFilters: []*schema.AttributeFilter{
{Key: "usagetype", Value: strPtr("Executions-CloudFrontFunctions")},
{Key: "groupDescription", ValueRegex: regexPtr("CloudFront Function")},
},
},
PriceFilter: &schema.PriceFilter{
PurchaseOption: strPtr("on_demand"),
StartUsageAmount: strPtr("2000000"),
},
UsageBased: true,
The price calculation seems as expected. I’ll prepare the PRicy-hydrogen-80135
12/19/2024, 2:36 AMicy-hydrogen-80135
12/23/2024, 3:21 AMlittle-author-61621