<?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 Vikram E on Medium]]></title>
        <description><![CDATA[Stories by Vikram E on Medium]]></description>
        <link>https://medium.com/@vikrame?source=rss-54f0f87e128c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*H3a0OQpV29ofkwLd.</url>
            <title>Stories by Vikram E on Medium</title>
            <link>https://medium.com/@vikrame?source=rss-54f0f87e128c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:19:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vikrame/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[Build a Chatbot using Amazon Lex and AWS Lambda]]></title>
            <link>https://medium.com/@vikrame/build-a-chatbot-using-amazon-lex-and-aws-lambda-b90c75ea6626?source=rss-54f0f87e128c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b90c75ea6626</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[amazon-lex]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Vikram E]]></dc:creator>
            <pubDate>Mon, 15 May 2017 02:43:28 GMT</pubDate>
            <atom:updated>2017-05-15T12:46:35.600Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*UfDH65tcj5dtsusnxklcTA.png" /><figcaption>Amazon Lex Chatbot</figcaption></figure><p>A chatbot is a service, powered by rules that are based on Artificial Intelligence(AI) and Machine Learning algorithms, that you interact with a chat interface. It could be a fun service or a real world service like Facebook Messenger, Slack etc to provide users more engaging experience. Oh yeah! a big opportunity all big companies are capitalizing and building one as you read this story.</p><p>How does Amazon Lex work? How to build your simple chatbot using AWS Lambda? We’re going to find out right away. To visualize a chatbot, we will create a bot to start and stop AWS EC2 servers.</p><h4><strong>Amazon Lex</strong></h4><p>First things first, login to <a href="https://aws.amazon.com/console/">aws management console</a> and open Lex to create a custom bot. Once we create a bot(bot name, IAM role etc), next step is to create a custom Intent and a custom slot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tz6aR6tsu1HXEirWFWncyA.png" /><figcaption>Create custom Lex bot</figcaption></figure><p>Let’s get familiar with few basic terms as we get started. An <strong>intent</strong> represents an action that fulfills a user’s request via chat. Create a custom Intent and name it <em>startServer </em>to start an EC2 Instance. A <strong>slot </strong>represents list of values used by the Intent. Custom slot <em>instance</em> of a custom slot type INSTANCE_NAME take values <em>dev, qa, prod, uat. </em><strong>Sample Utterance</strong><em> </em>is structured text that links the intent to the likely words/sentences types by the user. For example “I want to start a server”. This intent will be fulfilled by a AWS Lambda Function. You can add your prompt and Goodbye optional message to enrich the chat experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T3IoHXprG_Q6parDknQtKg.png" /><figcaption>start server intent</figcaption></figure><h4><strong>AWS Lambda</strong></h4><p>Yes! we will use the cool stuff in cloud computing — <em>serverless architecture</em>. AWS lambda lets you run code without provisioning or managing servers. Login to <a href="https://aws.amazon.com/console/">aws management console</a> and create Lambda function. Name your function and choose language in runtime section, in my case it is python 2.7</p><p>In the first section we will import boto3 library and define <em>lambda_handler </em>function to route the control to <em>dispatch</em> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JX9QD5DZMNJyCM-UsVTO3g.png" /><figcaption>lambda_handler</figcaption></figure><p>In the <em>dispatch</em> function, intent_name is extracted from the intent request and the control is transferred to the actual code to start the EC2 server <em>start_ec2</em> function. Based on the value from the current intent slot value instance name tag is extracted. Use boto3 AWS SDK for python function <em>start_instances </em>function to start the EC2 server. Finally return <em>close</em> <em>dialogAction</em> to Informs Amazon Lex not to expect a response from the user and provide close message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E14Dm5RDmfgg4uptZUjqmA.png" /><figcaption>start ec2 server</figcaption></figure><h4><strong>Demo</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NqDTklALGdFgio7KdbmPXg.png" /><figcaption>demo</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FB7vlA8TsOZw%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DB7vlA8TsOZw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FB7vlA8TsOZw%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/909fc987999d2035eb81dfa280aadcc0/href">https://medium.com/media/909fc987999d2035eb81dfa280aadcc0/href</a></iframe><p>That’s a simple rule based chatbot.</p><p>This bot is very limited. It can only respond to very specific commands. If you say the wrong thing, it doesn’t know what you mean. It is only as smart as it is programmed to be. We only scratched the tip of the iceberg. This introduction can help you build an AI based chatbots using Machine Learning, it can use Natural Language Process(NLP) and get smarter as it learns from the conversations.</p><p>Time to invent one :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b90c75ea6626" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next Gen Big Data with AWS — Part 1]]></title>
            <link>https://medium.com/@vikrame/next-gen-big-data-with-aws-part-1-e3f79b37251f?source=rss-54f0f87e128c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3f79b37251f</guid>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[emr]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Vikram E]]></dc:creator>
            <pubDate>Mon, 09 Jan 2017 14:08:35 GMT</pubDate>
            <atom:updated>2017-01-09T14:08:35.748Z</atom:updated>
            <content:encoded><![CDATA[<p>Create EMR Cluster based on S3 Event</p><h4>Then and Now</h4><p>For years, organizations run their big data workloads on their in-house infrastructure. Their cluster are up and running even during off peak working hours. With AWS Cloud-based adaptation efforts, organizations benefit faster availability in market, lower cost and newer revenue opportunity.</p><h4>Use Case</h4><p>AWS Lambda to spin up an EMR Cluster based on S3 event(like put object) and tear down the cluster once the computation is done for optimized resource utilization. In this demo we will load a csv file to S3 bucket which send a event notification to AWS Lambda. Using <em>boto3</em> API in lambda function, we will create EMR Cluster.</p><h4>AWS Lambda Function</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQcjeT2d_AvOEoNi0c6b3w.png" /><figcaption>AWS Lambda Function</figcaption></figure><p>Configure AWS Lambda function with Python runtime to run this <a href="https://github.com/bigdatajunkies/awslambda/edit/master/createEMRCluster.py">code</a>. <em>boto3</em><strong><em>.</em></strong><em>client(‘emr’)</em> is low-level API client representing EMR. <em>run_job_flow</em> RunJobFlow creates and starts running a new job flow. We will configure EMR Instances with <em>InstanceType</em>, <em>InstanceRole</em> etc. Also set up <em>EMR_EC2_DefaultRole, EMR_DefaultRole</em> in the run_job_flow. Save and Test lambda function to make sure the configuration setup is good.</p><h4>S3 Event</h4><p>Create a bucket and set up Event Notification to send trigger to the lambda function. <em>ObjectCreated</em>(put, post, copy) events will the trigger function when object with csv suffix is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GO0L47ytiWU16iOVrUWkWQ.png" /><figcaption>S3 ObjectedCreated Event trigger</figcaption></figure><h4>Action</h4><p>Once a s3 object is created in the bucket, a EMR cluster is created. Log on to AWS EMR console to check the progress. You can specify the Instance Types and applications to be installed in the run_job_flow section of Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tDBO6w5JoCv1aNwAhNzT1A.png" /><figcaption>EMR Cluster Starting</figcaption></figure><h4>Next</h4><p>Set up SNS notification to trigger another Lambda function to add a step to EMR cluster. The step will run a hive/ spark job with the uploaded S3 file as input and load the output file to S3 bucket. Finally tear down the cluster when no more steps to run by setting <em>KeepJobFlowAliveWhenNoSteps</em> to False. Stay tuned for part 2.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3f79b37251f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS CloudWatch and Lambda]]></title>
            <link>https://medium.com/@vikrame/aws-cloudwatch-and-lambda-8fd8abb088dd?source=rss-54f0f87e128c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fd8abb088dd</guid>
            <category><![CDATA[aws-cloudwatch]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Vikram E]]></dc:creator>
            <pubDate>Sat, 07 Jan 2017 22:02:48 GMT</pubDate>
            <atom:updated>2017-01-07T22:02:48.051Z</atom:updated>
            <content:encoded><![CDATA[<h4>Watchdog Service</h4><h4>Reminder</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*jIBM5JrjzhyRVgOO8rGxgw.jpeg" /><figcaption>A Reminder !</figcaption></figure><p>Human mind is prone to wander, if you don’t stay focused you get sidetracked very easily, you get deviated away from your goals, which is rarely to something good. Reminders helps you from not getting distracted and stay put. This happened to me many times when I was interacting with AWS cloud services. As I get my hands-on on different services, I get distracted and I forget to turn the services off, which did cost me a several $$ . I wanted a watchdog like service which can come handy to monitor and abort AWS services based on a schedule. Gladly, AWS has <em>Cloudwatch</em> and <em>Lambda</em> services to my rescue. So I set out myself to try this solution and put to use.</p><h4>Serverless</h4><p>AWS Lambda makes it effortless to run code without any DevOps distractions. I write my code and AWS Lambda takes it from there. I put my Developer Hat on to bring forth logic without any worry about the infrastructure. It frees me from managing servers, continuous scaling and provisioning. I can set up my code to automatically trigger from Cloudwatch based on predefined schedules. I save time and money with AWS Lambda.</p><h4>Use Case</h4><p>EC2 and EMR are two frequently used services I would like to stop/ terminate at the end of the day(Reminder), basically to reduce my usage by stopping at regular intervals. CloudWatch Events allow me to create an event that is triggered at a specified time or interval in response to events that take place in my account.</p><h4>Create an EC2 Instance</h4><p>I created an EC2 Instance for this demo. I spun up a t2 micro instance type with default settings. After the configuration the instance is up and running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdy9x5YLqKENry1sT-LfLA.png" /><figcaption>EC2 Instance in Running State</figcaption></figure><h4>Step Up Lambda Function</h4><p>Open Lambda console and navigate to Configure Functions. I chose python as the run time environment so I can use boto3 API. To Keep the demo simple, I have given a reference to my EC2 instance ID. Create a new role and edit the policy as follows and finally create the function.</p><p>{<br> “Version”: “2012–10–17”,<br> “Statement”: [<br> {<br> “Effect”: “Allow”,<br> “Action”: [<br> “logs:CreateLogGroup”,<br> “logs:CreateLogStream”,<br> “logs:PutLogEvents”<br> ],<br> “Resource”: “arn:aws:logs:*:*:*”<br> },<br> {<br> “Effect”: “Allow”,<br> “Action”: [<br> “ec2:Start*”,<br> “ec2:Stop*”<br> ],<br> “Resource”: “*”<br> }<br> ]<br>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hMNtf92GUBlz7w3mSaTY1Q.png" /><figcaption>Configure Lambda Function</figcaption></figure><h4>Step Up CloudWatch Rule</h4><p>Open Cloudwatch console and navigate to Events to Create a new rule. Under Event selector choose schedule. I set up Cron Expression to trigger <em>stopEC2Instance</em> target Lambda function (00 3 * * ? *). This schedule will be triggered at 3 AM UTC every day(You can change to your preferred time zone). Min-00, Hours-3,*-Day, *-Month, ?-Day of week and *-Year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*khhp0GiSTlm4vTSotwpX5A.png" /><figcaption>Cloudwatch Event Schedule Rule</figcaption></figure><h4>In Action</h4><p>Based on the schedule, Cloudwatch Triggered my Lambda function and the EC2 Instance is stopped. Cloudwatch provides log information which includes start time, end time and lambda billed duration of the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDHBRsKz7e-mF2cYgG2XGg.png" /><figcaption>EC2 Instance in Stopping State</figcaption></figure><h4>Up Next</h4><p>A significant portion of my work involves another AWS service, Elastic Mapreduce(EMR). Next up is to extend this use case to terminate all running EMR clusters based on a trigger schedule event. I am planning to extend this use case to stop all instances which are in running state. This was a real fun project for me, where I learnt quite a lot of things. I am determined to come up with a cool use case for my next project.</p><p>Stay Tuned !!!</p><p>AWS ❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fd8abb088dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>