-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
86 lines (83 loc) · 2.5 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sora-cam-label-detection-with-rekognition
Parameters:
soracomAuthKeyId:
Type: String
Default: "keyId-xxxxxxx"
soracomAuthKey:
Type: String
Default: "secret-xxxxxx"
deviceId:
Type: String
Default: "XXXXXXXXXXXX"
rekognitionRegion:
Type: String
Default: "ap-northeast-1"
targetLabelName:
Type: String
Default: "Person"
targetConfidence:
Type: String
Default: "90"
lineNotifyToken:
Type: String
Default: "replace it to your own token"
Resources:
DetectionFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: sora-cam-label-detection-with-rekognition
Timeout: 30
MemorySize: 256
CodeUri: sora_cam_label_detection_with_rekognition
Handler: app.lambda_handler
Runtime: python3.9
Environment:
Variables:
SORACOM_AUTH_KEY_ID: !Ref soracomAuthKeyId
SORACOM_AUTH_KEY: !Ref soracomAuthKey
DEVICE_ID: !Ref deviceId
LINE_NOTIFY_TOKEN: !Ref lineNotifyToken
REKOGNITION_REGION: !Ref rekognitionRegion
TARGET_LABEL_NAME: !Ref targetLabelName
TARGET_CONFIDENCE: !Ref targetConfidence
# If you change the trigger frequency, also change the following variable.
EVENT_RETRIEVE_INTERVAL_SEC: "60"
Architectures:
- x86_64
Role: !GetAtt DetectionFunctionRole.Arn
Events:
Schedule:
Type: Schedule
Properties:
Name: sora-cam-label-detection-with-rekognition-schedule
Schedule: cron(* * ? * * *)
DetectionFunctionRole:
Type: AWS::IAM::Role
Properties:
RoleName: "sora-cam-label-detection-with-rekognition-role"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action: "sts:AssumeRole"
Principal:
Service: lambda.amazonaws.com
Policies:
- PolicyName: "sora-cam-label-detection-with-rekognition-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: "*"
- Effect: "Allow"
Action:
- "rekognition:DetectLabels"
Resource:
- "*"