2
|
1 AWSTemplateFormatVersion: '2010-09-09'
|
|
2 Transform: AWS::Serverless-2016-10-31
|
|
3 Description: Serverless balance sheet analyzer using Textract and a serverless API
|
|
4
|
|
5 Conditions:
|
|
6 CreateProdResources: !Equals
|
|
7 - !Ref AWS::AccountId
|
|
8 - 572540046516 # Dennis account ID (Production)
|
|
9
|
|
10 Globals:
|
|
11 Function:
|
|
12 Runtime: python3.7
|
|
13 Handler: app.lambda_handler
|
|
14 Architectures:
|
|
15 - x86_64
|
|
16 Timeout: 20
|
|
17 MemorySize: 256
|
|
18 Tracing: Active
|
|
19
|
|
20 Resources:
|
|
21 S3Bucket:
|
|
22 Type: AWS::S3::Bucket
|
|
23 Properties:
|
|
24 BucketName: !If
|
|
25 - CreateProdResources
|
|
26 - finance-parser-data
|
|
27 - sandbox-finance-parser-data
|
|
28
|
|
29 ProcessDocumentFunction:
|
|
30 Type: AWS::Serverless::Function
|
|
31 Properties:
|
|
32 CodeUri: process_document/
|
|
33 Handler: app.lambda_handler
|
|
34 Runtime: python3.7
|
|
35 Policies:
|
|
36 - Version: "2012-10-17"
|
|
37 Statement:
|
|
38 - Effect: Allow
|
|
39 Action:
|
|
40 - textract:AnalyzeDocument
|
|
41 Resource: "*"
|
|
42 Events:
|
|
43 NewBalanceSheetEvent:
|
|
44 Type: S3
|
|
45 Properties:
|
|
46 Bucket: !Ref S3Bucket
|
|
47 Events: s3:ObjectCreated:*
|
|
48 Connectors:
|
|
49 S3Connector:
|
|
50 Properties:
|
|
51 Destination:
|
|
52 Id: S3Bucket
|
|
53 Permissions:
|
|
54 - Read
|
|
55 - Write |