-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(apigatewayv2): websocket api #13031
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
be70b93
feat(apigatewayv2): add support for WebSocket APIs
ayush987goyal 89f4ad9
fix config hashing
ayush987goyal 1cd6d41
fix readme
ayush987goyal ce05383
update
ayush987goyal ea5a32f
update readme
ayush987goyal 3369f85
update
ayush987goyal fe7a658
update
ayush987goyal 0ac9d48
update readme
ayush987goyal a066643
address comments
ayush987goyal 67b3bb5
address comments
ayush987goyal 5cffd46
address comments
ayush987goyal f949430
tweaks
ayush987goyal 1a1f0cf
Update packages/@aws-cdk/aws-apigatewayv2/lib/common/api-mapping.ts
cf16610
Merge branch 'master' into pr/ws
mergify[bot] 75f7e5e
Merge branch 'master' into pr/ws
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './http'; | ||
| export * from './websocket'; |
1 change: 1 addition & 0 deletions
1
packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './lambda'; |
44 changes: 44 additions & 0 deletions
44
packages/@aws-cdk/aws-apigatewayv2-integrations/lib/websocket/lambda.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { | ||
| IWebSocketRouteIntegration, | ||
| WebSocketIntegrationType, | ||
| WebSocketRouteIntegrationBindOptions, | ||
| WebSocketRouteIntegrationConfig, | ||
| } from '@aws-cdk/aws-apigatewayv2'; | ||
| import { ServicePrincipal } from '@aws-cdk/aws-iam'; | ||
| import { IFunction } from '@aws-cdk/aws-lambda'; | ||
| import { Names, Stack } from '@aws-cdk/core'; | ||
|
|
||
| /** | ||
| * Lambda WebSocket Integration props | ||
| */ | ||
| export interface LambdaWebSocketIntegrationProps { | ||
| /** | ||
| * The handler for this integration. | ||
| */ | ||
| readonly handler: IFunction | ||
| } | ||
|
|
||
| /** | ||
| * Lambda WebSocket Integration | ||
| */ | ||
| export class LambdaWebSocketIntegration implements IWebSocketRouteIntegration { | ||
| constructor(private props: LambdaWebSocketIntegrationProps) {} | ||
|
|
||
| bind(options: WebSocketRouteIntegrationBindOptions): WebSocketRouteIntegrationConfig { | ||
| const route = options.route; | ||
| this.props.handler.addPermission(`${Names.nodeUniqueId(route.node)}-Permission`, { | ||
| scope: options.scope, | ||
| principal: new ServicePrincipal('apigateway.amazonaws.com'), | ||
| sourceArn: Stack.of(route).formatArn({ | ||
| service: 'execute-api', | ||
| resource: route.webSocketApi.apiId, | ||
| resourceName: `*/*${route.routeKey}`, | ||
| }), | ||
| }); | ||
|
|
||
| return { | ||
| type: WebSocketIntegrationType.AWS_PROXY, | ||
| uri: this.props.handler.functionArn, | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.