Blog post

Serverless deployment

/partners/client-logo-1.svg
/partners/client-logo-2.svg
/partners/client-logo-3.svg
/partners/client-logo-4.svg
/partners/client-logo-5.svg
/partners/client-logo-6.svg

Serverless deployment

Nikola Ivanović

2021-04-08

We’ve covered Serverless deployment, and as you can see, it is effortless and requires minimal configuration.

In this article, we will cover a simple example of how to compile JavaScript code with Babel.

If you haven’t, install Serverless on your computer:

1npm install serverless -g

And clone this example:

1serverless install -u https://github.com/serverless/examples/tree/master/aws-node-function-compiled-with-babel -n  aws-node-function-compiled-with-babel

Check out how the serverless.yml file is configured.

This function enables using the latest JavaScript language features without waiting for AWS to provide new Node environments.

First, we will do the setup:

1npm install

and then the deployment:

1serverless deploy

And yes, that is all you have to do to deploy this useful compiler function.  

Now you can invoke the Lambda directly and see the resulting log:

1serverless invoke --function hello --log

The expected result in your command line should be something like this:

1{
2    "statusCode": 200,
3    "body": {
4        "message": "Success!"
5    }
6}
7--------------------------------------------------------------------
8START RequestId: 4388eeaffe-11e6-9e1bde31ed2e43 Version: $LATEST
92021 16:22:07.748 (+01:00)	4388eeaffe-11e6-9e1bde31ed2e43	{ response: { statusCode: 200, body: { message: 'Success!' } } }
10END RequestId: 4388eeaffe-11e6-9e1bde31ed2e43
11REPORT RequestId: 4388eeaffe-11e6-9e1bde31ed2e43	Duration: 23.13 ms	Billed Duration: 100 ms 	Memory Size: 1024 MB	Max Memory Used: 17 MB

There are many more great examples on the Serverless examples page, where you can even choose which platform and language you want for easier searching.

Conclusion

The serverless platform is a relatively new technology that is the future of web development, especially combined with AWS services. It has outstanding scaling, which you pay based on several requests. You don’t pay anything if your server is idle.

One more thing that will make this combo very popular is that configuration is fast and easy, which lets developers focus on other more important things on their web-applications.

Nikola Ivanović

2021-04-08

Nikola is JavaScript developer passionate about React, CSS, Animations and UX design. Loves frontend work but he is not afraid to touch backend.

See more blogs:

Leave your thought here

Your email address will not be published. Required fields are marked *