From 91cb865bdb8dbfed43fa57be3fe94285596bc332 Mon Sep 17 00:00:00 2001 From: Sarhad Date: Mon, 16 Dec 2024 14:16:59 +0400 Subject: [PATCH] fix(DMVP-5908): update sns module version --- README.md | 4 ++-- monitoring.tf | 8 +++++++- variables.tf | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 12e9496..82e7594 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ module "backup" { | Name | Source | Version | |------|--------|---------| -| [sns\_topic](#module\_sns\_topic) | terraform-aws-modules/sns/aws | ~> 6.0 | +| [sns\_topic](#module\_sns\_topic) | terraform-aws-modules/sns/aws | 6.1.1 | ## Resources @@ -78,7 +78,7 @@ module "backup" { | [backup\_retention\_days](#input\_backup\_retention\_days) | Number of days recovery points should be kept. | `number` | `7` | no | | [enable\_sns\_notifications](#input\_enable\_sns\_notifications) | Create an SNS topic where backup notifications go | `bool` | `true` | no | | [env](#input\_env) | Envrionment for the plan | `string` | `"prod"` | no | -| [kms\_key\_alias](#input\_kms\_key\_alias) | kms key alias | `string` | `""` | no | +| [kms\_key\_alias](#input\_kms\_key\_alias) | kms key alias | `string` | `null` | no | | [plan\_selection\_tag](#input\_plan\_selection\_tag) | Resource selection for the plan | `list(map(string))` |
[
{
"key": "Environment",
"value": "Production"
}
]
| no | | [region](#input\_region) | The region where resources should be managed. | `string` | `"eu-central-1"` | no | | [rules](#input\_rules) | List of rules to attach to the plan | `list(any)` |
[
{
"continuous_backup": true,
"name": "daily",
"schedule": "cron(0 12 * * ? *)",
"vault": "Backup"
}
]
| no | diff --git a/monitoring.tf b/monitoring.tf index 318c4db..f7f40ac 100644 --- a/monitoring.tf +++ b/monitoring.tf @@ -1,4 +1,5 @@ data "aws_iam_policy_document" "kms" { + count = var.alarm_lambda_arn != "" ? 1 : 0 statement { sid = "Enable IAM User Permissions" actions = ["kms:*"] @@ -48,6 +49,7 @@ data "aws_iam_policy_document" "kms" { } data "aws_iam_policy_document" "backup_notifications" { + count = var.alarm_lambda_arn != "" ? 1 : 0 policy_id = "aws_backup_${var.env}" statement { @@ -79,6 +81,7 @@ resource "aws_lambda_permission" "with_sns" { } resource "aws_kms_key" "this" { + count = var.alarm_lambda_arn != "" ? 1 : 0 description = "KMS key is used to encrypt this sns topic" deletion_window_in_days = 7 enable_key_rotation = true @@ -86,13 +89,15 @@ resource "aws_kms_key" "this" { } resource "aws_kms_alias" "backup_sns" { + count = var.enable_sns_notifications ? 1 : 0 name = "alias/aws_backup-sns-${var.env}" target_key_id = aws_kms_key.this.arn } module "sns_topic" { + count = var.enable_sns_notifications ? 1 : 0 source = "terraform-aws-modules/sns/aws" - version = "~> 6.0" + version = "6.1.1" name = "backups_${var.env}" @@ -110,6 +115,7 @@ resource "aws_sns_topic_subscription" "lambda" { } resource "aws_sns_topic_subscription" "email" { + count = var.alarm_lambda_arn != "" ? 1 : 0 for_each = length(var.alarm_email_addresses) > 0 ? toset(var.alarm_email_addresses) : toset([]) topic_arn = module.sns_topic.sns_topic_arn protocol = "email" diff --git a/variables.tf b/variables.tf index 145955c..e7dcbf4 100644 --- a/variables.tf +++ b/variables.tf @@ -48,7 +48,7 @@ variable "backup_plan_name" { variable "kms_key_alias" { description = "kms key alias" type = string - default = "" + default = null } variable "plan_selection_tag" {