aboutsummaryrefslogblamecommitdiff
blob: d9ba20464944455c53547c575afcd62383b64539 (plain) (tree)

























































                                                               
resource "aws_db_parameter_group" "mastodon" {
  name   = var.name
  family = var.rds_parameter_group
}

resource "aws_db_instance" "mastodon" {
  identifier             = var.name
  instance_class         = var.rds_instance_class
  allocated_storage      = var.rds_storage_size
  engine                 = var.rds_engine
  engine_version         = var.rds_engine_version
  username               = var.rds_username
  password               = random_password.rds_password.result
  port                   = var.rds_port
  db_subnet_group_name   = aws_db_subnet_group.mastodon.name
  vpc_security_group_ids = [aws_security_group.rds.id]
  parameter_group_name   = aws_db_parameter_group.mastodon.name
  publicly_accessible    = true
  skip_final_snapshot    = true

  backup_retention_period      = 7
  performance_insights_enabled = true
}

resource "random_password" "rds_password" {
  length  = 16
  special = false
}

resource "aws_ssm_parameter" "rds_host" {
  name  = "/${var.name}/rds/host"
  type  = "String"
  value = aws_db_instance.mastodon.address
}

resource "aws_ssm_parameter" "rds_port" {
  name  = "/${var.name}/rds/port"
  type  = "String"
  value = aws_db_instance.mastodon.port
}

resource "aws_ssm_parameter" "mastodon_db_name" {
  name  = "/${local.name}/rds/name"
  type  = "String"
  value = aws_db_instance.mastodon.db_name
}

resource "aws_ssm_parameter" "mastodon_db_user" {
  name  = "/${local.name}/rds/username"
  type  = "String"
  value = aws_db_instance.mastodon.username
}

resource "aws_ssm_parameter" "mastodon_db_password" {
  name  = "/${local.name}/rds/password"
  type  = "SecureString"
  value = random_password.rds_password.result
}
Powered by cgit v1.2.3 (git 2.41.0)