I'm learning how the GraphQL query generation work...
# help
a
I'm learning how the GraphQL query generation works. If one of the
schema.AttributeFilter
s is removed, will the
Cloud Pricing API Server
respond successfully? E.g.:
Copy code
// computeCostComponent returns a cost component for server compute requirements.                                                                                                           
func (r *PostgreSQLFlexibleServer) computeCostComponent() *schema.CostComponent {                                                                                                           
    attrs := getFlexibleServerFilterAttributes(r.Tier, r.InstanceType, r.InstanceVersion)                                                                                                   
                                                                                                                                                                                            
    return &schema.CostComponent{                                                                                                                                                           
        Name:           fmt.Sprintf("Compute (%s)", r.SKU),                                                                                                                                 
        Unit:           "hours",                                                                                                                                                            
        UnitMultiplier: decimal.NewFromInt(1),                                                                                                                                              
        HourlyQuantity: decimalPtr(decimal.NewFromInt(1)),                                                                                                                                  
        ProductFilter: &schema.ProductFilter{                                                                                                                                               
            VendorName:    strPtr("azure"),                                                                                                                                                 
            Region:        strPtr(r.Region),                                                                                                                                                
            Service:       strPtr("Azure Database for PostgreSQL"),                                                                                                                         
            ProductFamily: strPtr("Databases"),                                                                                                                                             
            AttributeFilters: []*schema.AttributeFilter{                                                                                                                                    
                {Key: "productName", ValueRegex: strPtr(fmt.Sprintf("/^Azure Database for PostgreSQL Flexible Server %s %s/i", attrs.TierName, attrs.Series))}, // <-------------                            
                {Key: "skuName", ValueRegex: regexPtr(fmt.Sprintf("^%s$", attrs.SKUName))}, // <-------------                                                                                                 
                {Key: "meterName", ValueRegex: regexPtr(fmt.Sprintf("^%s$", attrs.MeterName))}, // <-------------                                                                                             
            },                                                                                                                                                                              
        },                                                                                                                                                                                  
        PriceFilter: &schema.PriceFilter{                                                                                                                                                   
            PurchaseOption: strPtr("Consumption"),                                                                                                                                          
        },                                                                                                                                                                                  
    }                                                                                                                                                                                       
}
w
yep, it should work, try it 🙂 that’ll just cause more data to be returned by the API as the filters narrow-down the results
a
Awesome to know!
I'm building a custom interface to the
Cloud Pricing API Server
since I am not using Terraform, so I'm dissecting the
infracost
internals
Any other areas of interest that I should look at?
w
you’re on the right track, the resource files that Vadim mentioned have the filters you need. I can’t remember if I asked already but what’s the interface taking as input? a yaml of the filters?
a
TOML
Nice, clean key/value format
So I'm generating a custom
GraphQL
query based on TOML input
w
and users write that TOML?
a
yes, exactly
m
@able-pencil-95187 interesting, is this a completely custom thing for your company? I’ve not seen any IACs implemented in TOML before
a
@mysterious-teacher-68276 good morning! No, this is not an IAC, but an internal project I'm working on.
m
cool, what’s the project?
a
It is an internal project to retrieve cloud vendor cost estimates, but we don't use Terraform. I was impressed that Infracost open sourced the
Cloud Pricing API Server
, because that could easily be a proprietary offering. Kudos! Since we don't use Terraform, a custom interface using TOML is being explored.