@@ -14,16 +14,20 @@ export class PolicyStatement {
14
14
public effect : Effect ;
15
15
16
16
private action = new Array < any > ( ) ;
17
+ private notaction = new Array < any > ( ) ;
17
18
private principal : { [ key : string ] : any [ ] } = { } ;
18
19
private resource = new Array < any > ( ) ;
20
+ private notresource = new Array < any > ( ) ;
19
21
private condition : { [ key : string ] : any } = { } ;
20
22
21
23
constructor ( props : PolicyStatementProps = { } ) {
22
24
this . effect = props . effect || Effect . ALLOW ;
23
25
24
26
this . addActions ( ...props . actions || [ ] ) ;
27
+ this . addNotActions ( ...props . notactions || [ ] ) ;
25
28
this . addPrincipals ( ...props . principals || [ ] ) ;
26
29
this . addResources ( ...props . resources || [ ] ) ;
30
+ this . addNotResources ( ...props . notresources || [ ] ) ;
27
31
if ( props . conditions !== undefined ) {
28
32
this . addConditions ( props . conditions ) ;
29
33
}
@@ -37,6 +41,10 @@ export class PolicyStatement {
37
41
this . action . push ( ...actions ) ;
38
42
}
39
43
44
+ public addNotActions ( ...notactions : string [ ] ) {
45
+ this . notaction . push ( ...notactions ) ;
46
+ }
47
+
40
48
//
41
49
// Principal
42
50
//
@@ -98,6 +106,10 @@ export class PolicyStatement {
98
106
this . resource . push ( ...arns ) ;
99
107
}
100
108
109
+ public addNotResources ( ...arns : string [ ] ) {
110
+ this . notresource . push ( ...arns ) ;
111
+ }
112
+
101
113
/**
102
114
* Adds a ``"*"`` resource to this statement.
103
115
*/
@@ -142,10 +154,12 @@ export class PolicyStatement {
142
154
public toStatementJson ( ) : any {
143
155
return noUndef ( {
144
156
Action : _norm ( this . action ) ,
157
+ NotAction : _norm ( this . notaction ) ,
145
158
Condition : _norm ( this . condition ) ,
146
159
Effect : _norm ( this . effect ) ,
147
160
Principal : _normPrincipal ( this . principal ) ,
148
161
Resource : _norm ( this . resource ) ,
162
+ NotResource : _norm ( this . notresource ) ,
149
163
Sid : _norm ( this . sid ) ,
150
164
} ) ;
151
165
@@ -229,6 +243,13 @@ export interface PolicyStatementProps {
229
243
*/
230
244
readonly actions ?: string [ ] ;
231
245
246
+ /**
247
+ * List of not actions to add to the statement
248
+ *
249
+ * @default - no actions
250
+ */
251
+ readonly notactions ?: string [ ] ;
252
+
232
253
/**
233
254
* List of principals to add to the statement
234
255
*
@@ -239,10 +260,17 @@ export interface PolicyStatementProps {
239
260
/**
240
261
* Resource ARNs to add to the statement
241
262
*
242
- * @default - no principals
263
+ * @default - no resources
243
264
*/
244
265
readonly resources ?: string [ ] ;
245
266
267
+ /**
268
+ * NotResource ARNs to add to the statement
269
+ *
270
+ * @default - no resources
271
+ */
272
+ readonly notresources ?: string [ ] ;
273
+
246
274
/**
247
275
* Conditions to add to the statement
248
276
*
0 commit comments