-
Notifications
You must be signed in to change notification settings - Fork 7
/
template.yaml
89 lines (83 loc) · 2.78 KB
/
template.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
node18.x
Sample SAM Template for streaming-rag-on-lambda
Parameters:
FunctionURLAuthType:
Default: AWS_IAM
Description: What type of auth the Lambda should use for the FunctionURL
Type: String
AllowedValues: [ AWS_IAM, NONE ]
Resources:
DocumentBucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
StreamingRAGFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs18.x
CodeUri: function/.
Timeout: 300
MemorySize: 256
Architectures:
- x86_64
Environment:
Variables:
s3BucketName: !Ref DocumentBucket
region: !Ref AWS::Region
lanceDbTable: doc_table
FunctionUrlConfig:
AuthType: !Ref FunctionURLAuthType
Cors:
AllowCredentials: true
AllowHeaders:
- x-amz-security-token
- x-amz-date
- x-amz-content-sha256
- referer
- content-type
- accept
- authorization
AllowMethods:
- '*'
AllowOrigins:
- '*'
MaxAge: 0
InvokeMode: RESPONSE_STREAM
Policies:
- Statement:
- Effect: Allow
Action:
- 'bedrock:InvokeModel'
- 'bedrock:InvokeModelWithResponseStream'
Resource:
- !Sub 'arn:aws:bedrock:${AWS::Region}::foundation-model/anthropic.claude-*'
- !Sub 'arn:aws:bedrock:${AWS::Region}::foundation-model/amazon.titan-*'
- !Sub 'arn:aws:bedrock:${AWS::Region}::foundation-model/mistral.mixtral-*'
- Effect: Allow
Action: s3:GetObject
Resource: !Sub arn:aws:s3:::${DocumentBucket}/*
- Effect: Allow
Action: s3:ListBucket
Resource: !Sub arn:aws:s3:::${DocumentBucket}
Outputs:
StreamingRAGFunction:
Description: "Streaming Lambda Function ARN"
Value: !GetAtt StreamingRAGFunction.Arn
StreamingRAGFunctionURL:
Description: "Function URL for Streaming"
Value: !GetAtt StreamingRAGFunctionUrl.FunctionUrl
StreamingRAGFunctionIamRole:
Description: "Implicit IAM Role created for Streaming function"
Value: !GetAtt StreamingRAGFunctionRole.Arn
DocumentBucketName:
Description: "S3 bucket where LanceDB sources embeddings. Check this repository README for instructions on how to import your documents"
Value: !Ref DocumentBucket