1
0

enhance: updated module with suggestions from Qoder

This commit is contained in:
xpk
2026-04-11 00:13:55 +08:00
parent 355850fee9
commit 88396bceda
5 changed files with 83 additions and 9 deletions
+41 -5
View File
@@ -1,4 +1,36 @@
<!-- This readme file is generated with terraform-docs --> <!-- This readme file is generated with terraform-docs -->
## Example
```hcl
module "aws-backup" {
source = "../"
backup_kms_key = "arn..."
daily-backup-cron = "cron(0 20 * * ? *)"
daily-backup-retention = 30
monthly-backup-cron = ""
monthly-backup-retention = 360
service-opt-in = {
"Aurora" : false,
"DynamoDB" : false,
"EBS" : false,
"EC2" : true,
"EFS" : true,
"FSx" : false,
"Redshift" : false,
"RDS" : true,
"VirtualMachine" : false,
"S3" : true,
"EKS" : false,
"CloudFormation" : false,
"Neptune" : false,
"Redshift Serverless" : false,
"SAP HANA on Amazon EC2" : false,
"Storage Gateway" : false
}
}
```
# aws-backup # aws-backup
Module to configure AWSBackup service opt in and manage backup settings for typical workloads Module to configure AWSBackup service opt in and manage backup settings for typical workloads
@@ -10,7 +42,7 @@ No requirements.
## Providers ## Providers
| Name | Version | | Name | Version |
|------|---------| | ---- | ------- |
| aws | n/a | | aws | n/a |
## Modules ## Modules
@@ -20,7 +52,7 @@ No modules.
## Resources ## Resources
| Name | Type | | Name | Type |
|------|------| | ---- | ---- |
| [aws_backup_plan.ab-plan](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan) | resource | | [aws_backup_plan.ab-plan](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan) | resource |
| [aws_backup_region_settings.ab-settings](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_region_settings) | resource | | [aws_backup_region_settings.ab-settings](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_region_settings) | resource |
| [aws_backup_selection.ab-selection-by-service-type](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_selection) | resource | | [aws_backup_selection.ab-selection-by-service-type](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_selection) | resource |
@@ -33,7 +65,7 @@ No modules.
## Inputs ## Inputs
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:| | ---- | ----------- | ---- | ------- | :------: |
| backup\_kms\_key | KMS key arn for AWS Backup | `string` | `null` | no | | backup\_kms\_key | KMS key arn for AWS Backup | `string` | `null` | no |
| daily-backup-cron | Daily backup rule cron expression | `string` | n/a | yes | | daily-backup-cron | Daily backup rule cron expression | `string` | n/a | yes |
| daily-backup-retention | Daily backup retention period | `number` | n/a | yes | | daily-backup-retention | Daily backup retention period | `number` | n/a | yes |
@@ -41,11 +73,15 @@ No modules.
| enable-vss | Enable VSS for Windows Ec2 | `bool` | `false` | no | | enable-vss | Enable VSS for Windows Ec2 | `bool` | `false` | no |
| monthly-backup-cron | Monthly backup rule cron expression | `string` | `null` | no | | monthly-backup-cron | Monthly backup rule cron expression | `string` | `null` | no |
| monthly-backup-retention | Monthly backup retention period | `number` | `null` | no | | monthly-backup-retention | Monthly backup retention period | `number` | `null` | no |
| service-opt-in | If not specified, EC2, RDS, EFS, and S3 are enabled | `map(string)` | <pre>{<br/> "Aurora": false,<br/> "CloudFormation": false,<br/> "DynamoDB": false,<br/> "EBS": false,<br/> "EC2": true,<br/> "EFS": true,<br/> "EKS": false,<br/> "FSx": false,<br/> "Neptune": false,<br/> "RDS": true,<br/> "Redshift": false,<br/> "Redshift Serverless": false,<br/> "S3": true,<br/> "SAP HANA on Amazon EC2": false,<br/> "Storage Gateway": false,<br/> "VirtualMachine": false<br/>}</pre> | no | | service-opt-in | If not specified, EC2, RDS, EFS, and S3 are enabled | `map(bool)` | <pre>{<br/> "Aurora": false,<br/> "CloudFormation": false,<br/> "DynamoDB": false,<br/> "EBS": false,<br/> "EC2": true,<br/> "EFS": true,<br/> "EKS": false,<br/> "FSx": false,<br/> "Neptune": false,<br/> "RDS": true,<br/> "Redshift": false,<br/> "Redshift Serverless": false,<br/> "S3": true,<br/> "SAP HANA on Amazon EC2": false,<br/> "Storage Gateway": false,<br/> "VirtualMachine": false<br/>}</pre> | no |
## Outputs ## Outputs
No outputs. | Name | Description |
| ---- | ----------- |
| backup\_iam\_role\_arn | n/a |
| backup\_plan\_ids | n/a |
| backup\_vault\_arns | n/a |
--- ---
## Authorship ## Authorship
@@ -0,0 +1,27 @@
module "aws-backup" {
source = "../"
backup_kms_key = "arn..."
daily-backup-cron = "cron(0 20 * * ? *)"
daily-backup-retention = 30
monthly-backup-cron = ""
monthly-backup-retention = 360
service-opt-in = {
"Aurora" : false,
"DynamoDB" : false,
"EBS" : false,
"EC2" : true,
"EFS" : true,
"FSx" : false,
"Redshift" : false,
"RDS" : true,
"VirtualMachine" : false,
"S3" : true,
"EKS" : false,
"CloudFormation" : false,
"Neptune" : false,
"Redshift Serverless" : false,
"SAP HANA on Amazon EC2" : false,
"Storage Gateway" : false
}
}
+4 -3
View File
@@ -58,18 +58,19 @@ locals {
} }
"CloudFormation" : { "CloudFormation" : {
enabled = var.service-opt-in["CloudFormation"].enabled enabled = var.service-opt-in["CloudFormation"].enabled
arn-prefix = "arn:aws:cloudformation:*:*:stack/*/*"
} }
"Neptune" : { "Neptune" : {
enabled = var.service-opt-in["Neptune"].enabled enabled = var.service-opt-in["Neptune"].enabled
arn-prefix = "arn:aws:neptune-db:*:*:cluster:*"
} }
"Redshift Serverless" : { "Redshift Serverless" : {
enabled = var.service-opt-in["Redshift Serverless"].enabled enabled = var.service-opt-in["Redshift Serverless"].enabled
arn-prefix = "arn:aws:redshift-serverless:*:*:workgroup/*"
} }
"SAP HANA on Amazon EC2" : { "SAP HANA on Amazon EC2" : {
enabled = var.service-opt-in["SAP HANA on Amazon EC2"].enabled enabled = var.service-opt-in["SAP HANA on Amazon EC2"].enabled
} arn-prefix = "arn:aws:sap:*:*:application/*/*"
"Storage Gateway" : {
enabled = var.service-opt-in["Storage Gateway"].enabled
} }
} }
} }
+10
View File
@@ -0,0 +1,10 @@
output "backup_vault_arns" {
value = { for k, v in aws_backup_vault.ab-vault : k => v.arn }
}
output "backup_plan_ids" {
value = { for k, v in aws_backup_plan.ab-plan : k => v.id }
}
output "backup_iam_role_arn" {
value = aws_iam_role.ab-iam-role.arn
}
+1 -1
View File
@@ -27,7 +27,7 @@ variable "monthly-backup-retention" {
} }
variable "service-opt-in" { variable "service-opt-in" {
type = map(string) type = map(bool)
description = "If not specified, EC2, RDS, EFS, and S3 are enabled" description = "If not specified, EC2, RDS, EFS, and S3 are enabled"
default = { default = {
"Aurora" : false, "Aurora" : false,