Skip to content

Commit

Permalink
fix(aws-lambda): jsii use no long requires 'sourceAccount' (#728)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rix0rrr authored Sep 17, 2018
1 parent b0f3857 commit 9e7d311
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda/lib/lambda-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export abstract class FunctionRef extends cdk.Construct
const permissionId = `AllowBucketNotificationsFrom${bucketId}`;
if (!this.tryFindChild(permissionId)) {
this.addPermission(permissionId, {
sourceAccount: new cdk.AwsAccountId(),
sourceAccount: new cdk.AwsAccountId().toString(),
principal: new cdk.ServicePrincipal('s3.amazonaws.com'),
sourceArn: bucketArn,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda/lib/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface Permission {
* bucket owner's account ID. You can use this property to ensure that all
* source principals are owned by a specific account.
*/
sourceAccount?: any;
sourceAccount?: string;

/**
* The ARN of a resource that is invoking your function. When granting
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda/test/test.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export = {
fn.addPermission('S3Permission', {
action: 'lambda:*',
principal: new cdk.ServicePrincipal('s3.amazonaws.com'),
sourceAccount: new cdk.AwsAccountId(),
sourceAccount: new cdk.AwsAccountId().toString(),
sourceArn: new cdk.Arn('arn:aws:s3:::my_bucket')
});

Expand Down

0 comments on commit 9e7d311

Please sign in to comment.