Skip to content

Commit b909dcd

Browse files
author
Elad Ben-Israel
authored
fix(lambda): use IRole instead of Role to allow imports (#1509)
In order to allow passing in an imported role to a Lambda/Alias, we must use `IRole` instead of `Role`.
1 parent d7371f0 commit b909dcd

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

packages/@aws-cdk/aws-lambda/lib/alias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class Alias extends FunctionBase {
7171
/**
7272
* Role associated with this alias
7373
*/
74-
public readonly role?: iam.Role | undefined;
74+
public readonly role?: iam.IRole | undefined;
7575

7676
protected readonly canCreatePermissions: boolean = true; // Not used anyway
7777

packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface IFunction extends cdk.IConstruct, events.IEventRuleTarget, logs
3333
/**
3434
* The IAM role associated with this function.
3535
*/
36-
readonly role?: iam.Role;
36+
readonly role?: iam.IRole;
3737

3838
/**
3939
* Whether or not this Lambda function was bound to a VPC
@@ -123,7 +123,7 @@ export interface FunctionImportProps {
123123
*
124124
* If the role is not specified, any role-related operations will no-op.
125125
*/
126-
role?: iam.Role;
126+
role?: iam.IRole;
127127

128128
/**
129129
* Id of the securityGroup for this Lambda, if in a VPC.
@@ -149,7 +149,7 @@ export abstract class FunctionBase extends cdk.Construct implements IFunction {
149149
/**
150150
* The IAM role associated with this function.
151151
*/
152-
public abstract readonly role?: iam.Role;
152+
public abstract readonly role?: iam.IRole;
153153

154154
/**
155155
* Whether the addPermission() call adds any permissions

packages/@aws-cdk/aws-lambda/lib/lambda.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export interface FunctionProps {
111111
* @default a unique role will be generated for this lambda function.
112112
* Both supplied and generated roles can always be changed by calling `addToRolePolicy`.
113113
*/
114-
role?: iam.Role;
114+
role?: iam.IRole;
115115

116116
/**
117117
* VPC network to place Lambda network interfaces
@@ -284,7 +284,7 @@ export class Function extends FunctionBase {
284284
/**
285285
* Execution role associated with this function
286286
*/
287-
public readonly role?: iam.Role;
287+
public readonly role?: iam.IRole;
288288

289289
/**
290290
* The runtime configured for this lambda.
@@ -493,7 +493,7 @@ export class Function extends FunctionBase {
493493
export class ImportedFunction extends FunctionBase {
494494
public readonly functionName: string;
495495
public readonly functionArn: string;
496-
public readonly role?: iam.Role;
496+
public readonly role?: iam.IRole;
497497

498498
protected readonly canCreatePermissions = false;
499499

packages/@aws-cdk/aws-lambda/lib/singleton-lambda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface SingletonFunctionProps extends FunctionProps {
3737
export class SingletonFunction extends FunctionBase {
3838
public readonly functionName: string;
3939
public readonly functionArn: string;
40-
public readonly role?: iam.Role | undefined;
40+
public readonly role?: iam.IRole | undefined;
4141
protected readonly canCreatePermissions: boolean;
4242
private lambdaFunction: IFunction;
4343

0 commit comments

Comments
 (0)