Skip to content

Instantly share code, notes, and snippets.

@DavidDeCoding
Created August 16, 2022 19:20
Show Gist options
  • Save DavidDeCoding/164c79aa7ed6ba16e8c1584593c0a11e to your computer and use it in GitHub Desktop.
Save DavidDeCoding/164c79aa7ed6ba16e8c1584593c0a11e to your computer and use it in GitHub Desktop.
Whiteboarding - serverless.yml
service: whiteboarding
package:
individually: true
provider:
name: aws
runtime: python3.8
region: us-west-1
stage: ${opt:stage, "dev"}
lambdaHashingVersion: "20201221"
websocketsApiName: whiteboarding-backend-apis
websocketsApiRouteSelectionExpression: $request.body.action
websocketsDescription: All Apis for the backend of whiteboarding app
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:DescribeStream
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:ListStreams
Resource:
- { "Fn::GetAtt": ["WhiteboardingDynamoDBTable", "Arn"] }
environment:
WHITEBOARDING_TABLE: ${self:custom.whiteboardingTableName}
functions:
connectionHandler:
package:
include:
- "whiteboarding"
exclude:
- "requirements.txt"
- "package.json"
- "package-lock.json"
- ".serverless/**"
- ".virtualenv/**"
- "node_modules/**"
- ".pytest_cache"
- "tests/**"
- ".gitignore"
- "poetry.lock"
- "pyproject.toml"
- "README.md"
- "dist/**"
handler: whiteboarding.connection.handler
environment:
STAGE: ${self:provider.stage}
events:
- websocket:
route: $connect
- websocket:
route: $disconnect
defaultHandler:
package:
include:
- "whiteboarding"
exclude:
- "requirements.txt"
- "package.json"
- "package-lock.json"
- ".serverless/**"
- ".virtualenv/**"
- "node_modules/**"
- ".pytest_cache"
- "tests/**"
- ".gitignore"
- "poetry.lock"
- "pyproject.toml"
- "README.md"
- "dist/**"
handler: whiteboarding.default.handler
environment:
STAGE: ${self:provider.stage}
events:
- websocket:
route: $default
onMessageHandler:
package:
include:
- "whiteboarding"
exclude:
- "requirements.txt"
- "package.json"
- "package-lock.json"
- ".serverless/**"
- ".virtualenv/**"
- "node_modules/**"
- ".pytest_cache"
- "tests/**"
- ".gitignore"
- "poetry.lock"
- "pyproject.toml"
- "README.md"
- "dist/**"
handler: whiteboarding.on_message.handler
environment:
STAGE: ${self:provider.stage}
events:
- websocket:
route: onMessage
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true
dockerFile: Dockerfile
whiteboardingTableName: 'whiteboarding-table-${self:provider.stage}'
resources:
Resources:
WhiteboardingDynamoDBTable:
Type: 'AWS::DynamoDB::Table'
Properties:
AttributeDefinitions:
- AttributeName: whiteboardId
AttributeType: S
KeySchema:
- AttributeName: whiteboardId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.whiteboardingTableName}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment