diff --git a/modules/storage/aws-backup/README.md b/modules/storage/aws-backup/README.md index 8e501e6..31a2ddb 100644 --- a/modules/storage/aws-backup/README.md +++ b/modules/storage/aws-backup/README.md @@ -35,16 +35,7 @@ No modules. | backup-plan-name | Backup plan name | `string` | n/a | yes | | backup-plan-retention | Backup retention period | `number` | n/a | yes | | backup-rule-cron | Backup rule cron expression | `string` | n/a | yes | -| opt-in-aurora | Opt in audora backup | `bool` | n/a | yes | -| opt-in-dynamodb | Opt in dynamodb backup | `bool` | n/a | yes | -| opt-in-ebs | Opt in ebs backup | `bool` | n/a | yes | -| opt-in-ec2 | Opt in ec2 backup | `bool` | n/a | yes | -| opt-in-efs | Opt in efs backup | `bool` | n/a | yes | -| opt-in-fsx | Opt in fsx backup | `bool` | n/a | yes | -| opt-in-rds | Opt in rds backup | `bool` | n/a | yes | -| opt-in-redshift | Opt in redshift backup | `bool` | n/a | yes | -| opt-in-s3 | Opt in s3 backup | `bool` | n/a | yes | -| opt-in-virtualmachine | Opt in virtualmachine backup | `bool` | n/a | yes | +| service-opt-in | n/a |
map(object({|
enabled = bool
}))
{| no | ## Outputs diff --git a/modules/storage/aws-backup/main.tf b/modules/storage/aws-backup/main.tf index 859064d..51e72c1 100644 --- a/modules/storage/aws-backup/main.tf +++ b/modules/storage/aws-backup/main.tf @@ -3,35 +3,35 @@ locals { backup-config = { "Aurora" : { - enabled = var.opt-in-aurora + enabled = var.service-opt-in.Aurora.enabled arn-prefix = "arn:aws:rds:*:*:cluster:*" } "DynamoDB" : { - enabled = var.opt-in-dynamodb + enabled = var.service-opt-in.DynamoDB.enabled arn-prefix = "arn:aws:dynamodb:*:*:table/*" } "EBS" : { - enabled = var.opt-in-ebs + enabled = var.service-opt-in.EBS.enabled arn-prefix = "arn:aws:ec2:*:*:volume/*" } "EC2" : { - enabled = var.opt-in-ec2 + enabled = var.service-opt-in.EC2.enabled arn-prefix = "arn:aws:ec2:*:*:instance/*" } "EFS" : { - enabled = var.opt-in-efs + enabled = var.service-opt-in.EFS.enabled arn-prefix = "arn:aws:elasticfilesystem:*:*:file-system/*" } "FSx" : { - enabled = var.opt-in-fsx + enabled = var.service-opt-in.FSx.enabled arn-prefix = "arn:*:fsx:*" } "Redshift" : { - enabled = var.opt-in-redshift + enabled = var.service-opt-in.Redshift.enabled arn-prefix = "arn:aws:redshift:*:*:cluster:*" } "RDS" : { - enabled = var.opt-in-rds + enabled = var.service-opt-in.RDS.enabled arn-prefix = "arn:aws:rds:*:*:db:*" } # this version can't handle space @@ -40,11 +40,11 @@ locals { # arn-prefix = "arn:aws:storagegateway:*:*:gateway/*" # } "VirtualMachine" : { - enabled = var.opt-in-virtualmachine + enabled = var.service-opt-in.VirtualMachine.enabled arn-prefix = "arn:aws:backup-gateway:*:*:vm/*" } "S3" : { - enabled = var.opt-in-s3 + enabled = var.service-opt-in.S3.enabled arn-prefix = "arn:aws:s3:::*" } } diff --git a/modules/storage/aws-backup/variables.tf b/modules/storage/aws-backup/variables.tf index bccd003..cc568cf 100644 --- a/modules/storage/aws-backup/variables.tf +++ b/modules/storage/aws-backup/variables.tf @@ -13,58 +13,40 @@ variable "backup-plan-retention" { description = "Backup retention period" } -variable "opt-in-aurora" { - type = bool - description = "Opt in audora backup" -} - -variable "opt-in-s3" { - type = bool - description = "Opt in s3 backup" -} - -variable "opt-in-dynamodb" { - type = bool - description = "Opt in dynamodb backup" -} - -variable "opt-in-ebs" { - type = bool - description = "Opt in ebs backup" -} - -variable "opt-in-ec2" { - type = bool - description = "Opt in ec2 backup" -} - -variable "opt-in-efs" { - type = bool - description = "Opt in efs backup" -} - -variable "opt-in-fsx" { - type = bool - description = "Opt in fsx backup" -} - -variable "opt-in-rds" { - type = bool - description = "Opt in rds backup" -} - -# not supported in this version -# variable "opt-in-storagegateway" { -# type = bool -# description = "Opt in storage gateway backup" -# } - -variable "opt-in-virtualmachine" { - type = bool - description = "Opt in virtualmachine backup" -} - -variable "opt-in-redshift" { - type = bool - description = "Opt in redshift backup" +variable "service-opt-in" { + type = map(object({ + enabled = bool + })) + default = { + "Aurora" : { + enabled = false + } + "DynamoDB" : { + enabled = true + } + "EBS" : { + enabled = false + } + "EC2" : { + enabled = true + } + "EFS" : { + enabled = true + } + "FSx" : { + enabled = false + } + "Redshift" : { + enabled = true + } + "RDS" : { + enabled = true + } + "VirtualMachine" : { + enabled = false + } + "S3" : { + enabled = false + } + } } \ No newline at end of file
"Aurora": {
"enabled": false
},
"DynamoDB": {
"enabled": true
},
"EBS": {
"enabled": false
},
"EC2": {
"enabled": true
},
"EFS": {
"enabled": true
},
"FSx": {
"enabled": false
},
"RDS": {
"enabled": true
},
"Redshift": {
"enabled": true
},
"S3": {
"enabled": false
},
"VirtualMachine": {
"enabled": false
}
}