Created
March 6, 2019 09:46
-
-
Save yai333/f0b611a271dcc7ccec9f167b73ae5996 to your computer and use it in GitHub Desktop.
This file contains 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
service: serverless-chat | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
stackName: ${self:service}-${self:provider.stage} | |
stage: ${opt:stage, 'dev'} | |
region: ${opt:region, 'ap-southeast-2'} | |
iamRoleStatements: | |
- Effect: Allow | |
Action: | |
- "execute-api:ManageConnections" | |
Resource: | |
- "arn:aws:execute-api:*:*:**/@connections/*" | |
- Effect: Allow | |
Action: | |
- "dynamodb:PutItem" | |
- "dynamodb:GetItem" | |
- "dynamodb:UpdateItem" | |
- "dynamodb:DeleteItem" | |
- "dynamodb:Query" | |
- "dynamodb:Scan" | |
Resource: | |
- Fn::GetAtt: [ChatConnectionsTable, Arn] | |
- Fn::Join: | |
- "/" | |
- - Fn::GetAtt: [ChatConnectionsTable, Arn] | |
- "*" | |
environment: | |
CHATCONNECTION_TABLE: | |
Ref: ChatConnectionsTable | |
websocketApiName: websocket-chat-${self:provider.stage} | |
websocketApiRouteSelectionExpression: $request.body.action | |
functions: | |
connectionManager: | |
handler: handler.connectionManager | |
events: | |
- websocket: | |
route: $connect | |
authorizer: authorizerFunc # references the authorizerFunc function below | |
- websocket: | |
route: $disconnect | |
authorizerFunc: | |
handler: handler.authorizerFunc | |
defaultMessages: | |
handler: handler.defaultMessage | |
events: | |
- websocket: | |
route: $default | |
sendMessage: | |
handler: handler.sendMessage | |
events: | |
- websocket: | |
route: sendMessage | |
resources: | |
Resources: | |
ChatConnectionsTable: | |
Type: AWS::DynamoDB::Table | |
Properties: | |
AttributeDefinitions: | |
- AttributeName: connectionId | |
AttributeType: S | |
KeySchema: | |
- AttributeName: connectionId | |
KeyType: HASH | |
ProvisionedThroughput: | |
ReadCapacityUnits: 5 | |
WriteCapacityUnits: 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment