forked from taku-takamatsu/voice-enabled-photo-album
-
Notifications
You must be signed in to change notification settings - Fork 0
/
samTemplate.yaml
96 lines (95 loc) · 3.25 KB
/
samTemplate.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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: CD Deployment CCBD Assignment 2
Resources:
PhotoAlbumBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: 'cd-photo-album-b1'
A2LF0CORS:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: A2_LF0
Handler: lambda_function.lambda_handler
Runtime: python3.9
CodeUri: ./lambda_functions/LF0
Description: 'CCBD Assignment 2: Lambda function for CORS (/upload)'
MemorySize: 128
Timeout: 15
Role: 'arn:aws:iam::958611120422:role/service-role/A2-LF0-CORS-role-qavwwkmv'
Events:
PhotoAlbum:
Type: Api
Properties:
Path: /upload/{folder}/{sub-folder}/{object}
Method: OPTIONS
A2LF0CORS2:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: A2_LF0_2
Handler: lambda_function.lambda_handler
Runtime: python3.9
CodeUri: ./lambda_functions/LF0_2
Description: 'CCBD Assignment 2: Lambda function for CORS (/search)'
MemorySize: 128
Timeout: 15
Role: 'arn:aws:iam::958611120422:role/service-role/A2-LF0-CORS-role-qavwwkmv'
Policies:
S3ReadPolicy:
BucketName: !Ref PhotoAlbumBucket
Events:
PhotoAlbum:
Type: Api
Properties:
Path: /search
Method: OPTIONS
A2LF1:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: A2_LF1
Handler: lambda_function.lambda_handler
Runtime: python3.9
CodeUri: ./lambda_functions/LF1
Description: 'CCBD Assignment 2: Lambda function to index photos'
MemorySize: 256
Timeout: 30
Role: 'arn:aws:iam::958611120422:role/service-role/A2-LF1-index-photos-role-wp5z7lis'
Layers: [arn:aws:lambda:us-east-1:770693421928:layer:Klayers-python38-opensearch-py:1,arn:aws:lambda:us-east-1:770693421928:layer:Klayers-python38-requests:24]
Events:
S3PutObjectEvent:
Type: S3
Properties:
Bucket: !Ref PhotoAlbumBucket
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix
Value: images/
A2LF2:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: A2_LF2
Handler: lambda_function.lambda_handler
Runtime: python3.9
CodeUri: ./lambda_functions/LF2
Description: 'CCBD Assignment 2: Lambda function to search photos in Elastic Search'
MemorySize: 256
Timeout: 30
Role: 'arn:aws:iam::958611120422:role/service-role/A2-LF2-search-photos-role-o6u2gzjt'
Layers: [arn:aws:lambda:us-east-1:770693421928:layer:Klayers-python38-aws-requests-auth:16,arn:aws:lambda:us-east-1:770693421928:layer:Klayers-python38-requests:24]
Events:
PhotoAlbum:
Type: Api
Properties:
Path: /search
Method: GET
## required for S3 upload to trigger Lamdba
LambdaInvokePermission:
Type: 'AWS::Lambda::Permission'
Properties:
FunctionName: !GetAtt A2LF1.Arn
Action: 'lambda:InvokeFunction'
Principal: 's3.amazonaws.com'
SourceAccount: !Sub ${AWS::AccountId}
SourceArn: !GetAtt PhotoAlbumBucket.Arn