resource "aws_db_instance" "ameba-rds-stage-01" {
  # checkov:skip=CKV2_AWS_30: Ensure Postgres RDS as aws_db_instance has Query Logging enabled
  # checkov:skip=CKV_AWS_118: Ensure that enhanced monitoring is enabled for Amazon RDS instances
  # checkov:skip=CKV_AWS_157: Ensure that RDS instances have Multi-AZ enabled
  # checkov:skip=CKV_AWS_161: Ensure RDS database has IAM authentication enabled
  # checkov:skip=CKV_AWS_226: Ensure DB instance gets all minor upgrades automatically
  allocated_storage          = 40
  auto_minor_version_upgrade = false
  availability_zone          = "eu-central-1c"
  backup_retention_period    = 7
  backup_window              = "01:00-01:30"
  ca_cert_identifier         = "rds-ca-rsa2048-g1"
  copy_tags_to_snapshot      = true
  customer_owned_ip_enabled  = false
  db_name                    = "ameba"
  db_subnet_group_name       = "aoma-s-rds-sng"
  delete_automated_backups   = true
  deletion_protection        = true
  enabled_cloudwatch_logs_exports = [
    "postgresql",
    "upgrade",
  ]
  engine                                = "postgres"
  engine_version                        = "17.7"
  iam_database_authentication_enabled   = false
  identifier                            = "ameba-rds-stage-01"
  instance_class                        = "db.t4g.medium"
  iops                                  = 3000
  kms_key_id                            = "arn:aws:kms:eu-central-1:969009837416:key/2b32e148-37fb-46e6-bceb-93610c5e6c09"
  license_model                         = "postgresql-license"
  maintenance_window                    = "fri:01:50-fri:02:20"
  max_allocated_storage                 = 60
  monitoring_interval                   = 0
  multi_az                              = false
  network_type                          = "IPV4"
  parameter_group_name                  = "ameba-rds-stage-config-v17"
  performance_insights_enabled          = true
  performance_insights_kms_key_id       = "arn:aws:kms:eu-central-1:969009837416:key/2b32e148-37fb-46e6-bceb-93610c5e6c09"
  performance_insights_retention_period = 7
  port                                  = 5432
  publicly_accessible                   = false
  skip_final_snapshot                   = true
  storage_encrypted                     = true
  storage_throughput                    = 125
  storage_type                          = "gp3"
  apply_immediately                     = true
  allow_major_version_upgrade           = true
  tags = {
    "Business-Unit" = "SME-AOMA-Core"
    "Environment"   = "Stage"
    "Owner"         = "Nathaniel Lovett"
    "Project-Code"  = "SME-2000-0306A"
    "Project-Name"  = "AOMA-Core"
    "SSS"           = "IGNORE"
    "map-migrated"  = "migKNBMDMW06I"
  }
  tags_all = {
    "Business-Unit" = "SME-AOMA-Core"
    "Environment"   = "Stage"
    "Owner"         = "Nathaniel Lovett"
    "Project-Code"  = "SME-2000-0306A"
    "Project-Name"  = "AOMA-Core"
    "SSS"           = "IGNORE"
    "map-migrated"  = "migKNBMDMW06I"
  }
  username = "master_rds"
  vpc_security_group_ids = [
    "sg-0ce67d6556bc92791",
  ]

}

resource "aws_db_instance" "aoma-rds-stage" {
  # checkov:skip=CKV2_AWS_30: Ensure Postgres RDS as aws_db_instance has Query Logging enabled
  # checkov:skip=CKV_AWS_118: Ensure that enhanced monitoring is enabled for Amazon RDS instances
  # checkov:skip=CKV_AWS_157: Ensure that RDS instances have Multi-AZ enabled
  # checkov:skip=CKV_AWS_161: Ensure RDS database has IAM authentication enabled
  # checkov:skip=CKV_AWS_226: Ensure DB instance gets all minor upgrades automatically
  allocated_storage          = 750
  auto_minor_version_upgrade = false
  availability_zone          = "eu-central-1b"
  backup_retention_period    = 7
  backup_window              = "04:00-04:30"
  ca_cert_identifier         = "rds-ca-rsa2048-g1"
  copy_tags_to_snapshot      = true
  customer_owned_ip_enabled  = false
  db_name                    = "aoma"
  db_subnet_group_name       = "aoma-s-rds-sng"
  delete_automated_backups   = true
  deletion_protection        = true
  enabled_cloudwatch_logs_exports = [
    "postgresql",
  ]
  engine                                = "postgres"
  engine_version                        = "17.7"
  iam_database_authentication_enabled   = false
  identifier                            = "aoma-rds-stage"
  instance_class                        = "db.m6g.xlarge"
  iops                                  = 12000
  kms_key_id                            = "arn:aws:kms:eu-central-1:969009837416:key/2b32e148-37fb-46e6-bceb-93610c5e6c09"
  license_model                         = "postgresql-license"
  maintenance_window                    = "sat:02:51-sat:03:21"
  max_allocated_storage                 = 850
  monitoring_interval                   = 0
  multi_az                              = false
  network_type                          = "IPV4"
  parameter_group_name                  = "aoma-rds-stage-config-v17"
  performance_insights_enabled          = true
  performance_insights_kms_key_id       = "arn:aws:kms:eu-central-1:969009837416:key/2b32e148-37fb-46e6-bceb-93610c5e6c09"
  performance_insights_retention_period = 7
  port                                  = 5432
  publicly_accessible                   = false
  skip_final_snapshot                   = true
  storage_encrypted                     = true
  storage_throughput                    = 500
  storage_type                          = "gp3"
  apply_immediately                     = true
  allow_major_version_upgrade           = true
  tags = {
    "Business-Unit" = "SME-AOMA-Core"
    "Environment"   = "Stage"
    "Owner"         = "Nathaniel Lovett"
    "Project-Code"  = "SME-2000-0306A"
    "Project-Name"  = "AOMA-Core"
    "SSS"           = "IGNORE"
    "map-migrated"  = "migKNBMDMW06I"
  }
  tags_all = {
    "Business-Unit" = "SME-AOMA-Core"
    "Environment"   = "Stage"
    "Owner"         = "Nathaniel Lovett"
    "Project-Code"  = "SME-2000-0306A"
    "Project-Name"  = "AOMA-Core"
    "SSS"           = "IGNORE"
    "map-migrated"  = "migKNBMDMW06I"
  }
  username = "master_rds"
  vpc_security_group_ids = [
    "sg-0cbc68e01c7cdf1d0",
  ]

}

