-
Notifications
You must be signed in to change notification settings - Fork 2
/
template.yaml
117 lines (117 loc) · 3.39 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Resources:
Images:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::StackName}-images-${AWS::AccountId}
CollectionImages:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::StackName}-collectio-${AWS::AccountId}
CollectionTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: ObjectKey
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: ObjectKey
KeyType: HASH
TableName: !Sub ${AWS::StackName}-CollectionTable
CompareFaces:
Type: AWS::Serverless::Function
Properties:
Architectures:
- arm64
FunctionName: !Sub ${AWS::StackName}-CompareFaces
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: CompareFaces
CodeUri: src/CompareFaces
Handler: index.handler
Runtime: nodejs20.x
MemorySize: 4008
Timeout: 45
Tracing: Active
Policies:
- AWSXrayWriteOnlyAccess
- Version: 2012-10-17
Statement:
- Effect: Allow
Resource: "*"
Action:
- rekognition:SearchFacesByImage
- Version: 2012-10-17
Statement:
- Effect: Allow
Resource: !Sub arn:aws:s3:::${AWS::StackName}-images-${AWS::AccountId}/*
Action:
- s3:GetObject
Events:
Images:
Type: S3
Properties:
Bucket: !Ref Images
Events:
- s3:ObjectCreated:*
Environment:
Variables:
COLLECTION_NAME: !Ref RekognitionId
ManageCollection:
Type: AWS::Serverless::Function
Properties:
Architectures:
- arm64
FunctionName: !Sub ${AWS::StackName}-ManageCollection
Description: !Sub
- Stack ${AWS::StackName} Function ${ResourceName}
- ResourceName: ManageCollection
CodeUri: src/ManageCollection
Handler: index.handler
Runtime: nodejs20.x
MemorySize: 4008
Timeout: 45
Tracing: Active
Policies:
- AWSXrayWriteOnlyAccess
- Version: 2012-10-17
Statement:
- Effect: Allow
Resource: "*"
Action:
- rekognition:IndexFaces
- rekognition:DeleteFaces
- Version: 2012-10-17
Statement:
- Effect: Allow
Resource: !Sub arn:aws:s3:::${AWS::StackName}-collectio-${AWS::AccountId}/*
Action:
- s3:GetObject
- Version: 2012-10-17
Statement:
- Effect: Allow
Resource: !GetAtt CollectionTable.Arn
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:DeleteItem
Events:
CollectionImages:
Type: S3
Properties:
Bucket: !Ref CollectionImages
Events:
- s3:ObjectCreated:*
- s3:ObjectRemoved:*
Environment:
Variables:
TABLE_NAME: !Ref CollectionTable
TABLE_ARN: !GetAtt CollectionTable.Arn
COLLECTION_NAME: !Ref RekognitionId
Parameters:
RekognitionId:
Type: String
Description: Collection ID for Rekognition
Default: facespace