File tree Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ export interface CommonTaskDefinitionProps {
23
23
*
24
24
* @default An execution role will be automatically created if you use ECR images in your task definition
25
25
*/
26
- executionRole ?: iam . Role ;
26
+ executionRole ?: iam . IRole ;
27
27
28
28
/**
29
29
* The IAM role assumable by your application code running inside the container
30
30
*
31
31
* @default A task role is automatically created for you
32
32
*/
33
- taskRole ?: iam . Role ;
33
+ taskRole ?: iam . IRole ;
34
34
35
35
/**
36
36
* See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide//task_definition_parameters.html#volumes
@@ -112,7 +112,7 @@ export class TaskDefinition extends cdk.Construct {
112
112
/**
113
113
* Task role used by this task definition
114
114
*/
115
- public readonly taskRole : iam . Role ;
115
+ public readonly taskRole : iam . IRole ;
116
116
117
117
/**
118
118
* Network mode used by this task definition
Original file line number Diff line number Diff line change 1
1
import cdk = require( '@aws-cdk/cdk' ) ;
2
- import { Policy } from './policy' ;
2
+ import { IPrincipal , Policy } from './policy' ;
3
3
import { PolicyPrincipal , PolicyStatement } from './policy-document' ;
4
4
import { IRole , Role , RoleImportProps , RoleProps } from './role' ;
5
5
@@ -85,6 +85,20 @@ export class LazyRole extends cdk.Construct implements IRole {
85
85
return this . instantiate ( ) . principal ;
86
86
}
87
87
88
+ /**
89
+ * Grant the actions defined in actions to the identity Principal on this resource.
90
+ */
91
+ public grant ( identity ?: IPrincipal , ...actions : string [ ] ) : void {
92
+ return this . instantiate ( ) . grant ( identity , ...actions ) ;
93
+ }
94
+
95
+ /**
96
+ * Grant permissions to the given principal to pass this role.
97
+ */
98
+ public grantPassRole ( identity ?: IPrincipal ) : void {
99
+ return this . instantiate ( ) . grantPassRole ( identity ) ;
100
+ }
101
+
88
102
private instantiate ( ) : Role {
89
103
if ( ! this . role ) {
90
104
const role = new Role ( this , 'Default' , this . props ) ;
@@ -95,4 +109,4 @@ export class LazyRole extends cdk.Construct implements IRole {
95
109
}
96
110
return this . role ;
97
111
}
98
- }
112
+ }
Original file line number Diff line number Diff line change @@ -245,6 +245,16 @@ export interface IRole extends IConstruct, IPrincipal {
245
245
* Export this role to another stack.
246
246
*/
247
247
export ( ) : RoleImportProps ;
248
+
249
+ /**
250
+ * Grant the actions defined in actions to the identity Principal on this resource.
251
+ */
252
+ grant ( identity ?: IPrincipal , ...actions : string [ ] ) : void ;
253
+
254
+ /**
255
+ * Grant permissions to the given principal to pass this role.
256
+ */
257
+ grantPassRole ( identity ?: IPrincipal ) : void ;
248
258
}
249
259
250
260
function createAssumeRolePolicy ( principal : PolicyPrincipal , externalId ?: string ) {
@@ -331,4 +341,18 @@ class ImportedRole extends Construct implements IRole {
331
341
public attachManagedPolicy ( _arn : string ) : void {
332
342
// FIXME: Add warning that we're ignoring this
333
343
}
344
+
345
+ /**
346
+ * Grant the actions defined in actions to the identity Principal on this resource.
347
+ */
348
+ public grant ( _identity ?: IPrincipal , ..._actions : string [ ] ) : void {
349
+ // FIXME: Add warning that we're ignoring this
350
+ }
351
+
352
+ /**
353
+ * Grant permissions to the given principal to pass this role.
354
+ */
355
+ public grantPassRole ( _identity ?: IPrincipal ) : void {
356
+ // FIXME: Add warning that we're ignoring this
357
+ }
334
358
}
You can’t perform that action at this time.
0 commit comments