/
serverless.yml
69 lines (64 loc) · 2.34 KB
/
serverless.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
service: SlackAssistant
frameworkVersion: '3'
custom:
awsProfile: ${file(config.yml):config.awsProfile, 'default'}
awsRegion: ${file(config.yml):config.awsRegion, 'us-west-2'}
lambdaFunctionName: ${file(config.yml):config.lambdaFunctionName, 'slack-assistant-${sls:stage}'}
lambdaFunctionTimeout: ${file(config.yml):config.lambdaFunctionTimeout, '120'}
dynamodbTableName: ${file(config.yml):config.dynamodbTableName, 'slack_assistant_conversation_history_${sls:stage}'}
openaiApiKey: ${file(config.yml):config.openaiApiKey}
openaiModel: ${file(config.yml):config.openaiModel}
openaiTemperature: ${file(config.yml):config.openaiTemperature}
openaiSystemMessage: ${file(config.yml):config.openaiSystemMessage}
slackSigningKey: ${file(config.yml):config.slackSigningKey}
slackWebhook: ${file(config.yml):config.slackWebhook}
provider:
name: aws
runtime: nodejs16.x
profile: ${self:custom.awsProfile}
region: ${self:custom.awsRegion}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- Fn::GetAtt: [ HistoryTable, Arn ]
functions:
SlackAssistant:
name: ${self:custom.lambdaFunctionName}
handler: lib/index.handler
url: true
timeout: ${self:custom.lambdaFunctionTimeout}
environment:
SLACK_ASSISTANT_DYNAMODB_TABLE: ${self:custom.dynamodbTableName}
SLACK_ASSISTANT_OPENAI_API_KEY: ${self:custom.openaiApiKey}
SLACK_ASSISTANT_OPENAI_MODEL: ${self:custom.openaiModel}
SLACK_ASSISTANT_OPENAI_SYSTEM_MESSAGE: ${self:custom.openaiSystemMessage}
SLACK_ASSISTANT_OPENAI_TEMPERATURE: ${self:custom.openaiTemperature}
SLACK_ASSISTANT_SLACK_SIGNING_KEY: ${self:custom.slackSigningKey}
SLACK_ASSISTANT_SLACK_WEBHOOK: ${self:custom.slackWebhook}
package:
include:
- lib/**
exclude:
- node_modules/aws-sdk/**
resources:
Resources:
HistoryTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: key
AttributeType: S
KeySchema:
- AttributeName: key
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TableName: ${self:custom.dynamodbTableName}