<?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 GAURAV LANJEKAR on Medium]]></title>
        <description><![CDATA[Stories by GAURAV LANJEKAR on Medium]]></description>
        <link>https://medium.com/@gaurav.lanjekar?source=rss-a02a52d05c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Z6KJeYB0MXnIskyI.</url>
            <title>Stories by GAURAV LANJEKAR on Medium</title>
            <link>https://medium.com/@gaurav.lanjekar?source=rss-a02a52d05c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:57:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gaurav.lanjekar/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[Building a Financial Advisor using Bedrock Agents]]></title>
            <link>https://medium.com/@gaurav.lanjekar/building-a-financial-advisor-using-bedrock-agents-a8bc3b390cd4?source=rss-a02a52d05c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8bc3b390cd4</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[aws-bedrock]]></category>
            <dc:creator><![CDATA[GAURAV LANJEKAR]]></dc:creator>
            <pubDate>Wed, 29 Nov 2023 10:55:23 GMT</pubDate>
            <atom:updated>2023-11-29T10:55:23.152Z</atom:updated>
            <content:encoded><![CDATA[<p>I was super excited last night when bedrock agents became generally available and I could get my hands on it for the first time.</p><p>So, I decided to take it for a spin and build a financial advisor that can help me make investment decisions :)</p><h3>Why Bedrock</h3><p>Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon via a single API.</p><p>It makes it super easy to swap LLMs at will and to avoid vendor lock-in (apart from Amazon ofcourse :) )</p><h3>Bedrock Agents architecture</h3><p>Agents are able to orchestrate and analyze the task and break it down into the correct logical sequence using the FM’s reasoning abilities. So basically they use LLMs as their logical engine. Which is a very new way to write business logic</p><p>Some popular agent implementations are</p><ol><li><a href="https://platform.openai.com/docs/assistants/how-it-works">OpenAI assistant</a></li><li><a href="https://python.langchain.com/docs/modules/agents/">Langchain Agents</a></li></ol><p>Bedrock Agents follow more the approach of langchain agents</p><p>This is how the agent architecture looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJYrs8K4tKRgoqDl5JC3Ug.png" /><figcaption><a href="https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html">https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html</a></figcaption></figure><p>Bedrock Agents take care of all the plumbing and hosting so it is very quick to start experiment.</p><h3>The Financial Advisor Agent</h3><p>This is what our agent will be capable of doing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4t4H47S-zBI_DegZ2DNdg.png" /></figure><ol><li>It is able to look at query and if it needs more info asks the user about it.</li><li>Use the available tools to query for information</li><li>Use the tools multiple times if required</li><li>Create appropriate parameters for the tool</li><li>Finally use all the information gathered to answer the users question</li></ol><p>The tool that I have used over here is <a href="https://site.financialmodelingprep.com/">https://site.financialmodelingprep.com/</a> provides a nice financial API.</p><p>How do I add this tool to bedrock agent?</p><p>Bedrock agent uses a concept of action group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouewfN90poCU4JFf1UeqKQ.png" /></figure><p>An action group basically consists of an OpenAPI spec and a lambda to execute the endpoints. Essentially the agent looks at the spec sees which endpoint and method can be used, substitutes the parameters and passes this info to the lambda function for execution in a JSON. Following is the event JSON received in the lambda</p><pre>{<br>  agent: {<br>    alias: &#39;TSTALIASID&#39;,<br>    name: &#39;Company_financials_analyzer&#39;,<br>    version: &#39;DRAFT&#39;,<br>    id: &#39;&#39;<br>  },<br>  apiPath: &#39;/profile/{symbol}&#39;,<br>  sessionId: &#39;&#39;,<br>  inputText: &#39;Googl, aapl, mfst , amaz&#39;,<br>  sessionAttributes: {},<br>  promptSessionAttributes: {},<br>  httpMethod: &#39;GET&#39;,<br>  messageVersion: &#39;1.0&#39;,<br>  actionGroup: &#39;financial_info&#39;,<br>  parameters: [ { name: &#39;symbol&#39;, type: &#39;string&#39;, value: &#39;msft&#39; } ]<br>}</pre><p>you can see that I had the wrong symbol name provided but it corrected it to the right one using its training data. The LLM that I have used is Claude from Anthropic</p><p>The job of the lambda function is now to take this info and return back the data back to the agent. In our case the lambda basically just calls the financialmodelingprep api and returns the results</p><pre>{<br>  &quot;messageVersion&quot;: &quot;1.0&quot;,<br>  &quot;response&quot;: {<br>    &quot;actionGroup&quot;: &quot;financial_info&quot;,<br>    &quot;apiPath&quot;: &quot;/profile/{symbol}&quot;,<br>    &quot;httpMethod&quot;: &quot;GET&quot;,<br>    &quot;httpStatusCode&quot;: 200,<br>    &quot;responseBody&quot;: {<br>      &quot;symbol&quot;: &quot;MSFT&quot;,<br>      &quot;price&quot;: 382.7,<br>      &quot;beta&quot;: 0.885,<br>      &quot;volAvg&quot;: 23847422,<br>      &quot;mktCap&quot;: 2844325938739,<br>      &quot;lastDiv&quot;: 3,<br>      &quot;range&quot;: &quot;219.35-383.0&quot;,<br>      &quot;changes&quot;: 4.09,<br>      &quot;companyName&quot;: &quot;Microsoft Corporation&quot;,<br>      &quot;currency&quot;: &quot;USD&quot;,<br>      &quot;cik&quot;: &quot;0000789019&quot;,<br>      &quot;isin&quot;: &quot;US5949181045&quot;,<br>      &quot;cusip&quot;: &quot;594918104&quot;,<br>      &quot;exchange&quot;: &quot;NASDAQ Global Select&quot;,<br>      &quot;exchangeShortName&quot;: &quot;NASDAQ&quot;,<br>      &quot;industry&quot;: &quot;Software—Infrastructure&quot;,<br>      &quot;website&quot;: &quot;https://www.microsoft.com&quot;,<br>      &quot;description&quot;: &quot;Microsoft Corporation develops, licenses, and supports software, services, devices, and solutions worldwide. The company operates in three segments: Productivity and Business Processes, Intelligent Cloud, and More Personal Computing. The Productivity and Business Processes segment offers Office, Exchange, SharePoint, Microsoft Teams, Office 365 Security and Compliance, Microsoft Viva, and Skype for Business; Skype, Outlook.com, OneDrive, and LinkedIn; and Dynamics 365, a set of cloud-based and on-premises business solutions for organizations and enterprise divisions. The Intelligent Cloud segment licenses SQL, Windows Servers, Visual Studio, System Center, and related Client Access Licenses; GitHub that provides a collaboration platform and code hosting service for developers; Nuance provides healthcare and enterprise AI solutions; and Azure, a cloud platform. It also offers enterprise support, Microsoft consulting, and nuance professional services to assist customers in developing, deploying, and managing Microsoft server and desktop solutions; and training and certification on Microsoft products. The More Personal Computing segment provides Windows original equipment manufacturer (OEM) licensing and other non-volume licensing of the Windows operating system; Windows Commercial, such as volume licensing of the Windows operating system, Windows cloud services, and other Windows commercial offerings; patent licensing; and Windows Internet of Things. It also offers Surface, PC accessories, PCs, tablets, gaming and entertainment consoles, and other devices; Gaming, including Xbox hardware, and Xbox content and services; video games and third-party video game royalties; and Search, including Bing and Microsoft advertising. The company sells its products through OEMs, distributors, and resellers; and directly through digital marketplaces, online stores, and retail stores. Microsoft Corporation was founded in 1975 and is headquartered in Redmond, Washington.&quot;,<br>      &quot;ceo&quot;: &quot;Mr. Satya  Nadella&quot;,<br>      &quot;sector&quot;: &quot;Technology&quot;,<br>      &quot;country&quot;: &quot;US&quot;,<br>      &quot;fullTimeEmployees&quot;: &quot;221000&quot;,<br>      &quot;phone&quot;: &quot;425 882 8080&quot;,<br>      &quot;address&quot;: &quot;One Microsoft Way&quot;,<br>      &quot;city&quot;: &quot;Redmond&quot;,<br>      &quot;state&quot;: &quot;WA&quot;,<br>      &quot;zip&quot;: &quot;98052-6399&quot;,<br>      &quot;dcfDiff&quot;: 62.304,<br>      &quot;dcf&quot;: 320.39600293533726,<br>      &quot;image&quot;: &quot;https://financialmodelingprep.com/image-stock/MSFT.png&quot;,<br>      &quot;ipoDate&quot;: &quot;1986-03-13&quot;,<br>      &quot;defaultImage&quot;: false,<br>      &quot;isEtf&quot;: false,<br>      &quot;isActivelyTrading&quot;: true,<br>      &quot;isAdr&quot;: false,<br>      &quot;isFund&quot;: false<br>    },<br>    &quot;sessionAttributes&quot;: {},<br>    &quot;promptSessionAttributes&quot;: {}<br>  }<br>}</pre><p>Armed with this info the agent using the LLM can produce the output that we see.</p><h3>Conclusion</h3><p>Amazon bedrock provides a very good starting point. With its integration with knowledge base and seamless integration with AWS lambda makes it super powerful, combined with the fact that you can easily swap out LLMs makes it very flexible. What I enjoyed was also the traceability of the agent how it is thinking to fine tune your prompts. And of-course with versioning available, infrastructure available, access control Bedrock agent does look super strong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8bc3b390cd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[User Documentation as a Superpower]]></title>
            <link>https://medium.com/@gaurav.lanjekar/user-documentation-as-a-superpower-bf1169b55cb4?source=rss-a02a52d05c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf1169b55cb4</guid>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[user-documentation]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[thought-leadership]]></category>
            <dc:creator><![CDATA[GAURAV LANJEKAR]]></dc:creator>
            <pubDate>Thu, 28 Sep 2023 13:07:36 GMT</pubDate>
            <atom:updated>2023-09-28T13:07:36.455Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOBVtBHtjKSkHEE4R0je7Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@beatriz_perez?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Beatriz Pérez Moya</a> on <a href="https://unsplash.com/photos/XN4T2PVUUgk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>User documentation should not be a after thought, something boring or something done reluctantly. It is a superpower that can make your product more successful, your users more satisfied, and your life easier. In this blog post, I will explain why user documentation is so important, how to write it effectively, and how to make sure users read it.</p><h4>Why User Documentation Matters?</h4><p>User documentation is the written or visual communication that helps users understand and use your product. It can include manuals, tutorials, FAQs, videos, screenshots, diagrams, and more. User documentation serves several purposes:</p><p>- It helps users learn how to use your product quickly and easily, reducing frustration and increasing retention.<br>- It helps users solve problems and troubleshoot issues, reducing support requests and increasing satisfaction.<br>- It helps users discover new features and functionalities, increasing engagement and loyalty.<br>- It helps users trust your product and your brand, increasing credibility and reputation.</p><p>User documentation is not only beneficial for users, but also for developers. By writing user documentation, you can:</p><p>- Clarify your product vision and goals, ensuring alignment and consistency.<br>- Improve your product design and usability, identifying gaps and flaws.<br>- Test your product functionality and quality, finding bugs and errors.<br>- Showcase your product value and benefits, attracting new users and investors.</p><p>User documentation is not an optional or secondary task. It is an integral part of the product development process and a key factor for success.</p><h4><strong>How to Write User Documentation Effectively?</strong></h4><p><strong>Take the time to write it.</strong></p><p>Writing user documentation is not easy. It requires skills, time, and effort. This is the most important part, if you would like to write good documentation. A good practice is to include the effort for documentation in your stories and to include it as one of the acceptance criteria.</p><p><strong>Know your audience.</strong></p><p>Understand who your users are, wear their shoes, know what they need, what they expect, and how they learn. Use simple and clear language that matches their level of knowledge and expertise. Avoid jargon, acronyms, and technical terms that may confuse them. Use examples, scenarios, and stories that relate to their context and goals. A good practice here is to get someone else to read your documentation and ask if it makes sense</p><p><strong>Know your product.</strong></p><p>You cannot write good documentation if you don’t know what you are documenting. Understand what your product does, how it works, what it offers, and what it requires. Use accurate and consistent terminology that matches your product design and branding. Explain the features and functionalities that are relevant and useful for your users. Highlight the benefits and value that your product provides.</p><p><strong>Use different mechanisms for different cases.</strong></p><p>Understand what you want to achieve with your user documentation. Define the scope and objectives of each document or section. Use appropriate formats and media that suit your purpose and audience. For example, use manuals for detailed instructions, tutorials for step-by-step guidance, FAQs for common questions, videos for visual demonstrations, etc.</p><p><strong>Collaborate</strong></p><p>Developers, testers, product owners, product managers, marketing managers and obviously technical writers, everyone should be involved in user documentation in some capacity, whether it is reviewing, writing tutorials, or even trying out the steps written down. Documentation needs to be collaborative effort.</p><p><strong>Don’t forget the APIs</strong></p><p>Most of the digital products today boast of an API. It is hard to imagine, but developers are humans too and more importantly they are users as well. Don’t forget to document your APIs, use a standard like <a href="https://www.openapis.org/">OpenAPI </a>spec to do it.</p><h4>How to make sure users read the documentation you wrote?</h4><p>Creating user documentation is not only about writing.It is also about making sure users are able to read it when they need it.</p><p><strong>Online vs offline documentation</strong></p><p>There are various cases when you need your documentation to be available for e.g. physical products, on-premise products that have no internet access. Understand if your documentation needs to be offline, if not don’t do it. Sending Pdfs to your customers over emails and managing multiple versions of it is a pain you can avoid.</p><p><strong>Documentation platforms</strong></p><p>We live in a world where there are great documentation platforms available. Tools like <a href="https://readme.com/">Readme.com</a> , <a href="https://www.gitbook.com/">Gitbook</a>, <a href="https://document360.com/">Document360</a> and many more, allow you to create, edit, publish, manage, and update user documentation easily. Be kind to your self and use them</p><p><strong>Open vs Protected documentation</strong></p><p>Open documentation is controversial in a lot of companies. A publicly available documentation increases visibility and credibility. It showcases expertise in your industry and propels you forward into a thought leadership position. Although Protected documentation protects your IP. It adds complexity and friction to your users.</p><h3>Conclusion</h3><p>User documentation is a superpower that can make a difference in your product success. A clear documentation is not only a support structure for your users but also a great marketing tool to review old users, attract new users and establish yourself as a thought leader in your industry.</p><p>Happy Writing :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf1169b55cb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The cost of doing nothing]]></title>
            <link>https://medium.com/@gaurav.lanjekar/the-cost-of-doing-nothing-c9f0a56457c5?source=rss-a02a52d05c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9f0a56457c5</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[planning]]></category>
            <category><![CDATA[agencylife]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[agile]]></category>
            <dc:creator><![CDATA[GAURAV LANJEKAR]]></dc:creator>
            <pubDate>Tue, 29 May 2018 09:57:09 GMT</pubDate>
            <atom:updated>2018-05-29T09:57:09.158Z</atom:updated>
            <content:encoded><![CDATA[<p>Most organizations follow the principle of &quot;if it&#39;s not broken, don&#39;t fix it&quot;, it almost makes sense. Its a difficult choice to make, deliver value to the customer that they are waiting for or to fix something that the customer is not even aware of &quot;yet&quot;</p><p>In organizations where software is produced using cost per hour, this phenomenon is amplified. Where each task that is undertaken has an associated cost, Each developer hour is accounted for even the ones he spent for talking to fellow developers. The cost of doing something and the value you get in return has been worked on for years. But the cost of not doing something is really hard to calculate and is quite subjective. For Project managers, It is really hard to explain it to clients why a certain optimization is required or quantitatively explain how an architectural change will help them in the long run especially when it is the clients who drive the development of a product.</p><p>Another quite disregarded aspect is developer experience. Updating and upgrading tools is a part of this experience. If your developers are not happy with your product, neither will you customers. The most expensive resource in todays world is the developer. Finding the right processes and tools for him/her to be more productive is of great importance. It is really hard to explain clients why my jenkins server requires a upgrade :)</p><p>Obviously it not practical to prioritize refactoring, tool upgrades or even architectural changes every time. But it is very important to balance requirements and to consider the <strong>cost of not doing</strong> it on a longer run.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9f0a56457c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Microservices in production]]></title>
            <link>https://medium.com/@gaurav.lanjekar/serverless-microservices-in-production-bcc0c10b51b2?source=rss-a02a52d05c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc0c10b51b2</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[GAURAV LANJEKAR]]></dc:creator>
            <pubDate>Tue, 01 May 2018 15:12:58 GMT</pubDate>
            <atom:updated>2018-05-01T15:12:58.396Z</atom:updated>
            <content:encoded><![CDATA[<p>A few months ago we took the journey and built one of our projects ground up serverless way. And I want to share our journey the ups and downs of it.</p><p>First of all I work for cocomore.com a beautiful software agency right in the middle of Frankfurt. Now working for an Agency has its own perks, you get to work with a lot of different projects and a lot of young and dynamic people. But working in an agency also means you are very close to the customers and the risk appetite is fairly small. The project budget is almost continously under watch. So when this new project came along we were in a dilemma about the technology stack and the architecture. Being a AWS solutions architect the choice for AWS was pretty straight forward. Given the experience available in the company the choice of NodeJs as the backend and Angular as the frontend was not a big problem. We contemplated about docker on AWS ECS or simply running our own docker swarm cluster on EC2. We had tried out lambda and api gateway a few times ago and were pretty confident about it but we had not used it in production and were not sure if we would be able to recover (within budget) when we hit a road block (spoiler .. we did :P)</p><p>So we began with a simplistic architecture for our application. Due to strategic reasons we could not go with AWS Cognito and had our own solution for CIAM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3AXZu9FzezR7MJ0RfCYiQ.png" /></figure><p>So we had a SPA in Angular deployed on S3+Cloudfront giving us a really fast static website. We use Oauth2 Based authentication + JWT with our CIAM so the angular app can authenticate users. The user now to access his data used the API Gateway. We wrote our own authenticator and hooked it onto the api gateway. With this our apigateway was capable of authentication and passed the usercontext to downstream services. Now each of our microservices was a lambda function along with a Dynamodb Table. The microservices were small and did one thing right. We wrote our services in Node+serverless-express.</p><p><strong>Configuration and Deployment</strong></p><p>So far everything went well. We thought about using serverless framework to build our services but then we went against it as the AWS SAM (AWS SAM is a simplified version of cloudformataion) was already in good shape and we did not want to add another component to the mix.</p><p>We used cloudformation to write all our configurations, This is where we faced quite a lot of problems because we used a custom Authorizer we could not use the SAM template as its (<a href="https://github.com/awslabs/serverless-application-model/issues/248">https://github.com/awslabs/serverless-application-model/issues/248</a>) So we had to use the Swagger.yml file to create our API. This created problems for us :( We create one big swagger file madeup of a merge of all our microservices. But this meant that if there is an api change in one of the microservice the entire apigateway needs to be redeployed and then we have the possibility of making mistakes.</p><p>Another shortcoming of the SAM template is there is no provision to decompose the template file (<a href="https://github.com/awslabs/serverless-application-model/issues/349">https://github.com/awslabs/serverless-application-model/issues/349</a>) making the file grow quite a lot (already 1300+ lines).</p><p>Apart from these problems we could deploy things with speed and are always sure of the environment in production.</p><p><strong>Debugging</strong></p><p>Debugging a distributed application is a pain in itself but if you add cloudwatch to it your pain more or less doubles. The Cloudwatch UI is buggy the search functionality is not that powerfull. Corelating the api error logs with the lambda error logs is really painfull. We have started to use X-Ray and I would write how it goes in a few weeks. But overall the experience is not great. The good thing was monitoring, Setting up dashboards and metrics and alerts is really nice and recommended :)</p><p><strong>Event Driven Architecture.</strong></p><p>The communication within our services is based on events. So if something happens on one service it notifies the others via SNS notifications. This works well for indempotent services. But sometimes we have a problem of duplicate notifications or duplicate invocations. (but again SNS is atleast once delivery). We are thinking about moving to SQS (lets see how that goes :) )</p><p><strong>Startup Time</strong></p><p>The startup time for the application is a thing that you should consider if you want to choose serverless way. The first idle invocation (AWS basically creates a container from your lambda code and then starts it up) can take several seconds. We used statuscake to prewarm our lambda functions by calling our api at a fixed interval(5 mins). But again there are certain lamda functions that are harder to prewarm functions that sit under authentication (This can be done via clloudwatch events.) but then this is again non application specific code that I have to write and maintain.</p><p><strong>Conclusion</strong></p><p>Overall my experience with the serverless technologies was pleasant. The system scales well and I end up paying only for what I use. If I have to choose again I would definitely go with serverless once again. I hope with time the developer experience will improve with better debugging tools and best practices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc0c10b51b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating A Unfurl (Page preview) for Single Page Applications using Lambda@Edge]]></title>
            <link>https://medium.com/@gaurav.lanjekar/creating-a-unfurl-page-preview-for-single-page-applications-using-lambda-edge-7fd7290becbf?source=rss-a02a52d05c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fd7290becbf</guid>
            <category><![CDATA[preview]]></category>
            <category><![CDATA[unfurl]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[messenger]]></category>
            <dc:creator><![CDATA[GAURAV LANJEKAR]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 15:15:59 GMT</pubDate>
            <atom:updated>2018-02-15T15:15:59.194Z</atom:updated>
            <content:encoded><![CDATA[<p>I think almost every time you write a SPA, you come across the same dreaded question “How would my shared links appear on facebook?”.</p><p>The answer to it mostly come down to only Server Side Rendering(SSR). I like the fact that the same application can be rendered on the server side and angular (<a href="https://github.com/angular/universal">universal</a>) and react (<a href="https://github.com/zeit/next.js/">next.js</a>) both have support for SSR. SSR can be helpful but it also brings its own set of complexity, code changes and maintaining a server (although you can do the rendering on a lambda function as well).</p><p>In comes Lambda@Edge. Recently AWS announced Lambda@Edge which allows you to intercept /change requests before reaching the origin. So this is what we want to do in essence</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySTqSTne1VCwmq0UoTgr4A.png" /></figure><p>Our Modify Origin lambda function will be a simple lambda which will be invoked every time there is a cache miss and new content has to be fetched. A simple regex will identify if the request is from a bot if yes simply modify the origin to serve the content from a separate bucket or from a server which can generate open graph tags for a given URL. In my case I choose to have html pages generated for urls that I care on a s3 bucket.</p><pre>exports.handler = (event, context, callback) =&gt; {<br>  <strong>const </strong>request = event.Records[0].cf.request;<br>  <strong>const </strong>headers = request.headers;<br>  <strong>const </strong>origin = request.origin;<br><br>  //Setup the two different origins<br>  <strong>const </strong>botOrigin = &quot;botcontent.s3.eu-central-1.amazonaws.com&quot;;<br><br><br>  <strong>if</strong>(headers[&#39;user-agent&#39;][0].value.match(&quot;/slack|robot|facebook|face|/i&quot;)){<br>    <br>      console.log(&quot;bot-detected&quot;, headers[&#39;user-agent&#39;]);<br>      origin.custom.domainName = botOrigin;<br>      request.headers[&#39;host&#39;] = [{ key: &#39;host&#39;, value: botOrigin}];<br>    <br>  }<br><br>  callback(<strong>null</strong>, request);<br>};</pre><p>Its not ideal but we are able to route traffic for a page preview differently as for a normal user and all this is done for us at scale by AWS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fd7290becbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authenticating Api Gateway using Github Login]]></title>
            <link>https://medium.com/@gaurav.lanjekar/authenticating-api-gateway-using-github-login-d6a8cc7ff27e?source=rss-a02a52d05c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6a8cc7ff27e</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[GAURAV LANJEKAR]]></dc:creator>
            <pubDate>Sun, 04 Feb 2018 14:55:09 GMT</pubDate>
            <atom:updated>2018-02-04T14:55:09.683Z</atom:updated>
            <content:encoded><![CDATA[<p>Many of us use third party identity providers (Facebook, Google, Github, Twitter)to identify our user. With OAuth2 and now OIDC it is easier than ever to provide authentication capabilities to the static websites with simple javascript.</p><p>The next logical step is to allow the users to use their authentication and to access secure server side API’s. The idea is that the user authenticates using Github receives the token and then passes this token to the server side to authenticate himself.</p><p>I Really like API Gateway pattern to abstract away Authentication, Request Throttling, and even request and response transformation. AWS has a real good API gateway implementation called… surprise :) “API Gateway”</p><p>So what we want to do now is to configure API gateway to authenticate our requests using the token present in the request, validate this token, load the user in the usercontext and pass this to the downstream service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntTbKyM4wkh7BWjyTTddYg.png" /></figure><p>Api gateway allows authorization via Lambda Function (Custom Authorizer), Api gateway also allows authentication via another service which is cognito and IAM as well. But for the current purposes we will stick to the the Custom Authorizer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*nfN6q8K1RpwGqealgoa_hg.png" /></figure><p>The only thing now left to do is to write this Lambda function to validate Github tokens, We will use the Github v3 Authorization Api for it.</p><p><a href="https://developer.github.com/v3/oauth_authorizations/">Authorizations | GitHub Developer Guide</a></p><p>First Lets create a lambda function that deals with the validation process from github. Here is the code that does that</p><p><a href="https://github.com/gauravlanjekar/lambda-github-authorizer">gauravlanjekar/lambda-github-authorizer</a></p><p>Next step is to create an Authorizer in API Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*JZnc3k-_3C0ioVyEaiAUDQ.png" /></figure><p>Once this is done all that is remaining is to associate the Authorizer to a endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EI5uJZt63SroHyTg0-LFJw.png" /></figure><p>And thats it!! all the requests will now have be validated by github :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6a8cc7ff27e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>