Title
#general
shubham jain

shubham jain

04/20/2022, 9:17 AM
Hi Folks I was just playing around with infracost cloud pricing api. I could not find the schema/swagger for the API. I was wondering how can I get to know what all attributes do the queries support?
Vadim (Infracost)

Vadim (Infracost)

04/20/2022, 9:22 AM
Hello! Let me look this up for you. As a quick look, you can use these type definitions in API's source code https://github.com/infracost/cloud-pricing-api/blob/master/src/typeDefs.ts
9:23 AM
There are also several examples there to get you up to speed: https://github.com/infracost/cloud-pricing-api/tree/master/examples/queries
shubham jain

shubham jain

04/20/2022, 9:24 AM
Thanks a ton
Vadim (Infracost)

Vadim (Infracost)

04/20/2022, 9:36 AM
FYI, the API https://pricing.api.infracost.io/graphql has a playground, you just need to set
X-Api-Key
header to start using it. We recommend modheader extension https://bewisse.com/modheader/. After it loads there will be a tab there where you can see the schema:
shubham jain

shubham jain

04/20/2022, 10:40 AM
one the same lines, where could I find what all attribute filters are available from various vendors? Do I need to refer aws/azure/gcp docs?
Vadim (Infracost)

Vadim (Infracost)

04/20/2022, 10:47 AM
Yeah, this is a hard part of adding new resources and that's what makes Infracost useful: we manually map the attributes to TF values 🙂 We use scrapers to get the SKUs from vendor public APIs. You can try to query them, or, as a quicker route, you can look at what attributes our cloud pricing API expects. Here's an example what attributes Azure has: https://github.com/infracost/cloud-pricing-api/blob/master/src/scrapers/azureRetail.ts#L26
10:48 AM
I would make couple queries to to CPAPI to get attributes, and you'll see the pattern how they are structured
10:51 AM
Or if you're looking to specific resources, you can also take a look at Infracost resource's cost components to get the idea what filters they use. For example, here's AWS instance looking for compute cost: https://github.com/infracost/infracost/blob/master/internal/resources/aws/instance.go#L179