Skip to content

Commit 71a363b

Browse files
authored
Merge pull request #2 from B0go/aws-costs-alert
Add AWS estimated charges alert
2 parents 8f6d0c1 + 1daf49c commit 71a363b

File tree

7 files changed

+70
-0
lines changed

7 files changed

+70
-0
lines changed

Diff for: terraform/cloudwatch/.terraform.lock.hcl

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: terraform/cloudwatch/backend.tf

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
backend "s3" {
3+
profile = "personal-aws-terraform"
4+
bucket = "b0go-terraform-state"
5+
key = "terraform-infrastructure/terraform/cloudwatch/terraform.tfstate"
6+
dynamodb_table = "terraform-state-lock"
7+
region = "us-east-1"
8+
encrypt = true
9+
}
10+
}

Diff for: terraform/cloudwatch/cloudwatch.tf

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "aws_cloudwatch_metric_alarm" "total-estimate-charge" {
2+
alarm_name = "total-estimate-charge"
3+
comparison_operator = "GreaterThanOrEqualToThreshold"
4+
evaluation_periods = "2"
5+
metric_name = "EstimatedCharges"
6+
namespace = "AWS/Billing"
7+
period = "120"
8+
statistic = "Average"
9+
threshold = "10"
10+
alarm_description = "This alart monitors that the total estimated charge is below a threshold"
11+
alarm_actions = [aws_sns_topic.cloudwatch-alarms-topic.arn]
12+
}

Diff for: terraform/cloudwatch/providers.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "aws" {
2+
region = "us-east-1"
3+
profile = "personal-aws-terraform"
4+
}

Diff for: terraform/cloudwatch/sns.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "aws_sns_topic" "cloudwatch-alarms-topic" {
2+
name = "cloudwatch-alarms-topic"
3+
}
4+
5+
resource "aws_sns_topic_subscription" "victorbogo-me-topic-subscription" {
6+
topic_arn = aws_sns_topic.cloudwatch-alarms-topic.arn
7+
protocol = "email"
8+
endpoint = var.alarms-email
9+
}

Diff for: terraform/cloudwatch/variables.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "alarms-email" {
2+
type = string
3+
}

Diff for: terraform/cloudwatch/versions.tf

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = "~> 1.2.3"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = "4.15.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)