Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Created September 22, 2020 01:15
Show Gist options
  • Select an option

  • Save thanakijwanavit/9f024778c9175555fec5564c5afe1184 to your computer and use it in GitHub Desktop.

Select an option

Save thanakijwanavit/9f024778c9175555fec5564c5afe1184 to your computer and use it in GitHub Desktop.
search deployment template 2
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
villa-search-2
Sample SAM Template for villa-search-2
Globals:
Function:
Timeout: 3
Resources:
LambdaSearch:
Type: AWS::Serverless::Function
Properties:
CodeUri: search/
Handler: app.search
Runtime: python3.8
Layers:
- arn:aws:lambda:ap-southeast-1:770693421928:layer:Klayers-python38-pandas:16
- arn:aws:lambda:ap-southeast-1:394922924679:layer:cloudsearch-layer:1
DeepleSearch:
Type: AWS::Serverless::Function
Properties:
CodeUri: deepleAdapter/
Handler: app.deepleSearch
Runtime: python3.8
Timeout: 30
MemorySize: 3008
Environment:
Variables:
SEARCH_FUNCTION: !Ref LambdaSearch
Policies:
- LambdaInvokePolicy:
FunctionName: !Ref LambdaSearch
Layers:
- arn:aws:lambda:ap-southeast-1:394922924679:layer:lambda-layer:2
Events:
DeepleSearchEvent:
Type: Api
Properties:
Path: /deeplesearch
Method: post
RestApiId: !Ref DeepleSearchApi
DeepleSearchApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
DefaultAuthorizer: AWS_IAM
EndpointConfiguration:
Type: EDGE
MethodSettings:
- DataTraceEnabled: 'true'
HttpMethod: "POST"
LoggingLevel: INFO
ResourcePath: "/"
CachingEnabled: 'false'
MetricsEnabled: 'true'
OrismaSearch:
Type: AWS::Serverless::Function
Properties:
CodeUri: orismaAdapter/
Handler: app.orismaSearch
Runtime: python3.8
Timeout: 30
MemorySize: 3008
Environment:
Variables:
SEARCH_FUNCTION: !Ref LambdaSearch
Policies:
- LambdaInvokePolicy:
FunctionName: !Ref LambdaSearch
Layers:
- arn:aws:lambda:ap-southeast-1:394922924679:layer:lambda-layer:2
Events:
OrismaSearchEvent:
Type: Api
Properties:
Path: /orismaSearch
Method: get
RestApiId: !Ref OrismaSearchApi
OrismaSearchApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
Auth:
DefaultAuthorizer: AWS_IAM
EndpointConfiguration:
Type: REGIONAL
MethodSettings:
- DataTraceEnabled: 'true'
HttpMethod: "POST"
LoggingLevel: INFO
ResourcePath: "/"
CachingEnabled: 'false'
MetricsEnabled: 'true'
OrismaCloudFront:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
- DomainName: !Sub "https://${OrismaSearchApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/orismaSearch/"
Id: orismasearchorigin
ConnectionTimeout: 5
CustomOriginConfig:
HTTPPort: '80'
HTTPSPort: '443'
OriginProtocolPolicy: https-only
Enabled: 'true'
Comment: OrismaCloudSearch
DefaultCacheBehavior:
TargetOriginId: orismasearchorigin
SmoothStreaming: 'false'
ForwardedValues:
QueryString: 'true'
ViewerProtocolPolicy: allow-all
MinTTL: '100'
ViewerCertificate:
CloudFrontDefaultCertificate: 'true'
Outputs:
SearchFunction:
Description: "search Function"
Value: !GetAtt LambdaSearch.Arn
SearchIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt LambdaSearchRole.Arn
DeepleEndpoint:
Description: "endpoint for post request by postman"
Value: !Sub "https://${DeepleSearchApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/deeplesearch/"
DeepleSearchApi:
Value: !Ref DeepleSearchApi
OrismaEndpoint:
Description: "endpoint for post request by postman"
Value: !Sub "https://${OrismaSearchApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/orismaSearch/"
OrismaSearchApi:
Value: !Ref OrismaSearchApi
OrismaCloudFrontApi:
Value: !GetAtt OrismaCloudFront.DomainName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment