Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lambda): unable to access SingletonFunction vpc connections #14533

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-lambda/lib/singleton-lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export class SingletonFunction extends FunctionBase {
this.grantPrincipal = this.lambdaFunction.grantPrincipal;

this.canCreatePermissions = true; // Doesn't matter, addPermission is overriden anyway

if (this.lambdaFunction.isBoundToVpc) {
this._connections = this.lambdaFunction.connections;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this would be a better implementation.

class SingletonFunction .... {
  public get connections(): ec2.Connections {
    return this.lambdaFunction.connections;
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to override isBoundToVpc as well since the base implementation checks this._connections which is not set for the SingletonFunction

}

/**
Expand Down
Loading