aboutsummaryrefslogtreecommitdiff
blob: ae9a8f8c36fa5336f685c218520095b6e1f21f38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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_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)