Attempting to do as much local development as possible to create a workflow to perform sentiment analysis on feedback.
- Docker && Docker Compose
- aws-cli
- sam-cli
The lambda for the project was generated using sam init --runtime python3.7 and the modified the names and structures.
The top level docker-compose pulls in the localstack to help develop and test the stack offline.
The idea is that the workflow this would involve a .csv file uploaded to s3 everyday containing the previous days feedback. The lambda would run the feedback through textblob for simple NLP to detect sentiment. If feedback is negative it can be sorted into another bucket or just alerted on.
Pull up localstack.
docker-compose up -dCreate an s3 bucket to receive the feedback.
aws --endpoint_url=http://localhost:4572 s3 mb s3://daily-feedbackUpload some feedback
aws --endpoint_url=http://localhost:4572 s3 cp samples/feedback_01.csv s3://daily-feedback --acl public-readBuild the lambda with requirements
sam build -b ./build --user-container -m ./feedback-sentiment-analysis/requirements.txtsam local generate-event s3 put --bucket daily-feedback --key feedback_01.csv | sam local invoke --docker-network feedback-sentiment-analysis_sentiment -t build/template.yaml FeedBackSentimentAnalysisThe above command is telling sam to build our application against the container in order have textblob available to the lambda.
We are generating an example s3 put event with the information we pushed into localstack and piping that into the command to invoke the lambda.
While invoking the lambda we are telling it to invoke the particular FeedbackSentimentAnalysis function as defined in the template.yml and to attach to the running docker-network generated when starting localstack with docker-compose.