resource "aws_db_instance" "primary" { identifier = "prod-postgres" lifecycle { prevent_destroy = true } } resource "aws_s3_bucket_versioning" "data" { bucket = aws_s3_bucket.data.id versioning_configuration { status = "Enabled" } } resource "aws_cloudwatch_metric_alarm" "db_cpu" { alarm_name = "db-high-cpu" comparison_operator = "GreaterThanThreshold" evaluation_periods = 3 metric_name = "CPUUtilization" namespace = "AWS/RDS" period = 300 statistic = "Average" threshold = 80 alarm_actions = [aws_sns_topic.alerts.arn] }