package.jsonfile. To do that, let’s change the directory to
hello-appand run the following command:
app.jsfile and define our function.
fakernode nodule to generate random country, let’s install it using the
npmpackage manager. Since it’s the first package that we will install, npm will generate
package-lock.jsonfile. Later on, in the Dockerfile we will use
npm ci --only=productioncommand, which will read the lock file, and install all the dependencies for the project.
Let’s use the second option and build a docker image. We need to create a
Dockerfile with the following content first:
Now, let’s build a docker image
Finally, we can create a lambda function using the console. Let’s call it
hello-app and select the docker image that we just uploaded.
To access the lambda function we can add API Gateway trigger.
Test it with curl