<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Udayy Bambal on Medium]]></title>
        <description><![CDATA[Stories by Udayy Bambal on Medium]]></description>
        <link>https://medium.com/@udayy.bambal.devops?source=rss-5dce2e22aa14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eV4npeDVQ1xzSL50G9SHcw.jpeg</url>
            <title>Stories by Udayy Bambal on Medium</title>
            <link>https://medium.com/@udayy.bambal.devops?source=rss-5dce2e22aa14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:20:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@udayy.bambal.devops/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Serverless Framework for Node HTTP API on AWS.]]></title>
            <link>https://medium.com/@udayy.bambal.devops/serverless-framework-for-node-http-api-on-aws-15cb56972c15?source=rss-5dce2e22aa14------2</link>
            <guid isPermaLink="false">https://medium.com/p/15cb56972c15</guid>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Udayy Bambal]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 13:46:30 GMT</pubDate>
            <atom:updated>2023-03-03T14:23:28.644Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Demonstration of how to make a simple HTTP API with Node.js running on AWS Lambda and API Gateway using the Serverless Framework.</blockquote><p>Hey ya Geeks!</p><p>Lets start with a problem statement.</p><p>To manage infrastructure as an DevOps engineer, lets say we need to create an EC2, Dynamo db, AWS Lambda / API gateway and S3 for code versioning. There are so many things to maintain for doing this manually.<br>Using Terraform we can do this programmatically. But the problem here is we still have to write a long script.</p><p>Fortunately, we have a small upgrade or say an alternate way which can be use to create this infrastructure known as ‘Serverless Framework’.</p><p>Lets understand this through a small <strong>To-Do web application</strong>.<br>Now, consider this application is live and running. What do you think for how much time users will access this web application in 24 hours? Being tremendous ambitious, users will access it maximum for more or less than an hour. <br>Lets assume that charges to run an application is 100 bucks for an hour. Running it for 24 hours will cost 2400 bucks. Doesn’t look justified right?</p><p><strong>Serverless Architecture</strong> is an alternate way for this problem. It is an <strong>event driven system</strong> which triggers a function for any event in Todo app.</p><blockquote>To learn Serverless framework, we must look into:<br><strong>1. AWS cloud formation<br>2. AWS Lambda<br>3. AWS API Gateway<br>4. AWS Dynamo db<br>5. AWS S3 (Host)</strong></blockquote><p>Using this architecture, your cost will be reduced to 90% for static application.<br>For dynamic application we need a server for 24 hour running.<br>(or else with AWS lambda, we can use python templates where we can show HTML pages)</p><h3><strong>Serverless Framework</strong></h3><p>A top demand tool in 2023.<br><a href="https://www.serverless.com/"><strong>serverless.com</strong></a><strong> : </strong>All-in-one development solution for auto-scaling apps in AWS Lambda with the Serverless Framework and Serverless Monitoring.<br><strong>It is mostly focused on Backend API’s</strong>.<br><em>Note: This article is solely for knowledge purpose and is not sponsored by anyone.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUhB30pf0g4HCehFuMlzLw.png" /></figure><p>Its a free platform (for solo devs), so create your account here as fast as you can.</p><p>Now we will go step-wise to keep ourselves high.</p><p>To run a Serverless we actually need a server to install Serverless . Read it again 😅.<br>Considering <strong>Ubuntu</strong> as a local server to build this infrastructure here.</p><h3>Step 1 :</h3><p>We must have <strong>Node</strong> on our machine. Install it first.</p><ul><li>Run the apt update command on your Ubuntu Linux to update package repository contents database.</li></ul><pre>sudo apt update</pre><ul><li>After system update, install Node.js 14 on Ubuntu 22.04|20.04|18.04 by first installing the required repository.</li></ul><pre>curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -</pre><ul><li>Once the repository is added, you can begin the installation of Node.js 14 on Ubuntu Linux:</li></ul><pre>sudo apt -y install nodejs</pre><ul><li>Verify the version of Node.js installed.</li></ul><pre>$ node  -v<br>$ npm -v</pre><h3>Step 2 :</h3><p>Now to install Serverless Framework — click on <a href="https://www.serverless.com/framework/docs/getting-started">Documentation</a>page and follow the instructions:</p><ul><li>Install the serverless CLI via NPM:</li></ul><pre>sudo npm install -g serverless</pre><p>We have serverless installed host. Start building your project now.</p><p>Type ‘Serverless’ and enter-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*0gF0ylZTlE-huyrLFKh5xQ.png" /><figcaption>Serverless projects list</figcaption></figure><p>Using down arrow select ‘Node.js — HTTP API’ and give a name to project as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*yF8OdK8vj9j0m9c4JRlLEQ.png" /></figure><p>Do not deploy application for now as we need to set the platform, region, etc.</p><ul><li>Type ‘<strong>ls</strong>’ and you will see your ‘<strong>first-serverless-hello-api</strong>’ folder</li><li>Change the directory by typing ‘<strong>cd first-serverless-hello-api</strong>’ and again ‘ls’ to look into folder.</li><li>You will have ‘<strong>README.md</strong>’ , ‘<strong>index.js</strong>’ and ‘<strong>serverless.yml</strong>’ already available.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*vgPIufTkz2CYIpA2ov1A5Q.png" /></figure><h3>Step 3 :</h3><p>Basically, serverless.yml is a configuration file for connecting AWS account. That means, you will require ‘<strong>access keys</strong>’ and ‘<strong>IAM user</strong>’. And give access of all the essential functionalities to IAM user and add the respective <strong>user keys</strong> through <strong>AWS CLI</strong> to the host where serverless is installe<strong>d.</strong></p><ol><li>Open <strong>IAM Dashboard</strong> on AWS account and create a user ‘serverless-admin’ by clicking ‘<strong>Create users</strong>’. Click Next.</li><li>Now give permissions for all the functionalities we are going to use as mentioned above.</li><li>Click on ‘<strong>Create user</strong>’.</li><li>In <strong>Security Credential</strong> column, click on ‘<strong>Create Access Keys</strong>’</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*ZyQRRa_q5eltIUuryfmP6g.png" /></figure><p>5. Select ‘<strong>Command Line Interface</strong>’ and ‘<strong>Next</strong>’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*VdWRLAl2zmIV9UZnA_s6iQ.png" /></figure><p>6. Click on ‘<strong>Create access keys</strong>’ and tadaaaaa you have access keys ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*D5Ala1Q7gaeq1ekouHTkyg.png" /></figure><h3><strong>Step 4 :</strong></h3><p>On Ubuntu local server type ‘<strong>aws configure</strong>’ command and enter the access and secret access keys and ‘Default region name’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*7A7-bK1WH_CDWHAstcROEw.png" /></figure><p>This is the access key to deploy Todo application on AWS account.</p><h3>Step 5 :</h3><p>Lets just understand the <strong>serverless.yml</strong> file first.</p><ul><li>Type ‘<strong>vim serverless.yml</strong>’ and start to understand a file as shown</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*zXhyOKUTW4VBdmWRCELMmQ.png" /></figure><ul><li>Here ‘<strong>provider</strong>’ is creating AWS lambda function which will be used by Node.js.</li><li>And the ‘<strong>functions</strong>’ will have the name of the lambda function, the path, event, etc.</li></ul><h3>Step 6 :</h3><ul><li>Now type ‘<strong>serverless deploy</strong>’ command</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*gqNvBlzDjIh2mHuxRV0uUA.png" /></figure><ul><li>Now check the GET hyperlink from above image. It will look something like this.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*SsLWntiVMldqniQRLdYdIw.png" /></figure><h3>Step 7 :</h3><ul><li>For serverless dashboard to display the application use command ‘<strong>serverless login</strong>’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*GqBcWgeyQ0S1ipHAjqV8lw.png" /></figure><ul><li>Select ‘<strong>Serverless Framework Dashboard</strong>’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*TyIKQRsolY2-PyhsZSnLCQ.png" /></figure><ul><li>Copy the generated URL and paste it in browser. It will something look like this.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*OSX2PCxC3JgJflfLqVyB4Q.png" /></figure><ul><li>And click ‘<strong>continue to dashboard</strong>’.</li><li>On Ubuntu host type ‘<strong>sls deploy</strong>’. If not showing any changes on dashboard try to re-deploy.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*2efZIo7Cd-0RDLdUjLrijg.png" /></figure><ul><li>Hitting the generated URL above, you will get all of the dashboard where the complete analysis of traffic will be displayed. 😎</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGUFBS1rak9RsydbUfnPAQ.png" /></figure><p><strong>Wait a minute!</strong></p><p>What’s with <strong>AWS Dynamo db </strong>and<strong> S3 </strong>?</p><h3>Amazon S3</h3><p>Lets check with AWS S3. Its simple, whatever code package we have, is stored in S3.</p><ul><li>Go to Amazon S3</li><li>In bucket list click on the name ‘first-serverless-hello…’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*mO7q9KAW_GYPt3JNN5PefQ.png" /></figure><h3>Dynamo db</h3><p>Dynamo db is basically No SQL database. Where respective values are directly stored in variables. (Psst.. you can literally upload and assign a whole movie in a variable 😎). We are using its Billing mode as Pay-Per-Request. Check it out..</p><h3>Step 8 :</h3><p>Fork the repository by clinking on the link below:<br><a href="https://github.com/udaybambal/aws-node-http-api-project.git">https://github.com/udaybambal/aws-node-http-api-project.git</a><br>and switch your branch to ‘<strong>dev</strong>’.</p><p><em>This template demonstrates the source code repository of simple HTTP API with Node.js running on AWS Lambda and API Gateway using the Serverless Framework.</em></p><h3>Step 9 :</h3><ul><li>Switch your branch to ‘<strong>dev</strong>’.</li><li>Open ‘<em>serverless.yml</em>’ file.</li><li>you can change ‘<em>org: udaybambal</em>’ as per your desired name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*MQzEFbhEK-_uYRvzAFIv0A.png" /></figure><ul><li>Scroll down and check code for ‘<em>resources:</em>’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*yWP3pTq3kUkgP--oJ8Pv5A.png" /></figure><p>You can see ‘<strong><em>BillingMode: PAY_PER_REQUEST</em></strong>’</p><ul><li>We must create a separate git folder in Ubuntu host for database access. Directly cloning our repository from git can create a new folder.</li></ul><h3>Step 10:</h3><ul><li>In ‘<strong>serverless-projects</strong>’ folder, type command:<br>:<em>~/serverless-projects$ git clone https://github.com/udaybambal/aws-node-http-api-project.git</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ntImrRuR7Gm4Ml0tyheguA.png" /></figure><ul><li>To run any java script application you need node_modules<br>For this type command ‘<em>npm install</em>’. Thats it!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Mv-RWynXKjM2mDZK5BYZQ.png" /></figure><ul><li>Now, switch to a new branch ‘dev’ using command ‘checkout’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*ruq3UqMmH3jJSnWrOPR9bA.png" /></figure><ul><li>Finally run command ‘<em>serverless --org=udayyb</em>’.<br>Do you remeber this command is displayed when you login to serverless dashboard ?</li></ul><p>Now you have option displayed as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*Dn2uDYgOPJl3O87-zPpLCA.png" /></figure><ul><li>Select ‘create a new app’.</li><li>Write the application name as ‘aws-node-http-api-project’.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*o8xwFlJY54pf4TfPyOdHyQ.png" /></figure><ul><li>Approach as ‘Yes’. And deployment will get start.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*AuooNGsi1b73x5sJkju2-Q.png" /></figure><p>Check out the endpoints created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*t3_rTjTPEq8c3wV9vZmFnQ.png" /></figure><p>For your confirmation, you can test these API’s using postman</p><p>This whole process is for application back-end. <br>With some really cool frond-end skills you can create your ‘COOL WEB-APPLICATION’.</p><p><strong><em>Conclusion:<br></em></strong>Serverless has enabled developers to focus more on application logic rather than infrastructure, leading to faster delivery of features and improved agility.<br>The pay-per-use pricing model of serverless has made it more cost-effective compared to traditional server-based architectures, especially for applications with varying traffic patterns.</p><p>By removing the need for managing and provisioning infrastructure, serverless architectures have significantly reduced the time and resources required for deployment and maintenance.</p><p>However, serverless also has its limitations, such as cold start times and the lack of control over underlying infrastructure. Therefore, it’s important to evaluate the suitability of serverless for each specific use case and strike a balance between serverless and server-based architectures to achieve the best outcomes in DevOps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15cb56972c15" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>