All Projects β†’ terraform-aws-modules β†’ terraform-aws-pricing

terraform-aws-modules / terraform-aws-pricing

Licence: Apache-2.0 license
Terraform module which calculates price of AWS infrastructure (from Terraform state and plan) πŸ‡ΊπŸ‡¦

Programming Languages

HCL
1544 projects
shell
77523 projects

Projects that are alternatives of or similar to terraform-aws-pricing

Infracost
Cloud cost estimates for Terraform in pull requestsπŸ’°πŸ“‰ Love your cloud bill!
Stars: ✭ 4,505 (+3958.56%)
Mutual labels:  cost-estimation, terraform-cost-estimation
kubehelper
KubeHelper - simplifies many daily Kubernetes cluster tasks through a web interface. Search, analysis, run commands, cron jobs, reports, filters, git synchronization and many more.
Stars: ✭ 200 (+80.18%)
Mutual labels:  terraform-module
open-expenses
A curated list of (private) businesses publicly sharing their expenses.
Stars: ✭ 46 (-58.56%)
Mutual labels:  cost-estimation
terraform-aws-iam-system-user
Terraform Module to Provision a Basic IAM System User Suitable for CI/CD Systems (E.g. TravisCI, CircleCI)
Stars: ✭ 71 (-36.04%)
Mutual labels:  terraform-module
actions
A set of GitHub actions for Infracost. See cloud cost estimates for Terraform in pull requests. πŸ’°πŸ“‰ Love your cloud bill!
Stars: ✭ 147 (+32.43%)
Mutual labels:  cost-estimation
terraform-aws-sonarqube
SonarQube Terraform Module for AWS
Stars: ✭ 28 (-74.77%)
Mutual labels:  terraform-module
terraform-aws-lb-s3-bucket
Terraform module to provision an S3 bucket with built in IAM policy to allow AWS Load Balancers to ship access logs
Stars: ✭ 29 (-73.87%)
Mutual labels:  terraform-module
terraform-aws-ecs-alb-service-task
Terraform module which implements an ECS service which exposes a web service via ALB.
Stars: ✭ 108 (-2.7%)
Mutual labels:  terraform-module
terraform-aws-route53
Terraform module which creates Route53 resources on AWS πŸ‡ΊπŸ‡¦
Stars: ✭ 78 (-29.73%)
Mutual labels:  terraform-module
terraform-aws-transit-gateway
Terraform module which creates Transit Gateway resources on AWS πŸ‡ΊπŸ‡¦
Stars: ✭ 98 (-11.71%)
Mutual labels:  terraform-module
terraform-aws-enforce-mfa
A terraform module to enforce MFA for AWS groups and users
Stars: ✭ 24 (-78.38%)
Mutual labels:  terraform-module
terraform-aws-kms
This terraform module creates a KMS Customer Master Key (CMK) and its alias.
Stars: ✭ 14 (-87.39%)
Mutual labels:  terraform-module
terraform-aws-datadog-forwarders
Terraform module which creates resources on AWS to forward logs/metrics to Datadog πŸ‡ΊπŸ‡¦
Stars: ✭ 30 (-72.97%)
Mutual labels:  terraform-module
terraform-aws-ses
Terraform module to provision Simple Email Service on AWS
Stars: ✭ 24 (-78.38%)
Mutual labels:  terraform-module
terraform-kubernetes-dashboard
Terraform module for deploying Kubernetes Dashboard to k8s cluster
Stars: ✭ 13 (-88.29%)
Mutual labels:  terraform-module
terraform-aws-ecs-fargate-task-definition
Terraform module to create AWS ECS Fargate Task Definition
Stars: ✭ 20 (-81.98%)
Mutual labels:  terraform-module
terraform-aws-concourse
Terraform Module for a distributed concourse cluster on AWS
Stars: ✭ 12 (-89.19%)
Mutual labels:  terraform-module
terraform-digitalocean-kubernetes
A terraform module for managing and creating a Kubernetes cluster on digital ocean
Stars: ✭ 11 (-90.09%)
Mutual labels:  terraform-module
terraform-gke
A set of terraform modules for building GKE clusters.
Stars: ✭ 17 (-84.68%)
Mutual labels:  terraform-module
terraform-aws-eks-node-group
Terraform module to provision EKS Managed Node Group
Stars: ✭ 14 (-87.39%)
Mutual labels:  terraform-module

Terraform AWS pricing module

Terraform module, which calculates the AWS infrastructure cost in a variety of ways. This is not a traditional Terraform module because it does not create AWS infrastructure resources but using Terraform plan and Terraform states as input.

cost.modules.tf is entirely free cost estimation service, which is part of modules.tf that is currently in active development.

Join the mailing list on modules.tf to stay updated!

If you are looking into alternative ways calculating AWS infrastructure costs (for free), you can use terraform-cost-estimation.com or terraform-cost-estimation.

This is not an official HashiCorp product.

Supported Features

  • Calculate costs before creation (tfplan)
  • Calculate costs after creation (tfstate)
  • Calculate costs from multiple sources (local, remote states, specified resources)
  • Optionally, using cost.modules.tf
  • Can be executed on restricted CI/CD platforms where Terraform can run

Supported Resources

  • EC2 instances (on-demand) and Autoscaling Groups (Launch Configurations and Launch Templates):
    • aws_instance
  • EBS Volumes, Snapshots, Snapshot Copies
    • aws_ebs_volume
    • aws_ebs_snapshot
    • aws_ebs_snapshot_copy
  • Elastic Load Balancing (ELB, ALB, NLB)
    • aws_elb
    • aws_alb / aws_lb
  • NAT Gateways
    • aws_nat_gateway
  • Redshift Clusters
    • aws_redshift_cluster

Feature Roadmap

  • More EC2 instances (on-demand) and Autoscaling Groups (Launch Configurations and Launch Templates)
    • aws_autoscaling_group
    • aws_launch_configuration
    • aws_launch_template
  • EC2 Fleets (on-demand)
    • aws_ec2_fleet

Usages

Using AWS Pricing API: Terraform state or plan as JSON

provider "aws" {
  region = "us-east-1"
}

module "pricing" {
  source = "terraform-aws-modules/pricing/aws//modules/pricing"
  
  # content can be Terraform state or plan as JSON fetched from any source (see examples)
  content = jsondecode("{\"version\": 4, \"terraform_version\": \"0.14.4\", ...")
}

Using AWS Pricing API: Terraform plan as JSON from local file

provider "aws" {
  region = "us-east-1"
}

data "local_file" "local_plan" {
  filename = "local_plan.json"
}

module "pricing" {
  source = "terraform-aws-modules/pricing/aws//modules/pricing"
  
  content = jsondecode(data.local_file.local_plan.content)
}

Using AWS Pricing API: Specified resources

provider "aws" {
  region = "us-east-1"
}

module "pricing" {
  source = "terraform-aws-modules/pricing/aws//modules/pricing"
  
  resources = {
    "aws_instance.this#5" = { # Note: This means 5 instances (`count = 5`)
      instanceType = "c5.xlarge"
      location     = "eu-west-2"
    }
    "aws_instance.this2" = {
      instanceType = "c4.xlarge"
      location     = "eu-central-1"
    }
  }
}

Run in automation

@todo: Describe in more details...

# Project1 (with real EC2 resources):
terraform plan -out=plan.tfplan > /dev/null && terraform show -json plan.tfplan > plan.json

# Project2 (terraform-aws-pricing module):
TF_VAR_file_path=plan.json terraform apply
HOURLY_PRICE=$(terraform output -raw total_price_per_hour)

if HOURLY_PRICE < 10 then
  terraform apply plan.json # (from Project1)
else
  echo "Crash! Boom! Bang!"
end

Notes

AWS provider

Set AWS provider's region to us-east-1 or sa-east-1 when using modules/pricing because AWS Pricing service is only available in these regions.

You can also pass provider explicitly as described in the official documentation.

Debug & development tips

  1. debug_output = true will return more output which is often helpful only for development and debug purposes.

  2. call_aws_pricing_api = false will not call AWS Pricing API. Wrong filters produce a lot of noise, so it makes sense to disable this option when developing new filters.

  3. AWS Pricing API should always return one response for the filter. Running these commands can help identify available filters to put into modules/pricing/filters.tf (see dev directory also):

    aws pricing describe-services --service-code AmazonEC2 --format-version aws_v1 --max-items 1 --region us-east-1

    aws pricing get-products --region us-east-1 --filters file://filters.json --format-version aws_v1 --service-code AmazonEC2

Ephemeral Terraform backend

Sometimes, you may want to not store Terraform state in backend when dealing with pricing, you can use backend "inmem":

terraform {
  backend "inmem" {}
}

When you use this type of backend, there is no way to run terraform output.

Known issues/limitations

  1. Autoscaling groups resources
  2. When changing values price is sometimes higher after the first run because it is calculated based on keys and there can be some previous keys. Solution is to update code to include some unique key/prefix. Or just disable terraform state (no state = no past).
  3. At some point later, maybe add support for other providers like Azure and Google Cloud

Examples

Authors

Module created and managed by Anton Babenko.

Please reach out to Betajob if you are looking for commercial support for your Terraform, AWS, or serverless project.

License

Apache 2 Licensed. See LICENSE for full details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].