<?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 Devaka Dabare on Medium]]></title>
        <description><![CDATA[Stories by Devaka Dabare on Medium]]></description>
        <link>https://medium.com/@devakadabare?source=rss-7e2e2ced1114------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uV-w8t3u3EPoZpbEU-_1UA@2x.jpeg</url>
            <title>Stories by Devaka Dabare on Medium</title>
            <link>https://medium.com/@devakadabare?source=rss-7e2e2ced1114------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 08:51:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@devakadabare/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[Git Flow vs. Reality: Common Issues and Practical Fixes]]></title>
            <link>https://devakadabare.medium.com/git-flow-vs-reality-common-issues-and-practical-fixes-828038219427?source=rss-7e2e2ced1114------2</link>
            <guid isPermaLink="false">https://medium.com/p/828038219427</guid>
            <dc:creator><![CDATA[Devaka Dabare]]></dc:creator>
            <pubDate>Sat, 08 Feb 2025 12:34:23 GMT</pubDate>
            <atom:updated>2025-02-08T12:34:23.470Z</atom:updated>
            <content:encoded><![CDATA[<p>Git Flow is a popular branching strategy for managing software development, introduced by Vincent Driessen. It provides a structured way to handle feature development, releases, and hotfixes.</p><p>However, in practice, teams often face challenges like long-lived branches, complex merge conflicts, and slow integrations. These issues can delay development, increase bugs, and complicate deployments.</p><p>In this article, we’ll explore common Git Flow problems and practical solutions to improve workflow efficiency. If you struggle with branching complexity, conflict resolution, or slow releases, this guide will help you navigate those challenges effectively.</p><p><strong>Understanding Git Flow Branching</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*9rxiC_wJaJ3VqO3Tc0tNXw.png" /><figcaption>Git Flow Branching</figcaption></figure><p>Git Flow is a structured branching model that systematically helps teams manage feature development, releases, and bug fixes. The key branches in Git Flow include:</p><ol><li><strong><em>Master Branch: </em></strong>This is the main production-ready branch.<br>Only stable, released code is merged here.</li><li><strong><em>Develop Branch: </em></strong>Acts as an integration branch where new features are merged. Represents the latest completed development work.</li><li><strong><em>Feature Branches (e.g., Feature A): </em></strong>Created from develop to work on new features or enhancements. Once completed, it is merged back into develop.</li><li><strong><em>Release Branches (e.g., Release V1): </em></strong>Created from develop when preparing for a new version release.Allows bug fixes before merging into masterand develop.</li><li><strong><em>Hotfix Branches (Not shown in the diagram but part of Git Flow)</em>: </strong>Created from the masterto fix critical issues in production.Merged back into both masterand developafter the fix.</li></ol><h3><strong>How Branching Happens in Git Flow</strong></h3><p>In Git Flow, branches are structured hierarchically, where each branch serves a specific purpose in the development and release lifecycle. Below is a breakdown of how branching works:</p><ol><li><strong><em>Master as the Parent Branch</em></strong><br>The master branch is the primary, stable branch that holds production-ready code. It serves as the parent branch from which the Develop branch is created.</li><li><strong><em>Developing New Features</em></strong><br>A Develop branch is created from master. This acts as the main working branch where developers integrate their work.The masterbranch is the head branch for develop, meaning all new development originates from this point.When working on a new feature, a Feature branch (e.g., feature-A) is created from develop.Here, the developbranch serves as the parent branch for all feature branches.</li><li><strong><em>Merging Feature Branches</em></strong><br>After development is completed on a feature, it is merged back into the develop branch.<br>This ensures all new features are integrated before preparing for a release.</li><li><strong><em>Creating a Release Branch</em></strong><br>Once enough features are merged into develop, a Release branch (e.g., release-V1) is created from develop.<br>The release branch is used for final testing, bug fixes, and preparing for deployment.<br>(In real-world scenarios, teams might have QA (Quality Assurance) or UAT (User Acceptance Testing) branches between developand release, but for simplicity, we are considering just develop.)</li><li><strong><em>Deploying the Release and Merging Changes</em></strong><br>Once the release is finalized, it is deployed from the release branch.<br>After deployment, the Release branch is merged back into master, ensuring that the production branch has the latest changes.<br>The changes are then merged back into developto keep it updated with what is in production.</li></ol><h3><strong>Issues in Git Flow Branching and Their Challenges</strong></h3><h4><strong>Issue #1: Feature Dependencies Preventing Selective Releases</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*QqI4J9Nf4dAhXEhJSXj0Wg.png" /><figcaption>Git Flow Branching — Issue #1</figcaption></figure><p><strong>Scenario:</strong></p><ul><li><strong>Feature A</strong> is branched from develop, changes are made, and it is merged back.</li><li><strong>Feature B</strong> is branched from develop <em>after</em> Feature A was merged.</li><li>During testing (QA), <strong>Feature A is found to have critical bugs</strong>, while <strong>Feature B is working fine</strong> and the client requests an immediate release.</li></ul><p><strong>Problem:</strong></p><p>Since Feature B was branched <em>after</em> Feature A was merged into develop, <strong>it already includes the changes from Feature A</strong>.</p><ul><li>If we proceed with releasing Feature B, <strong>we will also be releasing Feature A unintentionally</strong>, including its bugs.</li><li>If we want to revert Feature A, <strong>we cannot do it without affecting Feature B</strong>, since their histories are now intertwined.</li></ul><p><strong>Why This Happens?</strong></p><ul><li>Git Flow merges <strong>all</strong> completed features intodevelop, which means any new branch taken from develop inherits all previously merged changes.</li><li>There is <strong>no easy way to separate Feature B from Feature A</strong> once it has been branched.</li></ul><h4>Issue #2: Merge Conflicts and Unwanted Feature Dependencies</h4><p><strong>Scenario:</strong></p><ul><li><strong>Feature A and Feature B are branched from </strong><strong>develop at the same time</strong>.</li><li>After development, <strong>Feature A is merged into </strong><strong>develop first</strong>.</li><li>Now, when trying to merge Feature B into develop, <strong>merge conflicts occur</strong>.</li><li>To resolve this, we normally <strong>pull the latest </strong><strong>develop into Feature B</strong>, fix conflicts, and then merge Feature B back into develop.</li></ul><p><strong>Problem:</strong></p><ul><li>When pulling from develop, <strong>Feature B now contains changes from Feature A</strong>, even though they were developed separately.</li><li>If we only want to merge Feature B, <strong>it will still contain Feature A’s changes</strong> because we merged the latest develop.</li><li>If <strong>Feature A has issues</strong> or is not meant to be released yet, <strong>Feature B gets affected unnecessarily</strong>.</li></ul><p><strong>Why This Happens?</strong></p><ul><li>In Git, when a feature branch merges into develop, all new branches <strong>inheriting from </strong><strong>develop after that</strong> get those changes.</li><li>Merge conflicts force developers to <strong>pull </strong><strong>develop into feature branches</strong>, which causes <strong>unwanted dependencies between independent features</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UOlsV5MxP0raDzTI" /><figcaption>Photo by <a href="https://unsplash.com/@haky?utm_source=medium&amp;utm_medium=referral">Shamin Haky</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Proposed Solution: Isolating Feature Branches from Master for Better Control</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9euH7Mj7clEhpXY1h0ZYPA.png" /><figcaption>Enhaced git flow</figcaption></figure><p>In this improved Git Flow model, we <strong>branch feature branches directly from </strong><strong>master</strong> instead of develop. This <strong>solves Issue #1</strong>, where unwanted dependencies between features were causing release complications.</p><h4><strong>How This Solution Works (Diagram Explanation)</strong></h4><ul><li>Every <strong>Feature Branch</strong> (Feature A, Feature B, etc.) now branches out <strong>from </strong><strong>master instead of </strong><strong>develop</strong>.</li><li>This ensures that each feature <strong>remains isolated</strong> from the other features under development.</li><li>Developers should <strong>regularly pull the latest changes from </strong><strong>master</strong> before pushing their code to avoid missing released updates.</li><li>Once development is completed:</li></ul><ol><li>The feature branch is merged into develop for integration testing.</li><li>If it passes QA and is ready for release, it is merged into the <strong>Release branch</strong>.</li><li>If the feature is <strong>not ready</strong>, it is <strong>not merged into the release branch</strong>, avoiding the risk of shipping unfinished work.</li></ol><h4><strong>Why Does This Solve Issue #1?</strong></h4><p>Previously, all feature branches were based ondevelop, so if one feature had issues, others inherited those issues.</p><ul><li><strong>Now, each feature is completely independent</strong> and can be merged only when it’s ready.</li><li>If <strong>Feature A has bugs</strong>, it won’t affect <strong>Feature B</strong>, since Feature B was <strong>never dependent on </strong><strong>develop</strong>.</li><li>Only features that <strong>pass QA</strong> and are <strong>approved for the next release</strong> are merged into the release branch.</li></ul><h4><strong>Handling Collaboration on Large Features</strong></h4><p>For <strong>large features involving multiple developers</strong>, we introduce <strong>sub-feature branches</strong>:</p><ol><li>The <strong>main feature branch</strong> (e.g., feature/main-feature-A) is created from master.</li><li>Developers can create <strong>sub-feature branches</strong> (e.g., feature/A-sub-1, feature/A-sub-2) from the main feature branch.</li><li>These sub-features merge back into the <strong>main feature branch</strong>, keeping work organized.</li><li>When the feature is complete, the <strong>main feature branch is merged into </strong><strong>develop or </strong><strong>release as needed</strong>.</li></ol><h4>Why This Solution Is Cleaner and More Efficient?</h4><p>✅ <strong>Feature branches stay isolated</strong> from other features, preventing unwanted dependencies.<br>✅ <strong>Selective releases become easier, </strong>we can decide which features go into a release without worrying about conflicts.<br>✅ <strong>QA is more controlled, </strong>only features that pass testing are merged into the release.<br>✅ <strong>Scalability improves</strong>, developers working on the same feature can collaborate efficiently without blocking others.</p><h3>Handling Merge Conflicts Without Polluting Feature Branches</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQ67FQWpfrT4SzCE8-7PTg.png" /><figcaption>Conflict resolving</figcaption></figure><h4>How It Works (Diagram Explanation)</h4><ol><li><strong>Do NOT pull from </strong><strong>develop/</strong><strong>qa directly into the feature branch.</strong></li><li>Instead, <strong>create a new conflict resolution branch</strong> (dev_conflict/FT_A) <strong>from the feature branch (</strong><strong>Feature A).</strong></li><li>Pull the latest changes from develop/qa into the <strong>conflict branch</strong>.</li><li><strong>Resolve conflicts</strong> in the conflict branch (dev_conflict/FT_A).</li><li>Once resolved, <strong>merge the conflict branch into </strong><strong>develop/</strong><strong>qa</strong>.</li><li>The original <strong>feature branch (</strong><strong>Feature A) remains clean</strong> and unchanged.</li><li>If the feature is approved for release, a <strong>PR is raised from the original feature branch to </strong><strong>release or </strong><strong>qa</strong>.</li></ol><h3>Why Does This Approach Work?</h3><p>✅ <strong>Feature branches remain clean</strong> without unnecessary merges.<br>✅ <strong>Conflict resolution happens in an isolated branch</strong>, making debugging easier.<br>✅ <strong>No risk of accidentally merging unwanted changes</strong> into a feature branch.<br>✅ <strong>Keeps feature history clean and organized</strong>, making rollbacks easier if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A_bzsABC0vHr403k" /><figcaption>Photo by <a href="https://unsplash.com/@benmullins?utm_source=medium&amp;utm_medium=referral">Ben Mullins</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Conclusion: Improving Git Flow for a Smoother Workflow</strong></p><p>Git Flow provides a structured approach to software development, but <strong>real-world challenges</strong> like unwanted feature dependencies, merge conflicts, and selective releases can complicate the process.</p><p>In this article, we explored <strong>common Git Flow issues</strong> and <strong>practical solutions</strong> to overcome them:<br>✅ <strong>Isolating feature branches from </strong><strong>master</strong> to prevent unwanted dependencies.<br>✅ <strong>Selective merging</strong> to ensure only approved features make it to production.<br>✅ <strong>Using conflict resolution branches</strong> instead of polluting feature branches.</p><p>By following these strategies, teams can <strong>keep their Git history clean, manage releases more effectively, and reduce the risk of deployment issues</strong>.</p><p>Adapting Git Flow to fit your team’s needs will <strong>lead to a more efficient, scalable, and conflict-free development process</strong>.</p><p>💬 <strong>If you found this article helpful, consider supporting it by sharing it with your team!</strong><br>📢 <strong>Have questions or suggestions? Drop a comment below, and let’s discuss!</strong></p><h3>Happy Coding! 🚀</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=828038219427" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revolutionizing Authentication: Embracing Passwordless Security with Cognito (Phone Number-OTP)]]></title>
            <link>https://devakadabare.medium.com/revolutionizing-authentication-embracing-passwordless-security-with-cognito-phone-number-otp-5c163425cf68?source=rss-7e2e2ced1114------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c163425cf68</guid>
            <category><![CDATA[cognito]]></category>
            <category><![CDATA[cognito-user-pools]]></category>
            <category><![CDATA[custom-authentication]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[lambda]]></category>
            <dc:creator><![CDATA[Devaka Dabare]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 09:55:36 GMT</pubDate>
            <atom:updated>2023-06-27T16:27:18.796Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explores the benefits, implementation process, and implications of passwordless authentication using Cognito (Phone Number - OTP). Discover how this innovative approach enhances user experience and strengthens account security, revolutionizing the way we protect sensitive information.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FduNowzaVje6Di3hnOu%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FduNowzaVje6Di3hnOu%2Fgiphy-downsized-large.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FduNowzaVje6Di3hnOu%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="290" frameborder="0" scrolling="no"><a href="https://medium.com/media/fee935dc8676ac20878d46106e4520c5/href">https://medium.com/media/fee935dc8676ac20878d46106e4520c5/href</a></iframe><p><strong>Step 1: — Setup Cognito Pool </strong>🔥</p><p>👉🏻Go to the Amazon Cognito console.<br>👉🏻Select the Phone number as a sign-in option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3IWVaf_cNEyIeNVuKUCbA.png" /><figcaption>Create Cognito pool</figcaption></figure><p>👉🏻Enable MFA authentication</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fHI4Zgc2UZL_xiLHcZqxQ.png" /><figcaption>Enable MFA</figcaption></figure><p>👉🏻Create an application client and select ALLOW_CUSTOM_AUTH as the authentication flow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_LrZcSVX8EDMGpS0xSBXw.png" /><figcaption>Cognito application client configurations</figcaption></figure><p><strong>Step 2: — Create Lambda functions and connect with the Cognito User pool </strong>🔥</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/0*lpxpjsDj5gTea70-.png" /><figcaption>Custom authentication challenge Lambda triggers</figcaption></figure><p>Amazon Cognito User Pools and custom authentication flows, the use of three separate Lambda triggers allows for increased flexibility and security in the authentication process. Here’s a deeper dive into each of the triggers and why they’re necessary:</p><p>👉🏻<strong><em>Define Auth Challenge</em></strong>: This Lambda function is responsible for deciding which challenges need to be presented to the user. This decision can be based on various factors such as the user’s risk level, their location, or the device they’re using. By separating this into a dedicated Lambda function, you have the flexibility to define complex and adaptive rules for when and which challenges should be presented to the user.</p><p>For this example, I will create the ‘Define auth challenge’ as below 👇 :</p><pre>exports.handler = (event, context, callback) =&gt; {<br>    console.log(event)<br>    <br>    if (event.request.session.length === 0) {<br>            <br>        event.response.issueTokens = false;<br>        event.response.failAuthentication = false;<br>        event.response.challengeName = &#39;CUSTOM_CHALLENGE&#39;;<br><br>    } else if (event.request.session.length &gt; 0 &amp;&amp; event.request.session[0].challengeResult === true) {<br><br>        event.response.issueTokens = true;<br>        event.response.failAuthentication = false;<br><br>    } else {<br>        event.response.issueTokens = false;<br>        event.response.failAuthentication = true;<br>    }<br>    callback(null, event);<br>};</pre><p>If the session array in the request object of the event is empty (i.e., event.request.session.length === 0). If it is, this means that no previous challenge has been presented to the user yet. So, it sets issueTokens to false (meaning it will not issue authentication tokens yet), failAuthentication to false (meaning it will not fail the authentication yet), and challengeName to ‘CUSTOM_CHALLENGE’ (indicating the type of challenge that it will present to the user).</p><p>If the session array is not empty and the challengeResult of the first session is true (i.e., the user has successfully answered a previous challenge), it sets issueTokens to true (meaning it will issue authentication tokens to the user) and failAuthentication to false.</p><p>If neither of the above conditions is true (which means that there has been a previous challenge and the user failed to answer it correctly), it sets issueTokens to false and failAuthentication to true (meaning it will fail the authentication).</p><p>Finally, it invokes the callback function with null as the first argument (indicating no error occurred) and event as the second argument. This passes the modified event object back to Amazon Cognito.</p><p>Read more: — <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html">https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html</a></p><p>👉🏻<strong><em>Create Auth Challenge:</em></strong> Once the challenges to be presented are decided, this Lambda function is responsible for generating the actual challenge. This might involve generating a unique one-time password (OTP), creating a CAPTCHA, or selecting from a pool of security questions. Having this as a separate Lambda function allows you to isolate the logic that generates the challenges and makes it easier to change or update this logic as necessary.</p><p>For this example, I will create the ‘Create auth challenge’ as below 👇 :</p><pre>const { SNSClient, PublishCommand } = require(&quot;@aws-sdk/client-sns&quot;);<br><br>// Define the AWS SNS client<br>const snsClient = new SNSClient({ region: &quot;us-east-1&quot; });<br><br>exports.handler = async (event) =&gt; {<br>    console.log(event)<br><br>    try {<br><br>        //Generate a random 4-digit number<br>        const OTP = Math.floor(1000 + (Math.random() * 5321));<br>        // const OTP = 121212<br><br>        //Send the OTP via SMS<br>        const params = {<br>            Message: `Your OTP is ${OTP}`,<br>            PhoneNumber: event.request.userAttributes.phone_number,<br>        };<br><br>        await snsClient.send(new PublishCommand(params));<br><br>        console.log(&quot;OTP sent via SMS: &quot; + OTP);<br><br>        event.response.publicChallengeParameters = {};<br>        event.response.privateChallengeParameters = {};<br><br>        // Set the privateChallengeParameters so they can be verified by the Verify Auth Challenge Response trigger<br>        event.response.publicChallengeParameters.phone = event.request.userAttributes.phone_number;<br>        event.response.privateChallengeParameters.answer = OTP;<br>        event.response.challengeMetadata = &#39;CUSTOM_CHALLENGE&#39;;<br><br>        return event;<br><br>    } catch (error) {<br>        console.log(error)<br><br>        throw error;<br><br>    }<br><br>};</pre><p>It sets up the challenge parameters in the event object. This includes the public challenge parameters, which are visible to the user, and the private challenge parameters, which are not. In this case, the user&#39;s phone number is set as a public challenge parameter, and the OTP is set as a private challenge parameter. This is so that the OTP can be verified later in the &quot;Verify Auth Challenge Response&quot; step. It also sets the challengeMetadata field to &#39;CUSTOM_CHALLENGE&#39; to specify the type of challenge.</p><p>Read more: — <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html">https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html</a></p><p>👉🏻<strong><em>Verify Auth Challenge Response:</em></strong> This Lambda function is responsible for checking the answer or response provided by the user to the challenge. Separating this logic into a dedicated function allows you to have complex verification logic. For example, you might want to allow for minor misspellings in security question answers, or you might want to use a third-party service to verify CAPTCHAs.👇</p><pre>exports.handler = (event, context, callback) =&gt; {<br>    <br>    if (event.request.privateChallengeParameters.answer === event.request.challengeAnswer) {<br>        event.response.answerCorrect = true;<br>    } else {<br>        event.response.answerCorrect = false;<br>    }<br>    callback(null, event);<br>}</pre><p>This function verifies the response to the custom challenge. If the answer provided by the user matches the expected answer, the function considers the challenge to be correctly answered. Otherwise, it considers the challenge to be incorrectly answered.</p><p>Read more: — <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html">https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-verify-auth-challenge-response.html</a></p><p>Now go to the Cognito user pool settings and add the above functions as defined.(user_pool -&gt; your_user_pool -&gt; add_lambda_trigger)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*GBqs8IZ1FcPSSyAflbJ37A.png" /><figcaption>Add Lambda Triggers</figcaption></figure><p><strong>Step 3: — Create an example React App </strong>🔥</p><p>Let&#39;s Create an example react application with a login page to test this. 👇</p><pre>&lt;div&gt;<br>    &lt;form onSubmit={handlePhoneNumberSubmit}&gt;<br>        &lt;label&gt;<br>            Phone Number:<br>            &lt;input type=&quot;text&quot; value={phoneNumber} onChange={e =&gt; setPhoneNumber(e.target.value)} /&gt;<br>        &lt;/label&gt;<br>        &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;<br>    &lt;/form&gt;<br>    &lt;form onSubmit={handleOtpSubmit}&gt;<br>        &lt;label&gt;<br>            OTP:<br>            &lt;input type=&quot;text&quot; value={otp} onChange={e =&gt; setOtp(e.target.value)} /&gt;<br>        &lt;/label&gt;<br>        &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;<br>    &lt;/form&gt;<br>  &lt;/div&gt;</pre><p><strong>Step 4: — Login Request </strong>🔥</p><p>To handle cognito calls I will use AWS v3 sdk.👇</p><pre>import React, { useState } from &#39;react&#39;;<br>import { CognitoIdentityProviderClient, InitiateAuthCommand, RespondToAuthChallengeCommand } from &quot;@aws-sdk/client-cognito-identity-provider&quot;;<br><br>const client = new CognitoIdentityProviderClient({ region: &quot;us-east-1&quot; });</pre><pre>const [phoneNumber, setPhoneNumber] = useState(&#39;&#39;);<br>const [otp, setOtp] = useState(&#39;&#39;);<br>const [session, setSession] = useState(null);<br><br>const handlePhoneNumberSubmit = async (event) =&gt; {<br>    event.preventDefault();<br><br>    const command = new InitiateAuthCommand({<br>        AuthFlow: &#39;CUSTOM_AUTH&#39;,<br>        ClientId: &#39;xxxxxxxxxxxx&#39;,<br>        AuthParameters: {<br>            &#39;USERNAME&#39;: phoneNumber,<br>            &#39;PASSWORD&#39;: &#39;Abc@1234&#39; // A placeholder password<br>        }<br>    });<br><br>    try {<br>        const response = await client.send(command);<br>        setSession(response.Session);<br>    } catch (error) {<br>        console.error(error);<br>    }<br>};</pre><p>In summary, this code initiates the custom authentication process with Amazon Cognito when the user submits their phone number. The response from Amazon Cognito, which includes session data, is stored in a state variable for later use.</p><p><strong>Step 5: — Verify OTP </strong>🔥</p><pre>const handleOtpSubmit = async (event) =&gt; {<br>    event.preventDefault();<br><br>    const command = new RespondToAuthChallengeCommand({<br>        ChallengeName: &#39;CUSTOM_CHALLENGE&#39;,<br>        ClientId: &#39;xxxxxxxxxxxxx&#39;,<br>        Session: session,<br>        ChallengeResponses: {<br>            &#39;USERNAME&#39;: phoneNumber,<br>            &#39;ANSWER&#39;: otp<br>        }<br>    });<br><br>    try {<br>        const response = await client.send(command);<br>        console.log(&#39;access token:&#39;, response.AuthenticationResult.AccessToken);<br>    } catch (error) {<br>        console.error(error);<br>    }<br>};</pre><p>This function is used to respond to the custom authentication challenge. It sends the OTP entered by the user to Amazon Cognito and logs the access token returned upon successful authentication.</p><p>Upon successful completion of all challenges in the custom authentication flow with Amazon Cognito User Pools, an authentication token is issued and sent to the client-side application. This token serves as a credential to authenticate the user for subsequent interactions with the application.</p><p><strong>Conclusion </strong>🔥🔥</p><p>The primary purpose of this article is to demonstrate the simplicity and straightforwardness of setting up a custom authentication flow for our applications using AWS Cognito.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FpWO49XP9L7TxbgQVib%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FpWO49XP9L7TxbgQVib%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FpWO49XP9L7TxbgQVib%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="362" frameborder="0" scrolling="no"><a href="https://medium.com/media/1663a2868fd926eaa15bf2644f42474c/href">https://medium.com/media/1663a2868fd926eaa15bf2644f42474c/href</a></iframe><p>Thank you very much for your time and I hope it was helpful.😎😎😎</p><p>Feel free to correct any mistakes or leave any feedback you have.🤩🤩🤩</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c163425cf68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Dynamic Applications with Lambda and GraphQL Subscriptions]]></title>
            <link>https://devakadabare.medium.com/building-dynamic-applications-with-lambda-and-graphql-subscriptions-482c2e98ffba?source=rss-7e2e2ced1114------2</link>
            <guid isPermaLink="false">https://medium.com/p/482c2e98ffba</guid>
            <category><![CDATA[subscription]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Devaka Dabare]]></dc:creator>
            <pubDate>Wed, 31 May 2023 20:20:14 GMT</pubDate>
            <atom:updated>2023-06-01T04:35:56.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xw9GqXTPDaDRKmrl4Guovw.png" /></figure><p>Creating a real-time application involves building a system that can provide live updates and data synchronization to users in real-time. In this guide, we will walk through the steps to create such an application using a powerful combination of AWS Lambda, GraphQL subscriptions, React, and DynamoDB.</p><p>Step 01: Create DynamoDb</p><p>To create a DynamoDB table, login to the AWS Management Console, navigate to the DynamoDB service, and click on “Create table.” Provide a name for the table and specify the primary key, which can be a partition key or a composite key. Define the attribute names and data types for the table’s properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdIB7VfxrT8EmqYY4eeWyg.png" /><figcaption>example dynamDB table with some data</figcaption></figure><p>Step 02: Create GraphQL API</p><p>To create a GraphQL API with DynamoDB as the data source using AWS AppSync, navigate to AppSync and select the Graph API option. Import DynamoDB as the GraphQL API Data Source and ensure you choose the correct table as the data source. In the next step, you can customize the GraphQL model by adding additional attributes as your ‘dynamo table’. Once done, you will have a GraphQL API with an auto-generated schema connected to DynamoDB, ready to power your application.</p><p>Step:03 Integrate with your app</p><p>To integrate your GraphQL API with your application, follow the instructions provided on the GraphQL homepage. These steps will guide you through the process of connecting your GraphQL API to your application seamlessly. By following these instructions, you can ensure smooth integration and leverage the power of GraphQL in your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acvtlmxiCMu16FFaH6adIQ.png" /><figcaption>Integration of GraphQL API</figcaption></figure><p>When configuring AWS Amplify in your local environment, it is important to grant the necessary permissions to your user in order to access Amplify effectively. In addition to assigning the <strong><em>AWSAmplifyFullAccess </em></strong>policy or creating custom policies, it is crucial to provide the <strong><em>AWSAppSyncFullAccess </em></strong>permission. This permission grants your user the necessary access to interact with AWS AppSync, including performing actions such as GetGraphqlApi and other operations related to your AppSync GraphQL API.</p><pre>amplify add codegen --apiId yourGraphQL_appId</pre><p>After running the above command you will get the files below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*nzRXN2kLVEG22vy1XHRqjw.png" /></figure><p>Step:04 Create Lambda Function</p><p>In order to handle data addition and updates, a Lambda function can be utilized with the assistance of the AWS Amplify package and GraphQL mutations. By triggering a mutation, the Lambda function will automatically execute the necessary logic to add or update the data.</p><p>Moreover, the GraphQL subscription, which listens to this specific mutation, will be triggered simultaneously. As a result, any subscribed applications will receive real-time updates, ensuring that the newly added or updated data is broadcasted to all relevant subscribers.</p><p>This combination of Lambda functions, GraphQL mutations, and subscriptions enables seamless data management and real-time synchronization across multiple applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*q-o5s01Mlq5698-43zspww.png" /><figcaption>File Structure — Lambda</figcaption></figure><p>The example code as below :</p><pre>const { API, graphqlOperation } = require(&#39;aws-amplify&#39;);<br>const { createExampleTable } = require(&#39;./graphql/mutations&#39;);<br><br>//configure appsync-amplify<br>API.configure({<br>    &quot;aws_appsync_graphqlEndpoint&quot;: &quot;https://xxxxxxx.appsync-api.us-east-1.amazonaws.com/graphql&quot;,<br>    &quot;aws_appsync_region&quot;: &quot;us-east-1&quot;,<br>    &quot;aws_appsync_authenticationType&quot;: &quot;API_KEY&quot;,<br>    &quot;aws_appsync_apiKey&quot;: &quot;da2-xxxxxxxxxxxx&quot;<br>});<br><br>exports.handler = async (event) =&gt; {<br>    try {<br>        //graphql mutation variables<br>        let variables = {<br>            input: {<br>                et_id: &quot;1&quot;,<br>                et_name: &quot;TestName &quot;,<br>                et_colm1: &quot;Test1&quot;,<br>                et_colm2: &quot;Test2&quot;,<br>                et_colm1: &quot;Test3&quot;,<br>                et_colm3: true<br>            }<br>        };<br><br>        //graphql mutation query<br>        let mutation = graphqlOperation(createExampleTable, variables);<br><br>        //execute mutation<br>        const result =  await API.graphql(mutation);<br><br>        return {<br>            statusCode: 200,<br>            body: JSON.stringify(result)<br>        }<br>    } catch (error) {<br>        console.log(error);<br>        return {<br>            statusCode: 500,<br>        }<br>    }<br>};</pre><p>Step:04 Configure The Front end Application</p><p>To achieve similar functionality as the Lambda function, utilize the AWS Amplify package and configure it as described previously. Then, use the subscription query, such as onCreateExampleTable, with the API.graphql method from Amplify to subscribe to the desired events. This will enable real-time updates and data synchronization by handling the received subscription data in the next callback and handling any subscription errors in the error callback.</p><pre>import { API, graphqlOperation } from &#39;aws-amplify&#39;;<br>import { onCreateExampleTable } from &#39;./graphql/subscriptions&#39;;<br><br>const subscribeToExampleTable = async () =&gt; {<br>  try {<br>    const subscriptionResult = await API.graphql(<br>      graphqlOperation(onCreateExampleTable)<br>    ).subscribe({<br>      next: (eventData) =&gt; {<br>        console.log(eventData);<br>        // Handle the subscription event data here<br>      },<br>      error: (errorData) =&gt; {<br>        console.log(errorData);<br>        // Handle any subscription errors here<br>      }<br>    });<br><br>    // To unsubscribe from the subscription:<br>    // subscriptionResult.unsubscribe();<br>  } catch (error) {<br>    console.error(&#39;Subscription Error:&#39;, error);<br>  }<br>};<br><br>// Call the subscription function<br>subscribeToExampleTable();</pre><p>In conclusion, programmers may design really dynamic and responsive applications by utilizing the strength of AWS Lambda and GraphQL subscriptions.</p><p>Now it’s your turn! Start implementing real-time features in your applications using Lambda and GraphQL subscriptions, and unleash the full potential of dynamic and engaging experiences for your users.</p><p>“Happy coding! :) ”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=482c2e98ffba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing Cors Issue on Lambda Functions]]></title>
            <link>https://devakadabare.medium.com/fixing-cors-issue-on-lambda-functions-b228c34d5966?source=rss-7e2e2ced1114------2</link>
            <guid isPermaLink="false">https://medium.com/p/b228c34d5966</guid>
            <category><![CDATA[cors]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Devaka Dabare]]></dc:creator>
            <pubDate>Wed, 31 May 2023 08:57:15 GMT</pubDate>
            <atom:updated>2023-05-31T20:20:29.367Z</atom:updated>
            <content:encoded><![CDATA[<p>When you create a Lambda function and expose it as a functional URL, you might encounter CORS (Cross-Origin Resource Sharing) issues from the front end. While it may work as expected in Postman, implementing the same API in the front-end application (such as React or Next.js) can result in CORS errors.</p><p>The error message typically appears as follows</p><p><strong><em>from origin ‘</em></strong><a href="http://localhost:3000&#39;"><strong><em>http://localhost:3000&#39;</em></strong></a><strong><em> has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. from front end</em></strong></p><h3>Fixing the issue</h3><p>This issue mainly occurs when you r expose the lambda directly using a functional URL and do not correctly set the cors setting on the AWS console.</p><p>Step 1: Go to your Lambda function<br>Navigate to the AWS Management Console and access the Lambda service. Locate and select your Lambda function from the list of functions.</p><p>Step 2: Access the Configurations tab<br>Locate and click on the “Configurations” tab within the selected Lambda function. This tab contains various settings for your Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*zAOTkR9SHMeWsFUo7hSCow.png" /></figure><p>Step 3: Configure cross-origin resource sharing (CORS)<br>Ensure that you have enabled CORS for your Lambda function. This setting allows cross-origin requests to access your Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*pF_JDzikZJLRjVE48IoySQ.png" /></figure><p>Step 4: Specify the allowed origin<br>In the “Allow Origin” section, specify either “*” to allow requests from any origin, or enter the specific origin URL from where you expect the requests to come. This ensures that the appropriate “Access-Control-Allow-Origin” header is included in the response.</p><p>Step 5: Add required headers<br>Scroll down to the “Allow Header” section. Here, you need to add the headers that are being sent from the front end. Include the relevant headers to ensure they are allowed by the CORS policy.</p><p>Step 6: Specify allowed methods<br>In the “Allow Methods” section, select the appropriate HTTP methods that should be allowed by the CORS policy. Choose the methods that are being used by your front-end application to interact with the Lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XFIwQHcqoVJz2FtIPThHg.png" /></figure><p>Step 7: Save the changes<br>Once you have completed the necessary configuration changes, save the changes to apply the updated CORS settings to your Lambda function.</p><p>By following these steps, you should be able to fix the CORS issue that occurs when accessing your Lambda function from the front end.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>If you liked this article, please show your appreciation by clapping 👏 below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b228c34d5966" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>