cycloidio / terracost

Cloud cost estimation for Terraform in your CLI
MIT License
286 stars 30 forks source link

estimation: Return a list of skipped resources #12

Closed patrislav closed 3 years ago

patrislav commented 3 years ago

Abstract

Currently, only the resources that had been successfully estimated are returned. The user has no way of knowing which resources from the plan were skipped (due to e.g. not being supported).

The skipped resources should be returned alongside the estimated ones.

Implementation details

This could be accomplished by including a SkippedResources []string field (or similar) in the cost.State struct, as well as having a helper method on the cost.Plan to extract them.

Suggestions/ideas

Many Terraform resources are inherently free (such as from the null or local providers) and shouldn't be included as "skipped." One idea could be to have a list of free resources that should never be estimated and that should never be marked as "skipped." The other would be to ignore all unknown providers and mark as skipped only unsupported resources of supported providers.

xlr-8 commented 3 years ago

Or it could also be nice to have a more detailed view returned:

CostEstimation: {
 estimated: +1000.00,
 processed: [
  "EC2": +900.00,
  "RDS": +100.00,
  "S3": -100.00
 ],
 free: ["SecurityGroup"],
 unsupported: ["ASG", "Athena"]
}

?

patrislav commented 3 years ago

You're suggesting grouping the skipped resources by service and displaying the service names instead of resources? Yes, we could tag each resource with a service name to which they belong, but there might be some problems:

  1. We might support a service only partially, e.g. EC2 has more than 30 resources but we support only two of them ATM (aws_instance and aws_ebs_volume), and some of them are free, so the EC2 service could be both "processed", "unsupported" and "free" at the same time.
  2. If new resources are added, we might not know to which service they belong until we update the list, so the software wouldn't know what to use for the "unsupported" list.

So, while we can have a list of processed services with a break down of their costs, I'm not sure whether it'd work with "free" and "unsupported".

xlr-8 commented 3 years ago

No no, it's just while I was writing those are the first things that came to mind, but you're right, it makes more sense with resources rather than services :+1: