Skip to content
main
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
May 31, 2021
May 31, 2021

aws-budget-limiter

Small Terraform script for creating a monthly AWS budget cap with notification emails.

How to use this AWS budget script:

Install terraform

This repo was created for version 0.15.4. Download Terraform here.

Create your AWS access keys

Create some AWS credentials and export them into your local shell session:

  • Open the Your Security Credentials page and click into Access Keys. Create a new access key. static/secret_access_key.png
  • Export this pair of keys into your local shell:
export AWS_ACCESS_KEY_ID="AKIAXYPRA6HBNUZKOG7T"
export AWS_SECRET_ACCESS_KEY="XwIr/9nKxyiq9VqKE+SDLBxK3jiC9qCxrNHZvI+j"

Download this aws-budget-limiter repository

Clone this repo and enter the new directory:

git clone https://github.com/dpritchett/aws-budget-limiter
cd aws-budget-limiter

Edit main.tf to customize your notification settings

At the very top of main.tf you'll see the variables that control this budget limiter. Tweak the admin_email setting so that AWS spend notifications end up in your actual inbox. If the $10 USD default isn't right for you, you can change that here as well.

locals {
  max_monthly_spend = "10"
  currency = "USD"
  admin_email = "you@yourdomain.com"
}

Initialize your Terraform setup

Initialize your terraform setup (should only need to do this the first time):

terraform init

Run the terraform plan to create your new AWS budget

Create your new AWS monthly budget by applying this terraform config:

terraform apply

# You'll see the config's proposed plan
# to add your new AWS budget and its
# notification thresholds. Type yes and
#hit enter, then terraform will execute the plan.

Review your new budget at the AWS budgets console:

budget_web_view.png

Warnings

  • If you are spending fast enough you can still go over before AWS's delayed spend counter figures it out. You'll still be on the hook for that extra spend.
  • Be careful with your AWS account keys. Don't check them into a public repo or share them with anyone else. For added safety, don't use an AWS account with full access if you can avoid it.

Resources

License: MIT Contributors: Daniel Pritchett twitter.com/dpritchett

About

Simple Terraform script for capping monthly AWS spend

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages