[PYTHON] A swampy story when using firebase on AWS lamda

I was addicted to Onuma when I was developing a product to participate in a hackathon, so I will write an article. I'm tracing the memory of about half a year ago, so it may be missing here and there. Also, please note that details such as creating an aws account and installing aws cli will not be described.

environment

・ MacOS Catalina

$ sw_vers
ProductName:	macOS
ProductVersion:	11.1
BuildVersion:	20C69

What I was trying to do

When the facial expression is recognized by the ios camera, take a picture and upload it to AWS S3. Triggered by the completion of uploading, the lmada function starts running and passes the uploaded image to the facial expression recognition API called AWS Recognition. Then, save the numerical value of the facial expression returned from the API in firebase. I was trying to make a product in which the browser acquires the saved information and displays it as a graph.

procedure

① AWS confing settings Since it was my first AWS, the setting of this part at the beginning was quite a demon. However, once you understand it, there is nothing here.

$ aws configure --profile user1
AWS Access Key ID [None]: {access key(Each one)}
AWS Secret Access Key [None]: {Secret access key(Each one)}
Default region name [None]: ap-northeast-1
Default output format [None]: json

(2) Description of lamda function * Source code will be omitted. There was a rainy day Onuma point here. I hit the API and got the data that quantified the facial expression, but the firebase admin SDK was not reflected well and I could not save the data.

A deadly battle that lasts for several hours. (Please stop fighting for death in a few hours. I wrote it after understanding this too.) At the end, it turned out that the cause was the lamda function, and the python runtime (the lamda function was written in python). (Because I was doing it) I only set it. However, the firebase admin SDK did not run well due to a runtime error due to some C code.

In the end, I was able to solve it by setting the lamda function to C language with a custom runtime.


At this point, all you have to do is get the data stored in the firestore from your browser, so it's easy.

I thought **, but ** I seemed to be addicted to the swamp related to API (the teammate who was in charge), and it was quite tough.

Impressions

At first glance, APIs and external libraries are magical, but when you actually use them, they are unfamiliar, so I think you may get stuck in a swamp. (It may be common sense for active engineers, but it was magical for me who is inexperienced) The teacher is better, "I can not use it unless I can make an external library by myself. That's exactly what I remembered now, and I thought it was necessary to understand the specifications by looking at github and the source code, and to be able to think about the cause of the error.

Also, when I touched AWS for the first time this time, I felt like I was itching to "touch AWS", but my teacher said, "You probably don't understand 1% of AWS yet. Yo. " It feels scary.

In conclusion, it was fun so I would like to play with AWS more.

Thank you for visiting.

Recommended Posts

A swampy story when using firebase on AWS lamda
A addictive story when using tensorflow on Android
SoC FPGA: A small story when using on Linux
Check types_map when using mimetypes on AWS Lambda (Python)
A little trick to know when writing a Twilio application using Python on AWS Lambda
Addictive points when downloading files using boto on AWS Lambda
A story that stumbled when using pip in a proxy environment
A memorandum when using beautiful soup
The story that a hash error came out when using Pipenv
Using a serial console on Ubuntu 20.04
A note on using tab completion when running Python interactively on Windows
A story about using Python's reduce
What I stumbled upon when using CodeIgniter on a Linux server
intel Atom (notebook) Frequent petit freezes when using linux on a PC.
A story about deploying a Twitter-linked app created using Flask + gunicorn on Heroku
Knowledge when making a bot using discord.py
Run TensorFlow on a GPU instance on AWS
A struggle when installing pyenv on Cygwin
Error, warning when using TensorFlow on Mac
A story about a 503 error on Heroku open
CPU usage is 100% when using pygame on Ubuntu 16.04
Periodically run a python program on AWS Lambda
Consider a cloud-native WebSocket application running on AWS
A story about simple machine learning using TensorFlow
Build a WardPress environment on AWS with pulumi
Try Tensorflow with a GPU instance on AWS
Try using a QR code on a Raspberry Pi
Python development on Ubuntu on AWS EC2 (using JupyterLab)
A story about displaying article-linked ads on Jubatus
A story about running Python on PHP on Heroku
A story when a Python user passes a JSON file
Create a GUI on the terminal using curses
A story stuck with Memory Error and No space left on device on AWS EC2
A story that was convenient when I tried using the python ip address module
A story that got stuck when trying to upgrade the Python version on GCE