-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
83 lines (79 loc) · 2.59 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
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Tags:
app: aws-bedrock-telegram-genai-chatbot
Runtime: python3.13
Architectures:
- arm64
LoggingConfig:
LogGroup: !Sub /aws/lambda/${AWS::StackName}
LogFormat: JSON
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension-Arm64:20 #Lambda Insights Layer - Specific for us-east-1 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versionsARM.html
- !Sub arn:aws:lambda:${AWS::Region}:615299751070:layer:AWSOpenTelemetryDistroPython:5 #Application Signals Layer - Specific for us-east-1 https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Application-Signals-Enable-Lambda.html
Tracing: Active
Environment:
Variables:
AWS_LAMBDA_EXEC_WRAPPER: /opt/otel-instrument
Resources:
TelegramFunction:
Type: AWS::Serverless::Function
Properties:
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: TelegramFunction
CodeUri: src/Function
Handler: bot.lambda_handler
MemorySize: 256
Timeout: 30
AutoPublishAlias: SnapStart
SnapStart:
ApplyOn: PublishedVersions
Policies:
- CloudWatchLambdaInsightsExecutionRolePolicy
- Statement:
- Effect: Allow
Action:
- ssm:GetParameter
Resource:
- arn:aws:ssm:*:*:parameter/bedrock-telegram-genai-chatbot/*
- Effect: Allow
Action:
- bedrock:InvokeModel
Resource: '*'
- DynamoDBCrudPolicy:
TableName: !Ref ChatHistory
Events:
ApiPOST:
Type: Api
Properties:
Path: /
Method: POST
Environment:
Variables:
CHATHISTORY_TABLE_NAME: !Ref ChatHistory
CHATHISTORY_TABLE_ARN: !GetAtt ChatHistory.Arn
TelegramFunctionLogGroup:
Type: AWS::Logs::LogGroup
DeletionPolicy: Retain
ChatHistory:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: chat_id
AttributeType: S
- AttributeName: timestamp
AttributeType: S
KeySchema:
- AttributeName: chat_id
KeyType: HASH
- AttributeName: timestamp
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
AttributeName: expireat
Enabled: true
Tags:
- Value: aws-bedrock-telegram-genai-chatbot
Key: app