-
Notifications
You must be signed in to change notification settings - Fork 0
/
samTemplate.yaml
128 lines (119 loc) · 3.55 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
AWSTemplateFormatVersion: 2010-09-09
Transform: "AWS::Serverless-2016-10-31"
Description: P1
Resources:
photobucket122:
Type: AWS::S3::Bucket
Properties:
BucketName: photobucket122
LF1:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda_function.lambda_handler
Runtime: python3.8
CodeUri: ./LF1
Description: ''
MemorySize: 128
Timeout: 3
Role: 'arn:aws:iam::920848894865:role/service-role/index-photos-role-ycr1189e'
Layers:
- 'arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-boto3:51'
- >-
arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-requests:15
- 'arn:aws:lambda:us-east-1:920848894865:layer:dependencies:1'
Events:
BucketEvent1:
Type: S3
Properties:
Bucket:
Ref: photobucket122
Events:
- 's3:ObjectCreated:Put'
LF2:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda_function.lambda_handler
Runtime: python3.9
CodeUri: ./LF2
Description: ''
MemorySize: 128
Timeout: 300
Role: 'arn:aws:iam::920848894865:role/service-role/search-photos-role-xlammunu'
Layers:
- >-
arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-requests:15
- 'arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-boto3:51'
- 'arn:aws:lambda:us-east-1:920848894865:layer:dependencies:1'
Events:
PhotoApi:
Type: Api
Properties:
Path: /search
Method: GET
PhotoApi:
Type: AWS::ApiGateway::RestApi
Properties:
BodyS3Location:
Bucket: codepipeline121
Key: "ai-photo-search-swagger.yaml"
Description: "Rest api having search photos and upload photos methods."
Name: PhotoApi
FailOnWarnings: true
EndpointConfiguration:
Types:
- "REGIONAL"
PermissionForAPIToLF2:
Type: "AWS::Lambda::Permission"
Properties:
Action: lambda:InvokeFunction
FunctionName: !GetAtt LF2.Arn
Principal: apigateway.amazonaws.com
SourceAccount: !Ref "AWS::AccountId"
SourceArn: !Join
- ""
- - "arn:aws:apigateway:us-east-1::/restapis/"
- !Ref PhotoApi
- "/resources/*/methods/GET"
PermissionForS3ToLF1:
Type: "AWS::Lambda::Permission"
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref LF1
Principal: s3.amazonaws.com
SourceAccount: !Ref "AWS::AccountId"
SourceArn: "arn:aws:s3:::photobucket122"
OpenSearchServiceDomain:
Type: AWS::OpenSearchService::Domain
Properties:
DomainName: 'photosearch'
EngineVersion: 'OpenSearch_1.0'
ClusterConfig:
InstanceCount: '1'
InstanceType: 't3.small.search'
EBSOptions:
EBSEnabled: true
Iops: '0'
VolumeSize: '10'
VolumeType: 'gp2'
AccessPolicies:
Version: '2012-10-17'
Statement:
-
Effect: 'Allow'
Principal:
AWS: "*"
Action: es:*
Resource: 'arn:aws:iam::920848894865:domain/photosearch'
DomainEndpointOptions:
EnforceHTTPS: true
EncryptionAtRestOptions:
Enabled: true
NodeToNodeEncryptionOptions:
Enabled: true
PhotoApiDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn: [PhotoApi]
Properties:
Description: The v1 deployment of photo album api
RestApiId: !Ref PhotoApi
StageName: v1