File tree Expand file tree Collapse file tree 2 files changed +83
-0
lines changed
infrastructure/terraform/modules/eventsub Expand file tree Collapse file tree 2 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ resource "aws_sns_topic" "main" {
2+ name = " my-topic-with-policy"
3+ }
4+
5+ resource "aws_sns_topic_policy" "main" {
6+ arn = aws_sns_topic. main . arn
7+
8+ policy = data. aws_iam_policy_document . sns_topic_policy . json
9+ }
10+
11+ data "aws_iam_policy_document" "sns_topic_policy" {
12+ policy_id = " __default_policy_ID"
13+
14+ statement {
15+ actions = [
16+ " SNS:Subscribe" ,
17+ " SNS:SetTopicAttributes" ,
18+ " SNS:RemovePermission" ,
19+ " SNS:Receive" ,
20+ " SNS:Publish" ,
21+ " SNS:ListSubscriptionsByTopic" ,
22+ " SNS:GetTopicAttributes" ,
23+ " SNS:DeleteTopic" ,
24+ " SNS:AddPermission" ,
25+ ]
26+
27+ condition {
28+ test = " StringEquals"
29+ variable = " AWS:SourceOwner"
30+
31+ values = [
32+ var . aws_account_id ,
33+ ]
34+ }
35+
36+ effect = " Allow"
37+
38+ principals {
39+ type = " AWS"
40+ identifiers = [" *" ]
41+ }
42+
43+ resources = [
44+ aws_sns_topic . test . arn ,
45+ ]
46+
47+ sid = " AllowAllSNSActionsFromAccount"
48+ }
49+
50+ statement {
51+ actions = [
52+ " SNS:Publish" ,
53+ ]
54+
55+ condition {
56+ test = " ArnLike"
57+ variable = " AWS:SourceArn"
58+
59+ values = [
60+ " arn:aws:sns:${ var . region } :${ var . shared_infra_account_id } :nhs-*-core-to-supplier-events" ,
61+ ]
62+ }
63+
64+ effect = " Allow"
65+
66+ principals {
67+ type = " AWS"
68+ identifiers = [" *" ]
69+ }
70+
71+ resources = [
72+ aws_sns_topic . test . arn ,
73+ ]
74+
75+ sid = " AllowAllSNSActionsFromSharedAccount"
76+ }
77+ }
Original file line number Diff line number Diff line change @@ -108,3 +108,9 @@ variable "force_destroy" {
108108 description = " When enabled will force destroy event-cache S3 bucket"
109109 default = false
110110}
111+
112+ variable "shared_infra_account_id" {
113+ type = string
114+ description = " The AWS Account ID of the shared infrastructure account"
115+ default = " 000000000000"
116+ }
You can’t perform that action at this time.
0 commit comments