Skip to content

Commit

Permalink
fix(DMVP-5908): update sns module version
Browse files Browse the repository at this point in the history
  • Loading branch information
SarhadMeta committed Dec 16, 2024
1 parent 6e7e301 commit 91cb865
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module "backup" {

| Name | Source | Version |
|------|--------|---------|
| <a name="module_sns_topic"></a> [sns\_topic](#module\_sns\_topic) | terraform-aws-modules/sns/aws | ~> 6.0 |
| <a name="module_sns_topic"></a> [sns\_topic](#module\_sns\_topic) | terraform-aws-modules/sns/aws | 6.1.1 |

## Resources

Expand Down Expand Up @@ -78,7 +78,7 @@ module "backup" {
| <a name="input_backup_retention_days"></a> [backup\_retention\_days](#input\_backup\_retention\_days) | Number of days recovery points should be kept. | `number` | `7` | no |
| <a name="input_enable_sns_notifications"></a> [enable\_sns\_notifications](#input\_enable\_sns\_notifications) | Create an SNS topic where backup notifications go | `bool` | `true` | no |
| <a name="input_env"></a> [env](#input\_env) | Envrionment for the plan | `string` | `"prod"` | no |
| <a name="input_kms_key_alias"></a> [kms\_key\_alias](#input\_kms\_key\_alias) | kms key alias | `string` | `""` | no |
| <a name="input_kms_key_alias"></a> [kms\_key\_alias](#input\_kms\_key\_alias) | kms key alias | `string` | `null` | no |
| <a name="input_plan_selection_tag"></a> [plan\_selection\_tag](#input\_plan\_selection\_tag) | Resource selection for the plan | `list(map(string))` | <pre>[<br/> {<br/> "key": "Environment",<br/> "value": "Production"<br/> }<br/>]</pre> | no |
| <a name="input_region"></a> [region](#input\_region) | The region where resources should be managed. | `string` | `"eu-central-1"` | no |
| <a name="input_rules"></a> [rules](#input\_rules) | List of rules to attach to the plan | `list(any)` | <pre>[<br/> {<br/> "continuous_backup": true,<br/> "name": "daily",<br/> "schedule": "cron(0 12 * * ? *)",<br/> "vault": "Backup"<br/> }<br/>]</pre> | no |
Expand Down
8 changes: 7 additions & 1 deletion monitoring.tf
Original file line number Diff line number Diff line change
@@ -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:*"]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -79,20 +81,23 @@ 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
policy = data.aws_iam_policy_document.kms.json
}

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}"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 91cb865

Please sign in to comment.