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

New serverless pattern - apigw-websocket-api-vpclink #2391

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

manasvijain99
Copy link

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

We have created a pattern which deploys a SAM template to create an Amazon API Gateway Websocket API endpoint with a VPC Link integration.

Comment on lines +13 to +15



Copy link
Contributor

@parikhudit parikhudit Sep 1, 2024

Choose a reason for hiding this comment

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

Please remove extra lines here. Review all the files as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename the folder as per the name of the pattern. You may find examples in the repository.


The SAM template deploys a websocket API Gateway and two Lambda functions required to run the application. This pattern deploys an Amazon API Gateway WebSocket API with a $connect route with a Lambda proxy integration which will invoke another Lambda function asynchronously and pass the Connection Id and the API Gateway stage URL to it. Then the Lambda function which got invoked asynchronously will check the validity of the connection. If the Connection Id is valid it will make an SDK API call to post a greeting to the client.

Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/s3-lambda
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the link

3. From the command line, use AWS SAM to build and deploy the AWS resources for the pattern as specified in the template.yml file:

```
sam build
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no requirements.txt file. Do you need this command?

Comment on lines +53 to +62
3. Connect to your WebSocketURL by executing the following command:
```
$ wscat -c <YOUR WEBSOCKET URL>
```

4. To test the custom route and its associated function, send a JSON-formatted request like the following example. The Lambda function sends back the value of the "data" key using the callback URL:
```
$ wscat -c <YOUR WEBSOCKET URL>
connected (press CTRL+C to quit)
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you kindly explain this with an example for better clarity?

@@ -0,0 +1,75 @@
## Websocket API Gateway acknowledgement for $connect route.

The SAM template deploys a websocket API Gateway and two Lambda functions required to run the application. This pattern deploys an Amazon API Gateway WebSocket API with a $connect route with a Lambda proxy integration which will invoke another Lambda function asynchronously and pass the Connection Id and the API Gateway stage URL to it. Then the Lambda function which got invoked asynchronously will check the validity of the connection. If the Connection Id is valid it will make an SDK API call to post a greeting to the client.
Copy link
Contributor

Choose a reason for hiding this comment

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

The explanation in first 2 lines redundant. Could you please rephrase it?

@parikhudit
Copy link
Contributor

Thanks for the contribution @manasvijain99. As this PR contains 2 new patterns, I'd request you to kindly update the PR to have just 1 pattern and have a new PR for another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants