main.tf 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. data "aws_rds_certificate" "latest" {
  2. latest_valid_till = true
  3. }
  4. locals {
  5. # GovCloud and Commercial use different CA certs
  6. ca_cert_identifier = var.aws_partition == "aws" ? "rds-ca-2019" : "rds-ca-2017"
  7. }
  8. output "ca_cert_identifier" {
  9. value = {
  10. "current": local.ca_cert_identifier,
  11. "latest": data.aws_rds_certificate.latest.id
  12. }
  13. }
  14. module "jira_db" {
  15. source = "terraform-aws-modules/rds/aws"
  16. version = "~> v2.0"
  17. identifier = var.identifier # this is the RDS identifier, not the DB name
  18. name = "jira" # the DB name
  19. engine = "postgres"
  20. # engine_version = "11.12" Leave this commented to use the latest from major_engine_version
  21. instance_class = var.instance_type
  22. allocated_storage = var.jira_rds_storage
  23. storage_encrypted = true
  24. kms_key_id = module.jira_key.key_arn
  25. ca_cert_identifier = local.ca_cert_identifier
  26. auto_minor_version_upgrade = true
  27. allow_major_version_upgrade = false
  28. # NOTE: Do NOT use 'user' as the value for 'username' as it throws:
  29. # "Error creating DB Instance: InvalidParameterValue: MasterUsername
  30. # user cannot be used as it is a reserved word used by the engine"
  31. username = "jira"
  32. password = "YourPwdShouldBeLongAndSecure!"
  33. port = "5432"
  34. vpc_security_group_ids = [ aws_security_group.jira_rds_sg.id ]
  35. backup_window = "00:00-03:00"
  36. maintenance_window = "Mon:03:00-Mon:06:00"
  37. # Backup retention is from 0 to 35
  38. backup_retention_period = var.environment == "test" ? 0 : 35
  39. tags = merge(var.standard_tags, var.tags)
  40. enabled_cloudwatch_logs_exports = ["postgresql", "upgrade"]
  41. # DB subnet group
  42. subnet_ids = var.subnets
  43. # DB parameter group
  44. family = "postgres11"
  45. # DB option group
  46. major_engine_version = "11"
  47. # Snapshot name upon DB deletion
  48. final_snapshot_identifier = "${var.identifier}-final-snapshot"
  49. # Database Deletion Protection
  50. deletion_protection = var.instance_termination_protection
  51. }