Creates a DocumentDB cluster and sets up an SNS topic for event subscription to monitor specific events like creation and failure.

Terraform Template

data "aws_availability_zones" "available" {
  state = "available"
}

resource "aws_docdb_cluster" "example" {
  availability_zones = [data.aws_availability_zones.available.names[0], data.aws_availability_zones.available.names[1], data.aws_availability_zones.available.names[2]]
  cluster_identifier = "example"
  master_password = "mustbeeightcharaters"
  master_username = "foo"
  skip_final_snapshot = true
}

resource "aws_docdb_event_subscription" "example" {
  enabled = true
  event_categories = ["creation", "failure"]
  name = "example"
  sns_topic_arn = aws_sns_topic.example.arn
  source_ids = [aws_docdb_cluster.example.id]
  source_type = "db-cluster"
}

resource "aws_sns_topic" "example" {
  name = "example-events"
}