<?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 Davide de Paolis on Medium]]></title>
        <description><![CDATA[Stories by Davide de Paolis on Medium]]></description>
        <link>https://medium.com/@dvddpl?source=rss-4c34338fa8b3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DdY2rmm5nCfzDlOwlh19VA.jpeg</url>
            <title>Stories by Davide de Paolis on Medium</title>
            <link>https://medium.com/@dvddpl?source=rss-4c34338fa8b3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 06:59:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dvddpl/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[There is no right or wrong, as long as it works — Actually, how you use DynamoDB makes a lot of…]]></title>
            <link>https://dvddpl.medium.com/there-is-no-right-or-wrong-as-long-as-it-works-actually-how-you-use-dynamodb-makes-a-lot-of-365a1d5b8d8f?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/365a1d5b8d8f</guid>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Wed, 31 May 2023 09:10:59 GMT</pubDate>
            <atom:updated>2023-06-01T07:13:29.786Z</atom:updated>
            <content:encoded><![CDATA[<h3>There is no right or wrong, as long as it works — Actually, how you use DynamoDB makes a lot of difference!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*nDXiN0g4hnP7YwhK.png" /></figure><p>Some time ago a friend of mine asked me for advice about a serverless app he was working on.<br> He had always worked as a frontend developer but due to some layoffs in his company, he had to fix/add features to the backend too.</p><p>The backend consisted of a simple ApiGateway + Lambda + Dynamo and specifically he was dealing with an issue aggregating data from multiple tables and editing records.</p><p>He was struggling in understanding <em>how</em> things were done and most importantly <em>why</em> they were done that way, his experienced developer’s 6th sense warned him about something fishy, but when you start with something new, be it a language or framework, and you happen to be working on an existing codebase, that has been running on production for at least a couple of years, you tend to assume that what you see is the way to go and you tend to learn from those examples and the patterns you find.</p><p>That’s why he approached me. <br> Just by looking at some metrics in AWS Cloudwatch and at the AWS Cost Explorer, <strong>it was pretty evident that something was <em>off</em> in the way the database had been modelled, or at least in how it was queried</strong>: compared to the number of requests to the backend, the number of Read and Write Capacity Units consumed was very very high!</p><p>Before we dive into the coding part, let me tell you a story:</p><p>I am a passionate climber and recently, wanting to push a bit beyond my current skills I decided to hire a trainer.</p><p>After one of the first climbs she asked me how it went, if I noticed something in the way I approached and concluded the route.</p><blockquote><em>How did it go?<br> Not really great, I made some mistakes while passing the </em>crux<em>.</em></blockquote><blockquote><em>But you reached the top! That’s what matters, wasn’t that your goal?<br> Naaa, I really got </em>the beta<em> wrong.</em></blockquote><blockquote><em>But you managed it, so why do you think you did it </em>wrong<em>?<br> Because I was slow, my movements were not elegant at all and I felt really </em>pumped<em> long before the top.</em></blockquote><blockquote><em>Alright, but that it’s not a matter of </em>right or wrong<em>. You reached the top, so you did good. You haven’t climbed </em>wrong<em>, you just climbed </em><strong><em>inefficiently</em></strong><em>. <br> You had not properly visualised your movements before you started, you tried different moves along the route, used your body weight and positioned your hands and foot in a way that costed you time and therefore energy.<br> If your goal is to climb faster, longer or harder you need to </em><strong><em>pay more attention at how efficient you move and at how you utilise your resources</em></strong><em> ( vision, breathing, explosive energy, stamina, mental strength, recovery time and so on).</em></blockquote><p>That immediately reminded me at the many times when during meetings at work ( be it discussions about the possibility of a refactor, a code review or just the estimate of a new feature) someone dropped the classic:</p><blockquote><strong><em>nobody cares about the code</em></strong><em>, as long as it satisfies the users needs, works and it shipped on time.</em></blockquote><p>Who cares if it’s NodeJs or Python, if it uses DynamoDB or PostgreSQL, if it’s Clean Code or a Big ball of Mud, if it has tests or if it’s an undocumented untestable mess — as long as it works, it’s OK!</p><p>As long as it works.</p><p>Of course no one cares <em>as long</em> as it works, because no one will notice how things are done until a big bug happens on production or the Cloud bill starts growing wild, or any new feature starts taking ages to be implemented and introduces exponentially more bugs.</p><p><strong>Technical Debt creeps in</strong> sprint after sprint and its poor code quality or wrong, bad, sorry inefficient/not-sustainable/unscalable architectural choices show their nefarious only after weeks or months or even years.</p><p>Will it become a problem? we don’t know, but we might know if we <strong>reason about our goals and about purpose</strong>.</p><blockquote><em>Is this piece of code a temporary feature?<br> Is this app just a proof of concept?<br> Do I need to hit the market as fast as possible, will it need to scale ?</em></blockquote><blockquote><em>How much will it cost?<br> Am I taking into account the possibility that if everything goes well I will need some future buffer to fix the shortcuts I am taking?</em></blockquote><p>In the case of my friend&#39;s code base, the backend was written by a contractor engaged to write a proof of concept. The code was then simply pushed to production and new functionality was added by inexperienced backend developers (like my friend) following the <strong>poor coding practices</strong> of a <em>prototype</em>, not the best practices a production app should have.</p><p>That resulted in an <strong>undocumented untestable mess</strong>, that indeed absolutely did the job, but at the expense of the poor developers that had to maintain it and of the management that paid the AWS bill ( who did not know and does not care, as long the app is making a profit ).</p><p>So, what was wrong inefficient, in my friend’s code base?<br> It turned out that</p><ul><li>the <strong>Database model was inappropriate</strong> considering how the app grew since the prototype (using NoSQL with more than 25 tables and different secondary indexes)</li><li>the queries to gather data were sort of <em>relational</em> and were not optimised properly ( being run simply in a sequence) — those queries were returning way more data that was needed, with considerable weight and complexity in aggregating, and filtering out data that was not necessary</li><li>since the edit operation always overwrote the entire row, loading the row was necessary in order to just edit a couple of properties</li><li>there was no caching whatsoever</li></ul><p>Let’s take a closer look at the advice I gave to my friend to <strong>improve the code base</strong>, <strong>reduce latency</strong> and <strong>cut costs</strong> altogether.</p><h3>Favour Single Table Design</h3><p>I won’t go into the details of Single Table Design vs Multi Table design too much, since AWS Hero Alex De Brie wrote extensively about it:<br> you can read really interesting stuff <a href="https://www.alexdebrie.com/posts/dynamodb-single-table/">here</a> and <a href="https://aws.amazon.com/de/blogs/database/single-table-vs-multi-table-design-in-amazon-dynamodb/">here</a> and watch this mindblowing talk by Rick Houlihan.</p><p>but to put it simply, using a Single Table Design means that you have rows containing different data and you use specific access patterns with Partition and Sort Keys and prefixes and Secondary indexes to load all/only the data you need.</p><p>Starting out with multiple tables can be simpler:</p><ul><li>need to store app configuration? here a configTable!</li><li>need to store user data? here, a userDataTable!</li><li>need to add user friends? here a userFriendsTable for you!</li><li>need to add user orders? tadaa! a userOrdersTable ready for you!</li><li>and so on in a very much Relational way of doing things</li></ul><p>This approach is not only <strong>not leveraging NoSQL</strong> and the amazing capabilities of DynamoDB, but will also in the long run ( actually, pretty soon!) reveal quite impractical and require making multiple requests to multiple tables and aggregating/joining data on your side — which bring us to the next point.</p><h3>Optimise queries to DynamoDB tables</h3><p>When the app needed some aggregation of data, the backend was often querying multiple tables at once, then composing an object with all the needed props and returning it to the client.</p><p>Continuing the example above, to gather all UserData with friends and orders you need to retrieve the right row from UserData table + the Orders of that UserID ( using a secondary index, because OrderTable has a PK with orderId) and then friends from Friends Table.</p><p>The implementation was suboptimal: requests were done in order, one after another, only to aggregate data when everything was finally available like in this pseudo code simplified way :</p><p>Much better would have been to <strong>make requests in parallel</strong> (so that you wait only for the one taking the longest, not for the sum of the 3):</p><p>Much much better, run 1 single call to dynamo with a<br><a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/classes/batchgetitemcommand.html">BatchGetItemCommand</a>:</p><p>Batch Commands can be very powerful. Especially for Transactions and multiple operations at once. I really recommend checking<a href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-example-table-read-write-batch.html"> them out</a></p><p>Small note: weirdly I was not able to use the BatchCommand without specifying the DynamoDataTypes in the KeyValueAttributes ( something that normally using the DocumentClient is not necessary)</p><h3>Load only what you need</h3><p>In many cases, the backend code was loading the entire row from a table even though <strong>the data that was necessary was just one property</strong>.</p><blockquote><em>To read data from a table, you use operations such as GetItem, Query, or Scan. Amazon DynamoDB returns all the item attributes by default. To get only some, rather than all of the attributes, use </em><a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ProjectionExpressions.html"><em>a projection expression</em></a><em>.</em></blockquote><p>So, if you just need the score and the language of a user, you don’t need to load the entire user data, but just those two attributes, it is as simple as specifying those properties in the GetItemCommandInput</p><p>I know, I know, using <strong>Projection Expression does not have any effect whatsoever on the cost of your request</strong> ( like Filters, they are applied <em>after</em> the data has been retrieved by DynamoDB, therefore there is no difference in terms of RCUs (Read Capacity Units). Nevertheless, there is fewer data sent out over the wire, which can have positive effects on latency ( and on your users&#39; data-plan consumption ) and in my opinion makes manipulating the response easier and the code cleaner.</p><h3>Update only what changed</h3><p>Assuming you want to change the email address or update the user loyalty points of a user, you would ideally receive from the client just the user_id and the new value and you would then <em>update</em> just those properties in the database.</p><p>Similarly to the way the requests were sequentially made to multiple tables and entire data was passed around, editing operations were written in a very simple and un-optimised way.</p><ul><li>Query the entire row</li><li>Edit a couple of properties in the loaded object</li><li>Overwrite the row with the modified object</li></ul><p>DynamoDB though, has an UpdateItemCommand that allows us exactly to <strong>update only specific attributes of a record</strong>, without requiring us to query for it — assuming we know its partition key (and eventually the sort key).</p><p>Dynamo comes with different handy UpdateExpressions ( Set to modify a value, ADD to increase/decrease numbers, REMOVE to remove attributes entirely, and so on) and most importantly you can even use <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html#Expressions.ConditionExpressions.SimpleComparisons"><strong>ConditionExpressions</strong></a> to determine which items should be modified: If the condition expression evaluates to true, the operation succeeds; otherwise, the operation fails.</p><p>I wrote a post some time ago about how to dynamically create Dynamic Update Expression from an object of modified properties — read it <a href="https://dev.to/dvddpl/dynamodb-dynamic-method-to-insert-or-edit-an-item-5fnh">here</a></p><h3>Want to know how that is affecting costs?</h3><blockquote>A strongly consistent read request of an item up to 4 KB requires one read request unit.</blockquote><blockquote>An eventually consistent read request of an item up to 4 KB requires one-half read request unit.</blockquote><blockquote>A transactional read request of an item up to 4 KB requires two read request units. <strong>If you need to read an item that is larger than 4 KB, DynamoDB needs additional read request units.</strong> from the <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.requests">docs</a></blockquote><p>After a simple refactoring, we changed the previous update method ( which was every time loading the entire row, to edit just a couple of properties and then overwrite the entire row with the modified object ) into a smaller method whose responsibility was receiving the PK and SK and the props/values that had change and taking advantage of the UpdateItem method of DynamoDB.</p><p>In our samples where the rows had just a few attributes and very little data this was the difference:</p><blockquote><em>get-edit-put: 101.073ms → 1 WCU and 0.5 RCU<br> update: 46.894ms → 1 WCU</em></blockquote><p><strong>Premature optimisation</strong>? Just <strong>overkill</strong> to shave off a few milliseconds? At the time of the prototype or when the application was launched to production probably it could have been considered so, but looking at how the app usage has increased and the code has evolved, ( <strong>thousands of requests per minute and records requiring 5 RCU each time</strong> ) a really meaningful change.</p><p>I agree, the syntax of Update Expressions is not the best, and it is definitely uglier and more complicated than editing a javascript object but UdpateExpressions allow us to express intent more clearly and most importantly leverage the capabilities of DynamoDB.</p><h3>Some more findings</h3><p>Something interesting I found out while writing some samples for this post is <strong>the difference between List and StringSet in the </strong><a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes"><strong>DynamoDB DataTypes</strong></a>.</p><p>Since I always used NodeJs and the <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/classes/_aws_sdk_lib_dynamodb.dynamodbdocumentclient-1.html">DynamoDBDocumentClient</a> I never had to bother about Marshalling and Unmarshalling and defining the data types: just pass a JSON or a JS object and DynamoDBDocumentClient takes care of everything.</p><p>While testing the Update Expression though, I struggled with removing items from an array/list.</p><p>Adding is simple, you don’t need to know the previous list of orders to be able to push a new one and overwrite the data on the database, just create an Update Expression with the new order id and Dynamo will append it to the list when updating the item. (more in the <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.UpdatingListElements">docs</a>)</p><p>To remove an item on the other hand, you need to specify the index, which is not something very handy, or something that you might know.</p><p>The docs state that <strong>in the case of Sets you can actually use the DELETE operator</strong> but whatever I tried was failing due to:</p><blockquote>Incorrect operand type for operator or function; operator: DELETE, operand type: LIST, typeSet: ALLOWED_FOR_DELETE_OPERAND</blockquote><p>In fact, checking my record in the Dynamo UI Console, my <em>orders</em> were a simple List, not a String Set.<br> When I tried to create manually from the console a new Attribute as a String Set I noticed that suddenly the console was not giving me the possibility to switch off the View DynamoDB JSON thus forcibly showing the data types.</p><p>Apparently then, if using DynamoDBDocumentClient, which has the advantage of saving you the marshalling/unmarshalling, you also lose some of the DynamoDB DataTypes and thus you can’t take advantage of specific update expressions (Drop a comment with a snippet if you know how to do that! it would be highly appreciated!)</p><h3>Cache what does not change frequently</h3><p>Some of the data that was loaded from Dynamo and returned to the Client was not user-specific, it could be generic app configuration, lists of available products to buy, feature flags, stats from the previous day and so on. But they were loaded from DynamoDB every time, for every user connecting.</p><p>Having Cloudfront before your API Gateway could be a valid solution to cache data and reduce the number of requests hitting your endpoint → lambda → dynamo.</p><p>Of course, Cloudfront is not free, and you need to understand how frequently your data changes, and if it makes sense to shift costs to the CDN, but having data cached would also have benefits on the responsiveness of your app.</p><p>If you can’t or don’t want to use a CDN you can consider other in-memory caches to avoid sending the requests to Dynamo — the risk of having stale data among Lambdas or different containers is high though, so unless you have a Fat Lambda and you need the same data for multiple endpoints/methods managed by the same handler I would not suggest it).<br> But there are also other solutions, that come at a cost, like <a href="https://www.gomomento.com/blog/using-a-cache-to-accelerate-dynamodb-or-replace-it">Momento</a> or <a href="https://aws.amazon.com/de/dynamodb/dax/">AWS DAX</a></p><p>In this post I wanted to highlight the fact that usually it is really not that important how things are done. But at some point, we need to consider where we want to go next, we need to reconsider the choices we have made and we might need to face the fact that before moving on, some changes are necessary.</p><p>Overall, my advice is:</p><ul><li>take time to think</li><li>start simple and iterate</li><li>take the time to tackle tech debt</li><li>RTFM: often when dealing with new problems or starting out with new languages we stick with what we know and use old approaches. This is the case with DynamoDB, if you always used relational Databases, or with functional programming if you come from strictly type and object oriented languages, or when adopting a serverless event driven mindset. <strong>Invest some time in reading the docs and understanding the tool you are using.</strong></li><li><strong>avoid judgement and blame</strong> — often, when looking at some legacy code, we tend to ask ourselves: &gt; how the heck could that guy end up writing this crap? how is it even possible that the architect/tech lead made this silly decision?</li></ul><p>the answer is that they did not know what we know now, <strong>in hindsight everything is obvious and simple</strong>, they could not predict if their proof of concept would evolve into a full blown production app nor if that app would have 500 users per day or 10 thousand per minute. <br> Always be patient and forgiving about whatever you find in a legacy code base, and whoever was responsible for writing it.</p><p>Specifically to DynamoDB these are my suggestions:</p><ul><li>use Single Table Design</li><li>use Batch whenever possible</li><li>leverage UpdateExpression and Condition Expressions</li></ul><p>Hope it helps!</p><p>Other related articles you might find interesting:</p><p>Foto von <a href="https://unsplash.com/@lee2d2?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">lee attwood</a> auf <a href="https://unsplash.com/de/fotos/1eQBP3Iit48?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><ol><li>The <em>crux</em> is the hardest part of a route <a href="https://dev.to/aws-builders/there-is-no-right-or-wrong-as-long-as-it-works-actually-how-you-use-dynamodb-makes-a-lot-of-difference-2668#fnref1">↩</a></li><li>(to climb a route — also referred as <em>to solve the problem</em> — you have to visualise the movements you will make, the beta is <a href="https://en.wikipedia.org/wiki/Beta_(climbing)">https://en.wikipedia.org/wiki/Beta_(climbing)</a> <a href="https://dev.to/aws-builders/there-is-no-right-or-wrong-as-long-as-it-works-actually-how-you-use-dynamodb-makes-a-lot-of-difference-2668#fnref2">↩</a></li><li>tight, swollen, burning, and sometimes painful feeling that occurs in our forearms when we’re climbing as a result of lactic acid build up. <a href="https://dev.to/aws-builders/there-is-no-right-or-wrong-as-long-as-it-works-actually-how-you-use-dynamodb-makes-a-lot-of-difference-2668#fnref3">↩</a></li></ol><p><em>Originally published at </em><a href="https://dev.to/aws-builders/there-is-no-right-or-wrong-as-long-as-it-works-actually-how-you-use-dynamodb-makes-a-lot-of-difference-2668"><em>https://dev.to</em></a><em> on May 31, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=365a1d5b8d8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Be the rising tide — grow as a lead or engineer by helping others]]></title>
            <link>https://dvddpl.medium.com/be-the-rising-tide-grow-as-a-lead-or-engineer-by-helping-others-9958d2cd9788?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9958d2cd9788</guid>
            <category><![CDATA[leadership-skills]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[technical-leadership]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Fri, 28 Apr 2023 09:16:56 GMT</pubDate>
            <atom:updated>2023-04-28T10:24:32.990Z</atom:updated>
            <content:encoded><![CDATA[<h3>Be the rising tide — grow as a leader or engineer by helping others</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*XB3MY8FeGPjLwKWToZC6XQ.jpeg" /></figure><h3>What makes us good? What makes us effective?</h3><p>Some time ago I was chatting with an ex-colleague about career paths: We have both been in Software Engineering for around 3 lustres and we had both moved to a Technical Leader / Lead Engineer position a couple of years back.</p><p>We both felt at a crossroads. Which way to go?</p><p>Take the pure <strong>Leadership path</strong> — which would mean giving up most of the technical aspects of our daily job and switching to a more people management focus — or stick to the <strong>Technical Path</strong> with Code Design and Architecture or become Subject Matter Experts?</p><ul><li>Technical Director, Engineering Manager, Director of Software Engineering, CTO?</li><li>Principal Engineer, Staff Engineer, Solutions Architect?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*zbfXBqmpPezxhByw.gif" /></figure><p>Should we venture into (partially) unknown grounds, where <strong>the needed skills are different from what the ones we have</strong> ( and that proved to be working very well for us)? Or should we stick to what has worked, and that we know we love 100%?</p><p>Will Larson (CTO at Carta, previously worked at Stripe, Uber and others — and author of the book <em>An Elegant Puzzle — Systems of Engineering Management</em> — that after years I finally moved from the ToRead list onto the CurrentlyReading list) wrote a very insightful post about how <a href="https://lethain.com/tech-lead-managers/">Tech Leadership roles can reveal themselves as traps</a> because of the mixed nature of the role that does not allow to fully experience each of its components and really take on the new challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzpWFHHI521a_ShKhlCrxw.png" /></figure><p>I personally found working as Tech Lead very satisfying <em>exactly because of the variety of tasks</em> and the possibility of exploring and growing as a Leader and continuing to express my creativity as an Engineer. (but under some circumstances, size and skill set of the team, time pressure and deadlines — I had indeed fallback to some behaviours mentioned in the article and felt the same pain).</p><p>Anyway, the chat was indeed as generic as deep and almost philosophical:</p><ul><li>What makes us good?</li><li>What makes us valuable?</li><li>What makes us effective?</li><li>What makes us great team players?</li><li>What makes us great leaders?</li><li>How do we define ourselves?</li><li>What is our role in the business?</li></ul><h3>How can we scale our productivity and efficiency?</h3><p>At some point, after talking about <strong>what type of leaders we would like to have, or to become.</strong>.<br> After discussing what it means to be a 10x developer, <strong>how to delegate and avoid micro-management</strong>, and how to find the balance between us actively solving problems versus empowering/enabling other’s own problem-solving skills, my friend dropped a quote that really struck:</p><p>| <strong>A rising tide lifts all boats</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*8vnjG3N7kIzVu8C6GbZgGg.jpeg" /></figure><p>“ <em>A rising tide lifts all boats</em>” is originally a phrase used mainly by politicians (JF Kennedy) and economists that refers to the macro-economic theory that <em>improvements in the general economy will benefit all participants in that economy</em>.</p><p>In our daily lives and jobs, it can simply mean that the positive effect of our actions spreads around us and lifts the people around us too, be it family members and friends or colleagues and reports. (of course, the opposite is also true, with our behaviour and our mood we can totally bring people down!).</p><p>In one of my first posts about <a href="https://dev.to/dvddpl/what-makes-a-10x-developer--1k0f">10X Mythical creatures</a>, I wrote that <strong><em>the real multiplying factor is sharing knowledge, fostering growth, and being an example of passion and hard work</em></strong>.<br> I believe that moving on in the career ladder ( be it technical, or even more in the management path) these characteristics take even more weight and allow us to scale.</p><blockquote><em>We can forward and grow as a team by sharing information about what makes us good.</em></blockquote><p>As a lead ( or senior ) or mentor for trainees and junior devs, share your secrets ( your habits, your toolbox ).<br> Don’t just help others by solving their problem: teach them, point them in the right direction, challenge them and help them find the solution themselves, only as a last resort, show them how it is done.</p><p>I know, it can be scary. You might think that if you share <em>too much</em>, or help out too often, others might become better than you, or simply learn and reach your level too quickly. And you might be concerned that that promotion you are hoping for, might land on their desk. Don’t worry, and remember that “a rising tide lifts all boats”, <strong>while you help others grow, you are also building new skills</strong>. <br> Don’t be the hero of your team, the rockstar, and definitely don’t be a brilliant jerk!</p><p>Great leaders and great people in general <em>lift people up</em>.</p><p>Help everyone improve, at their pace, based on their current skill. With your help, overall performance will rise.</p><p>It does not matter if you are a junior, a senior, a lead or a CTO, at different levels and with different scopes you can help people achieve their goals and that of your team or your company.</p><p>All the questions in the conversation with my ex-colleague were kinda blurred out by the biggest and most important question:</p><blockquote><strong><em>Are we a rising tide for our team?</em></strong></blockquote><p>After the conversation I googled a bit about the quote and about the application in leadership I ended up in this amazing Ted Talk by <em>Paresh Shah</em> that asks a similar question: <strong>Are you a Lifter</strong>?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEm_MUmYDqmY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEm_MUmYDqmY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEm_MUmYDqmY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/03d7e478b40f0891b670cd3e33d81fcb/href">https://medium.com/media/03d7e478b40f0891b670cd3e33d81fcb/href</a></iframe><p>A rising tide lifts all boats.<br><strong>Become the rising tide in your team.</strong></p><p>Other related articles you might find interesting:</p><ul><li><a href="https://dev.to/dvddpl/what-makes-a-10x-developer--1k0f">What makes a 10x Developer?</a></li><li><a href="https://dev.to/dvddpl/from-engineer-to-tech-lead-doubts-and-challenges-4n9e">From Engineer to Tech Lead — Doubts and Challenges</a></li><li><a href="https://dev.to/dvddpl/lego-bricks-pinheads-and-10x-developers-1jf7">Lego bricks, pinheads and 10X developers</a></li><li><a href="https://dev.to/dvddpl/the-screw-and-the-hammer-love-the-problems-not-your-solutions-2i0a">Love the problems not your solutions</a></li></ul><p>Foto von <a href="https://unsplash.com/@iam_robin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Robin Spielmann</a> auf <a href="https://unsplash.com/de/fotos/TUiNzx1vMBM?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><p><em>Originally published at </em><a href="https://dev.to/dvddpl/be-the-rising-tide-grow-as-lead-or-engineer-by-helping-others-2jig"><em>https://dev.to</em></a><em> on April 28, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9958d2cd9788" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Engineering is about trade-offs: make sure you have options!]]></title>
            <link>https://medium.com/better-programming/software-engineering-is-about-trade-offs-make-sure-you-have-options-f441b27fa98d?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f441b27fa98d</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Mon, 20 Mar 2023 07:14:10 GMT</pubDate>
            <atom:updated>2023-04-03T16:58:06.833Z</atom:updated>
            <content:encoded><![CDATA[<h4>Architectural patterns comparison</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPZ0UtqmvkZy2SD1Zhcaxg.png" /><figcaption>Photo by <a href="https://unsplash.com/@soymeraki?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Javier Allegue Barros</a> from <a href="https://unsplash.com/de/fotos/C7B-ExXpOIE?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I am standing in my kitchen, waiting for my cappuccino to be ready. I am still, but my mind is restless.</p><p>I just met with my director, a senior engineer, and a couple of stakeholders from the marketing department to discuss a new functionality needed for one of our apps.</p><p>How can we do that?</p><p>As soon as multiple AWS services pop into my mind, I draw imaginary diagrams in my head connecting all the puzzle pieces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*m40RLBmdmUBcQ5PS.gif" /><figcaption><a href="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExM2M4YjFiZTJiZGM0OTljYjliNmJhNDdhZTM4ZWM4MGQ5ZDQ3MWUyZSZjdD1n/3o6Yg4GUVgIUg3bf7W/giphy.gif">Source by giphy</a></figcaption></figure><p>Only the beeping coffee machine brings me back to reality, but I have a pretty neat idea already!</p><p>Before, I would have rushed into coding a PoC or creating a diagram of the solution to attach to tickets thoroughly described for my team members. But not now!</p><h3>Haste Makes Waste</h3><p>As enthusiastic as I can be, and as good as my solution can look, this is not a good approach as an engineer or a lead (which should empower people, help them grow, and gather their valuable input).</p><p>We need different perspectives, we need alternatives, we need options.</p><p>Remember fast, cheap, and good — Pick two?</p><p>This is a simplification, and even if we were in an ideal world where all three can be achieved, it would still be beneficial to consider different approaches instead of sticking to the first idea that pops into our minds.</p><ul><li>What would be the fastest way of implementing that? (they want it yesterday, of course!)</li><li>What would be the best (performance-wise and in terms of architecture)?</li><li>What would be the cheapest? (what AWS service should we use? Lambda, EC2, Fargate?)</li></ul><p>Recently, I was listening to <a href="https://techleadjournal.dev/episodes/120/">Episode 120 of Tech Lead Journal, </a>and I was struck by one statement:</p><blockquote>It’s better for me as an architect to know there are five different concurrency solutions to this problem than to know how to solve this concurrency problem deeply in one of those solutions. Cause as an architect, you need options, because you’re doing trade-offs, and you need to be able to trade-off one thing versus another.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZxi8ZzOLpsYhof0-sUQxg.png" /></figure><p>This is such a nice way to phrase it, and I could not agree more.</p><p>Having options is the only way you can make trade-offs and the only way to make educated choices.</p><p>Not having options or not thinking through possible alternatives does not allow you to experiment with different solutions and ultimately decide what is best or the least worst — because, yes, sometimes, budget, time, and other constraints allow us only to choose the best among unsatisfactory alternatives.</p><p>It’s also the “Law of the Instrument” at play. The famous cognitive bias of the Golden Hammer:</p><blockquote>If the only tool you have is a hammer, it is tempting to treat everything as if it were a nail.</blockquote><p>I discussed it in another article some time ago — <a href="https://dev.to/dvddpl/the-screw-and-the-hammer-love-the-problems-not-your-solutions-2i0a">The screw and the hammer: Love the problems, not your solutions</a>.</p><p>For these reasons (and maybe because you never really overcome your impostor syndrome, and it’s good so), I try to resist the urge to stick to one solution.</p><p>Whenever I am confronted with a problem or asked to think about a solution, I force myself to come up with multiple approaches. Or if I am short on time or ideas, I ask other colleagues (and have great meetings discussing requirements and brainstorming solutions).</p><p>Depending on the complexity, RFCs (Requests For Comments) are a great way to structure your thoughts and ask your peers for more input.</p><p>This is also something I try to teach to junior devs. As developers, we tend to get excited easily. We have a task, we have an idea, convert that idea into a few lines of code, and dopamine starts to flow (if it works, if it does not, we are dragged down in a loop of fix-test-fix-test, and we have already lost track of the original problem, focused as we are in fixing our own bug.</p><p>No matter how simple or complex the task is, try to come up with multiple solutions:</p><blockquote><em>is a </em><em>map.filter.reduce better here, a </em><em>for ... of, or maybe a </em><em>while loop?</em></blockquote><p>Think about the quickest and dirtiest, or easiest (most familiar) solution.<br>Then think about the best solution you could come up with if you had no budget or time constraints, really the by-the-book solution!</p><p>Then find a middle ground. Or simply a different one.</p><p>Sure, it requires time and effort, but it is a great exercise.</p><p>It sparks your creativity, your problem-solving skills, and your ability to think outside the box, and will help you properly, extensively, and objectively consider pros, cons, and trade-offs.</p><p>Challenging your own ideas and solutions also fosters critical thinking and reduces the ego we inevitably put in our code/design.</p><p>It is not my code, my solution anymore. It is one of the many possible ones; I know there could be others better or worse or similar, but I picked that in the end because of… reasons — that you hopefully documented in an ADR (Architecture Decision Record).</p><h3>An Example</h3><p>Let’s have a look at a (greatly simplified) example of the feature discussed in the above meeting:</p><ul><li>The user should be able to unsubscribe from a service by making a request to an API.</li><li>After one week from that request, they should receive a reminder that the service will be disabled the following week.</li><li>The week after, the service is disabled.</li><li>If, during the previous 14 days, the user happened to have accessed the service (another API keeps track of user logins to that service), then the entire process is interrupted: no email will be sent, and no unsubscription will take place. The user must make another request if they are still willing to unsubscribe.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-HKlLt_IYdjOL6MNYiuww.png" /></figure><h3>Solution 1 — Dynamo and Lambda Scheduler</h3><p>The unsubscription request goes through an API Gateway. A Lambda takes care of validation and adds the request to DynamoDB.</p><p>EventBridge (aka the good ol’ CloudWatch Event) schedules the invocation of another Lambda at a regular interval (every day or every hour) to load all the pending requests and checks for each if there was a login by the user.</p><p>If a login is found, the request is deleted from Dynamo, and the process ends. Otherwise, depending on how much time has passed, we send an email via SNS or inform another service of the completed unsubscription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*cujWfZ_RIYpB7CPmpaphTg.png" /></figure><h3>Solution 2 — Lambdaless Integration and Dynamo Streams</h3><p>API Gateway + direct Dynamo Integration to save requests for unsubscription.</p><p>We don’t need a Lambda to add the request to Dynamo — we can use a JSON Schema Validator (and a Velocity template to manipulate the payload itself) within API Gateway and use a direct integration to DynamoDB.</p><p>Check out my previous posts about <a href="https://dev.to/dvddpl/reduce-lambda-invocations-and-code-boilerplate-by-adding-a-json-schema-validator-to-your-api-gateway-15af">JSON Schema for APIGateways</a> and <a href="https://dev.to/aws-builders/look-ma-no-lambda-lambdaless-apigateway-and-dynamodb-integration-with-cdk-2hbd">Lambdaless integrations</a>.</p><p>The item on DynamoDB will have a TTL to automatically remove it after one week. At that point, a DynamoDB Stream will trigger a Lambda, which is in charge of checking for the logins.</p><p>If the user logged in, we do nothing since the process is automatically terminated with the TTL removal of the item from Dynamo.</p><p>Otherwise, we invoke SNS to send an email and add another item to Dynamo with a similar TTL that specifies we are at stage 2 of the process.</p><p>Stage 2 will be similar: TTL, DynamoStream, and Lambda are triggered.</p><p>As you can see, we have fewer Lambda functions, fewer unnecessary invocations by the scheduler, and we don’t need to manually code the deletion from Dynamo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tpPoIooCcLoTgzU0c5r31Q.png" /></figure><h3>Solution 3 — Step Function!</h3><p>Step Functions are a perfect way of <strong>orchestrating</strong> this kind of behaviour.<br> Standard workflows are priced by state transitions and allow up to a year (way more than we need).</p><p>APIGateway can <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html">start the execution</a> of a Step Function, and we can define our first state as a delay of a week. The next state will be a Lambda function to assess user logins, and then we will add a Fork Task. After that, the step function will terminate or proceed with an SNS notification and another delay task.</p><p>And finally, a similar flow is followed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YkHGad4gFZkhPvyfrd2POw.png" /></figure><h3>Which Solution Is Best?</h3><p>This is a pretty basic example, and I believe that many other approaches could be thought of by giving it more thought or bringing in more people.</p><p>Often by thinking of different approaches, you can then mix and match some of the ideas (like using direct integration in the first scenario) or possible pitfalls (will DynamoDB be able to hyper-scale, or should we add SQS in the recipe? <a href="https://www.webdayconf.it/e/sessione/3122/From-0-to-1-000-000-How-to-build-a-serverless-raffle-service-for-hyperscale">This was one of the great talks</a> I watched last week at WebDay23 in Milan).</p><p>Another benefit is that challenging our solutions and discussing them with others can bring up aspects of the problem that were not specifically addressed by the stakeholders and need to be clarified:</p><ul><li>What if we need to authorise the request to API Gateway?</li><li>What if we want to prevent multiple requests from the same user?</li><li>What about another API returning the status of the current request?</li></ul><p>So, guess what? There is no best solution. It depends on time, skills, and budget (step functions can be expensive, but how much would we pay for unnecessary Lambda executions, Dynamo read and writes, and for the code complexity of solution 1?)</p><blockquote><em>Of course, I have my preference and my opinions. I am very interested in yours, especially if you have other approaches that are radically different.</em></blockquote><h3>Final Thoughts</h3><p>It doesn’t matter if your idea popped up while playing kicker with your colleagues, walking the dog, explaining the problem to a rubber duck, or taking a shower.</p><p>Challenge it, play the devil’s advocate, and come up with alternatives so you can compare the options and choose the trade-off that best fits your requirements and constraints.</p><p>But while doing that, beware of <a href="https://en.wikipedia.org/wiki/Analysis_paralysis">analysis paralysis</a> and remember that perfection does not exist. Requirements will change (and likely corrupt our plans) no matter how sound and future-proof our solution is, so don’t waste too much time in coming up with ideas until you have the best.</p><figure><img alt="header that reads “time cost” strategy a — short bar graph strategy b — short bar graph analyzing whether strategy a or b is more efficient — long bar graph caption: the reason I am so inefficient" src="https://cdn-images-1.medium.com/max/658/1*L2MQ9Sh6KxsfTiSKm9ZuWg.png" /></figure><p>Exercise your critical thinking, your thinking outside the box, and evaluate alternatives, but avoid falling into the overthinking trap.</p><blockquote>Imperfect action is better than perfect inaction.<em> — Harry S. Truman</em></blockquote><p>Often it is better to get started with something and iterate quickly/adjust the course.</p><p>Here’s other articles related to this topic that you might find interesting:</p><ul><li><a href="https://dev.to/dvddpl/learn-how-to-ask-good-questions-be-aware-of-the-xy-problem-1ic3">Learn how to ask good questions. Be aware of the XY Problem</a></li><li><a href="https://dev.to/dvddpl/the-screw-and-the-hammer-love-the-problems-not-your-solutions-2i0a">The screw and the hammer: Love the problems, not your solutions.</a></li><li><a href="https://dev.to/dvddpl/keep-ego-away-from-coding-4gi5">Keep your ego away from coding</a></li><li><a href="https://dev.to/dvddpl/make-mistakes-and-ask-questions-its-ok-gah">Make mistakes; it’s ok!</a></li></ul><p><em>Originally published at </em><a href="https://dev.to/aws-builders/software-engineering-is-about-trade-offs-make-sure-you-have-options-architecture-patterns-comparison-p00"><em>https://dev.to</em></a><em> on March 20, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f441b27fa98d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/software-engineering-is-about-trade-offs-make-sure-you-have-options-f441b27fa98d">Software Engineering is about trade-offs: make sure you have options!</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[My first 6 months as AWS Community Builder: boosting my career and fighting Imposter Syndrome!]]></title>
            <link>https://dvddpl.medium.com/my-first-6-months-as-aws-community-builder-boosting-my-career-and-fighting-imposter-syndrome-57a873ea769f?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/57a873ea769f</guid>
            <category><![CDATA[imposter-syndrome]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[tech-lead]]></category>
            <category><![CDATA[awscommunitybuilder]]></category>
            <category><![CDATA[sofware-engineering]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 16:54:28 GMT</pubDate>
            <atom:updated>2023-03-13T07:37:51.415Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*PflDgb9bzugNjCxuWvUNhQ.png" /></figure><p>Last August I became AWS Community Builder! I decided to wait a bit before publishing this post for two main reasons:</p><ul><li>I wanted to be in the program for a few months to really understand what it is like to be a Community Builder and <strong>provide more info about the pros and eventually, the cons.</strong></li><li>dev.to, Medium and LinkedIn are literally flooded by posts of new Community Builders telling the world they were accepted and why you should become one too ( and I realise now how my timing is wrong because a new round of community builders has been accepted just this week… 🤦‍♂️)</li></ul><p>AWS Community Builders Program is open to any individual who is 18 or older and <strong>passionate about building on AWS</strong> and loves to connect with other developers, exchange ideas and share knowledge.</p><p>While in the program you can get access to technical resources, education, and networking opportunities with other <strong>AWS technical enthusiasts and emerging thought leaders.</strong></p><p>To apply to the Community Builders program you just need to submit your application by filling up a form where you provide info about yourself, your experience and your motivation and link any resource that you already produced like Blog Posts, Podcasts, Video tutorials and so on.</p><blockquote><strong><em>Applications will be reviewed twice a year</em></strong><em>, and applicants who are accepted into the program will be invited on a twice-yearly basis. While </em><strong><em>there is no single specific criterion for being accepted into the program, emphasis is placed on evidence and accuracy of technical content</em></strong><em> that helps other AWS-focused builders, such as blog posts, videos, open source contributions, and presentations.</em></blockquote><p>You don’t have to be already an acclaimed blogger or a guru in AWS stuff to be accepted: <strong>the diversity of people and experiences is one of the great things about the program.</strong> It doesn’t matter if you just started with AWS and you are eager to share your journey or if you are a seasoned engineer and have been building with AWS for many years. There is room for everybody and opportunity to share and access resources at every level of experience.</p><p>This does not mean that to get in, you just have to apply, though. There is a selection and <strong>acceptance rate</strong> usually varies each year and it depends on the number of active/renewed members each year and their overall yearly targets. I have no idea if the acceptance rate is 5%, 20% or 50% but I think that some competition to be accepted really exist!<br><strong>I applied in 2021</strong>, after blogging for a couple of years — <strong>and my application was rejected</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*ovJsZT-Gqh52I9Wi.gif" /></figure><p>The year after I wrote fewer posts overall, but they were more focused on articles and tutorials about AWS services. Last summer I tried again, and I was accepted! ( and that’s why I feel so <em>honoured and proud</em> about being one right now! )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*33AWcaxax-jf8n_i.gif" /></figure><p>At the moment the application form for this program is closed but it will re-open in July 2023 and you can <a href="https://aws.amazon.com/developer/community/community-builders/">add your name to the waitlist</a> to be notified and give it a chance!.</p><p>You can do that for <em>the fame</em> (looks good on your CV), for <em>the people</em> ( great devs you can get in touch with), for <em>the money</em> (vouchers and credits) or for <em>the skills</em> ( workshops and knowledge sharing).<br> Or simply, <em>for the swag!</em></p><p>Seriously, there are really plenty of benefits you have access to, and everyone has more than one reason to join.</p><p>Let’s see the current benefits (which might slightly change year from year):</p><h3>Learning opportunities</h3><ul><li>Cloud academy</li><li>Workshops</li><li>Vouchers for Certifications</li></ul><p>There are regular <strong>sessions/webinars</strong> from AWS people or other Builders that will help you level up, both from a technical perspective but also with your skills as a writer, presenter, and conference speaker.<br> With the Program you get <strong>free access for a year to </strong><a href="https://cloudacademy.com/learning-paths/aws-solutions-architect-associate-saa-c03-certification-preparation-for-aws-1-7446/"><strong>Cloud Academy</strong></a>, one of the leading global cloud learning platforms.<br> And since you have access to hundreds of courses, you can then take advantage of the <strong>Exam Voucher</strong> you receive as CommunityBuilder ( <strong>one Foundational, Associate, or Professional/Specialty Exams per 12 months</strong>) and finally take that certification <a href="https://dev.to/aws-builders/preparing-for-aws-solutions-architect-associate-saa-c03-certification-resources-and-cheat-sheets-2h2k">you have always been putting off</a>.</p><h3>Experimenting with AWS services</h3><p>As a member you will have access to the Beta Program and will be able to <strong>join special sessions</strong> or discussions with AWS employees about new features or <strong>super secret new services</strong>!</p><p>You will also receive a <strong>$500 AWS credit</strong> to help you learn, experiment, and grow by trying our new AWS services. That’s a great way to test services that are out of the free tier, or simply build something cool and then blog/video/tweet about what you learned.</p><h3>Connecting with other experts and enthusiasts</h3><p>Once you are accepted in the program <strong>you get access to a Slack Workspace which is a safe, inclusive place to ask questions</strong> and dig into helping solve each other’s tech challenges. Everyone is there to help each other.</p><p>I met lots of interesting people from all over the world, had questions answered, or was exposed to threads that proved very interesting and useful weeks later when facing issues at work.<br> Many questions spawn discussions where many people contribute with their experience and are super helpful to then establish some best practices or simply form an educated opinion. Often this ends up in very detailed blog posts ( like this one about <a href="https://blog.serverlessadvocate.com/serverless-aws-cdk-pipeline-best-practices-patterns-part-1-ab80962f109d">CDK Pipelines</a>) .</p><p>Furthermore, in the Slack channels there are some quite “established voices of the cloud” like <a href="https://www.lastweekinaws.com/blog/">Corey Quinn</a>, <a href="https://www.readysetcloud.io/blog/">Allen Helton</a>, <br><a href="https://blog.serverlessadvocate.com/">Lee Gilmore</a><br><a href="https://theburningmonk.com/">Yan Cui</a> and many others AWS Heroes as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*UD2gcwBA66kloOeM.gif" /></figure><p>I am not usually a fanboy but having the possibility of reading their threads and having questions answered directly by people I have been reading and following for years, and contributed a lot to my professional growth is kinda exciting!</p><p>Besides the Slack Channel, you have access to a special Organisation here on Dev.to, so that your posts have automatically a bigger visibility thanks to all the followers that subscribed.</p><h3>Swag</h3><p>Each Builder will receive a welcome kit full of great branded stuff. <br> And often, not only that. During workshops and calls some other swag is given out to participants, as well as based on the contribution ( below one mega mug I won thanks to some posts here on Dev) or by engaging on slack.<br> The quality is very high and since they are made for the builders are simply great to show (off) in the office or at meetups and conventions for an instant <strong>feeling of belonging!</strong></p><p>Of course, you also have sweet logos, banners and other assets that you can use in your content and to tell the world that you are a Community Builder!</p><p>I mentioned at the top of the article that I wanted to wait to share my experience to reveal possible cons. Do they exist?</p><p>Well, Of course not! The program is amazing, so the people and the opportunities arising. But… and this is entirely subjective, you need to be aware of a couple or things:</p><h3>Beware of Imposter Syndrome</h3><p>It is a bit daunting. I have been working in Software Engineering for 18 years, and have been building serverless applications for the last 5. Despite that, when reading some discussions. or checking other people&#39;s content, <strong>I realise how much I don’t know.</strong></p><p>This is good of course, <em>getting out of the comfort zone</em>, <em>learning in public</em> and <em>not being the smartest in the room</em> have always be my mantra, so I am more than happy being exposed to all this <strong>AWSomeness</strong>!</p><p>There were days when I kinda felt miserable (and guilty) for publishing one post every 2 weeks, and about a _simple write-up about something so trivial like IAM, when out there students with already 3 certifications are posting daily tutorials about AWS services I haven’t even heard of yet..</p><p>This brings me to the second issue:</p><h3>Be Self Disciplined</h3><p>We are a lot of Community Builders. <br> We all love to learn, experiment and share knowledge.<br><strong>The amount of content being produced by Community Builder is enormous</strong>.<br> Sometimes I log into slack in the morning and I see dozen or hundreds of messages of people asking questions and boosting their content. So many interesting topics, great videos or podcasts, tutorials about that service you always wanted to start using.<br> The urge of reading them all or follow all the discussions is very high. You need to keep it under control. Or you might spend the entire day reading and watching other people&#39;s content, not getting anything done yourself ( and feeling bad about it — see Imposter Syndrome above).</p><p>Try to be self-disciplined, <strong>keep your curiosity under control</strong>, set a timer to when and how long to spend on slack, and read other people&#39;s content, <strong>set boundaries</strong>.</p><blockquote><em>Being motivated and enthusiastic about learning and sharing is great, but we all need some time off.</em></blockquote><h3>Balance consumption and creation</h3><p>Reading other people’s content and learning new stuff is great, but <strong>we became Community Builder because we also want to share our knowledge, talk about our journey, so we need time to build and create</strong>. <br> This is again strictly connected with self discipline, I realised that sometimes I had to stop <em>consuming</em> for a while to concentrate on producing my own work. (Furthermore, sometimes I had been put off by publishing an article, because I felt I wasn’t adding much value compared to others or because someone else, just published a similar one..</p><p>Don’t compare yourself to others, we have all our own style, our perspective, and level of experience. There is room for everybody. But make sure you have enough time at the end of your day ( or at the beginning ) to reduce the noise and concentrate on what you want to share!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*o_KO9yUHo6_MC_W3YisUug.jpeg" /></figure><h3><strong>Final Thoughts</strong></h3><p>I have been a Community Builder for about 7 months and I love it, I really hope my application is renewed for the next year.</p><p>By being community builder I am prompted to write more blog posts and in order to do that i have to learn, read and experiment more.</p><p>This proved very beneficial in my daily job, I could solve problems or come up with solutions much faster and with more confidence.<br> By participating in discussions and reading content from other Builders I was able to connect with lots of other passionate engineers.<br><strong>You never know what positive impact could have in your next career step. It might be collaborating on an open-source project or having a job offer</strong>. Or simply you might change your mind about something you are strong opinionated, or you find friends sharing the same passion.</p><p>Joining the Community Builder program is not a guarantee to land a 6 figures job in Big Tech, but will definitely help shape your skills and step up your game!</p><p><em>Originally published at </em><a href="https://dev.to/aws-builders/boost-your-career-by-becoming-an-aws-community-builder-4hkj"><em>https://dev.to</em></a><em> on March 3, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57a873ea769f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working on legacy code-bases can make us better developers, here is why.]]></title>
            <link>https://dvddpl.medium.com/working-on-legacy-code-bases-can-make-us-better-developers-here-is-why-7bd690feda0e?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bd690feda0e</guid>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[tech-lead]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[legacy-code]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Wed, 15 Feb 2023 18:52:12 GMT</pubDate>
            <atom:updated>2023-02-16T07:29:43.454Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-ng9eT5B82-6cG1h.png" /></figure><p>It does not matter if you are a seasoned senior full-stack engineer or if you just started your journey into this industry, I bet you will have for sure encountered legacy code-bases or projects that grew rapidly from a quick prototype into a full-fledge production application (without receiving enough love and care).</p><p>You will agree with me that when confronted with them it is easy to fall into apathy and just give up all the passion we had for software engineering and just start to contribute to the entropy instead of putting all our efforts into <em>crafting code</em>.</p><blockquote><em>this code base is a smoking pile of crap, why bother?</em></blockquote><p>Or at best, if the fire still burns inside you it is easy to get angry, frustrated, upset, confused, mad at everyone who came before us.</p><blockquote><em>“Battle not with monsters, lest ye become a monster, for if you gaze into the abyss, the abyss gazes also into you. (F. Nietzsche)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*xTZbDTeakBnGxip0ey_Cyg.jpeg" /></figure><p>When you are tackling these monster repositories, don’t let the monsters ( bad coding practices, sloppy implementations, lack of discipline and documentation ) take over you. Don’t let negative feelings of anger and frustration get hold onto you. <br> When you gaze into that abyss, it gazes back, and <strong>it tells you what you are really made of</strong><br> (Occasionally) working on such projects can actually give you a lot more than you think, besides headaches.</p><p>I don’t know if in my career I have been very unlucky or incredibly lucky.</p><p>I started quite late with web development, I was basically self-taught and was hired by a tiny web agency for a rather long internship that ultimately became a junior dev contract.<br>A few months after that, the senior ( and only ) developer left the company for greener pastures.<br> I was alone, dealing with the messy undocumented codebase of a bunch of websites. Although painful, it was probably the biggest boost I could give to my first steps in software engineering.<br> Fast forward 5 years, the small gig has been acquired by a bigger corporation and I find myself being outsourced to different companies to help out in the refactoring of projects where <strong>the technical debt had reached the tipping point</strong>.<br> Again I was confronted with legacy codebases, touched by dozen of different hands, and the only thing that they had in common was the absence of documentation, consistency and proper error handling or monitoring.<br> Since then I changed a few companies, and even when staying at the same company I had the opportunity as a lead engineer or technical lead to be assigned to — often critical — projects that were orphans of their creators/maintainers ( due to people resigning, massive layoffs or simply, company reorganisations. Again, adding features or fixing bugs and redeploying the application was <strong>a discovery journey full of unknowns and surprises.</strong></p><p>Despite the fuck-ups, the struggles, the rants ( and sometimes the strong desire of <em>looking up the address of whatever name Git Blame Annotations were disclosing</em>) I am grateful for every single project I worked on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*HdQzE-lh6KYAveow9GCv9A.jpeg" /></figure><p>I learned a lot about coding and reverse engineering, about sane and safe refactoring (with approaches like <strong>strangler fig</strong> and Test Driven Development).</p><p>And they made me realise, that <strong>with hindsight <em>everything</em> is clear and relatively simple</strong>, that none writes code sloppily ( or wrong ) on purpose.</p><p>They taught me to be patient and <strong>avoid blame when I see implementations that make no sense</strong> (in hindsight!).<br> They taught me to be humble about my own code and solutions;<br> to <a href="https://dev.to/dvddpl/keep-ego-away-from-coding-4gi5">leave Ego out of coding</a>, as well as judgment: yes, maybe the code that I see here and now is crappy and unnecessarily complicated, but it is probably <em>the best that the person who wrote it</em> ( that could as well be me, months back!) <em>could do considering their skills and the information/requirements they got at that point in time</em>.</p><blockquote><em>The only thing that matters is what we can do to improve it or fix it.</em></blockquote><p>Such projects on the other hand taught me that <strong>shitty codebases do not appear overnight</strong>.</p><p>They are the result of the sum of all the tiny mistakes, the shortcuts, of all the times we shrug our shoulders when pushing code or close an eye during a code review to avoid conflicts.<br> It’s <strong>the theory of the broken window</strong>. <br> It’s a slow <strong>death from a thousand cuts</strong>.</p><p>All this has also taught me to be relentless in demanding from myself and my team members discipline and high standards in our deliverables — everyone has to do their part as a <strong>great</strong> boy-scout!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*OcU1EgWeHZYqy0RZLOPBjQ.jpeg" /></figure><p>And even when the team and each member are doing their best, repositories might be not in good shape because of a <strong>lack of cohesion, conventions, shared best practices and tools that enable and enforce discipline</strong>.</p><p>The projects I hated the most, taught me the importance of consistency, simplicity, and readability. <br> The project that I inherited just to fix a bug every 3 months, or to redeploy due to a dependency being deprecated, showed me the necessity of automated tools that enforce productivity and quality best practices among team members.</p><blockquote><em>I came here to fix a production bug. I found the issue and can fix the code, but how the heck do I install and deploy the application?</em></blockquote><p>Every time I was struggling trying to deploy an application that was missing dependencies, environment variables and tests, I decided that no one<strong> after me should go through the same struggle</strong> — I documented the necessary steps to install, run and test the app, possibly I took the time to set up a CI/CD pipeline. <br> Don’t get me wrong, I am not a fan of comments, nor of big text documents in Confluence or Google Drive, just keep the major technical decision as <strong>Architecture Decision Record</strong> and some basic instructions about installing, running, testing, deploying ( and maybe some why and hows about the implemented business logic) as close as possible to the code (and up-to-date!).</p><p>Every time I had to fix a bug, I added a unit or integration test making sure that no further changes to the code base could regress it, and if possible I added a metric and alarm to catch it before our customer-agents or product-owners came panicking to us asking what’s wrong.</p><p>I had the opportunity of being exposed to some pretty messed up projects, and had the incredible luck of having some great colleagues — and when I was or felt alone, I resorted to inspiring guides in the community.</p><p>The good and the bad news is that <strong>the journey never ends</strong>: the longer you work in Software Engineering, the more likely the chances are that you will work on bigger projects and more complex challenges.</p><blockquote><em>Knowing how to navigate bad repositories and being able to tolerate the frustration are incredible skills that go far beyond from being a great developer.</em></blockquote><p>Next time you want to bang your head on the table, just breathe and think about what good you can learn from that code base.</p><blockquote><em>Your struggle is your strength. If you can resist becoming negative, bitter or hopeless, in time, your struggles will give you everything. (Bryant McGill)</em></blockquote><p>(then when you are over, and possibly you have left it in a slightly better shape for the next unfortunate one, do a favour to your mental health and try to have the chance to work on something new! ;-) )</p><p>Other related articles:</p><p>Foto von <a href="https://unsplash.com/@volkanolmez?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Volkan Olmez</a> auf <a href="https://unsplash.com/de/fotos/wESKMSgZJDo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><p><em>Originally published at </em><a href="https://dev.to/dvddpl/working-on-legacy-code-bases-can-make-us-better-developers-here-is-why-n6g"><em>https://dev.to</em></a><em> on February 15, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bd690feda0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Send slack notifications with AWS Chatbot]]></title>
            <link>https://dvddpl.medium.com/send-slack-notifications-with-aws-chatbot-393165c4406f?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/393165c4406f</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[slackbot]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[solutions-architecture]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Fri, 13 Jan 2023 11:31:30 GMT</pubDate>
            <atom:updated>2023-02-01T11:10:28.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*vB8tBG5xDnkJUTuF.png" /></figure><p>What I really love about AWS and Serverless is that over time new services pop up ( <em>yeah well, this is not always a good thing, as pointed out by </em><a href="https://www.lastweekinaws.com/blog/the-feudal-lords-of-amazon/"><em>Corey Quinn</em></a>) or <strong>features are added that make everything simpler and even cheaper</strong>.</p><p>For our project we always set up <strong>Metrics, Alarms and Notifications</strong> to be able to quickly react when something is behaving weirdly.<br> One of the way we set up our monitoring system was via <strong>Slack Notifications</strong>.</p><h3>Old approach: SNS + Lambda</h3><p>In order to send notifications to Slack, we used <a href="https://aws.amazon.com/sns/">SNS</a> and Lambda.</p><p>In our CDK stack we:</p><ul><li>created an SNS Topic</li><li>created a Lambda function in charge of sending out the notification to Slack</li><li>created a subscription to the above topic for our lambda</li></ul><p>In order to send messages to Slack, you need to enable <strong>WebHooks</strong>, see <a href="https://api.slack.com/messaging/webhooks">here</a>.</p><p>Our Lambda function needed that webhook URL, together with the ID of the Channel we wanted to send notifications too ( and we decided to pass them via CDK context.json.</p><p>Our Lambda was not doing much actually, just grabbing the message from the SNS Event it receives as payload — as described <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-sns-example.html#with-sns-example-create-test-function">here</a> — and then using <a href="https://axios-http.com/docs/intro">Axios</a> (but any HTTP client would do) to send an HTTP request to slack webhook.</p><p>As you can see above, we had to manipulate a bit the SNS message object in order to extract meaningful information we wanted to display in the slack notification.</p><p>Then, in any project where we had metrics and alarm, we had to simply retrieve the Topic we created above and bind it to an Alarm Action.</p><h3>New approach: SNS + AWS Chatbot</h3><p>It was as you can see already simple enough, and we used that for years already. Recently I was setting up Slack Notifications for a new project on a new team and while I was checking out that old repo and some newer documentation I realised <a href="https://aws.amazon.com/de/chatbot/">AWS ChatBot</a> exists.</p><blockquote><em>AWS Chatbot is an interactive agent that makes it easier to monitor and interact with your AWS resources in your Slack channels and chat channels. By using AWS Chatbot, you can receive alerts and run commands to return diagnostic information, invoke AWS Lambda functions, and create AWS Support cases so that your team can collaborate and respond to events faster.</em></blockquote><p>Of course, Chatbot does a lot more than receiving Slack Notifications — actually, it is more a powerful tool to <strong>send</strong> messages from Slack in order to run some commands on your AWS resources (like launching deployments, starting instances, triggering lambdas and so on) but I will explain that in another post.</p><p>But for now, let’s focus on how Chatbot simplified our Monitoring system basically allowing us to <strong>get rid of the Lambda function</strong>.</p><p>In our new SlackNotification stack, we still create a Topic, but then instead of creating a Lambda, you set up the configuration of your SlackBot.</p><blockquote><strong><em>beware</em></strong><em>: it is not possible to create a new SlackChannelConfiguration on a Slack Channel already assigned to another configuration, so make sure you create it in a separate specific repository, and you just reference it in other project ( something that we also did for the old approach, anyway)</em></blockquote><p>Once you have your Slackbot set up, wherever we want to send slack notifications when an Alarm enters Error state, we do as before.<br> In any project just get the topic from its ARN and attach an Action to your alarm.</p><h3>But you are just exchanging Lambda with Chatbot, where’s the gain?</h3><p>I might argue that you have less code to maintain, and easier infrastructure, but that wouldn’t be a great selling point — we are talking about one single Lambda, which we haven’t touched in years — so let me say just this:</p><blockquote><strong><em>There is no additional charge for AWS Chatbot</em></strong><em>. You pay only for the underlying services. </em><a href="https://aws.amazon.com/chatbot/pricing/"><em>source</em></a></blockquote><p>So, basically, by getting rid of the Lambda, you are not going to pay for all the lambda invocations for every single slack notification, and you only pay, as before, only for the use of SNS.<br> Again, hopefully, you do not have millions of slack notifications every day, so costs could be quite irrelevant, but if you can have a simpler system for less money, why not?<br> Even migrating takes few minutes ( it definitely took me longer to write this post!)</p><h3>where do I find Slack IDs?</h3><p>the easiest way to find both the WorkspaceID and the ChannelID is to open your Slack Application in your browser and go to the channel you want to become your recipient. The URL will be something like this — <a href="https://app.slack.com/client/WORKSPACE_ID/CHANNEL_ID.">https://app.slack.com/client/WORKSPACE_ID/CHANNEL_ID.</a></p><p>While reading <a href="https://slack.com/help/articles/206819278-Send-emails-to-Slack">Slack documentation I found another option</a> you might find interesting. It seems you can send emails directly to slack by simply getting an email for your channel:</p><p>Since SNS can send emails without many hassles or configuration overhead it might be an easy solution. I haven’t tried that though, so I can tell you much more. (feel free to comment below if you have experience and opinions)</p><p>Other posts you might find interesting:</p><p>Foto by <a href="https://unsplash.com/@hostreviews?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Stephen Phillips — Hostreviews.co.uk</a> on <a href="https://unsplash.com/de/fotos/aE0iX-bLCJc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><p><em>Originally published at </em><a href="https://dev.to/aws-builders/send-slack-notifications-with-aws-chatbot-5gfe"><em>https://dev.to</em></a><em> on January 13, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=393165c4406f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS IAM (Identity and Access Management) Cheat-sheet/Wrap-up]]></title>
            <link>https://dvddpl.medium.com/aws-iam-identity-and-access-management-cheat-sheet-wrap-up-75692f712fe8?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/75692f712fe8</guid>
            <category><![CDATA[aws-solutions-architect]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[access-management]]></category>
            <category><![CDATA[tech-lead]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 06:20:41 GMT</pubDate>
            <atom:updated>2023-03-13T09:03:29.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*FTKABgDauwR2kn-4eUPwnA.png" /></figure><p>This article is part of a <a href="https://dev.to/dvddpl/series/19869">series to prepare for AWS Solutions Architect Associate Exam</a> — check below for other posts.</p><p>I remember that when I started with AWS, one of the first things I did was interact with <strong>S3 Buckets</strong>, back then it wasn’t even a big deal to have your Bucket Public so that you could serve your assets without hassles.<br>Then policies went a bit stricter, I also added <strong>Lambdas</strong> to the recipe, and whatever was working fine locally, suddenly stopped working when deployed.</p><p>In the beginning, I really could not wrap my head around those Permissions: permission assigned to me as Developer, Roles for the Lambdas and Policies attached to the Bucket.</p><p>Everything seemed so similar and so complicated.</p><p>I wished I took the time back then to <strong>start with IAM first</strong>, because it is one of the basic services and topics everything else on AWS revolves around.</p><p>Since I am preparing for AWS Solutions Architect Certificate, I prepared this wrap-up/cheat-sheet, which I think is very useful for people just starting out with AWS as well.</p><blockquote><em>IAM can be defined by its ability to manage, control and govern authentication, authorisation and access control mechanism of identities to your resources within your AWS Account.</em></blockquote><p>The main concepts in IAM are:</p><h4>IAM USERS</h4><p>Users are <strong>entities</strong> that represent a person or a service/application ( like in the case of Service Accounts)</p><h4>IAM GROUPS</h4><p>Groups are <strong>collections of users</strong> and have policies attached to them. They help organise users (into departments or functions — like developers or admins) and <strong>simplify access management at scale</strong> because when you need to add or remove policies that change is automatically applied to all users in that group.</p><h3>IAM ROLES</h3><p>Roles can be assumed by trusted entities — a user or a service can assume a role to obtain temporary security credentials.</p><p><a href="https://dev.to/dvddpl/serverless-days-hamburg-2019---day-1-workshops-195o">Pic from a workshop I attended some years ago</a></p><p>They can be used to temporarily grant access to some resources that the User ( or the Group to which they belong) does not have normally access to. Or to grant access to resources in other AWS Accounts ( as i explained in <a href="https://dev.to/dvddpl/how-can-you-access-aws-resources-from-different-accounts-use-different-profiles-1gb9">this post</a>). Another use case is for example to allow an application to access some resources (because of course you don’t want to embed credentials in the software itself, do you!? ( I have <a href="https://dev.to/dvddpl/invoke-aws-services-cross-account-from-lambda-with-aws-cdk-and-aws-sdk-v3-oll">a post for this</a> too)</p><h3>IAM POLICIES</h3><p>Policies are <strong>documents</strong> that define permissions.</p><p>They can be:</p><p>Here there is not much to say other than Inline Policies are <strong>embedded</strong> within the user, group, or role to which they are applied and in case the user, group or role is deleted, the policy will be deleted too. And they don’t scale very well, since you have to edit them individually should something change. Therefore it is advisable to use Managed Policies ( either created by you or AWS)</p><p>Depending on how they behave and affect the target you can find:</p><h4>Identity-Based Policies</h4><p>They can be applied to <strong>users, groups or roles</strong>. <br> They define what action that identity can take on a specific resource.</p><h4>Resource-Based policies</h4><p>They can be attached to resources and define what action can be taken on that resource by a specific identity (principal).</p><blockquote><em>See them as the 2 sides of the same medal.<br> The perspective of the identity, and the perspective of the resource.</em></blockquote><h4>Session Policies</h4><p>They are used with AssumeRole api actions.</p><h4>Permission Boundaries</h4><p>They can be associated with <strong>roles or users</strong> and set the <strong>maximum level of permissions</strong> an identity-based policy can an IAM Entity grant.</p><p><strong>They don’t grant any permission</strong> but only <strong>act as a guard</strong> on other permission policies. (More on this below)</p><h4>Service Control Policies</h4><p>AWS Organisation service Control Policies (SCP) specify the <strong>maximum level of permission for an organisation</strong>. So similar to Permission Boundary but on an Account Level. If your company has multiple accounts you can set up SCPs to define the max permissions on all members of each account.</p><h3>Anatomy of a IAM Policy</h3><p>An IAM Policy is a JSON document where one or more Statements are listed.</p><pre>{ &quot;Version&quot;: &quot;2012-10-17&quot;, &quot;Statement&quot;: [<br>{ <br>&quot;Sid&quot;: &quot;DynamoDBTableAccess&quot;,<br>&quot;Effect&quot;: &quot;Allow&quot;, <br>&quot;Action&quot;: [ <br>    &quot;dynamodb:PutItem&quot;, <br>    &quot;dynamodb:GetItem&quot;, <br>    &quot;dynamodb:Query&quot; <br>], <br>&quot;Resource&quot;: &quot;arn:aws:dynamodb:YOUR_REGION:YOUR_ACCOUNT:table/NAME&quot; }]}</pre><p>A Statement is what defines a specific permission and contains the following:</p><ul><li><strong>Action</strong> — define what you can (or cannot, in case of Effect Deny) do to a resource like viewing, creating, editing, and deleting.</li><li><strong>Resource</strong> — an entity that exists within an AWS Service. it defines what actions are available element specifies the object or objects that the statement covers.</li><li><strong>Effect</strong> element is required and specifies whether the statement results in an allow or an explicit deny.</li><li><strong>Condition</strong> element (or Condition block) lets you specify conditions for when a policy is in effect. (for example allow access only from specific IP or if MFA is enabled &quot;Condition&quot;: {&quot;Bool&quot;: {&quot;aws:MultiFactorAuthPresent&quot;: &quot;true&quot;}})</li><li><strong>Sid</strong> — an optional identifier for each statement, can be customised to make each statement, if you have more than one in the same policy, more readable and, well identifiable</li><li><strong>Principal</strong> — this is only available/necessary in <strong>Resource Based policies</strong>, and identifies <em>who</em> is entitled to execute the action on the resource</li></ul><p>In the example above we are Allowing a user or application to Query for Items, Get a specific item or Insert an Item on a DynamoTable (every other action on that table will not be permitted).</p><p>There are some more Properties that can be used in the JSON document like <strong>NotPrincipal</strong> or <strong>NotAction</strong>.<br> NotAction for example can be used to simplify the IAM Policy and reduce the list of Actions you have to want to allow or deny.</p><p>Instead of having:</p><pre>Action : [ <br>&quot;cloudtrail:CreateTrail&quot;, <br>&quot;cloudtrail:ListTrails&quot;, <br>&quot;cloudtrail:GetTrail&quot;, <br>// and many more ]</pre><p>you could just specify:</p><pre>NotAction : [ &quot;cloudtrail:DeleteTrails&quot; ]</pre><p>It basically lists <strong>a limited set of Actions that should <em>not</em> match instead of listing a set of Actions that should.</strong></p><p>Honestly, as for all the negated statements and conditions, I find them <em>less readable and more error-prone</em>, maybe it’s just me, but they also <strong>warn about the risks</strong> on <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_notaction.html">the official docs</a>.</p><blockquote><em>actions specified in this element are the only actions in that are limited. This, in turn, means that all of the applicable actions or services that are not listed are allowed if you use the Allow effect.</em></blockquote><p>Since Actions are implicitly denied, and you are defining a policy where you ALLOW ALL <em>BUT</em>. Therefore <strong>the inappropriately use of the combination can make the policy too permissive, leading eventually to unauthorised access.</strong></p><p>Why risk, just to save a few lines in the policy?</p><h3>Resource Policies vs Users/Group Policies vs Roles</h3><p>It is very important to note the distinctions and how useful these different approaches are.</p><p>A user might be in the Developers group but might be the only one needing to access a specific resource to execute a specific task for a short amount of time.</p><p>We don’t want to add an inline policy because that would be bound with that specific user only all the time ( not easily maintainable and not safe — maybe next week another developer will take over that task and need that policy ).<br> We don’t want to allow all the users in the Developers group to have access to that resource, all the time.</p><p>Therefore having a Policy attached to a Role is the best option because we can simply edit the trusted relationship to specify <em>who</em> can assume that role and therefore be able to <strong>temporarily</strong> have the permissions listed in the policy.</p><blockquote><em>On the </em>Trusting<em> entity you need to create a Role, where you specify that a </em>Trusted<em> entity, a user or a group, will be able to act on a specific resource.<br> But you also need a policy on the Trusted Entity to be able to assume the role.</em></blockquote><p>In other words, the role grants me the permission to do something on a resource, but if I don’t have permission to assume that role, I won’t be able to do anything anyway.</p><p>I wrote <a href="https://dev.to/dvddpl/invoke-aws-services-cross-account-from-lambda-with-aws-cdk-and-aws-sdk-v3-oll">a post explaining roles</a> to access resources cross-account, but the idea is the same.</p><h3>Privilege escalation</h3><p>As mentioned above, Permission Boundaries are special types of policies which do not grant any permissions, rather they guard that someone cannot be granted permissions higher that a certain level. This is very important to prevent something called <strong>Privilege Escalation</strong>.</p><blockquote><em>With a permission boundary you can for example define that users created via IAM by a user, will not have higher permissions than the user itself.</em></blockquote><p>Why is this necessary? Because without Permission Boundaries <strong>you could overcome the restrictions on your user</strong> simply by creating a user which has higher permissions than you have. <br> Imagine you have full access to IAM, but no access to S3 or EC2 Resources.<br> If you can create a new user, with S3 access, you could then login with such user and have access to resources that are denied to your own account! Thus escalating your privileges.</p><h3>How are policies evaluated?</h3><p>Evaluation logic is as follows:</p><ul><li>By default all requests are denied (implicit deny).</li><li>An explicit allow overrides the implicit deny.</li><li>An explicit deny overrides any explicit allows.</li></ul><p>If you have 2 policies which are overlapping, imagine an Identity-Based policy ALLOWING access to S3 buckets and a Resource-Based policy on a specific bucket DENYING access, the explicit deny on the Resource-Based policy would override the Allow on the Identity-Based policy.</p><p>This is the order of Evaluation of the policies:</p><ol><li>Organisational Service Control Policies</li><li>Resource-based Policies</li><li>IAM Permission Boundaries</li><li>Identity-based Policies</li></ol><p>If for the Action being taken nothing is specified or an Allow is found, process continues down the chain. If a Deny is found, Action is rejected.</p><p>Remember:</p><blockquote><em>Everything is implicitily Denied,<br> Explicit Deny overrides every explicit Allows!</em></blockquote><p>This short video greatly explains explicit deny and permission boundaries.</p><h3>Best Practices</h3><ul><li>Lock away your AWS account root user access keys</li><li>Grant <strong>least privilege</strong> access — don’t give open policies expecting that they will be restricted later. It will never happen</li><li>Enable <strong>identity federation</strong> : centrally manage users and access across multiple applications and services. For federation to multiple accounts in your organisation AWS Single Sign On. ( Post coming soon )</li><li>Enable <strong>MFA</strong>. (you can use <strong>Credential Report</strong> to export a report of all the users in your AWS organisation and check the status of their credentials, psw expiration, MFA is enabled and so on)</li><li>Rotate credentials regularly</li><li>Enable <strong>IAM Access Analyser</strong> to analyse public, cross-organisation access. ( see post serverless days workshop)</li><li>Use Permission boundaries to prevent privilege escalation</li><li>Use Roles to delegate permissions</li></ul><h3><a href="https://dev.to/dvddpl/series/19869">AWS Solutions Architect Associate Certificate Cheat-sheets (16 Part Series)</a></h3><p><a href="https://dev.to/aws-builders/preparing-for-aws-solutions-architect-associate-saa-c03-certification-resources-and-cheat-sheets-2h2k">Preparing for AWS Solutions Architect — Associate (SAA-C03) Certification — Resources and Cheat-sheets</a></p><p><a href="https://dev.to/aws-builders/aws-iam-identity-and-access-management-cheat-sheetwrap-up-28mo">AWS IAM (Identity and Access Management) Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-ec2-elastic-compute-cloud-cheat-sheet-write-up-4lc5">AWS EC2 — Elastic Compute Cloud Cheat-sheet / write-up</a></p><p><a href="https://dev.to/aws-builders/aws-elastic-load-balancing-and-autoscaling-cheat-sheetwrite-up-48ja">AWS Elastic Load Balancing and Autoscaling Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-organizations-and-control-tower-cheat-sheetwrite-up-223">5AWS Organizations and Control Tower Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-virtual-private-cloud-vpc-cheat-sheetwrite-up-1i8b">AWS Virtual Private Cloud (VPC) Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-storage-cheat-sheetwrite-up-2i1b">AWS Storage Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-databases-cheat-sheetwrite-up-iik">AWS Databases Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-datastores-and-analytics-cheat-sheetwrite-up-4daf">AWS Datastores and Analytics Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-serverless-cheat-sheetwrite-up-5g44">AWS Serverless Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-logging-monitoring-and-auditing-cheat-sheetwrite-up-33k4">AWS Logging, Monitoring and Auditing Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-costs-and-budgets-cheat-sheetwrite-up-2peg">AWS Costs and Budgets Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-ai-and-ml-stack-cheat-sheetwrite-up-33el">AWS AI and ML stack Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/dvddpl/aws-mobile-and-web-apps-cheat-sheetwrite-up-2f9j">AWS Mobile and Web apps Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/aws-security-in-the-cloud-cheat-sheetwrite-up-5873">AWS Security in the Cloud Cheat-sheet/Write-up</a></p><p><a href="https://dev.to/aws-builders/disaster-recovery-cheat-sheetwrite-up-o62">Disaster Recovery Cheat-sheet/Write-up</a></p><p><em>Originally published at </em><a href="https://dev.to/aws-builders/aws-iam-identity-and-access-management-cheat-sheetwrap-up-28mo"><em>https://dev.to</em></a><em> on September 12, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75692f712fe8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Look Ma’, No Lambda! Lambdaless APIGateway and DynamoDB integration (with CDK)]]></title>
            <link>https://dvddpl.medium.com/look-ma-no-lambda-lambdaless-apigateway-and-dynamodb-integration-with-cdk-8737c13711a9?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8737c13711a9</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[tech-lead]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 05:47:11 GMT</pubDate>
            <atom:updated>2022-08-31T04:19:43.818Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZQGqgyi_L4_Vg6hR.png" /></figure><p>Serverless is awesome! On the other hand, it might take some time to get used to the tons of AWS Services out there which can be used to build an application. And it can happen that you end up with an architecture that is unnecessarily complex and costly.</p><p>Think of a simple CRUD API to manage a user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*YKEj4264aZwV05iKl3zrsQ.png" /></figure><p>What we see normally in thousands of tutorials is API Gateway + Lambda + DynamoDB. (with the Lambda being a single function for each endpoint / method or a Fat Lambda / Lambdalith handling multiple endpoints/methods). This is also the approach shown in the official — and very useful- git repo <a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/api-cors-lambda-crud-dynamodb">AWS CDK Samples</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*ZjQ64cUwoaXAQ8pkWw6bDA.jpeg" /></figure><blockquote><em>you might not even need a Lambda function?</em></blockquote><p>Yes, <strong>often that Lambda function does nothing else than receiving the payload and (maybe after some validation) stuffing it into dynamo</strong> ( in case of a creation or edit ) or simply forwarding the GET or DELETE commands to dynamo. (see again the content of the Lambda in the <a href="https://github.com/aws-samples/aws-cdk-examples/blob/master/typescript/api-cors-lambda-crud-dynamodb/lambdas/get-one.ts">official sample</a>).</p><p>If that is the case, then, yes, you don’t need the lambda at all because APIGateway comes with lots of different integrations with other AWS Services (like DynamoDB or SQS) that can help us streamline our application, simplify the infrastructure, the code base and even reduce costs!</p><p>There are some tradeoffs, but let’s first look at how to for example, create a RESTful API which puts and retrieves items to and from DynamoDB.</p><h3>AWS Service Integrations</h3><p>Here you can see how you can set up an API Gateway with Service Proxy Intregration directly from the <a href="https://aws.amazon.com/de/blogs/compute/using-amazon-api-gateway-as-a-proxy-for-dynamodb/">UI Console</a>, which is nice to get our hands dirty and understand the steps, but <strong>we don’t want to set up our infrastructure with thousands clicks, do we? No, we want <em>Infrastructure As Code</em></strong>, therefore let’s see how to do that using AWS CDK.</p><p>First we need to create our Table, as usual.</p><p>Then, and again here nothing is different from the solution <em>with</em> the Lambda in place, Create a role for API Gateway and the RestAPI :</p><p>This time, rather than creating the Integration with Lambda and assigning our Lambda the permissions necessary to read and write to dynamo (like <br> dynamoTable.grantReadWriteData(myLambda)) we create a policy for our Dynamo Table, we create a Role for our APIGateway and attach that policy to that role which we will then assign to our endpoint - methods.</p><p>Something that we need to setup are the <a href="https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-apigateway.MethodOptions.html#methodresponses">MethodOptions</a> responses and their templates. This is especially necessary because in our Lambda we would return the body and the status response code. In case of Dynamo direct integration we need to map the errors or the successful response so that meaningful data is returned to the client.</p><p>Here I am mapping any error code in the 400 range to a simple Bad Input message and all the errors in the range 500 to Internal Service Errors. Of course you can get into more details and customize the response how you prefer.</p><p>You can read more about the <strong>mapping template reference</strong> <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html">here</a></p><p>Now we can create a Validator and a Model where we define our <a href="https://json-schema.org/">JSON Schema</a> — very like in your lambda you would validate the payload of the incoming request somehow — possibily with a <a href="https://www.npmjs.com/package/@middy/validator">middleware like Middy and JSON Schema</a>.</p><p>The concept is similar, the JSON schema specifies the properties which are required and optional and how they should look like.</p><p>Now add the CRUD methods to our endpoints and provide all the pieces we created above.</p><p>The GET method to retrieve a user by its id is very straightforward.</p><p>The most interesting thing here is that instead of Lambda Integration, here we have an AWSIntegration and we are specifying to which AWS Service we are proxying the request and to which command:</p><p>Within the integration options we assign the role we created above credentialsRole: apiRole - without it our Request would fail due to missing permissions to access the table.</p><h3>Mapping Templates</h3><p>Another thing to note in the above code is how the mapping template grabs the id from the path parameters $method.request.path.userId ( imagine a request made to myapigateway/users/12345 and assign it to the Key used to search the table.</p><p>Mapping templates are very handy because they allow us to map, manipulate and override whatever we received in the request.<br> For example we can rename property names in case we don’t want to expose or use the properties/columns of our database. You will understand more what I mean in the next section.</p><p>Let’s now see the method in charge of the creation of a user. <br> (i won’t go into the details of how userID is generated — this is out of the scope of this tutorial, so here to simplify I am just concatenating the uniqueId of the request with the playername).</p><p>Wow. this is quite some stuff here. let’s try to break it up.</p><p>Again here the Response model is necessary to map the response from Dynamo (remember that we don’t have Lambda code to do that) in case we want to hide some values or rename some properties. We also want to map the errors that we might receive if something goes wrong.</p><p>And now the juicy part: the <strong>Request Mapping</strong>, where we tell APIGateway to use the Model and Validator, and we specify how to manipulate the payload to rename some properties or create new ones.</p><p>This is not strictly necessary, if we have control on the client and we agreed to have a specific payload we can just use that as is, but it might happen that we need to adjust it ( like in my example user_name was coming from an old php application and i want to rename it as name, keep track of the requestId to facilitate tracking the request and correlated requests and operations in different parts of the infrastructure, or eventually taking advantage of the TimeToLive functionality on DynamoDb to delete the item after some time.</p><p>Here for example I am taking the requestTimeEpoch from the context of the Request to generate the timestamp when the item will have to be automatically deleted.</p><p>Again this is not really necessary, but whenever I found myself dropping a lambda in favour of a direct integration, then I found myself a bit struggling to manipulate the payloads or adding properties with the VLTs therefore I thought it might be useful to have a couple of samples.</p><p>The last method I will show you is the Deletion.</p><p>Not much to say here, and I think that by this time the idea is clear and you basically can continue with PATCH method on the User/{id} endpoint and so on.</p><h3>Pros and Cons</h3><h3>Debugging</h3><p>If you follow this approach, and I really suggest you doing it, there is only one problem which is testability and debuggability of what is going on.</p><p>When you have your logic and validation <strong>in the lambda</strong> that is proxying the request from API Gateway to Dynamo, <strong>you can run it locally, debug it from your IDE, have unit tests on the validation and execution logic</strong>.</p><p>When you have velocity templates… it is just magic. At least for me, I haven’t found a way to test and debug them. <br> (There is a way of <a href="https://aws.amazon.com/de/blogs/mobile/introducing-template-evaluation-and-unit-testing-for-aws-appsync-resolvers/">evaluating templates for AppSync</a>, but so far I did not find a way for ApiGateway).</p><p>What helps though is activating <strong>APIGateway Logs</strong>, so that <em>everything</em> going on is logged to CloudWatch:</p><p>In the CDK it is just a matter of adding a couple of parameters in your APIGateway deployment options:</p><p>Then in CloudWatch you will be able to see the method request headers, the request body <strong>before transformation</strong>, the request <strong>query string or path parameters</strong>, if available, and the request body after transformations ( those applied by your VLT ). <br> You can see the invocation to your dynamo table and its response.<br> If you have mappings on the response you can also take a look at those, and understand why something does not work as expected.</p><blockquote><em>This logging though will store a lot of data in CloudWatch so be careful because it could get very expensive. Disabled it after you run some tests and you are sure everything is working as expected.</em></blockquote><p>Otherwise the only way to have a similar result is manually Testing the Gateway API from the console. (that means, deploying your stack then go to your APIGateway in your browser, <strong>go the the Integration and Mapping Templates. Edit your template there and the run Test</strong>.</p><h3>Less is more</h3><p>Since you don’t have the Lambda running ( coldstarting or not ) you will have <strong>lower latency and lower costs</strong> (one service less to be counted in your bill). But is is <em>less code</em>?</p><p>That not really… especially if you need to use Velocity Templates to map your requests and response and do data transformation, you still need a lot of code — <strong>it will be in your IaC</strong> rather than in your deployed Lambda, but it is <strong>still code that needs to be written and maintained</strong>.</p><h3>Conclusion</h3><p>I really love how this approach is lean and simple, but I must say that I found <strong>working with VLT was quite hard</strong> — cumbersome to implement and hard/impossible to test, (despite the <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html">documentation being very extensive</a>) so, like in many circumstances we need to be aware of <strong>costs and benefits</strong>.</p><p>If you need advanced validation, you need to do lots data manipulation in your requests or responses and you are not handling millions of requests every day ( or second ) where latency and costs really would make a difference, I think keeping Lambda in the system could be still a good idea since you (and anyone in your team, no matter how junior) can write the logic in your language of preference (node, java or python) and you can <strong>write and run unit tests</strong> on it.</p><p>On the other hand if your Lambda really does nothing else than validating and proxying requests to Dynamo ( or other service like StepFunctions or SQS), you can keep your MappingTemplates to a minimum (or you must shave cents and milliseconds) this approach is definitely the way to go.</p><p>Simple, less expensive, with lower latency and less pieces in the infrastructure that have to be maintained and monitored.</p><p><em>Originally published at </em><a href="https://dev.to/aws-builders/look-ma-no-lambda-lambdaless-apigateway-and-dynamodb-integration-with-cdk-2hbd"><em>https://dev.to</em></a><em> on August 29, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8737c13711a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Invoke AWS Services Cross Account from Lambda (with AWS CDK and AWS SDK v3)]]></title>
            <link>https://dvddpl.medium.com/invoke-aws-services-cross-account-from-lambda-with-aws-cdk-and-aws-sdk-v3-2ddbb8e9c7ae?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ddbb8e9c7ae</guid>
            <category><![CDATA[tech-lead]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 20:25:27 GMT</pubDate>
            <atom:updated>2022-04-28T06:30:18.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*qY2qX0Y8NiQeZMlX.png" /></figure><p>Recently we started a big refactor of an application that was running on another team’s AWS Account.<br> Our plan is to move to a serverless architecture using our own account to gradually dismiss the old one.</p><p>In order to achieve that, we deployed a Lambda on one account which was in charge of <em>forwarding</em> every request to other AWS Services in another account.<br> Some of the services we invoke cross-account are SSM ( to retrieve credentials and other configuration stuff), SQS ( to push POST and PATCH requests to a queue to handle batch processing and retries, DynamoDB, to read data in case of GET requests.</p><h3>Create a Cross Account Role</h3><p>To access resources CrossAccount we need to a Role that one account can Assume to “impersonate” the other account, and also create a Policy with the right permissions about the service and actions you want to trigger.</p><p>In the new account / CDK Stack,</p><p>Here the only interesting part is that we need to add to our cdk.context.json the reference to otherAccountID.</p><h3>Add Policies</h3><p>Then assign Policies for every service we will be using:</p><p>The first policy allows the role to getParameters from SSM.<br> The resource ARN must be specified.<br> If SSM parameter was created via CDK it is possible to reference it like this: mySSM.parameterArn but <em>hardcoding</em> the reference again in the cdk.context.json and using it like this arn:aws:ssm:${this.region}:${this.account}:parameter${ssmKey} is also a possibility.</p><p>Similarly, here we are assigning Permissions to retrieve items from DynamoDB.</p><p>While in the following we grant rights to push items to a queue.</p><p>Having this <strong>granular policies</strong> in your cross account role are very important to expose access only to the services you plan to use and not have security issues.<br> It might be a bit harder at the beginning when you are not sure if you are doing everything right, or confusing when you in few weeks or months add another service ( or like in our example, try to Put an Item in Dynamo) and it does not work until you update the policies but it is better to stick to the <em>The Principle of Least Privilege</em>.</p><blockquote><em>a subject should be given only those privileges needed for it to complete its task. If a subject does not need an access right, the subject should not have that right.</em></blockquote><p>Now that we have our role and policies set up in our main account, let’s go to our Lambda in the other account and assume the CrossAccount Role so that we can init our AWS Services with the right Credentials.</p><h3>First implementation (kinda working, until..)</h3><p>In our handler we were first checking if we had stored the credentials and if not we invoke STS AssumeRole.<br> Then we passed the loaded credentials to our AWS Client.</p><p>After deploying and testing everything worked, until we realised that <strong>when the Lambda Container stays up for a long time ( due to frequent requests), the Credentials expire.</strong></p><h3>Just check for Expire?</h3><p>First quick fix was checking in the handler if the Credentials were expired and eventually reloading it.</p><p>But it didn’t feel right and especially with multiple services and AWS clients we wanted to have some better code in place in order to refresh the credentials <em>automatically</em>.</p><h3>Extend Credentials class to handle refresh</h3><p>By <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Credentials.html#refresh-property">checking the docs</a> we found some interesting methods:</p><p>which could be used by subclasses overriding them.</p><p>Therefore we changed our method into a Class:</p><p>The key part here is that in the assumeRole we don’t return directly the Parent Class, but an object which contains also ExpiredTime information</p><p>Also, instead of manually checking if Credentials exist and are expired and eventually reload them, we could safely every time invoke await credentials.getPromise() which does that for us.</p><h3>Not yet optimal</h3><p>This solution was working fine, but there was something that was really bothering me.</p><p>We were storing the Credentials and refresh them, but we were, at every run of the lambda handler, instantiate a new AWS Client in order for it to receive valid credentials.</p><p>I can’t tell <em>how much</em> this is a problem, but it <a href="https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html">is a general recommendation</a> to <strong>initialize SDK clients outside of the function handler. Subsequent invocations processed by the same instance of your function can reuse these resources. This saves cost by reducing function run time.</strong></p><p>Therefore I dug in the docs even more, I checked the source code of AWS SDK Client in my IDE and and also thanks to Typescript, I noticed something interesting.</p><p>Every Client accepts a configuration object which contains the Credentials to be used. <strong>Either the Credentials, or a Provider of Credentials!</strong></p><p>What does that Provider do?</p><blockquote><em>A function that, when invoked, returns a promise that will be fulfilled with a value of type T.<br> Example:A function that reads credentials from shared SDK configuration files, assuming roles and collecting MFA tokens as necessary.</em></blockquote><p>How to use it?<br> By looking up the CredentialsProvider in the new AWS SDK V3 docs I immediately found what I was looking for<a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_credential_providers.html#fromtemporarycredentials">.fromTemporaryCredentials</a><br> that <em>returns a CredentialProvider that retrieves temporary credentials from STS AssumeRole API.</em></p><p>I throw away most of the code that was written previously to extend the Credential Class and handle the refresh method and I simply passed the ARN of my CrossAccountRole to the fromTemporaryCredentials to get a Provider&lt;Credentials&gt; which will take care of the refresh automatically.</p><p>By simply passing that CredentialsProvider in the ServiceConfig, I can initiate my services outside the Lambda handler and reuse them, but be sure that when the Credentials are expired, they will be refreshed, without me even knowing it!</p><p>It took us a bit to get to this final version (unless someone has some hints or different approaches — feel free to leave a comment! ) but now <strong>it shines in its simplicity</strong>.</p><p>Of course when developing a feature it is important to get shit done and deliver, and as this story shows, we did go live with the first working implementation but then we iterate on it until we found the proper way of doing it.</p><p><strong>Never stop at the first quick solution that works</strong>, try to improve your code, and most importantly <strong>read the docs</strong> to really understand what you are using.</p><p>Hope it helps!</p><p>Photo by <a href="https://unsplash.com/@marcojodoin">Marc-Olivier Jodoin</a> on Unsplash</p><p><em>Originally published at </em><a href="https://dev.to/dvddpl/invoke-aws-services-cross-account-from-lambda-with-aws-cdk-and-aws-sdk-v3-oll"><em>https://dev.to</em></a><em> on April 27, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ddbb8e9c7ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Reviews are bottlenecks. What is the point of Code Reviews?]]></title>
            <link>https://dvddpl.medium.com/code-reviews-are-bottlenecks-what-is-the-point-of-code-reviews-f1b59e5ffc51?source=rss-4c34338fa8b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1b59e5ffc51</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[tech-leadership]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[pull-request-reviews]]></category>
            <dc:creator><![CDATA[Davide de Paolis]]></dc:creator>
            <pubDate>Tue, 19 Apr 2022 08:29:49 GMT</pubDate>
            <atom:updated>2022-04-20T05:54:29.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kup1-FKY0OE9Yj472JcLnw.png" /></figure><p>Let’s admit it.<br> Code reviews are bottlenecks.</p><blockquote><em>Most code reviewers are gatekeepers.</em></blockquote><p>By controlling and ultimately deciding what gets into the main branch they slow down the entire process — <strong>screwing the original estimates and jeopardizing the sprint</strong>.</p><p>I am myself often a gatekeeper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*UF767lBP2qTaLK93hXwNkQ.jpeg" /></figure><p>Sometime ago a colleague said jokingly that <em>I am like </em><strong><em>the Dungeon Boss</em></strong><em> in videogames</em>: the developer has to go past the level — the implementation of the feature described in their ticket — and when they are done, or they think they have accomplished their challenge, here comes the hardest part, the end boss: the code reviewer!</p><p>Once, a ticket that was estimated for 1 day, (but took 3 days of development), required almost 4 hours of code review with endless threads, and then almost 2 days to apply all the changes that satisfied the reviewer.</p><p>What did go wrong?</p><ul><li>naive and optimistic estimation</li><li>unclear or only partially documented task definition</li><li>lack of code design</li><li>a desire of be quick</li><li>misunderstanding of the scope of the task</li><li>unclear definition of done</li><li>first experiences with working remotely due to the lockdown and the pandemic</li><li>communication issues</li><li>a sloppy implementation</li><li>a nitpicking reviewer</li><li>some rivalry among the envolved parties</li></ul><p>This was clearly an exception, and it would be too easy to only <strong>blame the developer, or the reviewer</strong> — the reasons and causes of this time consuming bloodbath were many and reveal some <strong>disfunction in the process</strong>.</p><p>A lot of developers don’t like them when they have to review, because it is boring or they <strong>feel bad at judging other people’s code</strong><br> Many developers don’t like them when they are the ones being reviewed, because, well, <strong>nobody likes having its mistakes and flaws being pointed out.</strong></p><p>Project Managers and Team Lead don’t like them because they are the biggest <em>incognita</em> in the success of the sprint, often deadlines are not met because of the changes requested by the reviewer, and because to to the PR threads and endless back and forth and comments <strong>the mood in the team can become toxic</strong>.</p><p>But… Are these good reasons to stop doing code reviews?<br> What is the benefit of having them? How can we make them better?</p><h3>Spend time on your Code review</h3><p>Do not just carelessly scroll a PullRequest ( or MergeRequest if you are using Gitlab), as a daily annoying chore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*X7xNU6MqY-bvJjK2.gif" /></figure><p>You are doing something very useful!</p><ul><li>for yourself: you can learn something about the new feature being implemented or about a bug being fixed, about coding styles and about different ways of approaching a problem.</li><li>for the reviewee: you can share some knowledge and give advice and help people grow and become better developers.</li><li>for the team: you contribute in raising awareness of the codebase and adoption of coding standards to make the team a “well oiled machine”</li><li>for the project: you help keeping the quality high, prevent bugs or memory leaks to sneak into production, contribute in delivering a great product that is maintainable and extendable.</li></ul><p>Therefore, take some time to understand the task, and understand the changes, don’t just check if the snippet of code in the changes is just <em>not wrong or ugly</em>.<br> And <strong>take the time to properly write useful, reasonable and respectful comments</strong>.</p><h3>Automate whatever is possible</h3><p>Code review should not focus on gritty details as indentation, brackets, semicolumns, or any other coding standards that a good linter could detect.<br> Pick any linter, we use a <a href="https://dev.to/dvddpl/lint-rules-updates-a-sane-and-safe-approach-to-fixes-4nhp">very opinionated one</a> ( and we love it, and somehow hate it when new stricter rules are introduced) but it helps us to avoid wasting time on such things. Just run the linter before every commit and you can focus on the interesting stuff — the code implementation!</p><h3>Be clear, be supportive, be kind</h3><p>In the same way you are not carelessly scrolling a PR you should not be there staring at the screen with an evil smile <strong>looking for a flaw so that you can point it out bragging about your experience, your skills, how good you are.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/0*PDB89QQcQGnQZ2M8.gif" /></figure><p><strong>You are there to help</strong> — and mentor — the reviewee, to avoid that wrong solutions or bugged implementations make it into production, to help the team deliver better code, to avoid that bad code gets into the code base and degrades the quality, and the future developer experience.</p><h3>Reduce conflicts</h3><p>Some times code reviews are a problem simply because they surface rivalry or power-games in the team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*IMHUuFyNC24klFkm_RqJfw.jpeg" /></figure><p>Maybe there are 2 senior engineers engaging in an <strong>alpha male battle</strong> for the next promotion and raise.<br> Maybe a (brilliant and skilled) junior developer is resentful for their lower title and wage and and is trying to call out other regulars/seniors.<br> Maybe it is a micromanaging and controlling leader that simply wants to state his authority over team members.</p><p>Again this is not a problem of Code Reviews, but often, to avoid these conflicts, <strong>the solution is to avoid having Code Reviews</strong> — which is bad for the quality code base and for the growth of the team.</p><p>If code code reviews become long, tedious and ultimately conflictual, <strong>try pair programming</strong>.</p><p>I can’t guarantee it wont be conflictual, <strong>power-games will arise in pair programming too</strong>, but with different nuances, and the process is overall sped up.</p><p>Synchronous communication is better and more efficient.<br><strong>A poorly written comment can be misunderstood</strong>, both from technical and emotional point of view. <br> Then the reader asks for clarification, the thread increase in size with both people trying to make themselves clearer but <strong>the result is often frustration, anger, passive-aggressive behaviour or condescending language.</strong></p><p>While talking and seeing each other, sharing a screen and pointing directly at the code, we have more context and need less time to recalibrate a misunderstanding or ask for clarification.</p><p>On top of that, by pair programming you prevent the frustration (or the rejection) that comes from a comment that requires the developer to throw away the code they wrote.<br> Things are discussed on the go, before they are being written, before you invested time on them and the developer become less attached to their solution. (check also my previous post: <a href="https://dev.to/dvddpl/keep-ego-away-from-coding-4gi5">Keep your Ego away from coding</a>)</p><h3>Keep your Pull Request small</h3><p>One of the reason why Code review become too time consuming, boring and ultimately, useless, is that too often Merge Requests are too big! There is simply, way too much code to review, too much context too understand which would require too much time to review — time which is often not even clearly allocated in the team sprint.</p><p>Code reviews should be done within minutes.<br> In order for this to be possible, another great suggestion from <a href="https://twitter.com/housecor">Cory House</a>:</p><blockquote><em>Focus on 1 thing.<br> Only change what’s necessary for that 1 thing.<br> Handle bugs, new features, and refactors in separate PRs.<br> When I see an unrelated improvement opportunity, I handle it in a separate PR.</em></blockquote><h3>Be proactive and clear in your communication</h3><p>This is true for reviewer and reviewee. Spend time in writing your comments, the goal is improving the code base and merge the feature into main. therefore the exchange of messages should be effective.</p><p>Imagine this comment about an edited script in package.json — apparently unrelated to the feature which is focus of the merge request:</p><p>why is this change necessary? - was CI broken?</p><p>To that the reviewee, replied:</p><p>fixed. (while actually reverting entirely the change)</p><p>How helpful is that answer?<br> Questions asked during code reviews have multiple reasons, we might have not understood the issue, we might need more context to understand the change.<br> Replying FIXED does not help understand why that change was necessary in that MR or needed at all.</p><p>Of course, <strong>communication works in 2 directions</strong>.</p><p>So let’s imagine my comment from why is this change necessary? - was CI broken? to something less judgemental or invasive:</p><blockquote><em>I noticed you added a change to package json which is not part of the feature.<br> Is this a change necessary for your local tests or did you find that something in our CI/deployment was broken? (if so that is a great finding! Thanks for the fix ! -<br> otherwise please remember to revert your local changes that might break our CI pipeline. :wink!<br> oh, maybe next time create a mini MR directly to main so that everyone benefits of the same fix immediately.</em></blockquote><p>Now let’s imagine what the reviewee could have answered instead of fixed</p><blockquote><em>honestly I did not quite get why the dependency we are using stopped working, but after some investigation with </em>awesome_colleague<em> we realised that </em><em>some technical explanation. As you pointed out though I realized that this change is only necessary while testing locally therefore I reverted my change - I will eventually create an additional script for local env and push it to a different branch/PR.</em></blockquote><p>As you see, being concise while providing all the information, and without becoming too blunt is not that simple.</p><p>I am quite known for being pretty direct, but if I write “ <em>please rename this method XYZ</em>”, (especially if we have been working together for months or years) you can be pretty sure there is no underlying offensive message or personal judgement.</p><p>Or do i still have to say:</p><blockquote><em>This method could be renamed as XYZ because that would make it both more concise and descriptive. What is your opinion about that?</em></blockquote><p>(feel free to disagree with me in the comments — I am genuinely looking forward hearing different opinions and improve my communication)</p><p>The point is <strong>Both parties should do their best to avoid misunderstandings, and to assume good will on the other</strong>.</p><h3>Use conventional comments</h3><p>To achieve both conciseness and politeness a great tip is using <em>Conventional </em><strong><em>Comments</em></strong>.</p><p>We have been using <em>Conventional </em><strong><em>Commits</em></strong> for years now — they are very useful to have standards within the team, make the commit history nice, clean and readable, and the Changelog is one of the main pros from adopting them.<br> Thanks to <a href="https://dev.to/nickytonline/how-i-review-pull-requests-44nl">this post from NickTaylor</a> I found out about <br><a href="https://conventionalcomments.org/">Conventional Comments</a> and immediately fell in love with them.</p><p>They help to smooth out comments that could be misunderstood, to be polite even when you really want to save up keystrokes.<br> And also provide some more context about the action necessary — should the reviewee work on every single thing pointed out, <strong>immediately</strong> as a priority, or can the code be merged and then “refactored”, are those just suggestions for the future or mandatory steps?</p><p>A comment saying simply This is not worded properly is a bit too blunt and also does not give clear instruction about what is necessary.<br> compare that to :</p><h3>Recap</h3><p>Most of the time when Code review become a bottleneck there are multiple reasons which we should address for the sake of the project. <br> Dismissing code reviews is not a solution — it would be like stopping writing code because there are bugs…</p><p><strong>Code Reviews are opportunities</strong> to share knowledge, raise interesting questions, leveraging team skills and increase overall awareness of the codebase. <br> And they prevent buggy code to make it in production.</p><ul><li>Discuss, agree and define standards within your team (linting, conventional comments, process of review)</li><li>Define guidelines for when things get rough: If a comment is unclear, instead of replying with a passive aggressive answer, ask in person or join a slack huddle, to sort out the issue quickly, don’t let it escalate or go on for hours with multiple back and forth ( which distract everyone from what they are doing)</li><li>Don’t have just one person become the bottleneck. Reviews should be shared among the team, be done by different ( and sometimes by multiple) people in the team.</li></ul><p>Photo by <a href="https://unsplash.com/@sajjadahmadi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sajjad Ahmadi</a> on <a href="https://unsplash.com/s/photos/traffic-jam?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><p><em>Originally published at </em><a href="https://dev.to/dvddpl/code-reviews-are-bottlenecks-what-is-the-point-of-code-reviews-1j5f"><em>https://dev.to</em></a><em> on April 19, 2022.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1b59e5ffc51" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>