UPD: refactored service opt in variables

This commit is contained in:
xpk 2024-04-30 09:58:58 +08:00
parent fb75064a58
commit 52b35ca6bc
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
3 changed files with 47 additions and 74 deletions

View File

@ -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 | <pre>map(object({<br> enabled = bool<br> }))</pre> | <pre>{<br> "Aurora": {<br> "enabled": false<br> },<br> "DynamoDB": {<br> "enabled": true<br> },<br> "EBS": {<br> "enabled": false<br> },<br> "EC2": {<br> "enabled": true<br> },<br> "EFS": {<br> "enabled": true<br> },<br> "FSx": {<br> "enabled": false<br> },<br> "RDS": {<br> "enabled": true<br> },<br> "Redshift": {<br> "enabled": true<br> },<br> "S3": {<br> "enabled": false<br> },<br> "VirtualMachine": {<br> "enabled": false<br> }<br>}</pre> | no |
## Outputs

View File

@ -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:::*"
}
}

View File

@ -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
}
}
}