Small Terraform script for creating a monthly AWS budget cap with notification emails.
This repo was created for version 0.15.4
. Download Terraform here.
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.
- Export this pair of keys into your local shell:
export AWS_ACCESS_KEY_ID="AKIAXYPRA6HBNUZKOG7T"
export AWS_SECRET_ACCESS_KEY="XwIr/9nKxyiq9VqKE+SDLBxK3jiC9qCxrNHZvI+j"
Clone this repo and enter the new directory:
git clone https://github.com/dpritchett/aws-budget-limiter
cd aws-budget-limiter
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 (should only need to do this the first time):
terraform init
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:
- 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.
License: MIT Contributors: Daniel Pritchett twitter.com/dpritchett