<?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 Vasilii Trofimchuk on Medium]]></title>
        <description><![CDATA[Stories by Vasilii Trofimchuk on Medium]]></description>
        <link>https://medium.com/@vthub?source=rss-f1be13d365f0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*A8koyswCXnf9Rbf4xQa3HQ.jpeg</url>
            <title>Stories by Vasilii Trofimchuk on Medium</title>
            <link>https://medium.com/@vthub?source=rss-f1be13d365f0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:50:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vthub/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[A Series of Unfortunate Extinctions]]></title>
            <link>https://vthub.medium.com/a-series-of-unfortunate-extinctions-812bc4dcbe3b?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/812bc4dcbe3b</guid>
            <category><![CDATA[climate-action]]></category>
            <category><![CDATA[climate-change]]></category>
            <category><![CDATA[animals]]></category>
            <category><![CDATA[environment]]></category>
            <category><![CDATA[wildlife]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Thu, 31 Dec 2020 19:40:51 GMT</pubDate>
            <atom:updated>2021-12-02T18:39:39.193Z</atom:updated>
            <content:encoded><![CDATA[<p>Throughout the last 200 years, the earth has seen unprecedented changes to its human and wildlife population, its environmental balances, and its climate. The years following the second industrial revolution accelerated the rate of change like never before causing wildlife to <a href="https://www.wwf.org.uk/updates/living-planet-report-2018">shrink by 60% after 1970</a>.</p><p>Looking back at the historical records of naturalists and adventurers one might begin to wonder if some animals were indeed citizens of our planet, or it is one of those brilliant inventions of a fiction writer. It is hard to imagine that just a few decades ago Mexico had seen its own grizzly bear, Tasmania hosted a dog-like tiger and the Bering Sea was home to a gigantic ten tons aquatic mammal — a Steller’s Sea Cow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fe-LuS2dx6Dy0e3MBmDNtg.png" /><figcaption>Lost Animals. Illustration by <a href="https://yanatibear.com/">Yanatibear</a> ©</figcaption></figure><p>These examples of extinct species are both fascinating and educational. They contain crucial learnings that could aid our own survival. With all the micro and macro environments interconnected in one <a href="https://www.wired.com/2015/02/sahara-keeps-amazon-green/">global and fragile network</a> changes in balances far away from where you are now might bring about changes you would never expect.</p><h3>Mexican Grizzly Bears</h3><p>Some 70 years ago a Silver Bear roamed the northern territories of Mexico sometimes going into the states of New Mexico and Arizona in the USA. Smaller than their cousins from Canada and the US, Mexican Grizzly Bears were mainly feeding on plants, fruits, insects, and small mammals, and lived a solitary life in grasslands and mountain pine forests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nrHvUS7K8BbciG-4hYK2eA.jpeg" /><figcaption>Mexican Grizzly Bear. Illustration by <a href="https://yanatibear.com/">Yanatibear</a> ©</figcaption></figure><p>However, these gracious and calm creatures were not well understood by people at that time which led to a quick and blind wipeout of an entire species. Thinking it would protect the cattle, in the mid-20 century Mexican ranchers launched a campaign to kill all Mexican Grizzly Bears with the last grizzly bear seen in the region in 1968. This became an infamous example of trading survival of wildlife for money to ride a wave of meat demand.</p><p>Around the world places previously inhabited by bears now stand empty with just national symbols reminding about the presence of these majestic animals. Among these places are Egypt, Germany, Israel, Jordan, Morocco, Netherlands, Portugal, Tunisia, and the United Kingdom.</p><h3>Tasmanian Tiger</h3><p><a href="https://www.dailymail.co.uk/news/article-8335471/Extraordinary-final-recording-Benjamin-known-Tasmanian-Tiger-unearthed-80-years.html">Black and white footage</a> of a last known Tasmanian Tiger Benjamin from Hobart Zoo is a reminder that what we see today might not be available to witness tomorrow. Dog-like Tasmanian Tigers were once populous night hunters in both Australia and Tasmania who following tough competition with Dingo eventually settled and ruled Tasmania island.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6KyWBNXWYORRrQogJHiFQ.jpeg" /><figcaption>Tasmanian Tiger. Illustration by <a href="https://yanatibear.com/">Yanatibear</a> ©</figcaption></figure><p>Similar to Mexican Grizzly Bears, Tasmanian Tigers were perceived as a threat to sheep and chickens by colonizers who arrived from Europe. Ridiculously enough Tasmanian government offered a <em>bounty</em> for Tigers’ scalps in 1888 causing the whole population of species to go extinct by the mid-20 century. Some believe that people’s aggression against Tasmanian tigers was manipulated, as with this example of a possibly <a href="https://australian.museum/learn/news/blog/investigating-a-picture-of-an-thycaline/">staged photo of one of Tasmanian Tigers</a>.</p><p>Australia stands out as an example of a human impact. Since European colonization around 250 years ago, Australia lost some 100 animal and plant species. Similar to the last Tasmanian Tiger they will forever remain only in books and on archive records.</p><p>Though not everything might seem gloom and doom. Scientists and environmentalists hope that Tasmanian Tigers might have miraculously survived the eradication order and <a href="https://www.cnn.com/2019/10/16/australia/tasmanian-tiger-intl-hnk-scli/index.html">could still be hiding</a> in the Tasmanian wilderness far from people and civilization.</p><h3>Steller’s Sea Cow</h3><p>Like many other wild species, <a href="https://www.britannica.com/animal/sea-cow">Steller’s Sea Cow</a> hasn’t had an opportunity to enjoy long and happy coexistence with humans. It took only 27 years from the moment Georg Steller added the Sea Cow to the list of species until Sea Cows became history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f1iSjGBkix7a7Qokce_lgw.jpeg" /><figcaption>Steller’s Sea Cow. Illustration by <a href="https://yanatibear.com/">Yanatibear</a> ©</figcaption></figure><p>Toothless gigantic mammals were awkward onshore but gracious in the water. Floating on the surface Sea Cows were feeding on seaweed and kelp reaching the length of a transit bus and weighing up to ten tons.</p><p>The slow giant mammal unable to submerge was too easy a target for harpooning from passing ships leading to wasteful killings for food and fur.</p><p>As a matter of fact, the Sea Cows population was on a decline years before they were hunted down. Unfortunately for us though, their prior decline was also caused by a <a href="https://www.theatlantic.com/science/archive/2017/04/pleistoseacow/522831/">human impact, just indirectly</a>. One of Sea Cows’ primary food sources was kelp which ran low numbers caused by the unusual spread of sea urchins. The urchins spread in turn was caused by sea otters (who eat urchins) being hunted down by fur traders.</p><p>And once more, this example shows how interconnected the world is, where a seemingly small change can lead to a ripple effect across the globe and across the ecosystems.</p><p>Unfortunately, people’s greed and unsustainable living didn’t stop with Tasmanian Tigers, Sea Cows, and Mexican Grizzly Bears. Species direct and indirect eradication <a href="https://www.businessinsider.com/12-rare-animals-that-are-almost-extinct-2016-7#white-rumped-vulture-8">continues today</a> causing wildlife to decline at rates never seen before. As a matter of example, Pangolins have been declared to be the most trafficked animal in the world, with approximately one pangolin poached <a href="https://wholeeartheducation.com/pangolin-most-illegally-traded-animal-in-the-world/">every five minutes</a>.</p><p>10,000 years ago wildlife mammals accounted for 99% of all mammals on the planet earth. Today, uncontrolled hunting, illegal poaching, deforestation, and unsustainable farming left us <a href="https://www.ecowatch.com/biomass-humans-animals-2571413930.html">only 4%</a> of all mammals to represent the variety and richness of the wildlife.</p><p>While we cannot go back and fix mistakes of the past we all can take steps today to help the planet heal. Fortunately for us, our planet is resilient to sustain the damages we made so far. With <a href="https://medium.com/climate-conscious/david-attenboroughs-witness-statement-59a2c86f5ec">the right and united actions</a>, there is hope that the animals at the edge of extinction will come back to their original numbers, nature will find ways to clear the water and freshen the air, and ecosystems will once again find their balances ensuring happy and long coexistence for all of us.</p><p><em>This article couldn’t have been possible without inspiration, support and illustrations by </em><a href="https://medium.com/@yanatibear"><em>Alya</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=812bc4dcbe3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Emergency Help for Your Next Ambiguous Problem]]></title>
            <link>https://medium.com/swlh/emergency-help-for-your-next-ambiguous-problem-9fae0ab844e1?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fae0ab844e1</guid>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[decisions]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[ambiguity]]></category>
            <category><![CDATA[decision-making]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Wed, 30 Dec 2020 20:24:37 GMT</pubDate>
            <atom:updated>2020-12-30T20:24:37.575Z</atom:updated>
            <content:encoded><![CDATA[<p>Once in a while, you get hit with a problem you find difficult to tackle. You don’t know where to start and how to approach it.</p><p>For example, imagine the situation where you are tasked to research a topic you know nothing about, or you think about moving to a new apartment and trying to weigh the pros and cons of different places, or you have competing job offers from two different companies you like and don’t know which one to choose.</p><p>The dilemma in all these situations is, whether you trust your gut and pick what you feel is right, or you make an intentional effort to choose the best option given all the information you have. What road you take will impact the chances of getting the positive result you want. And while the first path might seem easy, the second path boosts your chances of getting high-quality long-term results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DkburNHpMW9iUb-z" /><figcaption>Photo by <a href="https://unsplash.com/@jannerboy62?utm_source=medium&amp;utm_medium=referral">Nick Fewings</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Regardless of the path you choose, you will still be a subject of a fundamental limitation of any decision-making — that is, you will never have all the data you need to make the perfect decision. You have to rely on what you have now and make your best effort to get more information, balancing it with spiraling down to the analysis paralysis.</p><p>As with any activity, the first step is the hardest one. This article presents a simple framework for getting you out of the initial stupor of making progress in your problem-solving. It is not aimed to give you an instrument to find a solution itself, but rather gives you a tool to make the first step towards finding one.</p><h3>CPR</h3><p>When faced with a problem you don’t know how to approach, you risk getting into a state of frustration going around the problem in circles never really attempting to make progress. There are few things that can help you start with the right foot.</p><p>First, you can explicitly state what you will focus on and what you will not focus on during the decision-making process. Second, you might want to tap into the wisdom of others who have different values and points of view. Lastly, ensure you leave yourself enough time to reflect and relax in order to turn on your creative thinking.</p><p>These three activities are bundled into a <strong>CPR</strong> (<strong>C</strong>onstraints, <strong>P</strong>erspective, and <strong>R</strong>ecreation) framework — your emergency help to start cracking your next problem.</p><h3>Constraints</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GiZ_UoRMuopH407O" /><figcaption>Photo by <a href="https://unsplash.com/@shali?utm_source=medium&amp;utm_medium=referral">莎莉 彭</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Constraints are some hard or soft limitations that impact how you get to your final decision. The magic of manifesting the constraints is that you make it clear for your own brain what is that you want and can control, and what is outside of your responsibility. These constraints can be applied to the process of finding a solution or to the solution itself.</p><p>For example, you can set a time constraint on your research activities or on the timeframe when you make a final decision. Also, you can make visible constraints that are present in the real world — for example, you might decide to avoid buying an electric car if there are no charging stations in your area.</p><p>Constraints might also materialize in a list of tenets that will help guide your thinking. For example, when looking for a new place to rent one tenet might read: “I want a new apartment to be the walkable distance from at least one grocery store”.</p><p>List all non-negotiable, as well as nice-to-have constraints, and be explicit about what is what. The list will help narrow your focus and free your mind from things you don’t care about. Setting limitations and making them explicit will make the process less overwhelming and as a result, will enable you to make your first steps towards the solution easier.</p><h3>Perspective</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kfT9muET0LSxMhYR" /><figcaption>Photo by <a href="https://unsplash.com/@gerveld?utm_source=medium&amp;utm_medium=referral">Gerard Lakerveld</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>While setting constraints helps you narrow your choices, seeking different perspectives enables you to uncover new and illuminating alternatives. The fastest and easiest way to explore these new perspectives is to ask around.</p><p>Start a conversation with your friend, a spouse, or a colleague. If you are not comfortable talking about the topic itself, use some tangential issue that will help you gain insights without sharing too much. When listening, seek something that you didn’t think about before. Pay attention to what is important for them? Should their priorities impact your thinking? Probe if your conversation partner has any specific constraints. Be cautious though not to blindly adopt new values that are not yours. Guard your own perspective but still keep an open mind for different points of view.</p><p>Here are a few questions that might help you start with the conversation: Have you ever thought about X? What would be important for you if you did Y? In your past when making a decision about Z, what did you consider?</p><p>In fact, talking with somebody might also bring a side effect of getting to a solution by vocalizing the problem. Sometimes when we hear ourselves out loud something clicks in our head giving us new comprehension. At the same time, if the conversation is not an option for you, check out books, articles, and forums that are all great sources of new and versatile viewpoints.</p><p>Seeking divergent perspectives is an invaluable instrument in getting you out of analysis paralysis in the decision-making process. Tapping into the knowledge and experience of people around you will reward you with a better and more balanced solution.</p><h3>Recreation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jmNVwlPDF68EpLQZ" /><figcaption>Photo by <a href="https://unsplash.com/@anton_mishin?utm_source=medium&amp;utm_medium=referral">Anton Mishin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It might feel counter-intuitive but once you dipped your toes and started to think about the problem, it might be helpful to pause and give your brain some time to reflect. Once you worked on setting up some constraints and engaged in fruitful conversations with people around you, take a break and <a href="https://www.goodreads.com/book/show/52668196-do-nothing">do nothing</a>. Don’t try to switch to another problem or another mentally strenuous activity. The opposite rather, do some breathing exercises, do some sports, stare out the window, or go take a nap.</p><p><a href="https://www.sciencedaily.com/releases/2009/05/090511180702.htm">Research</a> shows that in moments of calm our brains are able to find hidden connections, establish effect-causes relationships, and level up the overall topic comprehension. Apparently, similar to our digestive system our brains need time to digest the information we received.</p><p>Taking a break in the middle of a problem solving when you feel energized and driven might be the last thing you would want yourself to do. However, it will pay off to stop well before you become too agitated or even drained to avoid burnout. Finding the balance between effective problem-solving and refreshing breaks is a skill that needs development. To <a href="https://www.inc.com/kat-boogaard/how-to-realistically-take-a-break-during-your-workday.html">aid yourself</a>, set up a reminder to take a break once every few hours, or follow the Pomodoro approach.</p><p>Regardless of the issue’s complexity and your problem-solving skills, thinking too much about the problem can lead to an unhealthy strain that will fog your judgment and take you further away from the balanced and satisfying decision. Regular healthy breaks will improve the likelihood of getting over the hump on a way to find a solution for your problem.</p><p>Making a decision whether large or small is not an easy task. It could easily overwhelm and create unhealthy stress. The pressure of making the best possible choice might cause us to behave in unexpected ways, especially when the potential choice has a long-lasting impact (career, relocation, corporate strategy, etc.). If coin flip is not your preferred approach you can employ a CPR framework to get going on a balanced and educated decision-making process — set constraints, search for new perspectives, and don’t forget to relax and recharge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fae0ab844e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/emergency-help-for-your-next-ambiguous-problem-9fae0ab844e1">Emergency Help for Your Next Ambiguous Problem</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Your Multi-Account Git Setup]]></title>
            <link>https://medium.com/better-programming/simplifying-your-multi-account-git-setup-e8ac50798990?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8ac50798990</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 02:09:01 GMT</pubDate>
            <atom:updated>2020-09-09T02:09:01.614Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using git and GitHub with multiple SSH keys on the same machine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-_KJfC5YzSaMWeVj" /><figcaption>Photo by <a href="https://unsplash.com/@diegojock?utm_source=medium&amp;utm_medium=referral">Diego Jock</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Do you have a habit of changing hostnames when you clone git repositories to use the private key and username from the right account? You can make your life easier, save time, and free your mind for more impactful work by placing your local projects in per-account root folders and accordingly updating your git configurations. Read on to learn how.</p><p>Imagine you have two accounts on GitHub (or GitLab, or Bitbucket, or any other repository hosting):</p><ol><li><strong>Account A</strong> — your work account, and</li><li><strong>Account B</strong> — your personal account</li></ol><p>These two accounts have their unique usernames and they use their unique private keys. When working with the code in these repositories locally you need a way to specify what username and what private key to use for each repository. You have two options to make both accounts work on the same machine.</p><h3>A Quick and Dirty Way</h3><p>To let your local git know what names and private keys to use, you can create two ssh configurations in ~/.ssh/config, that will contain something like the following:</p><pre>Host github-<strong>work</strong><br>    Hostname github.com<br>    IdentityFile ~/.ssh/id_rsa_<strong>account_a</strong><br>Host github-<strong>personal</strong><br>    Hostname github.com<br>    IdentityFile ~/.ssh/id_rsa_<strong>account_b</strong></pre><p>Every time you clone a work or a personal repository you will need to manually change the remote host from github.com to github-work or to github-personal. Additionally, after cloning, you need to set up a related git username and git email to the one associated with the related account.</p><p>It would work great but sometimes you might forget to change the hostname causing local git to use the default account, or you accidentally set user.email to your personal email on your work project.</p><p>All in all, apart from wasting your time on every clone, you sometimes make a mistake and realize it only after a push to remote causing inconvenience to the rest of your team. Gladly there is a better way.</p><h3>A Better Way</h3><p>By putting a structure around how you store your projects locally, you can supercharge your development processes and forget about changing clone URLs forever.</p><h4>Step 1: Split projects into two sub-directories</h4><pre>~/<br>	workspaces/<br>		<strong>account_a</strong>/<br>			project_panda/<br>			project_tiger/<br>			project_swan/<br>		<strong>account_b</strong>/<br>			project_mice/<br>			project_cricket/<br>			project_elephant/</pre><h4>Step 2: Modify git configuration</h4><p>For your <strong>Account A,</strong> add the following configuration.</p><p>Update ~/.gitconfig to conditionally include custom account configuration for project under ~/workspaces/account_a directory:</p><pre>[includeIf &quot;gitdir:~/workspaces/<strong>account_a</strong>/“]<br>path = ~/.gitconfig_<strong>account_a</strong></pre><p>Now create ~/.gitconfig_account_a file to set up your <strong>Account A</strong> username and email and point to the ssh configuration with the private key:</p><pre>[core]<br>    sshCommand=&quot;ssh -F ~/.ssh/<strong>config_account_a</strong>&quot;<br>[user]<br>    name = Account A Name<br>    email = <strong>account.a</strong>.email@example.com</pre><p>Finally, create ~/.ssh/config_account_a file to specify github username and private key:</p><pre>Host github.com<br>    Hostname github.com<br>    IdentityFile ~/.ssh/id_rsa_<strong>account_a</strong><br>    IdentitiesOnly yes<br>    User <strong>account_a</strong>_user_name</pre><p>A similar configuration goes for <strong>Account B</strong>:</p><p>In ~/.gitconfig:</p><pre>[includeIf &quot;gitdir:~/workspaces/<strong>account_b</strong>/“]<br>path = ~/.gitconfig_<strong>account_b</strong></pre><p>In ~/.gitconfig_account_b:</p><pre>[core]<br>    sshCommand=&quot;ssh -F ~/.ssh/<strong>config_account_b</strong>&quot;<br>[user]<br>    name = Account B Name<br>    email = <strong>account.b</strong>.email@example.com</pre><p>Lastly, create ~/.ssh/config_account_b:</p><pre>Host github.com<br>    Hostname github.com<br>    IdentityFile ~/.ssh/id_rsa_<strong>account_b</strong><br>    IdentitiesOnly yes<br>    User <strong>account_b</strong>_user_name</pre><h4>Step 3: Update remotes</h4><p>If you previously used remotes with modified hostnames (for example, github-work and github-personal), you can now revert it to the original hostname github.com:</p><pre>git@<strong>github-work</strong>:awesome_you/project_panda.git -&gt; git@<strong>github.com</strong>:awesome_you/project_panda.git</pre><p>Once remotes are updated, try it out and see if it works.</p><h4>Step 4: Try it out</h4><p>Now, every time you want to clone a repository for one of your accounts, go to a respective directory and use git commands as usual. Here is an example for a project in <strong>Account A</strong>:</p><pre># cd ~/workspaces/<strong>account_a</strong><br># git clone git@github.com:awesome_you/project_panda.git<br># cd project_panda<br># git config --get user.email<br><strong>account.a</strong>.email@example.com</pre><p>And the following is an example for a project in <strong>Account B</strong>:</p><pre># cd ~/workspaces/<strong>account_b</strong><br># git clone git@github.com:awesome_you/project_mice.git<br># cd project_mice<br># git config --get user.email<br><strong>account.b</strong>.email@example.com</pre><p>As you can see, projects have been cloned using related credentials for respective accounts without the need to modify clone URLs.</p><p>Managing multiple git accounts for the same SCM hosting provider is tricky and requires some tweaks in the git configuration. While, undoubtedly, you can use modified hostnames for different accounts, the approach is prone to errors and accidental commits with a personal account to your work repo. To level up your development processes, split your projects in separate root directories locally, and forget about headaches caused by fixing the author on committed changes once and for all.</p><p>I want to thank <a href="https://medium.com/@arnellebalane">Arnelle</a> for the following article that became an inspiration to write this post:</p><p><a href="https://medium.com/uncaught-exception/setting-up-multiple-gitlab-accounts-82b70e88c437">Setting up multiple GitLab accounts</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8ac50798990" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/simplifying-your-multi-account-git-setup-e8ac50798990">Simplifying Your Multi-Account Git Setup</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Traits of Payment Engineering]]></title>
            <link>https://medium.com/swlh/5-traits-of-payment-engineering-231243af1b16?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/231243af1b16</guid>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[payments-technology]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[payment-processing]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Fri, 28 Aug 2020 00:24:01 GMT</pubDate>
            <atom:updated>2020-08-28T16:35:52.908Z</atom:updated>
            <content:encoded><![CDATA[<p>As with any engineering area, payments engineering has its own character and its own unique aspects. Creating and operating payment systems has long been a peculiar niche different from social networking, medical, or any other type of applied software engineering.</p><p>Some engineers come into the payment industry once and never leave, some, on the other hand, retreat after a short exposure. After spending close to 10 years in the payments industry and learning from some of the brightest minds I thought to share some peculiarities of the space.</p><p>This article aims to help engineers, technical executives and engineering leaders coming from non-payments background to quickly grasp key differences of payment engineering and be able to make an immediate impact on their teams and their businesses. This article can also be helpful for those who are exploring an option to come and join the payment engineering workforce and not sure if they will enjoy tackling payment engineering unique challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nMsTc9NgqbWQab_y" /><figcaption>Photo by <a href="https://unsplash.com/@cfitz?utm_source=medium&amp;utm_medium=referral">Cody Fitzgerald</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What is so different about payment engineering?</h4><p>The reason why many businesses exist out there is that they exchange certain services for customer funds (think <a href="https://www.spotify.com/">Spotify</a>) or the other way around, paying out customers for their services (think Amazon Sellers or Uber Drivers). This makes the money processing activities somewhat a universal part for most consumer and service companies out there. All these businesses have their unique payment processing status quo in part dictated by company history and growth. Some companies rely on off-the-shelf solutions like <a href="https://stripe.com/">Stripe</a>, <a href="https://squareup.com/">Square</a>, or <a href="https://www.adyen.com/">Adyen</a>, while others go deeper into the stack and invest in payment processing and optimization.</p><p>The reason payment engineering spanned out to be a distinct engineering space is dictated, on one side, by the fact that payments rely on a set of very unique integration protocols (like <a href="https://www.iso.org/standard/31628.html">ISO8583</a>, <a href="https://www.iso20022.org/">ISO20022</a>, Batch Settlement File formats, <a href="https://www.emvco.com/emv-technologies/3d-secure/">3-D Secure</a>, etc.). On the other side, it takes time to understand the end-to-end flows together with all involved parties and their technical and financial relationships (acquires, issuers, payment gateways, schemes, etc.). To make things worse, regulatory requirements and regional mandates set a high bar when it comes to compliance and security of payment systems.</p><p>Specific traits of payment engineering vary depending on what type of organization you are in (merchant, gateway, acquirer, issuer, payment method provider, or other), and whether you deal directly with payment methods like bank accounts or credit cards, or surface some alternative payment methods (for ex. <a href="https://www.paypal.com/">PayPal</a>, <a href="https://www.klarna.com/">Klarna</a>, <a href="https://www.trustly.net/">Trustly</a>, etc). Across the board the specifics of payment engineering can be clubbed into the following five traits:</p><ol><li>The value of the payment system correctness</li><li>High security bar and unique compliance requirements</li><li>Cross-functional collaboration within the organization</li><li>Integration and collaboration with other players in the payments space</li><li>Peculiar challenges in building great customer experience</li></ol><p>These traits can be represented as a pyramid where <em>correctness</em> is placed at the bottom — symbolizing the biggest level of direct control that the payment engineering team has. And going all the way up to <em>customer end-to-end payment experience</em> where payment engineering has the least amount of control (think about the fragmentation of experience throughout payment journey between an issuer, a payment method, an acquirer, and a merchant).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PiCiDEZFLhPlFlbzBtcI8Q.png" /></figure><h4>Trait #1. Payment engineering values correctness over speed</h4><blockquote>With processing payments data, high importance is placed on getting things right. Whether it is correct handling of decimal points for different currencies, or setting right flags in the payment integrations.</blockquote><p>The correctness of a payment system is paramount from the early days of its existence. Correctness comes in different forms and flavors but most often includes correctness of monetary calculations, correctness of payment integrations, and correctness of a payment system state.</p><p><em>Correctness of monetary calculations</em> ensures that payment systems can properly do basic arithmetical operations. While it sounds silly, things might get messy when you need to do tax calculations, multi-payment-method operations, or process cross-border transactions (transactions that involve more than one currency). Getting rounding rules right and consistent with your business practices is easy when you start from the beginning and hard when you attempt to fish out bugs later. So, you might decide to have an extra layer of validation and unit testing in place to avoid silly mistakes falling through the cracks.</p><p><em>Correctness of payment integrations</em> ensures that whatever messages you pass to your processing partners are right and aligned with what your business expects. This aspect of payment system correctness is explained more in Trait #4.</p><p><em>Correctness of a payment system state</em> guarantees that transactions you process are stored, visible, and match with what other players in the payment flow see. As a result, <em>transactional</em> processing becomes a crucial part of the design and operations of payment systems, where transactions move payment system from one consistent state to another (or don’t move at all should the transaction fail).</p><p>You might be asking: “Shouldn’t all computer systems value correctness?”. The answer is yes, but only to a certain extent. For example, if you look at the social networking applications, where a mismatch in a count of likes under the post is not as impactful as under-reported taxes for you and your clients. Additionally, it is hard to revert an impact of production mistakes when you post invalid data to your downstream dependencies losing the ability to change it.</p><p>To tackle the challenges of correctness in payment systems, engineers and engineering leaders need to possess meticulous attention to details and high-quality standards. It is not unusual to see payment teams strive to abnormally high test coverage in payment systems specifically for the reason that a benefit of preventing mistakes from going into production outweighs potential delays caused by adding an extra layer of unit and integration tests.</p><p>Regardless of where you are in the payment flow, building a payment processing system that is correct, reliable, and stable is a key to successful payments business. It is often better to slow down and ensure an extra set of checks and balances is in place before getting the payment system out to your customers.</p><h4>Trait #2. Payments have high security and compliance bar</h4><blockquote>Payment processing requires stricter than usual security controls and impose an additional layer of business and security compliance that impacts engineering processes.</blockquote><p><em>Information security</em> and <em>compliance</em> takes a special place in the hearts of payment engineers and broader payment teams. A particular set of compliance requirements differ depending on the type of payment information you collect and process. It can materialize in either <a href="https://www.pcisecuritystandards.org/">PCI DSS compliance</a> if you happen to handle credit card data, or <a href="https://www.nacha.org/rules/operating-rules">NACHA security requirements</a> for ACH transfers, or many other regional and payment method specific mandates. And if only information security compliance is not enough, local governing bodies can enforce other business compliance requirements, for example, requirements to collect specific data from the entities you plan to send money to (KYB/KYC), or perform transaction monitoring and reporting for anti-money laundering, or special requirements connected with the type of financial license your organization holds.</p><p>A broad set of regulatory requirements and processing mandates becomes an important input into payment engineering activities. These inputs guide decisions on how to store information, how to process customer data, and what technical providers to use and what technology providers not to use (for ex. cloud services, open-source libraries, etc.). Engineering decisions can vary from small like logging reduction (to hide customer and payment method data from logs) and ending with software development lifecycle and operational procedures (payment method data access, a four-eye principle for infrastructure and access control changes, etc.).</p><p>Successful payment engineering teams embrace the best industry practices and compliance requirements from day one and make them business-as-usual. Setting high security bar and ensuring adherence to compliance requirements is the job of each person on the team. Continuous curiosity and willingness to look beyond your scope will power up your ability to deliver secure and compliant payment systems.</p><p>As a general rule of thumb, don’t do compliance for the sake of being compliant. Compliance guidelines have been built with the goal of building trust between payment industry players and building reliable payment systems. Most of the guidelines are based on reflections from past incidents and security breaches. Embedding compliance requirements uniformly into your organization will enable you to swiftly pass regular assessments and at the same time will make you a stronger organization.</p><h4>Trait #3. Payment engineering requires cross-functional collaboration</h4><blockquote>Payments are interlaced with internal business processes. A complex net of dependencies multiplied by a variety of payment operations (a charge, refund, chargeback, adjustment, payouts, etc.) creates an almost infinite number of possible use cases that payment engineering teams need to wrap their head around.</blockquote><p>Payment workflows can be tied to a diverse set of internal processes and events. A specific set of dependencies varies based on your location in the payment flow — whether you are on the merchant, acquiring or issuing side (or somewhere in the middle). For example, if you look at the dependencies within the merchant, payment operations are triggered as a result of internal physical (for ex. shipping, delivery) or virtual (for ex. recurring billing) events. While for an issuer, payment processing will be tightly integrated with internal fraud systems, customer support, and account management services.</p><p>The more complicated internal business processes are, the harder it is for the payment engineering team to navigate and manage payment system complexity.</p><p>A great variety of business processes and structures leads to very unique payment system designs that are guided by the company’s history and future vision.This leads to an expectation for payment engineering teams to know and navigate the internals of the company and its business.</p><p>Engineers and leaders who have an ability to navigate a cross-functional environment, understand constraints, priorities, and processes of other teams within the organization will get an edge in building payment systems that nicely fit in the overall organizational architecture. If you find yourself in the payment engineering department that has a reputation of a bottleneck, your skill and willingness to build relationships across the business units will dramatically improve your chances of building a payment system your internal customers love and pivoting to a reputation of an enabler and a reliable partner.</p><p>Getting a payment system to be well integrated into the rest of the business workflows is a challenging and often long process. An in-depth understanding of the internal corporate structure and business processes along with setting up well-defined boundaries of a payment system will supercharge an ability of a payment engineering team to build payment systems that are reliable and scalable.</p><h4>Trait #4. Payment engineering involves significant integration efforts</h4><blockquote>Multitude of payment processing flows, payment service providers, acquirers, and issuers makes integration efforts to be a significant part of payment engineering job.</blockquote><p>Payments don’t happen in the vacuum. Regardless of where you are in the payment processing chain you always need to integrate with somebody. Merchants integrate with gateways, acquirers and payment method providers, gateways integrate with acquirers, acquirers integrate with schemes and so on, and so forth. On top of payment flow integration, there is plenty of auxiliary services that a company might decide to integrate with. For example, an integration with transaction risk analysis services (like <a href="https://www.ravelin.com/">Ravelin</a>, <a href="https://ekata.com/">Ekata</a>, <a href="https://www.riskified.com/">Riskified</a>, <a href="https://kount.com/">Kount</a>, etc.), payment monitoring and optimization solutions (like <a href="https://www.processout.com/">ProcessOut</a> or <a href="http://www.pazien.com/">Pazien</a>), compliance solution providers (like <a href="https://www.verygoodsecurity.com/">VGS</a>), or many-many others.</p><p>Looking at the variety of payment players, it seems like every payment-related company uses its own lingo and a set of terms. Some companies call authentication a pre-auth, some call charge a debit, some have disbursements, some have payouts. Different languages are in part caused by specifics of particular industry the company is in, sometimes it is caused by legacy, and sometimes it has been heavily influenced by the first payment related product or system the company used. Matching an external set of concepts to your internal terminology is a challenge to start. On top of that, the variety of unique messaging, flows, and data formats creates a struggle of mapping this variety to your internal data models and architecture. As a result, it is often seen that external dependencies influence how payment engineering teams think and design their payment systems (adding asynchronous flows, adding keep-alive proxies, etc.).</p><p>Decrypting integration specifications and translating them into the code is an inevitable part of the payment engineering job. Rarely though the teams can figure integration by themselves. This forces payment engineering teams to master communication and interrogation skills to uncover valuable integration information from processing partners. When things go south and square peg doesn’t fit in the round hole, integration work needs an open mind to be able to rethink your payment system design and / or integration approach.</p><p>In the ever-growing payment industry with a new payment fintechs popping up almost every week, the integration work becomes to some payment engineering teams their bread and butter. The never-ceasing integration effort of payment teams fuels a gigantic network of global payments that enables frictionless and convenient ways for customers to shop globally.</p><h4>Trait #5. Payment engineering is about end-customer experience</h4><blockquote>While often neglected, focus on customer experience throughout payment journeys (whether it is a charge, refund, or payment related customer support inquiries) builds long-lasting trust and partnership with your customers.</blockquote><p>Looking at the dashboards of payment gateways with thousands of transactions processed per second, it is hard to grasp that behind every transaction there is a real person. These transactions often signify a culmination of some kind of journey — quick like a transit pass purchase, or multi-day effort like picking up a new fridge or a vacation package. Regardless of the case, it places a great responsibility on everybody involved in the payment processing.</p><p>The correctness and stability of payment systems for a long time have been valued higher than their visual appeal or convenience. Even today across the internet and brick-and-mortar retails you can see examples of terrible customer experience, whether it comes in a form of an excruciatingly long delays or credit card forms that seems to have been created in the 90s.</p><p>For any kind of merchant, payment processing plays an important role in finalizing the customer journey. A final click on a “Pay Now” button shows the success of many teams involved — marketing, logistics, retail frontend, etc. At this moment you are one step away from converting a prospective customer into a satisfied customer (or dissatisfied customer should the transaction fail).</p><p>Modern days payment engineering teams are tasked not only with meeting the requirements of implementation specs but also actively advocating on behalf of the customer. It is a pleasure to see companies like <a href="https://stripe.com/">Stripe</a>, <a href="https://squareup.com/">Square</a> and others pushing the envelope and setting the bar high in user experience, while simultaneously ensuring their systems are reliable, fast, and developer-friendly.</p><p>Successful payment engineering teams aggregate and process an enormous amount of fragmented and heterogeneous inputs ranging from business requirements and internal organizational specifics and ending with payment protocols and security and compliance requirements. Ability to hold, structure, share, and use knowledge from all these inputs and apply it in building payment system differentiates mature payment industry experts from inexperienced payment engineering teams.</p><p>When it comes to payment engineering leadership, those leaders that feel comfortable navigating the complexity of the organizational business processes and broader payment flows beyond one’s business will help their teams to be successful and move fast to deliver best of class payment experience to their customers.</p><p>Payment engineering is a fascinating and exciting field that offers unique challenges for software developers and engineering leadership. Whether you are thinking about switching to payment engineering or want to better understand what a payment engineering team does — I hope the shortlist of traits above shed some light on the technical and process constraints that surround payment engineering.</p><p>I would love to hear from you. Tell me what you see as unique characteristics of payment engineering, and if you are a payment engineer or an engineering manager — share your view on what it means to be one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=231243af1b16" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/5-traits-of-payment-engineering-231243af1b16">5 Traits of Payment Engineering</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Non-Geek Guide to Continuous Software Delivery]]></title>
            <link>https://medium.com/swlh/non-geek-guide-to-continuous-software-delivery-aea670f99fba?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/aea670f99fba</guid>
            <category><![CDATA[continuous-delivery]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Sun, 26 Jul 2020 06:10:36 GMT</pubDate>
            <atom:updated>2020-08-04T20:28:29.075Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Continuous delivery</em> enables quick iterative releases of new features and bug fixes to your customers and, at the same time, minimizes the risk of making deployment mistakes, introducing new bugs and regressions. If you struggle to keep up with ever-multiplying bugs or you keep your fingers crossed for good luck before each release, you might need to rethink the way you build and deploy your product.</p><p>This article aims to help non-technical people like non-technical product managers, project managers, and executives to support their engineering teams on the path to building better high-quality products, keep high delivery pace and avoid unpleasant surprises for your valued customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YE4MXvnGnwZyfakJ" /><figcaption>Photo by <a href="https://unsplash.com/@jannesglas?utm_source=medium&amp;utm_medium=referral">Jannes Glas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>How to continuously deliver?</h4><p>The continuous delivery process starts with keyboard strokes of your engineering team and ends with the experience your customer has with the product. The goal of continuous delivery is to <em>shorten the time</em> and <em>avoid mistakes</em> between these two points in time. A well-oiled mature continuous delivery system takes deployment management burden off your engineering team, allowing them to focus on engineering and product build. As a consequence, a continuous delivery system decreases the on-boarding time for new joiners allowing them to start contributing within the first few days if not hours.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*C2wiVTuK3sO76oKFyFfLJQ.png" /></figure><p>While there is a great variety of different continuous delivery approaches, you can split all involved activities and steps into the following:</p><ol><li>source code management,</li><li>automated and manual code quality control — including verification of your unique functional, performance, security and compliance requirements (PCI, HIPPA, etc.),</li><li>stage-by-stage deployment with automated and manual acceptance testing, and</li><li>production deployment and continuous monitoring.</li></ol><h4>Store your code in the code repository</h4><p>The very first and most important step towards continuous delivery is a centralized place to store and share code. Code is the key (and sometimes the only) outcome of software engineering activities, and this code needs a place to live. This place is a common and shared environment that everybody on your engineering team knows and uses every day. You can think of a code repository as a Google Drive or Dropbox for engineers to share and work on the code. A great place to start your journey to build continuous delivery is to introduce a code repository in your organization if you happen not to have one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*RTNoep8EOzrbHMNMX8gvbg.png" /></figure><p>The code repository of choice is most often <a href="https://git-scm.com/">git</a> available through providers like <a href="https://github.com/">github</a>, <a href="https://about.gitlab.com/">gitlab</a> or <a href="https://bitbucket.org/">bitbucket</a> to name a few <a href="https://en.wikipedia.org/wiki/Comparison_of_source-code-hosting_facilities">[1]</a>. These providers offer powerful free tiers that will serve you for a long time until you will see a need to pay for premium features. Check-in with the team if they have any preference or prior experience before choosing any specific platform.</p><p>The most common way to approach your code management is to have one code repository per product (or a piece of product) that has its distinct life cycle. For example, backend code will have one repository, a frontend website will have another, admin and a metrics dashboard will be in a third repository. Take it is a rule that every piece of code should have its repository — starting from frontend and backend code, and ending with database schema code, serverless functions, and infrastructure definition.</p><p>Setting up a code repository might seem like a waste of precious time especially in a startup environment. However, look at it as a high ROI investment and major mitigation for various operational risks. Consequences of not having centralized storage for code artifacts can vary from minor things like a decrease in productivity and slow knowledge sharing to more disastrous events like loss of your entire products should your engineers’ laptops break or get stolen.</p><p>The code repository is an integral part of any software development process and should be adopted by any technological company early its days. The code repository makes it possible for engineers to store and share code, track revisions, and incoming change requests.</p><h4>Review, inspect and test every product change</h4><p>All changes to your products are made by humans, and humans are prone to making mistakes — which is not bad, but rather how things are. And while we can all ask our colleagues and teams to write bug-free code — bugs still do slip through the cracks. To minimize the risk of getting bad product changes into our customers’ hands we can introduce a couple of additional hops that the change needs to jump through. First, we can employ computer programs (<em>automated tests</em> and various <em>code analysis</em> tools) to be impartial judges of the quality of changes we introduce. Second, other people on the team might be able to spot issues or deficiencies in the change the author overlooked (<em>manual review process</em>). Both of these steps ideally would be triggered automatically on every code change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*Qvvr_d3R6kFcfJez8DAm6A.png" /></figure><p>Most of code repository providers (including <em>github</em>, <em>gitlab</em> and <em>bibucket</em>) provide tools to build continuous delivery <em>pipelines</em>. A pipeline is a set of predefined steps that run automatically following a particular event (code commit, time schedule, manual trigger). An example of a pipeline definition could be “on every commit, build the product and run automated tests on it”. Configuring and streamlining pipelines will require some time and iterations but will quickly bring the reward of stable products and happy customers.</p><p>One of the options how the process of accepting new code change into repository can look as following:</p><ol><li><strong>Submit new code change</strong>. The author of a code change submits a change request to the code repository. At this stage, code is placed in a separate “sandbox” (also known as a pull-request, or change-request). This is done to prevent potentially harmful changes to making their way into the main code base unverified.</li><li><strong>Trigger automated tests</strong>. On changes submitted to the code repository, pipeline executes tests that validate basic functionality, compliance with code style, and security standards. If the pipeline fails, it notifies the author of spotted errors and waiting for the author to provide a fix.</li><li><strong>Open a code review request</strong>. At the same, either automatically after smoke tests or on author request, the code management system opens a code review request where teammates can check out the change candidate, leave comments, improvement suggestions or ask questions. Once all involve satisfied and approve a request — change can make it to the next stage. 1–2 people to look through the code is usually enough.</li></ol><p>Once steps above are completed, your code is ready to be <em>merged</em> to the main codebase where it will slowly progress through a series of <em>stages</em> and additional verifications.</p><p>Early validation of changes avoids costly impact on your customers. Setting up gatekeepers prior code merged into the main branch helps ensure that at any given moment your main code base is stable and functional. One of the additional benefits of having such gatekeepers is to allow engineers to work on different changes simultaneously and not stepping on each other toes. Each new incoming change is an increment on top of a stable and tested product.</p><p>There are countless articles on how to build your manual review process as well as on how to build test automation. Below are some articles that I would recommend as a starting place to dive deeper into the topic:</p><ol><li><a href="https://google.github.io/eng-practices/review/reviewer/">How to do a code review — Google’s Engineering Practices</a></li><li><a href="https://stackoverflow.blog/2019/09/30/how-to-make-good-code-reviews-better/">How to Make Good Code Reviews Better — The Overflow</a></li><li><a href="https://bitbucket.org/blog/level-up-your-code-review-with-continuous-integration">Level up your code review with continuous integration — Bitbucket</a></li></ol><h4>Deploy changes stage by stage</h4><p>Your code change is now ready and finally merged into the main codebase. It might be tempting to get and <em>deploy</em> your change right to production. However, you run a risk of having a product that has functionally correct but either fails to communicate with its downstream dependencies (database, other services), or due to miscommunication it is not what you expected to see. For these reasons, you can decide to introduce a multi-stage deployment that will first deploy your code internally — for you and your team to have a look, and then externally — for the public. In its minimal setup, it translates into two stages — a development stage and a production stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TOXwIe-rsqJq5XvuVJnFw.png" /></figure><p><em>The development stage</em> is an environment where your product is similar way and structure as in production, with a difference that it doesn’t process production data, and only you and your team have access to it. In the development stage you can run <em>integration tests</em> to verify integration with downstream dependencies (databases, metric aggregators, etc.), run automated <em>user experience tests</em> to automatically check that all buttons, links, and fields are functional and behave as expected, as well as to try out the product by clicking through it yourself — <em>perform manual testing</em>. In the case of the customer portal, for example, the development stage would be a website with restricted access, in the case of an app — development stage would be a draft version of an app available through beta testing tools (like TestFlight for iOS).</p><p><em>The production stage</em> is the final stage where customers interact with your product. The goal of the whole continuous delivery process is to ensure that as little bugs as possible end up here. The production stage works on production data, integrates with other production services, and serves real customer traffic.</p><p>While at least two stages can be considered as a minimal setup, depending on the type of the product you build (SaaS APIs, licensed software, software for hardware components, customer portals, machine-learning algorithms, etc.) you might need to have a broader set of stages. Here is a non-exhaustive list of possible options:</p><ul><li><strong>Development stage</strong> — for your internal testing and validation</li><li><strong>Testing stage</strong> — to allow your customers to integrate with it in their test environment (relevant for SaaS companies)</li><li><strong>Performance Testing stage</strong> — to run load testing and measure the performance of a system similar in setup to production</li><li><strong>Canary stage</strong> — to deploy release candidate and divert production traffic partially to it. This will allow you to get a sneak peek preview of how new change will behave in production without impacting 100% of your traffic <a href="https://rollout.io/blog/canary-deployment/">[2]</a>.</li><li><strong>Production stage</strong> — your final stage that your customers are continuously interacting with.</li></ul><p>All major code repository providers have pipeline solutions to enable you to configure multi-stage deployments. Some will have rich pre-defined workflows and integrations, others will give you just bare basics to build on top of them. In addition to code repository providers there are solutions focused solely on continuous delivery — for example, <a href="https://circleci.com/">circleci</a>, <a href="https://travis-ci.org/">travisci</a>, etc which can help you solve some unique problems like mobile testing, custom approval workflows, and others.</p><p>There is no-one-size-fits-all pipeline configuration, so work with your team to figure out what stages, transitions, and notification you need and how to best configure and run your unique pipeline.</p><h4>Monitor, rinse and repeat</h4><p>If you have your code change deployed automatically, but then you manually go to the browser and nervously check if production is still up and running you can say you have a <em>Schrödinger’s Production</em> (analogous to <em>Schrödinger’s Cat</em> <a href="https://en.wikipedia.org/wiki/Schr%C3%B6dinger%27s_cat">[3]</a>).</p><p>With almost any kind of product, you would want to continuously monitor its status, performance, and other metrics that are important for your business (conversion rates, latencies, resource consumption, etc.). Monitoring approach and a specific set of metrics will largely depend on the type of product you deliver (SaaS, IoT, mobile applications, etc.). The main point is that in order for you be able to proactively react to <em>outages</em> and issues with your product you would need some minimal set of health checks that will trigger <em>alarm</em> notifications to you and your team. Last thing you would probably want it your customers reaching out to you notifying that your product is out of order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9fGNSQIVC6pjZLro4TObw.png" /></figure><p>An example of a basic health check for your backend server is a periodic ping from a monitoring system to your production server that expects a successful response. For a mobile application, it could be analytics platforms that provide you an aggregated view of your customers’ activity. Big unexpected deviations in customer activity might be an indicator of issues the newly released version.</p><p>There is plenty of metric aggregators and other solutions that can help you streamline your monitoring. For example, <a href="https://www.datadoghq.com/">datadog</a> provides beautiful easy-to-configure dashboards with countless integrations for your cloud and mobile needs; or <a href="https://aws.amazon.com/cloudwatch/">CloudWatch</a> for those who’d like to stick to AWS. Again, when picking a tool, ask around and check-in with your team if they already have some experience with any of the monitoring platforms. This could potentially save you a lot of time finding and onboarding the right solution for your needs.</p><p>Having said all that, issues do get sneak into production unnoticed despite our best efforts. In anticipation of that, you might decide to give your customers a quick and easy way to report problems with your service — a feedback form, a “report problem” button, etc.</p><p>Visibility into your product operations is an essential part of continuously delivering stable and reliable software products. A well-configured monitoring system will bring you peace of mind and will save precious time should things go south.</p><h4>Why do I need all that?</h4><p>Let’s face it. Building products is hard, and what is harder is to keep the pace up when product complexity grows. Through research and analysis, it became apparent that leaving the quality of your code unattended can bring disastrous consequences to your team and to your business as a whole. Without proactive measures to continuously keep the code quality up the amount of maintenance effort grows, while the speed of delivery of new features goes down. Investing time to automate your testing and deployment processes as well as dedicating time to removing technical debt is rather a necessity than an option. Check out a nice <a href="https://www.mindtheproduct.com/stop-technical-debt-from-slowing-your-product-down-by-asa-schachar/">talk by Asa Schachar</a> on the topic of technical debt and how to proactively tackle it.</p><p>Companies and startups too often fall into the trap of fast delivery and short-cuts forgetting to balance speed with sustainability. You might have heard the phrase “if it works, don’t touch it” that usually becomes a motto of teams that didn’t prioritize continuous delivery and automated validation in their development process.</p><p>Investing time in the continuous delivery system will make your customers and your engineering team happier by increasing the stability of the product and increasing confidence in introducing new changes. Tailored and well-functioning delivery system will have your back even if you happen to make a mistake.</p><p>This article doesn’t aim to provide a definitive guide to continuous delivery and continuous integration, but rather its goal is to help non-technical leaders or those starting on a technical path get an introduction into the software delivery process. Continuous delivery concepts are important to understand for everybody in the organization — including technical and non-technical leaders. It allows the team to synchronize around basic principles and constraints of software delivery and properly manage expectations.</p><p>While every company and every organization is different in ways they build and deliver products, introducing continuous delivery will bring immediate benefits to your team and your customers, and will help ensure the long-term sustainability of your delivery processes and your product.</p><p>I would love to hear from you about your experience of setting up continuous delivery in your organization and what issues you have faced on that journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aea670f99fba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/non-geek-guide-to-continuous-software-delivery-aea670f99fba">Non-Geek Guide to Continuous Software Delivery</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Steps to Run Scheduled Jobs on AWS Elastic Container Service]]></title>
            <link>https://vthub.medium.com/running-ecs-fargate-tasks-on-a-schedule-fd1ca428e669?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd1ca428e669</guid>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[fargate]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Thu, 27 Feb 2020 04:32:19 GMT</pubDate>
            <atom:updated>2020-09-01T18:32:04.212Z</atom:updated>
            <content:encoded><![CDATA[<p>With an ever growing number of microservices within the companies and across the internet, there is often still a need to execute long-running offline tasks. The purpose of such tasks can vary from doing routine checks and cleanups to performing complex data analysis and machine learning on collected data. One of the approaches to manage recurring long-running tasks on AWS is to leverage Elastic Container Service (or ECS).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W2BztQUs-RU8W7Zc" /><figcaption>Photo by <a href="https://unsplash.com/@szucslaszlo?utm_source=medium&amp;utm_medium=referral">Szűcs László</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why ECS?</h3><p>There are several alternative approaches to consider before even starting on a path of scheduled ECS tasks. The most prominent being <em>lambda functions</em> and <em>continuously running services</em>. Both of them have limitations that you might need to consider to evaluate their fitness for your problem.</p><p>Lambda functions’ limitations include code size limit and execution time limit — read about lambda limitations more <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html">here</a>.</p><p>As for continuously running services, they will increase your AWS bill by keeping your resources continuously in use. Moreover, you might need to expose and properly secure a network endpoint to centralize the management of your execution schedule outside of individual containers or machines.</p><h3>Overview of the approach</h3><p>In order to create a scheduled ECS FARGATE task, you need to complete the following three steps:</p><ol><li>Have a docker repository (for ex. ECR) with an image that you want to run</li><li>Create an ECS cluster and define a task with the above image</li><li>Configure CloudWatch Event Rule to periodically launch the ECS task</li></ol><p>Throughout the post, I will describe the infrastructure in the form of terraform configuration with a full project example available on <a href="https://github.com/vthub/scheduled-ecs-task">github</a>.</p><h3>Creating an ECR repository</h3><p>As an initial step, you will need to create an ECR repository to store your docker images. You can follow the official <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-create.html">AWS guide</a> for this purpose. For sample project to work, create a repository with a name scheduled-ecs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xA12U9WRwoxux3XquCUglQ.png" /></figure><h3>Getting Docker image ready</h3><p>Once you have your ECR repository ready, let’s create a simple docker image that will do some ficult networking tasks. In the example below, a python script will call <a href="https://httpbin.org/">httpbin</a> and expect a 200 response. Otherwise, docker will exit with non-zero code.</p><p>Python script code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1fc2a0058056fb653e69d6fd7c5114d/href">https://medium.com/media/e1fc2a0058056fb653e69d6fd7c5114d/href</a></iframe><p>Dockerfile contents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c86fa3cc37e4fb1307f3eaaa250ddb0/href">https://medium.com/media/4c86fa3cc37e4fb1307f3eaaa250ddb0/href</a></iframe><p>Once the docker image is ready, you can try to run it locally to verify that your docker image can successfully call httpbin:</p><pre>docker build -t scheduled-ecs-task <strong>.<br></strong>docker run scheduled-ecs-task</pre><p>You should see something like:</p><pre># docker run scheduled-ecs-task<br>Calling httpbin<br>Successfully completed</pre><p>Once you built and verified your image, upload it to ECR repository (you can find your ECR repository URI on the ECR screen in AWS console):</p><pre><strong>eval</strong> <strong>“$(aws ecr get-login — no-include-email — region us-west-2)”<br></strong>docker build -t scheduled-ecs <strong>.<br></strong>docker tag scheduled-ecs:latest <strong>“YOUR_ECR_REPO_URI:latest”<br></strong>docker push <strong>“YOUR_ECR_REPO_URI:latest”</strong></pre><h3>Defining ECS Cluster, Service and Task</h3><p>When you successfully published your docker image to the ECR repository, you are ready to create a cluster, task definition and a service. The following terraform configuration describes the necessary infrastructure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3986763d4a5cda3b14b794c45b025341/href">https://medium.com/media/3986763d4a5cda3b14b794c45b025341/href</a></iframe><p>In the above example, you can spot the service configuration. This configuration is not required for a scheduled execution and was rather provided as an example if you will decide to run your task continuously in the future.</p><p>The task definition is sourced from the def.json:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/004e5d11937861a36804be7d8e109cdf/href">https://medium.com/media/004e5d11937861a36804be7d8e109cdf/href</a></iframe><p>Above resources and definitions reference log and network configurations not mentioned in the post. To find related resources see the full sample project on <a href="https://github.com/vthub/scheduled-ecs-task">github</a>.</p><h3>Scheduling an ECS Task</h3><p>To tell AWS to run ECS task periodically, you can follow the <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html">official AWS docs</a> that go through the process of setting up CloudWatch Events along with cron scheduling to kick off ECS tasks.</p><p>First, you need to create a CloudWatch rule that will specify the schedule when to trigger a particular CloudWatch event:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8392014d27ac6236fda106177af4e8c/href">https://medium.com/media/c8392014d27ac6236fda106177af4e8c/href</a></iframe><p>Along with rate expression, you can use <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions">other cron-like</a> definitions.</p><p>Second, create a CloudWatch event target and point it to the ECS cluster, where you want your task to be triggered:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d730ff7f179060183c8d61a342a34e1e/href">https://medium.com/media/d730ff7f179060183c8d61a342a34e1e/href</a></iframe><p>As you see above, the event target configuration includes the ECS target, which, in essence, is a service configuration that Cloud Watch will add to the cluster every time Event Rule is triggered. Meaning Cloud Watch starts up a service inside a cluster, rather than a task inside a service.</p><p>You might be wondering why the ECS target’s network configuration requires a public IP. It seems that public IP enables the FARGATE type task to communicate with ECR to pull the image. Otherwise, you will get a CannotPullContainerError / Client.Timeout exceeded while awaiting headers error. As a mitigation for security risk caused by open public IP, you can update the security group to disallow any incoming connections.</p><h3>Permissions</h3><p>Historically, both ECS and CloudWatch Events had limited capabilities to debug and troubleshoot setup issues. Especially when it comes to the permissions and security, therefore ensure that <em>(a)</em> your ECS service has necessary permissions to pull the image from ECR (AmazonECSTaskExecutionRolePolicy managed policy) and <em>(b)</em> your CloudWatch Event has permissions to kick-off ECS task. <a href="https://github.com/vthub/scheduled-ecs-task/blob/3f297fcae4e346e5e6b16a6c975db1c9eae219c9/infrastructure/iam.tf#L75-L101">Here</a> is sample policy for CloudWatch Event that includes two required actions ecs:RunTask and iam:PassRole:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ea9f50bf89c79834160a42a5ae873c7/href">https://medium.com/media/5ea9f50bf89c79834160a42a5ae873c7/href</a></iframe><h3>Testing</h3><p>After you have configured ECR, ECS and CloudWatch Events, you should be able to see the execution metrics in the CloudWatch console. Hopefully, you will see lots of successful executions, and none failed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aooLmJifcvSINJU31BlFwg.png" /></figure><p>To find currently running task go to Cluster then “Tasks” tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3mnfhHsVhK4fxDbDlCQX5g.png" /></figure><p>You can also see a history of finished task executions if you toggle “Desired task status” from “Running” to “Stopped”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Hlg4IO2LWM_fDlp12JjEg.png" /></figure><h3>Troubleshooting</h3><p>There are a few reasons why things might not work from the first attempt. Below are a few troubleshooting tips:</p><p><strong>ECS cannot pull container an image ECR</strong>. In this case, you will the following error on your task page: CannotPullContainerError. To solve this issue, check that your Task execution role has ECR access and also check that your service or CloudWatch rule has Public IP enabled.</p><p><strong>CloudWatch Event doesn’t trigger ECS</strong>. This is happening most probably due to the misconfiguration in the IAM role that CloudWatch uses. Verify that it has both ecs:RunTask and iam:PassRole permissions.</p><p><strong>ECS pulls an image but doesn’t seem to do anything or stops without running the code</strong>. As your long-running task might be computationally or memory-intensive, check that you have enough memory and CPU units both in a task and in a container definition. Without enough memory or CPU units, the task can abruptly stop.</p><h3>References</h3><ol><li>Ready-made terraform module for deploying scheduled ECS task: <a href="https://github.com/dxw/terraform-aws-ecs-scheduled-task">https://github.com/dxw/terraform-aws-ecs-scheduled-task</a></li></ol><p>Check out the source code with code samples from this article on github:</p><p><a href="https://github.com/vthub/scheduled-ecs-task">vthub/scheduled-ecs-task</a></p><p>Running Docker images on AWS requires a bit of a know-how and a bit of a luck. Hopefully Docker support will improve in the future to allow 1-click deployments, out-of-box rollbacks and build version tracking. Until then, I hope above information helped you deploy your Docker image to the ECS cluster without unnecessary headache. Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd1ca428e669" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure Your Static Website with AWS CloudFront and Lambda]]></title>
            <link>https://vthub.medium.com/lambda-edge-and-jwt-authentication-to-protect-sensitive-components-of-your-reactjs-app-901e0c10fd35?source=rss-f1be13d365f0------2</link>
            <guid isPermaLink="false">https://medium.com/p/901e0c10fd35</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[cognito]]></category>
            <dc:creator><![CDATA[Vasilii Trofimchuk]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 16:58:06 GMT</pubDate>
            <atom:updated>2020-08-24T21:51:15.154Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the possible applications of Lambda@Edge is pre-processing and post-processing of the requests that flow through CloudFront. Therefore Lambda@Edge can be used to authorize the user to access a resource behind CloudFront. CloudFront is often used to serve static content such as Single Page Applications stored in S3.</p><p>This article covers an approach on how to protect sensitive parts of your Single Page Application written using ReactJS by leveraging both frontend and backend Authorization, AWS Cognito, Lambda@Edge and CloudFront.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p6a7XLf8TDoW08io" /><figcaption>Photo by <a href="https://unsplash.com/@octoberroses?utm_source=medium&amp;utm_medium=referral">Aubrey Odom</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Even though you should not store any sensitive data in your frontend, you might want to hide the front-end logic of your App (things like field names, endpoints and data structures) from unauthorized users to prevent, for example, reverse engineering.</p><h3>TL;DR</h3><p>You can protect selected parts of your ReactJS App by splitting code in chunks with webpack, serving them through CloudFront, and authorizing with Lambda@Edge and AWS Cognito. Code is <a href="https://github.com/vthub/aws-react-jwt-auth">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6yFc-Yg9j8IvCN3JjG1wAQ.png" /><figcaption>High-Level Diagram</figcaption></figure><h3>Creating a Single Page Application</h3><p>First, we need to create a simple ReactJS App. For this, we can use create-react-app .</p><pre># create-react-app aws-react-jwt-auth</pre><p>Within your app, create two separate components— a <strong>public component</strong> that will hold information available to the public without authorization and a <strong>protected component</strong>, that will be loaded and available only for authorized users.</p><p>Public component (Public.js):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9955f123ec9447d021d75f0a47c4114/href">https://medium.com/media/d9955f123ec9447d021d75f0a47c4114/href</a></iframe><p>Protected component (Protected.js), that contains some logic that you don’t wish to expose to the public:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c74f44d8e0c6bf66e8d6c94d91d2220/href">https://medium.com/media/7c74f44d8e0c6bf66e8d6c94d91d2220/href</a></iframe><p>App.js will need to facilitate navigation between public and protected components and is as simple as possible for needs of this post:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f86756a0a2b088841152eff21134215/href">https://medium.com/media/0f86756a0a2b088841152eff21134215/href</a></iframe><p>If you now run your application locally, you will see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMEWOgBuGliJkxhrBI1M-w.gif" /><figcaption>Navigation between public and protected components</figcaption></figure><p>If you check network logs, you will see that all the chunks of the App are loaded at the same time on App startup.</p><h4>Loading Protected Component On-Demand</h4><p>In order to avoid loading of a protected component at the startup time, create an Async wrapper. To read more about this approach check out <a href="https://serverless-stack.com/chapters/code-splitting-in-create-react-app.html">this article</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8d0e304507eb96dd1de0eb34d445421/href">https://medium.com/media/b8d0e304507eb96dd1de0eb34d445421/href</a></iframe><p>To enable asynchronous loading for a specific component, modify App.js and wrap protected component with newly introduced asyncComponent function:</p><pre>import asyncComponent from &quot;./AsyncComponent&quot;;<br>import {withAuthenticator} from &#39;aws-amplify-react&#39;;<br><br><strong>const AsyncProtected = asyncComponent(() =&gt; import(&quot;./Protected&quot;));</strong><br><br>class App extends Component {<br>    render() {<br>        return (<br>            ...<br>               &lt;Route path=&quot;/protected&quot; component={<strong>AsyncProtected</strong>}/&gt;<br>            ...<br>        );<br>    }<br>}</pre><h4>Separating JS chunks</h4><p>While the protected component is now loaded asynchronously we don’t control where the respective code component is. To change that and place sensitive code separately, mark protected components with <a href="https://webpack.js.org/api/module-methods/">webpack magic comments</a> in App.js:</p><pre><strong>const </strong>AsyncProtected = asyncComponent(() =&gt; <strong>import</strong>(<strong>/* webpackChunkName: &quot;protected/a&quot; */ </strong>&quot;./Protected&quot;));</pre><p>If you check logs now, you will see the magic 🧙‍♂️:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFsrnMF_qTC7vz5im9vQgw.gif" /><figcaption>Loading protected components separately</figcaption></figure><h4>Configuring User Pool in AWS Cognito</h4><p>Quick and easy way to enable user authentication through AWS Cognito is to use AWS Amplify library that has an extension for ReactJS Apps.</p><p>First, go to AWS Console and <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-as-user-directory.html">create a new User Pool</a> in AWS Cognito with default settings. Under newly created User Pool add a new App Client and don’t forget to de-select “Generate Client Secret” as there are no secrets in javascript. 😉</p><p>The configuration will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_od0RRjYmXbppht2z31UA.png" /><figcaption>Cognito configuration</figcaption></figure><h4>Integrating ReactJS App with Cognito using Amplify</h4><p>Next, add AWS Amplify libraries to your single page app:</p><pre>npm i aws-amplify aws-amplify-react</pre><p>Configure Auth module in your App, for example in index.js. The configuration includes references to your User Pool and Client configured above as well as the storage configuration for JWT tokens:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bc861739e2a3f7ec602e8d84c8277d4/href">https://medium.com/media/0bc861739e2a3f7ec602e8d84c8277d4/href</a></iframe><p>Wrap protected component routing in withAuthenticator() before it gets loaded in App.js to enable authentication:</p><pre>&lt;Route path=&quot;/protected&quot; component={<strong>withAuthenticator(</strong>AsyncProtected<strong>)</strong>}/&gt;</pre><p>Here is complete <a href="https://gist.github.com/vthub/a796f5102cee41466069119ac514badf">App.js</a>.</p><p>Now, <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-create-user-accounts.html">register a user in your Cognito User Pool</a> and try out the authentication (I <a href="https://github.com/vthub/aws-react-jwt-auth/blob/master/src/Protected.js">added</a> “Sign Out” button for ease testing):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ep_GgHU_rqlPUror3HJpRg.gif" /><figcaption>Adding authentication with AWS Cognito and Amplify to you App</figcaption></figure><p>While your App is now protecting the contents of the second component, it is done on the best effort. And still, everybody who opens network logs and checks what is loaded can see javascript code of the protected component. Note: don’t store any sensitive data on the frontend. This post offers you a way to protect the logic of how you process your sensitive data from the backend, not the sensitive data itself.</p><p>Let’s now protect the code of the second component on the backend using Lambda@Edge.</p><h3>Creating CloudFront Distribution</h3><p>There are plenty of articles about deploying single page apps to S3 behind CloudFront. One that is my favorite:</p><p><a href="https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af">Deploying create-react-app to S3 or CloudFront</a></p><p>Follow steps in the article to prepare your S3 and CloudFront distribution for the next step.</p><h3>Creating Lambda@Edge function to Authorize access</h3><p>Now, it is time to secure a JS chunk with protected logic of the App on the backend. For this, we will need to create a Lambda@Edge function that will validate authorization with JWT when the related chunk is requested.</p><p>First of all, create a new Lambda in N. Virginia — where all Lambda@Edge functions live.</p><p>In the code, filter out all the requests that do not go to /static/js/protected path and ignore them as they don’t require authorization:</p><pre>exports.handler = (event, context, callback) =&gt; {<br>    const cfrequest = event.Records[0].cf.request;<br>    if (!cfrequest.uri.startsWith(&quot;/static/js/protected&quot;)) {<br>        callback(null, cfrequest);<br>        return true;<br>    }<br>    ...<br>}</pre><p>All other requests will be subject to authorization using JWT that client is expected to send in the headers. Validation of JWT token consists of the following steps:</p><ol><li>Check if the JWT token is present and has a valid structure</li><li>Ensure that JWT token was generated by the trusted User Pool</li><li>Validate JWT signature</li></ol><p>The full code is available in the <a href="https://github.com/vthub/aws-react-jwt-auth/blob/master/lambda/index.js">GitHub repository</a>.</p><h4>Deploying Lambda</h4><p>Once your Lambda is ready, prepare it for deployment.</p><p>Update Trust Relationship of the role of your Lambda to include edgelambda.amazonaws.com in your AssumeRole statement:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: [<br>          &quot;<strong>edgelambda.amazonaws.com</strong>&quot;,<br>          &quot;lambda.amazonaws.com&quot;<br>        ]<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><p>Now you can deploy you Lambda@Edge and attach it to CloudFront distribution. Open your Lambda and then go to <em>Actions &gt; Deploy to Lambda@Edge</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gVX4tROJnmC7GZi3Xrc7Yw.png" /><figcaption>Pick the right CloudFront distribution in the deployment dialog</figcaption></figure><p>After deployment, wait for a couple of minutes for Lambda to propagate and then try accessing your protected JS chunk. You should see 401 error page, like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zQzLg2M81YHLfEtDsk3vkw.png" /><figcaption>A protected chunk of JS is now secured on the backend</figcaption></figure><p>Now, everything is ready for final testing.</p><h3>Let’s Test It</h3><p>To validate the setup, go to CloudFront distribution URL, open protected component and login with you AWS Cognito credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Ga_OWx_bKXyF6nvPHv6WQ.gif" /><figcaption>End-to-end test</figcaption></figure><h3>👏</h3><h3>Final Notes and Considerations</h3><ol><li>While this post offers you a way to protect some of the parts of your JS App by backend authorization, it doesn&#39;t secure the data that JS App loads. Secure your APIs separately</li><li>Avoid storing any sensitive data in the JS App code.</li><li><a href="https://aws.amazon.com/lambda/edge/">Lambda@Edge</a> costs <a href="https://aws.amazon.com/lambda/pricing/">money</a> and it is not part of Free-Tier.</li><li><a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html">AWS Cognito</a> gives you much more than just username/password login covered in this article. For example, you can add authenticators like Social Sign-In, SAML, MFA.</li><li>Complete App and Lambda code is available on <a href="https://github.com/vthub/aws-react-jwt-auth">GitHub</a>.</li></ol><p>Hope you enjoyed this post. Clap and comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=901e0c10fd35" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>