Skip to content

Designed to analyze terraform template files and return a cost estimate of running the infrastructure, assuming AWS is the target cloud. Perhaps other clouds can be supported going forward?

License

Notifications You must be signed in to change notification settings

BjornTwitchBot/terraform_cashier

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform_cashier

Go Report Card Build Status codecov

This uses https://github.com/Bjorn248/graphql_aws_pricing_api to get pricing data

Designed to analyze terraform template files and return a cost estimate of running the infrastructure, assuming AWS is the target cloud. Perhaps other clouds can be supported going forward?

NOTE: This only calculates the cost of EC2 and RDS resources right now. To add support for more resources, open a PR or leave a comment. I'm always looking for feedback.

This is very much in a prototype state right now. Any advice or assistance is appreciated.

Plan File

This relies on terraform plan files generated using terraform plan -out=<filename>. It is recommended that you plan against an empty state so that all of your resources are present in the plan file.

Empty/Blank state plan

If you are using remote state, you will need to disable this. I accomplish this by renaming the file that defines my remote state, appending the extension .off. Then, I have to run terraform init again to initialize a blank local state. Then I can generate a plan that contains all my resources using the following command terraform plan -out=<filename> -refresh=false.

Environment Variables

Variable Name Description
AWS_REGION The Region for which you want to create a price estimation (e.g. us-east-1)
TERRAFORM_PLANFILE Where cashier should find your terraform plan output.
RUNNING_HOURS (Optional) The number of running hours normally used in a month for your resources, on average. Defaults to 730 assuming 24/7 operation.
PRINT_VERSION (Optional) If true will print current version of cashier and exit

Installation and usage

Simply download the latest release from the releases page here: https://github.com/Bjorn248/terraform_cashier/releases Make sure that the binary is set executable Set your environment variables appropriately

export TERRAFORM_PLANFILE="./terraform.plan"
export AWS_REGION="us-west-1"

And then run the cashier binary

If you wish to see the current version of cashier, use the following environment variable

PRINT_VERSION=true

Docker

The Docker image is not published on Docker Hub or any other registry provider, although you can build and use it locally.

Build

$ docker build -t local/cashier:0.0.1 .

Run

$ docker run -v $(pwd):/data local/cashier:0.0.1

Run using custom ENV_VARs

$ docker run --env AWS_REGION=us-east-1 --env TERRAFORM_PLANFILE=/data/terraform.plan -v $(pwd):/data local/cashier:0.0.1

Local Development

This project uses https://github.com/kardianos/govendor for dependency management. Be sure to install all required dependencies to build this locally using govendor sync.

About

Designed to analyze terraform template files and return a cost estimate of running the infrastructure, assuming AWS is the target cloud. Perhaps other clouds can be supported going forward?

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 78.9%
  • HCL 18.8%
  • Dockerfile 2.3%