-
Notifications
You must be signed in to change notification settings - Fork 16
/
excellexbot.yaml
108 lines (105 loc) · 3.14 KB
/
excellexbot.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: Upload Excel xlsx to S3 and trigger Excel Lex Bot
Parameters:
DynamodbAutoScaling:
Type: String
Default: false
AllowedValues:
- true
- false
Description: Enable DynamoDB AutoScaling
Metadata:
AWS::ServerlessRepo::Application:
Name: ExcelLexBot
Description: ExcelLexBot is a serverless application that converts an Excel file (xlsx) in predefined format into an Amazon Lex chatbot.
Author: Cyrus Wong
SpdxLicenseId: Apache-2.0
LicenseUrl: LICENSE.txt
ReadmeUrl: README.md
Labels: ['Lex']
HomePageUrl: https://github.com/wongcyrus/ExcelLexBot
SemanticVersion: 0.0.3
SourceCodeUrl: https://github.com/wongcyrus/ExcelLexBot
Resources:
ExcelLexBotS3TriggerFunction:
Type: AWS::Serverless::Function
Properties:
Description: Create Lex Chat Bot when upload xlsx file.
Handler: s3_trigger_handler.lambda_handler
Runtime: python3.7
MemorySize: 512
Timeout: 300
Tracing: Active
Layers:
- !Ref LibLayer
Policies:
- AWSXrayWriteOnlyAccess
- AWSLambdaExecute
- AmazonLexFullAccess
- AmazonSNSFullAccess
- AmazonDynamoDBFullAccess
- AWSLambda_FullAccess
- Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- cloudformation:CreateStack
- cloudformation:DescribeChangeSet
- cloudformation:CreateChangeSet
- cloudformation:DeleteChangeSet
- cloudformation:DeleteStack
- cloudformation:ExecuteChangeSet
- cloudwatch:DescribeAlarms
- cloudwatch:PutMetricAlarm
- cloudwatch:DeleteAlarms
- iam:CreateRole
- iam:DeleteRole
- iam:AttachRolePolicy
- iam:DetachRolePolicy
- iam:PutRolePolicy
- iam:DeleteRolePolicy
- iam:PassRole
Resource: "*"
Environment:
Variables:
DynamodbAutoScaling: !Ref DynamodbAutoScaling
LibLayer: !Ref LibLayer
CodeUri: builder/
Events:
XlsxPut:
Type: S3
Properties:
Bucket: !Ref Bucket
Events: s3:ObjectCreated:Put
Filter:
S3Key:
Rules:
-
Name: suffix
Value: .xlsx
XlsxDelete:
Type: S3
Properties:
Bucket: !Ref Bucket
Events: s3:ObjectRemoved:Delete
Filter:
S3Key:
Rules:
-
Name: suffix
Value: .xlsx
LibLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: lib
CompatibleRuntimes:
- python3.7
LicenseInfo: 'Available under the MIT-0 license.'
RetentionPolicy: Delete
Bucket:
Type: AWS::S3::Bucket
Outputs:
LexExcelBucket:
Description: Lex Excel Bucket
Value: !Ref Bucket