Skip to content

Commit

Permalink
add optional second form of backup using AWS Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Aug 27, 2024
1 parent 5f7c6ec commit 8c43ead
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
26 changes: 23 additions & 3 deletions terraform/032-db-backup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ locals {
aws_region = data.aws_region.current.name
}


/*
* AWS data
*/

data "aws_caller_identity" "this" {}

data "aws_region" "current" {}


/*
* Create S3 bucket for storing backups
*/
Expand Down Expand Up @@ -191,9 +201,19 @@ resource "aws_cloudwatch_event_target" "backup_event_target" {
}

/*
* AWS data
* AWS backup
*/
module "aws_backup" {
count = var.enable_aws_backup ? 1 : 0

data "aws_caller_identity" "this" {}
source = "github.com/silinternational/terraform-modules//aws/backup/rds?ref=8.8.0"
app_name = var.app_name
app_env = var.app_env
source_arns = [data.aws_db_instance.this.db_instance_arn]
backup_cron_schedule = var.aws_backup_cron_schedule
notification_events = var.aws_backup_notification_events
}

data "aws_region" "current" {}
data "aws_db_instance" "this" {
db_instance_identifier = "idp-${var.idp_name}-${var.app_env}"
}
18 changes: 18 additions & 0 deletions terraform/032-db-backup/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@ variable "service_mode" {
variable "vpc_id" {
type = string
}

variable "enable_aws_backup" {
description = "enable backup using AWS Backup service"
type = bool
default = false
}

variable "aws_backup_cron_schedule" {
description = "cron-type schedule for AWS Backup"
type = string
default = "0 14 * * ? *" # Every day at 14:00 UTC, 12-hour offset from backup script
}

variable "aws_backup_notification_events" {
description = "The names of the backup events that should trigger an email notification"
type = list(string)
default = ["BACKUP_JOB_FAILED"]
}

0 comments on commit 8c43ead

Please sign in to comment.