Created
February 19, 2021 16:06
-
-
Save pacarvalho/0146c7df44b43bc12fd9f6686083944e to your computer and use it in GitHub Desktop.
SAM Template for Collaborative Filter Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Transform: AWS::Serverless-2016-10-31 | |
Description: > | |
collaborative-filtering | |
SAM project for collaborative-filtering | |
Imports data from SQL and exports results to S3 | |
Parameters: | |
RdsPassword: | |
Description: "What is the DB password?" | |
Type: String | |
Resources: | |
RecommendationFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
CodeUri: src/trainer_function | |
Handler: app.lambda_handler | |
Runtime: python3.7 | |
MemorySize: 4096 | |
Timeout: 900 | |
VpcConfig: | |
SecurityGroupIds: | |
- !Ref RecommendationFunctionSecurityGroup | |
SubnetIds: | |
- add-here-subnet-1-id | |
- add-here-subnet-2-id | |
Environment: | |
Variables: | |
BUCKET: !Sub "${EnvironmentValue}-collaborative-filtering" | |
RDS_ENDPOINT: add-here-db-endpoint | |
RDS_USERNAME: add-here-db-username | |
RDS_PASSWORD: !Ref RdsPassword | |
RDS_DB_NAME: add-here-db-name | |
SURPRISE_DATA_FOLDER: /tmp | |
Policies: | |
- AWSLambdaExecute # Managed Policy | |
- Version: "2012-10-17" # Policy Document | |
Statement: | |
- Effect: Allow | |
Action: | |
- logs:CreateLogGroup | |
- logs:CreateLogStream | |
- logs:PutLogEvents | |
- s3:GetOBject | |
- s3:PutObject | |
- s3:ListBucket | |
Resource: "*" | |
Events: | |
InvocationLevel: | |
Type: Schedule | |
Properties: | |
Schedule: "rate(1 hours)" | |
Layers: | |
- the-arn-of-my-python-scikit-surprise-layer | |
RecommendationFunctionSecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
VpcId: add-here-vpc-id | |
GroupDescription: The relevant RDS instance will be configured to allow this security group to access it | |
OutputBucket: | |
Type: "AWS::S3::Bucket" | |
Properties: | |
BucketName: !Sub "${EnvironmentValue}-collaborative-filtering" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment