Hi Folks I was just playing around with infracost ...
# general
h
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?
b
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
There are also several examples there to get you up to speed: https://github.com/infracost/cloud-pricing-api/tree/master/examples/queries
h
Thanks a ton
🙌 1
b
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:
❤️ 1
h
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?
b
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
I would make couple queries to to CPAPI to get attributes, and you'll see the pattern how they are structured
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
👍 1