Skip to content

Commit

Permalink
Add budget
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswilding committed Jul 7, 2021
1 parent 2b8ffef commit e9c3421
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
21 changes: 21 additions & 0 deletions budget/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions budget/budget.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
data "aws_iam_policy_document" "budget" {
statement {
actions = [
"SNS:Publish",
]

effect = "Allow"

principals {
type = "Service"
identifiers = ["budgets.amazonaws.com"]
}

resources = [aws_sns_topic.budget.arn]
}
}

resource "aws_sns_topic" "budget" {
name = "budget"
}

resource "aws_sns_topic_policy" "budget" {
arn = aws_sns_topic.budget.arn

policy = data.aws_iam_policy_document.budget.json
}

resource "aws_sns_topic_subscription" "budget" {
topic_arn = aws_sns_topic.budget.arn
protocol = "sms"
endpoint = "+447828835419"
}


resource "aws_budgets_budget" "budget" {
name = "budget"
budget_type = "COST"
limit_amount = "25"
limit_unit = "USD"
time_unit = "MONTHLY"
time_period_start = "2021-07-01_00:00"

notification {
notification_type = "ACTUAL"
comparison_operator = "GREATER_THAN"
threshold = 100
threshold_type = "PERCENTAGE"
subscriber_email_addresses = ["[email protected]"]
subscriber_sns_topic_arns = ["${aws_sns_topic.budget.arn}"]
}
}
15 changes: 15 additions & 0 deletions budget/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
backend "s3" {
bucket = "terraform-nu2dp3915g"
key = "budget/state.tf"
region = "eu-west-1"

dynamodb_table = "terraform"
}
}

provider "aws" {
region = "eu-west-1"
}

data "aws_caller_identity" "current" {}

0 comments on commit e9c3421

Please sign in to comment.