File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
packages/plugins/aws/src/resources Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2021, Nitric Technologies Pty Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
1
14
import { cronToAwsCron } from './schedule' ;
2
15
3
16
describe ( 'Cron Expression Conversion' , ( ) => {
@@ -78,7 +91,7 @@ describe('Cron Expression Conversion', () => {
78
91
describe ( 'When converting the expression' , ( ) => {
79
92
let awsExpValues : string [ ] = [ ] ;
80
93
beforeAll ( ( ) => {
81
- // Expected result = '0/1 * ? * 1 *'
94
+ // Expected result = '0/1 * ? * 2-4 *'
82
95
awsExpValues = cronToAwsCron ( exp ) . split ( ' ' ) ;
83
96
} ) ;
84
97
Original file line number Diff line number Diff line change @@ -137,6 +137,35 @@ export class NitricScheduleEventBridge extends pulumi.ComponentResource {
137
137
} ,
138
138
defaultResourceOptions ,
139
139
) ;
140
+
141
+ const snsTopicSchedulePolicy = topic . sns . arn . apply ( ( arn ) =>
142
+ aws . iam . getPolicyDocument ( {
143
+ // TODO: According to the docs, 'conditions' are not supported for a policy involving EventBridge
144
+ // See: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-use-resource-based.html#eb-sns-permissions
145
+ // "You can't use of Condition blocks in Amazon SNS topic policies for EventBridge."
146
+ // This means any EventBridge rule will be able to publish to this topic.
147
+ policyId : '__default_policy_ID' ,
148
+ statements : [
149
+ {
150
+ sid : '__default_statement_ID' ,
151
+ effect : 'Allow' ,
152
+ actions : [ 'SNS:Publish' ] ,
153
+ principals : [
154
+ {
155
+ type : 'Service' ,
156
+ identifiers : [ 'events.amazonaws.com' ] ,
157
+ } ,
158
+ ] ,
159
+ resources : [ arn ] ,
160
+ } ,
161
+ ] ,
162
+ } ) ,
163
+ ) ;
164
+
165
+ new aws . sns . TopicPolicy ( `${ schedule . name } Target${ topic . name } Policy` , {
166
+ arn : topic . sns . arn ,
167
+ policy : snsTopicSchedulePolicy . apply ( ( snsTopicPolicy ) => snsTopicPolicy . json ) ,
168
+ } ) ;
140
169
}
141
170
142
171
this . registerOutputs ( {
You can’t perform that action at this time.
0 commit comments