Skip to content

This is a personal project created so I could learn about the websocket support in API Gateway.

License

Notifications You must be signed in to change notification settings

austoonz/powershell-core-simple-websockets-chat-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PowerShell Core Port of simple-websockets-chat-app

This is a PowerShell Core port of the simple-websockets-chat-app sample for AWS Lambda. For more information see the Announcing WebSocket APIs in Amazon API Gateway blog post.

Deploy

To deploy this sample, ensure you have setup a PowerShell Core Development Environment for AWS Lambda.

First, execute the following PowerShell commands in the root directory of this repository. This will import the WebSocket PowerShell Module and compile the PowerShell Core AWS Lambda Function.

Import-Module -Name 'AWSLambdaPSCore'

$functionScript = [System.IO.Path]::Combine('.', 'WebSocket', 'WebSocket.ps1')
$websocketManifest = [System.IO.Path]::Combine('.', 'WebSocket', 'WebSocket.psd1')
$lambdaPackage = [System.IO.Path]::Combine('.', '_packaged', 'WebSocket.zip')

Import-Module $websocketManifest

$null = New-AWSPowerShellLambdaPackage -ScriptPath $functionScript -OutputPackage $lambdaPackage

This sample can be deployed using the AWS Lambda .NET Core Global Tool.

To install the global tool, execute the following command. Be sure at least version 3.1.0 of the tool is installed.

dotnet tool install -g Amazon.Lambda.Tools

To upgrade the global tool, execute the following command.

dotnet tool update -g Amazon.Lambda.Tools

To deploy the sample application, execute the following command in the root directory of this repository.

dotnet lambda deploy-serverless <stack-name> --template template.yaml --region <region> --s3-bucket <storage-bucket>

To test the WebSockets functionality, use a WebSockets client (such as the Chrome "Simple WebSocket Client" extension) to connect to the value listed in the CloudFormation "WebSocketURI" output.

To send messages to connected clients, send a JSON message formatted like this, with the value of "data" as the message to send.

{"action":"sendmessage", "data":"Hello World"}

To delete the sample application, execute the following command.

dotnet lambda delete-serverless <stack-name>

About

This is a personal project created so I could learn about the websocket support in API Gateway.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published