Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Terraform
terraform.tfstate
terraform.tfstate.*
.terraform/

35 changes: 35 additions & 0 deletions terraform/aws/cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -----------------------
# SNS Topic for Alerts
# -----------------------
resource "aws_sns_topic" "alerts" {
name = "devops-alerts-topic"
}

# SNS Email Subscription
resource "aws_sns_topic_subscription" "email" {
topic_arn = aws_sns_topic.alerts.arn
protocol = "email"
endpoint = var.alert_email
}

# -----------------------
# CloudWatch Alarm - ECS CPU Utilization
# -----------------------
resource "aws_cloudwatch_metric_alarm" "ecs_cpu_high" {
alarm_name = "ecs-cpu-utilization-high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 1
metric_name = "CPUUtilization"
namespace = "AWS/ECS"
period = 300
statistic = "Average"
threshold = 70
alarm_description = "CPU utilization exceeds 70% for ECS service"
alarm_actions = [aws_sns_topic.alerts.arn]

dimensions = {
ClusterName = aws_ecs_cluster.this.name
ServiceName = aws_ecs_service.this.name
}
}

19 changes: 19 additions & 0 deletions terraform/aws/secrets.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -----------------------
# Secrets Manager Secret
# -----------------------
resource "aws_secretsmanager_secret" "app_secret" {
name = "devops/backend/app-secret"

tags = {
Name = "devops-backend-secret"
}
}

# -----------------------
# Secret Value
# -----------------------
resource "aws_secretsmanager_secret_version" "app_secret_value" {
secret_id = aws_secretsmanager_secret.app_secret.id
secret_string = var.app_secret_value
}