comparison template.yaml @ 3:2e5f3664f3e4

documents analyzer almost finished
author Dennis C. M. <dennis@denniscm.com>
date Fri, 02 Jun 2023 20:12:29 +0100
parents ef8a4d95755a
children 2daf0dc08247
comparison
equal deleted inserted replaced
2:ef8a4d95755a 3:2e5f3664f3e4
12 Runtime: python3.7 12 Runtime: python3.7
13 Handler: app.lambda_handler 13 Handler: app.lambda_handler
14 Architectures: 14 Architectures:
15 - x86_64 15 - x86_64
16 Timeout: 20 16 Timeout: 20
17 MemorySize: 256 17 MemorySize: 128
18 Tracing: Active 18 Tracing: Active
19 19
20 Resources: 20 Resources:
21 S3Bucket: 21 S3Bucket:
22 Type: AWS::S3::Bucket 22 Type: AWS::S3::Bucket
23 Properties: 23 Properties:
24 BucketName: !If 24 BucketName: !If
25 - CreateProdResources 25 - CreateProdResources
26 - finance-parser-data 26 - finance-parser-data
27 - sandbox-finance-parser-data 27 - sandbox-finance-parser-data
28 NotificationConfiguration:
29 EventBridgeConfiguration:
30 EventBridgeEnabled: true
28 31
29 ProcessDocumentFunction: 32 StateMachine:
33 Type: AWS::Serverless::StateMachine
34 Properties:
35 Tracing:
36 Enabled: true
37 DefinitionUri: statemachine/statemachine.asl.json
38 DefinitionSubstitutions:
39 AnalyzeDocumentFunctionArn: !GetAtt AnalyzeDocumentFunction.Arn
40 ProcessDocumentFunctionArn: !GetAtt ProcessDocumentFunction.Arn
41 UploadDocumentFunctionArn: !GetAtt UploadDocumentFunction.Arn
42 Events:
43 StateChange:
44 Type: EventBridgeRule
45 Properties:
46 Pattern:
47 source:
48 - aws.s3
49 detail-type:
50 - Object Created
51 detail:
52 bucket:
53 name:
54 - !Ref S3Bucket
55 object:
56 key:
57 - "prefix": "unprocessed/"
58 Connectors:
59 StateMachineConnector:
60 Properties:
61 Destination:
62 - Id: AnalyzeDocumentFunction
63 - Id: ProcessDocumentFunction
64 - Id: UploadDocumentFunction
65 Permissions:
66 - Write
67
68 AnalyzeDocumentFunction:
30 Type: AWS::Serverless::Function 69 Type: AWS::Serverless::Function
31 Properties: 70 Properties:
32 CodeUri: process_document/ 71 CodeUri: analyze_document/
33 Handler: app.lambda_handler 72 Handler: app.lambda_handler
34 Runtime: python3.7 73 Runtime: python3.7
35 Policies: 74 Policies:
36 - Version: "2012-10-17" 75 - Version: "2012-10-17"
37 Statement: 76 Statement:
38 - Effect: Allow 77 - Effect: Allow
39 Action: 78 Action:
40 - textract:AnalyzeDocument 79 - textract:AnalyzeDocument
41 Resource: "*" 80 Resource: "*"
42 Events:
43 NewBalanceSheetEvent:
44 Type: S3
45 Properties:
46 Bucket: !Ref S3Bucket
47 Events: s3:ObjectCreated:*
48 Connectors: 81 Connectors:
49 S3Connector: 82 S3Connector:
50 Properties: 83 Properties:
51 Destination: 84 Destination:
52 Id: S3Bucket 85 Id: S3Bucket
53 Permissions: 86 Permissions:
54 - Read 87 - Read
55 - Write 88 - Write
89
90 ProcessDocumentFunction:
91 Type: AWS::Serverless::Function
92 Properties:
93 CodeUri: process_document/
94 Handler: app.lambda_handler
95 Runtime: python3.7
96 Connectors:
97 S3Connector:
98 Properties:
99 Destination:
100 Id: S3Bucket
101 Permissions:
102 - Read
103 - Write
104
105 UploadDocumentFunction:
106 Type: AWS::Serverless::Function
107 Properties:
108 CodeUri: upload_document/
109 Handler: app.lambda_handler
110 Runtime: python3.7
111 Connectors:
112 DynamoConnector:
113 Properties:
114 Destination:
115 Id: DynamoTable
116 Permissions:
117 - Write
118 S3Connector:
119 Properties:
120 Destination:
121 Id: S3Bucket
122 Permissions:
123 - Read
124
125 DynamoTable:
126 Type: AWS::DynamoDB::Table
127 Properties:
128 TableName: FinanceParser
129 BillingMode: PAY_PER_REQUEST
130 DeletionProtectionEnabled: !If
131 - CreateProdResources
132 - True
133 - False
134 KeySchema:
135 - AttributeName: pk
136 KeyType: HASH
137 - AttributeName: sk
138 KeyType: RANGE
139 AttributeDefinitions:
140 - AttributeName: pk
141 AttributeType: S
142 - AttributeName: sk
143 AttributeType: S