Skip to content

Commit

Permalink
fix(DMVP-5761): Update SNS module for support Budget policy
Browse files Browse the repository at this point in the history
  • Loading branch information
aramkarapetian committed Nov 11, 2024
1 parent 0247729 commit 265f3a3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 12 deletions.
1 change: 1 addition & 0 deletions modules/topic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource "aws_sns_topic" "this" {

name = var.name
delivery_policy = jsonencode(var.delivery_policy)
policy = jsonencode(var.policy)
}

data "aws_sns_topic" "this" {
Expand Down
4 changes: 0 additions & 4 deletions modules/topic/tests/topic-with-no-subscriptions/0-setup.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
terraform {
required_providers {
test = {
source = "terraform.io/builtin/test"
}

aws = {
source = "hashicorp/aws"
version = "~> 4.33"
Expand Down
39 changes: 39 additions & 0 deletions modules/topic/tests/topic-with-no-subscriptions/1-example.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
module "this" {
source = "../../"
name = "test-topic"

policy = {
"Version" : "2008-10-17",
"Id" : "__default_policy_ID",
"Statement" : [
{
"Sid" : "__default_statement_ID",
"Effect" : "Allow",
"Principal" : {
"AWS" : "*"
},
"Action" : [
"SNS:GetTopicAttributes",
"SNS:SetTopicAttributes",
"SNS:AddPermission",
"SNS:RemovePermission",
"SNS:DeleteTopic",
"SNS:Subscribe",
"SNS:ListSubscriptionsByTopic",
"SNS:Publish"
],
"Resource" : "arn:aws:sns:us-east-1:xxxxxxx:account-alarms-handling-virginia",
"Condition" : {
"StringEquals" : {
"AWS:SourceOwner" : "xxxxxx"
}
}
},
{
"Sid" : "AWSBudgets-notification-1",
"Effect" : "Allow",
"Principal" : {
"Service" : "budgets.amazonaws.com"
},
"Action" : "SNS:Publish",
"Resource" : "*"
}
]
}
}
16 changes: 8 additions & 8 deletions modules/topic/tests/topic-with-no-subscriptions/2-assert.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "test_assertions" "dummy" {
component = "sns-modules-topic"
# resource "test_assertions" "dummy" {
# component = "sns-modules-topic"

equal "scheme" {
description = "As module does not have any output and data just make sure the case runs. Probably can be thrown away."
got = "all good"
want = "all good"
}
}
# equal "scheme" {
# description = "As module does not have any output and data just make sure the case runs. Probably can be thrown away."
# got = "all good"
# want = "all good"
# }
# }
6 changes: 6 additions & 0 deletions modules/topic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ variable "delivery_policy" {
}
}
}

variable "policy" {
type = any
description = "The SNS Access policy"
default = null
}

0 comments on commit 265f3a3

Please sign in to comment.