Skip to content

Commit 9e7d311

Browse files
authored
fix(aws-lambda): jsii use no long requires 'sourceAccount' (#728)
Change the typing of 'sourceAccount' to be optional string, so that the typing over JSII will be properly inferred. The current type is 'any' so that we can pass in Tokens, but since the Token stringification change typing as a string no longer forms an obstacle, and in fact it will be more inline with upcoming type system changes. Fixed #714.
1 parent b0f3857 commit 9e7d311

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export abstract class FunctionRef extends cdk.Construct
317317
const permissionId = `AllowBucketNotificationsFrom${bucketId}`;
318318
if (!this.tryFindChild(permissionId)) {
319319
this.addPermission(permissionId, {
320-
sourceAccount: new cdk.AwsAccountId(),
320+
sourceAccount: new cdk.AwsAccountId().toString(),
321321
principal: new cdk.ServicePrincipal('s3.amazonaws.com'),
322322
sourceArn: bucketArn,
323323
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface Permission {
4242
* bucket owner's account ID. You can use this property to ensure that all
4343
* source principals are owned by a specific account.
4444
*/
45-
sourceAccount?: any;
45+
sourceAccount?: string;
4646

4747
/**
4848
* The ARN of a resource that is invoking your function. When granting

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export = {
118118
fn.addPermission('S3Permission', {
119119
action: 'lambda:*',
120120
principal: new cdk.ServicePrincipal('s3.amazonaws.com'),
121-
sourceAccount: new cdk.AwsAccountId(),
121+
sourceAccount: new cdk.AwsAccountId().toString(),
122122
sourceArn: new cdk.Arn('arn:aws:s3:::my_bucket')
123123
});
124124

0 commit comments

Comments
 (0)