RDS Cluster

 avatar
vnlebaoduy
yaml
7 months ago
1.2 kB
6
Indexable
Never
resource "aws_rds_cluster" "mysql" {
  cluster_identifier = "mysql-cluster"
  engine             = "aurora-mysql"
  engine_version     = "5.7.mysql_aurora.2.11.2"

  database_name   = var.rds_database_name
  master_username = var.rds_database_username
  master_password = var.rds_database_password

  db_subnet_group_name   = aws_db_subnet_group.mysql.name
  vpc_security_group_ids = [aws_security_group.private_sg.id]
    
  skip_final_snapshot         = true
  # final_snapshot_identifier   = "mysql-cluster"
  allow_major_version_upgrade = true
  apply_immediately           = true

  lifecycle {
    ignore_changes = [
      availability_zones,
    ]
  }

  tags = {
    Name = "elearning-dosm-ec2-mysql"
    Project = var.project_code
  }
}

resource "aws_rds_cluster_instance" "mysql" {
  cluster_identifier = aws_rds_cluster.mysql.id
  engine             = aws_rds_cluster.mysql.engine
  engine_version     = aws_rds_cluster.mysql.engine_version
  identifier         = "mysql-instance-01"
  instance_class     = "db.t3.small"

  performance_insights_enabled = false
  publicly_accessible          = false

  tags = {
    Name = "elearning-dosm-ec2-mysql-cluster"
    Project = var.project_code
  }
}