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-name | Backup plan name | `string` | n/a | yes |
| backup-plan-retention | Backup retention period | `number` | n/a | yes | | backup-plan-retention | Backup retention period | `number` | n/a | yes |
| backup-rule-cron | Backup rule cron expression | `string` | 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 | | 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 |
| 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 |
## Outputs ## Outputs

View File

@ -3,35 +3,35 @@
locals { locals {
backup-config = { backup-config = {
"Aurora" : { "Aurora" : {
enabled = var.opt-in-aurora enabled = var.service-opt-in.Aurora.enabled
arn-prefix = "arn:aws:rds:*:*:cluster:*" arn-prefix = "arn:aws:rds:*:*:cluster:*"
} }
"DynamoDB" : { "DynamoDB" : {
enabled = var.opt-in-dynamodb enabled = var.service-opt-in.DynamoDB.enabled
arn-prefix = "arn:aws:dynamodb:*:*:table/*" arn-prefix = "arn:aws:dynamodb:*:*:table/*"
} }
"EBS" : { "EBS" : {
enabled = var.opt-in-ebs enabled = var.service-opt-in.EBS.enabled
arn-prefix = "arn:aws:ec2:*:*:volume/*" arn-prefix = "arn:aws:ec2:*:*:volume/*"
} }
"EC2" : { "EC2" : {
enabled = var.opt-in-ec2 enabled = var.service-opt-in.EC2.enabled
arn-prefix = "arn:aws:ec2:*:*:instance/*" arn-prefix = "arn:aws:ec2:*:*:instance/*"
} }
"EFS" : { "EFS" : {
enabled = var.opt-in-efs enabled = var.service-opt-in.EFS.enabled
arn-prefix = "arn:aws:elasticfilesystem:*:*:file-system/*" arn-prefix = "arn:aws:elasticfilesystem:*:*:file-system/*"
} }
"FSx" : { "FSx" : {
enabled = var.opt-in-fsx enabled = var.service-opt-in.FSx.enabled
arn-prefix = "arn:*:fsx:*" arn-prefix = "arn:*:fsx:*"
} }
"Redshift" : { "Redshift" : {
enabled = var.opt-in-redshift enabled = var.service-opt-in.Redshift.enabled
arn-prefix = "arn:aws:redshift:*:*:cluster:*" arn-prefix = "arn:aws:redshift:*:*:cluster:*"
} }
"RDS" : { "RDS" : {
enabled = var.opt-in-rds enabled = var.service-opt-in.RDS.enabled
arn-prefix = "arn:aws:rds:*:*:db:*" arn-prefix = "arn:aws:rds:*:*:db:*"
} }
# this version can't handle space # this version can't handle space
@ -40,11 +40,11 @@ locals {
# arn-prefix = "arn:aws:storagegateway:*:*:gateway/*" # arn-prefix = "arn:aws:storagegateway:*:*:gateway/*"
# } # }
"VirtualMachine" : { "VirtualMachine" : {
enabled = var.opt-in-virtualmachine enabled = var.service-opt-in.VirtualMachine.enabled
arn-prefix = "arn:aws:backup-gateway:*:*:vm/*" arn-prefix = "arn:aws:backup-gateway:*:*:vm/*"
} }
"S3" : { "S3" : {
enabled = var.opt-in-s3 enabled = var.service-opt-in.S3.enabled
arn-prefix = "arn:aws:s3:::*" arn-prefix = "arn:aws:s3:::*"
} }
} }

View File

@ -13,58 +13,40 @@ variable "backup-plan-retention" {
description = "Backup retention period" description = "Backup retention period"
} }
variable "opt-in-aurora" { variable "service-opt-in" {
type = bool type = map(object({
description = "Opt in audora backup" enabled = bool
} }))
default = {
variable "opt-in-s3" { "Aurora" : {
type = bool enabled = false
description = "Opt in s3 backup" }
} "DynamoDB" : {
enabled = true
variable "opt-in-dynamodb" { }
type = bool "EBS" : {
description = "Opt in dynamodb backup" enabled = false
} }
"EC2" : {
variable "opt-in-ebs" { enabled = true
type = bool }
description = "Opt in ebs backup" "EFS" : {
} enabled = true
}
variable "opt-in-ec2" { "FSx" : {
type = bool enabled = false
description = "Opt in ec2 backup" }
} "Redshift" : {
enabled = true
variable "opt-in-efs" { }
type = bool "RDS" : {
description = "Opt in efs backup" enabled = true
} }
"VirtualMachine" : {
variable "opt-in-fsx" { enabled = false
type = bool }
description = "Opt in fsx backup" "S3" : {
} enabled = false
}
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"
} }