<?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 Vadim Nicolaev on Medium]]></title>
        <description><![CDATA[Stories by Vadim Nicolaev on Medium]]></description>
        <link>https://medium.com/@vadim-vicolaev-v?source=rss-79f01f06bb75------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cDNb5e_gOhrbb17sdA8ulg.jpeg</url>
            <title>Stories by Vadim Nicolaev on Medium</title>
            <link>https://medium.com/@vadim-vicolaev-v?source=rss-79f01f06bb75------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:01:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vadim-vicolaev-v/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[Better way to get secrets in serverless world]]></title>
            <link>https://itnext.io/better-way-to-get-secrets-in-serverless-world-1aba8a71b3a1?source=rss-79f01f06bb75------2</link>
            <guid isPermaLink="false">https://medium.com/p/1aba8a71b3a1</guid>
            <category><![CDATA[helpers]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Vadim Nicolaev]]></dc:creator>
            <pubDate>Sun, 28 Mar 2021 16:27:55 GMT</pubDate>
            <atom:updated>2021-04-01T11:46:08.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Most likely if you are actively using serverless technologies, You already implemented such kind of helper to retrieve some secret data from secret Manager at runtime. I thought there could be some pitfalls and area for improvement.</p><p>In this example, we will implement a helper to get secret values from <a href="https://aws.amazon.com/ru/secrets-manager/">AWS Secret Manager</a></p><p>You’re welcome on board to disassemble such kind of helper! We will use typescript. Based on the technique used here, it will be possible to use any programming language (well, almost).</p><p>Let’s define the initial <strong>“look” </strong>of our helper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n9h948tYjLwgDNNNyiI3Rw.png" /></figure><p>Already could appear question. Why the hell is it so complicated ? Function returns a function ? Let’s figure it out together. Firstly we need to understand how we will use this helper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xnTR9J27rdUw_gYYrX8Uqg.png" /></figure><p><a href="https://typeofnan.dev/what-is-a-higher-order-function/">HOF</a> helps us to “<strong>create</strong>” multiple different function which will return secrets value by different <strong>secretId. </strong>It looks more accurate than using <strong>secretId</strong> as separate parameter for out helper. Without HOF it requires to extend logic of helper itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sv5nuPidL1v5yNIcxLnf6w.png" /></figure><p>So far should not appear new questions. Let’s define main logic of our helper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1YPPxBH0eLFEWbMYHLHmw.png" /></figure><p>There is nothing special, we receive <strong>SecretString</strong>, then we parse it and try to get values by provided keys.</p><p>At this point, we could stop it and go for a cup of coffee/tea and rewatch the best episodes of <strong>Rick and Morty</strong>, but as I said earlier, there is an area for improvement with own pitfalls.</p><blockquote>When running a serverless function, it will stay active (a.k.a., hot) as long as you’re running it. Your container stays alive, ready and waiting for execution.</blockquote><blockquote>After a period of inactivity, your cloud provider will drop the container, and your function will become inactive, (a.k.a., cold).</blockquote><p>source: <a href="https://www.serverless.com/blog/keep-your-lambdas-warm">https://www.serverless.com/blog/keep-your-lambdas-warm</a></p><p>Now we can benefit knowing that fact and don’t make additional calls to <strong>AWS Secrets Manager</strong>, <a href="https://aws.amazon.com/secrets-manager/pricing/">cause it cost not only time but money as well.</a> A simple <strong>Map</strong> will help us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v41gwFMK8ekiJhH4wQ3yqA.png" /></figure><p>After successfully receiving data from <strong>secretManager</strong> we put it in map where key is secretId and value is a parsed string(secret values). Thus we avoid repeated calls to <strong>secretManager, </strong>cause we’r getting value from <strong>Map </strong>directly(In case if lambda warm of course).</p><p>You might thinking this is the end. But with such implementation, you can easily wipe yourself in the foot! Let’s pretend you have a super successful startup. Constant traffic leaves your lambdas constantly warm ! You look in the logs and understand that you need to change one of the secret values, because some API keys are defined wrong for prod <em>env</em>. You open <em>aws console</em>, change the values to the correct ones. Some time passes, but by the logs lambda still works incorrectly. That causes permanent warm and helper use “<strong>cached</strong>” secret values from <strong>Map. </strong>How can we fix it ? Correct, add some expiration time for our secret, let’s say that non of the values should not be “<strong>cached</strong>” in the map more than <em>10 minutes.</em> Let’s implement it. That is how looks our final implementation of <strong>getSecretValues </strong>helper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpc5YO18C-GFJqoqZ6bqRA.png" /></figure><p>I hope You find it helpful. I’m open for any kind of feedback. Feel free to share with Yours helpers/tricks which might be useful in serverless world. This helper is a part of my <a href="https://github.com/collierrgbsitisfise/serverless-bonk-template">serverless-bonk-templet</a>. <a href="https://github.com/collierrgbsitisfise/serverless-bonk-template/blob/master/src/helpers/getSecretValues.ts">Here You can find original source of helper</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1aba8a71b3a1" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/better-way-to-get-secrets-in-serverless-world-1aba8a71b3a1">Better way to get secrets in serverless world</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>