Add backup vault backup plan module (#3536)
* ft/adding backup vault backup plan module * ft/adding missing licence * resource name updated * corrected the variable sequece in readme.md * corrected lint error * corrected lint error * addressed the comments * fixing the lint issues * addressed comments * updated readme.md, changed sample project id in example * updated readme.md * added other resource [managment server, associations, default backup plan] * new example added in readme * ft/pass test cases * fix: change the variables.tf file sequence * fix: change module versions * fix: change module versions * fix: change module versions * fix: change module versions * updated varaible structure * module name in version.tf * added missing empyt line * corrected readme.md tests * remove project id to genric id * removed extra file * corrected syntex error * applied terraform fmt * fix/lint issue * changed as per github comments * Add inventories --------- Co-authored-by: Yashwant Mahawar <myashwant@google.com> Co-authored-by: Julio Castillo <jccb@google.com>
This commit is contained in:
203
modules/backup-dr/README.md
Normal file
203
modules/backup-dr/README.md
Normal file
@@ -0,0 +1,203 @@
|
||||
# Terraform Google Backup DR Plan
|
||||
|
||||
This Terraform module creates a Google Cloud Backup and DR backup plan and, optionally, a backup vault.
|
||||
|
||||
## Description
|
||||
|
||||
This module allows you to define a backup plan for your Google Cloud resources. You can specify backup rules, including schedules and retention policies. The module can also create a new backup vault or use an existing one.
|
||||
|
||||
## Examples
|
||||
|
||||
<!-- BEGIN TOC -->
|
||||
- [Description](#description)
|
||||
- [Examples](#examples)
|
||||
- [Create backup vault (basic usage)](#create-backup-vault-basic-usage)
|
||||
- [Create backup vault (extended options)](#create-backup-vault-extended-options)
|
||||
- [Create vault and plan](#create-vault-and-plan)
|
||||
- [Create only backup plan with existing vault](#create-only-backup-plan-with-existing-vault)
|
||||
- [Create management_server](#create-management_server)
|
||||
- [Variables](#variables)
|
||||
- [Outputs](#outputs)
|
||||
<!-- END TOC -->
|
||||
|
||||
### Create backup vault (basic usage)
|
||||
```hcl
|
||||
module "dr_example" {
|
||||
source = "./fabric/modules/backup-dr"
|
||||
project_id = "your-gcp-project-id"
|
||||
location = "us-central1"
|
||||
name = "backup-vault-01"
|
||||
}
|
||||
# tftest modules=1 resources=1
|
||||
```
|
||||
|
||||
### Create backup vault (extended options)
|
||||
```hcl
|
||||
module "dr_example" {
|
||||
source = "./fabric/modules/backup-dr"
|
||||
project_id = "your-gcp-project-id"
|
||||
location = "us-central1"
|
||||
name = "backup-vault"
|
||||
vault_config = {
|
||||
access_restriction = "WITHIN_ORGANIZATION"
|
||||
annotations = {
|
||||
"key" = "value"
|
||||
}
|
||||
backup_minimum_enforced_retention_duration = "100000s"
|
||||
backup_retention_inheritance = "INHERIT_VAULT_RETENTION"
|
||||
description = "Backup Vault managed by Terraform IAC."
|
||||
allow_missing = false
|
||||
force_update = false
|
||||
ignore_backup_plan_references = false
|
||||
ignore_inactive_datasources = false
|
||||
labels = {
|
||||
"key" = "value"
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest inventory=extended.yaml
|
||||
```
|
||||
|
||||
### Create vault and plan
|
||||
```hcl
|
||||
module "dr_example" {
|
||||
source = "./fabric/modules/backup-dr"
|
||||
project_id = "your-gcp-project-id"
|
||||
location = "us-central1"
|
||||
name = "backup-vault"
|
||||
|
||||
backup_plans = {
|
||||
my-backup-plan = {
|
||||
resource_type = "compute.googleapis.com/Instance"
|
||||
description = "Backup Plan for GCE Instances."
|
||||
backup_rules = [
|
||||
{
|
||||
rule_id = "daily-backup-rule"
|
||||
backup_retention_days = 30
|
||||
standard_schedule = {
|
||||
recurrence_type = "HOURLY"
|
||||
hourly_frequency = 6
|
||||
time_zone = "America/Los_Angeles"
|
||||
backup_window = {
|
||||
start_hour_of_day = 1
|
||||
end_hour_of_day = 5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
rule_id = "monthly-backup-rule"
|
||||
backup_retention_days = 30
|
||||
standard_schedule = {
|
||||
recurrence_type = "MONTHLY"
|
||||
time_zone = "America/Los_Angeles"
|
||||
week_day_of_month = {
|
||||
week_of_month = "FIRST"
|
||||
day_of_week = "MONDAY"
|
||||
}
|
||||
backup_window = {
|
||||
start_hour_of_day = 1
|
||||
end_hour_of_day = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest inventory=vault-plan.yaml
|
||||
```
|
||||
|
||||
### Create only backup plan with existing vault
|
||||
```hcl
|
||||
module "dr_example" {
|
||||
source = "./fabric/modules/backup-dr"
|
||||
project_id = "your-gcp-project-id"
|
||||
location = "us-central1"
|
||||
|
||||
vault_reuse = {
|
||||
vault_id = "backup-vault-test"
|
||||
}
|
||||
|
||||
backup_plans = {
|
||||
"my-backup-plan" = {
|
||||
resource_type = "compute.googleapis.com/Instance"
|
||||
description = "Backup Plan for GCE Instances."
|
||||
backup_rules = [
|
||||
{
|
||||
rule_id = "daily-backup-rule"
|
||||
backup_retention_days = 30
|
||||
standard_schedule = {
|
||||
recurrence_type = "HOURLY"
|
||||
hourly_frequency = 6
|
||||
time_zone = "America/Los_Angeles"
|
||||
backup_window = {
|
||||
start_hour_of_day = 1
|
||||
end_hour_of_day = 5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
rule_id = "monthly-backup-rule"
|
||||
backup_retention_days = 30
|
||||
standard_schedule = {
|
||||
recurrence_type = "MONTHLY"
|
||||
time_zone = "America/Los_Angeles"
|
||||
week_day_of_month = {
|
||||
week_of_month = "FIRST"
|
||||
day_of_week = "MONDAY"
|
||||
}
|
||||
backup_window = {
|
||||
start_hour_of_day = 1
|
||||
end_hour_of_day = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest inventory=reuse.yaml
|
||||
```
|
||||
|
||||
### Create management_server
|
||||
```hcl
|
||||
module "dr_example" {
|
||||
source = "./fabric/modules/backup-dr"
|
||||
project_id = "your-gcp-project-id"
|
||||
location = "us-central1"
|
||||
|
||||
management_server_config = {
|
||||
name = "backup-dr-mgmt-server"
|
||||
location = "us-central1"
|
||||
type = "BACKUP_RESTORE"
|
||||
network_config = {
|
||||
network = "default"
|
||||
peering_mode = "PRIVATE_SERVICE_ACCESS"
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest inventory=server.yaml
|
||||
```
|
||||
|
||||
<!-- BEGIN TFDOC -->
|
||||
## Variables
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [location](variables.tf#L47) | Location for the Backup Vault and Plans (e.g. us-central1). | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L71) | Project ID. | <code>string</code> | ✓ | |
|
||||
| [backup_plans](variables.tf#L17) | Map of Backup Plans to create in this Vault. | <code title="map(object({ resource_type = string description = optional(string) backup_rules = list(object({ rule_id = string backup_retention_days = number standard_schedule = object({ recurrence_type = string hourly_frequency = optional(number) days_of_week = optional(list(string)) days_of_month = optional(list(number)) months = optional(list(string)) week_day_of_month = optional(object({ week_of_month = string day_of_week = string })) time_zone = string backup_window = object({ start_hour_of_day = number end_hour_of_day = number }) }) })) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [management_server_config](variables.tf#L52) | Configuration to create a Management Server. If null, no server is created. | <code title="object({ name = string type = optional(string, "BACKUP_RESTORE") network_config = optional(object({ network = string peering_mode = optional(string, "PRIVATE_SERVICE_ACCESS") })) })">object({…})</code> | | <code>null</code> |
|
||||
| [name](variables.tf#L65) | Name of the Backup Vault to create. Leave null if reusing an existing vault via `vault_reuse`. | <code>string</code> | | <code>null</code> |
|
||||
| [vault_config](variables.tf#L76) | Configuration for the Backup Vault. Only used if `vault_reuse` is null. | <code title="object({ description = optional(string) labels = optional(map(string), {}) annotations = optional(map(string), {}) access_restriction = optional(string) backup_minimum_enforced_retention_duration = optional(string, "100000s") backup_retention_inheritance = optional(string) force_update = optional(bool, false) ignore_inactive_datasources = optional(bool, false) ignore_backup_plan_references = optional(bool, false) allow_missing = optional(bool, false) })">object({…})</code> | | <code>{}</code> |
|
||||
| [vault_reuse](variables.tf#L93) | Configuration to reuse an existing Backup Vault. | <code title="object({ vault_id = string })">object({…})</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
| name | description | sensitive |
|
||||
|---|---|:---:|
|
||||
| [backup_plans](outputs.tf#L16) | The ID of the created Backup Plans. | |
|
||||
| [backup_vault_id](outputs.tf#L21) | The ID of the Backup Vault. | |
|
||||
| [management_server](outputs.tf#L26) | The Management Server created. | |
|
||||
| [management_server_uri](outputs.tf#L31) | The Management Server ID created. | |
|
||||
<!-- END TFDOC -->
|
||||
Reference in New Issue
Block a user