echomike80 / terraform-aws-rds-snapshot-tool

Based on the CloudFormation templates from https://github.com/awslabs/rds-snapshot-tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS S3 Bucket with replica Terraform module

Terraform module which creates ressources for the RDS snapshot tool on source and destination accounts on AWS.

This module is based on the CloudFormation templates from https://github.com/awslabs/rds-snapshot-tool

Terraform versions

Terraform 0.12 and newer.

Usage

Source account:

module "rds_snapshot_tool_src" {
  source                = "/path/to/terraform-aws-rds-snapshot-tool"

  name                  = var.name
  region                = var.region
  is_source_account     = true

  backup_interval       = var.backup_interval
  delete_old_snapshots  = true
  destination_account   = var.destination_account_id
  share_snapshots       = true
}

Destination account:

module "rds_snapshot_tool_dest" {
  source                = "/path/to/terraform-aws-rds-snapshot-tool"

  name                  = var.name
  region                = var.region
  is_source_account     = false

  delete_old_snapshots  = true
  kms_key_source        = var.kms_key_source
  kms_key_destination   = var.kms_key_destination
  region_dest           = var.region_dest
}

Requirements

Name Version
terraform >= 0.12.6
aws >= 2.65

Providers

Name Version
aws >= 2.65

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_rule.copy_snapshots_dest_rds resource
aws_cloudwatch_event_rule.delete_old_snapshots_dest_rds resource
aws_cloudwatch_event_rule.delete_old_snapshots_rds resource
aws_cloudwatch_event_rule.share_snapshot_rds resource
aws_cloudwatch_event_rule.take_snapshots_rds resource
aws_cloudwatch_event_target.copy_snapshots_dest_rds resource
aws_cloudwatch_event_target.delete_old_snapshots_dest_rds resource
aws_cloudwatch_event_target.delete_old_snapshots_rds resource
aws_cloudwatch_event_target.share_snapshot_rds resource
aws_cloudwatch_event_target.take_snapshots_rds resource
aws_cloudwatch_log_group.copy_snapshots_dest_rds resource
aws_cloudwatch_log_group.delete_old_snapshots_dest_rds resource
aws_cloudwatch_log_group.delete_old_snapshots_rds resource
aws_cloudwatch_log_group.share_snapshots_rds resource
aws_cloudwatch_log_group.take_snapshots_rds resource
aws_cloudwatch_metric_alarm.copy_snapshots_rds_failed resource
aws_cloudwatch_metric_alarm.delete_old_snapshots_dest_rds_failed resource
aws_cloudwatch_metric_alarm.delete_old_snapshots_rds_failed resource
aws_cloudwatch_metric_alarm.share_snapshots_rds_failed resource
aws_cloudwatch_metric_alarm.take_snapshots_rds_failed resource
aws_iam_policy.events resource
aws_iam_policy.lambda_snapshots_dest_rds resource
aws_iam_policy.lambda_snapshots_rds resource
aws_iam_policy.state_machine resource
aws_iam_role.events resource
aws_iam_role.lambda_snapshots_dest_rds resource
aws_iam_role.lambda_snapshots_rds resource
aws_iam_role.state_machine resource
aws_iam_role_policy_attachment.events resource
aws_iam_role_policy_attachment.lambda_snapshots_dest_rds resource
aws_iam_role_policy_attachment.lambda_snapshots_rds resource
aws_iam_role_policy_attachment.state_machine resource
aws_lambda_function.copy_snapshots_dest_rds resource
aws_lambda_function.delete_old_snapshots_dest_rds resource
aws_lambda_function.delete_old_snapshots_rds resource
aws_lambda_function.share_snapshots_rds resource
aws_lambda_function.take_snapshots_rds resource
aws_sfn_state_machine.copy_snapshots_dest_rds resource
aws_sfn_state_machine.delete_old_snapshots_dest_rds resource
aws_sfn_state_machine.delete_old_snapshots_rds resource
aws_sfn_state_machine.share_snapshots_rds resource
aws_sfn_state_machine.take_snapshots_rds resource
aws_sns_topic.copy_snapshots_dest_rds_failed resource
aws_sns_topic.delete_old_snapshots_dest_rds_failed resource
aws_sns_topic.delete_old_snapshots_rds_failed resource
aws_sns_topic.share_snapshots_rds_failed resource
aws_sns_topic.take_snapshots_rds_failed resource
aws_sns_topic_policy.delete_old_snapshots_rds_failed resource
aws_sns_topic_policy.share_snapshots_rds_failed resource
aws_sns_topic_policy.take_snapshots_rds_failed resource
aws_caller_identity.current data source
aws_iam_policy_document.sns_topic_policy data source

Inputs

Name Description Type Default Required
backup_automatically Enable taking snapshots automatically bool true no
backup_interval Interval for backups in hours. Default is 24. number 24 no
backup_schedule Backup schedule in Cloudwatch Event cron format. Needs to run at least once for every Interval. The default value runs once every at 1AM UTC. More information: http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html string "0 1 * * ? *" no
cross_account_copy Enable copying snapshots across accounts. Set to FALSE if your source snapshosts are not on a different account. bool true no
delete_old_snapshots Set to true to enable deletion of snapshot based on RetentionDays. Set to false to disable. bool true no
destination_account Destination account with no dashes. string "000000000000" no
instance_name_pattern Python regex for matching cluster identifiers to backup. Use "ALL_INSTANCES" to back up every RDS instance in the region. string "ALL_INSTANCES" no
is_source_account Provisioning in source account? bool true no
kms_key_destination Set to the ARN for the KMS key in the destination region to re-encrypt encrypted snapshots. Leave None if you are not using encryption. string "None" no
kms_key_source Set to the ARN for the KMS key in the SOURCE region to re-encrypt encrypted snapshots. Leave None if you are not using encryption. string "None" no
lambda_cw_log_retention Number of days to retain logs from the lambda functions in CloudWatch Logs. number 7 no
log_level Log level for Lambda functions (DEBUG, INFO, WARN, ERROR, CRITICAL are valid values). string "ERROR" no
name Name to be used on all resources string n/a yes
region Name of region from the state machine string "eu-central-1" no
region_dest Destination region for snapshots. string "eu-central-1" no
retention_days Number of days to keep snapshots in retention before deleting them. number 28 no
share_snapshots Set to true to enable sharing of snapshots based on destination_account and instance_name_pattern. Set to false to disable. bool true no
snapshot_pattern Python regex for matching instance names to backup. Use "ALL_SNAPSHOTS" to back up every RDS instance in the region. string "ALL_SNAPSHOTS" no
source_region_override Set to the region where your RDS instances run, only if such region does not support Step Functions. Leave as NO otherwise. string "NO" no
tagged_instance Set to TRUE to filter instances that have tag CopyDBSnapshot set to True. Set to FALSE to disable. string "FALSE" no
tags A mapping of tags to assign to the resource map(string) {} no

Outputs

No outputs.

Authors

Module managed by Marcel Emmert.

License

Apache 2 Licensed. See LICENSE for full details.

About

Based on the CloudFormation templates from https://github.com/awslabs/rds-snapshot-tool


Languages

Language:HCL 100.0%