<?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 Gaukhar on Medium]]></title>
        <description><![CDATA[Stories by Gaukhar on Medium]]></description>
        <link>https://medium.com/@g900?source=rss-6ad12cfb3653------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a86sN59OR0aJ_2K0fIVUcA.jpeg</url>
            <title>Stories by Gaukhar on Medium</title>
            <link>https://medium.com/@g900?source=rss-6ad12cfb3653------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 14:58:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@g900/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[Securing credentials in React app with AWS]]></title>
            <link>https://g900.medium.com/securing-credentials-in-react-app-with-aws-6dad771ed3cf?source=rss-6ad12cfb3653------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dad771ed3cf</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[hosting]]></category>
            <category><![CDATA[aws-amplify]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Gaukhar]]></dc:creator>
            <pubDate>Sun, 23 May 2021 08:50:30 GMT</pubDate>
            <atom:updated>2022-03-13T09:48:54.221Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS S3 is a nice choice when you want to host a static website - it’s cheap, you can find many tutorials, AWS has a nice <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html">documentation</a> on this.</p><p>S3 hosting works very well until you have to interact with protected APIs. In order for your website to be seen by everyone, the S3 bucket where the website is hosted has to be publicly accessible. AWS warns us with this message:</p><blockquote>When you turn off block public access settings to make your bucket public, anyone on the internet can access your bucket. We recommend that you block all public access to your buckets.</blockquote><p>We can’t store any access keys, secrets, passwords because this will compromise the security of the services that we intend to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dZcK9zswebuXk9FD" /><figcaption>Photo by <a href="https://unsplash.com/@franckinjapan?utm_source=medium&amp;utm_medium=referral">Franck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The solution to this problem is hosting with AWS Amplify. Everything you need is to connect your repository and configure build settings.</p><p>In the example below I will show how I store credentials for calling lambda function from React App.</p><h4>Creating .env file</h4><p>The first thing we need to do is to create a .env file with our credentials in the root directory of the application:</p><pre>cd your_app_directory<br>touch .env<br>echo &quot;REACT_APP_AWS_ACCESS_KEY=some_access_key&quot; &gt;&gt; .env<br>echo &quot;REACT_APP_AWS_SECRET_KEY=some_secret_key&quot; &gt;&gt; .env<br>echo &quot;REACT_APP_LAMBDA_API=&#39;https://lambda_api_link.com&#39;<em>&quot; &gt;&gt; .env<br></em>echo &quot;REACT_APP_AWS_REGION=some_region&quot; &gt;&gt; .env</pre><h4>Modifying code to use environment variables</h4><p>Here is how environmental variables are used in the code for calling lambda function:</p><pre><em>useEffect</em>(() =&gt; {<br>    const aws = new AwsClient({<br>        accessKeyId: process.env.REACT_APP_AWS_ACCESS_KEY,<br>        secretAccessKey: process.env.REACT_APP_AWS_SECRET_KEY,<br>        region: process.env.REACT_APP_AWS_REGION<br>    })<br><br>    async function invokeMyLambda(event) {<br>        const res = await aws.fetch(`${process.env.REACT_APP_LAMBDA_API}`)<br>        return res.json()<br><br>    }</pre><pre>    invokeMyLambda({my: &#39;event&#39;}).then(json =&gt; {<br>            if(json.body.undefined !== true){<br>                ...do something here...<br>            }<br>        }<br>    ).catch(err =&gt; console.log(err))<br><br>}, [])</pre><h4>Adding .env file to .gitignore</h4><p>After creating .env file and modifying code, don’t forget to add .env file to .gitignore. If you do forget, the whole thing we do here is pointless :D</p><pre>echo &quot;.env&quot; &gt;&gt; .gitignore</pre><p>We are ready to push our repository to git and proceed to AWS Amplify now</p><h4>Configuring AWS Amplify</h4><p>After signing into your AWS account, choose the AWS Amplify service.</p><p>Click on the “New app” button and choose the “Host web app” option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mkg5aaRmP0WShXnSqMnweQ.png" /><figcaption>Connecting to repo</figcaption></figure><p>As you can see, you can connect to various repository hosting services</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZ9cNNkkrnEhjYaVu8A6PQ.png" /><figcaption>Configuring repo connection</figcaption></figure><p>After GitHub authorization, we can select our repository and the branch that should be deployed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-MjN3IdCoUOwWybip8CXQ.png" /><figcaption>Build configuration</figcaption></figure><p>In the next step, we have to configure our build, replace the default build file’s content with the next one:</p><pre>version: 1<br>frontend:<br>  phases:<br>    preBuild:<br>      commands:<br>        - yarn install<br>    build:<br>      commands:<br>        - yarn build <br>        - echo &quot;REACT_APP_AWS_ACCESS_KEY=$REACT_APP_AWS_ACCESS_KEY&quot; &gt;&gt; /.env<br>        - echo &quot;REACT_APP_AWS_SECRET_KEY=$REACT_APP_AWS_SECRET_KEY&quot; &gt;&gt; /.env<br>        - echo &quot;REACT_APP_LAMBDA_API=$REACT_APP_LAMBDA_API&quot; &gt;&gt; /.env<br>        - echo &quot;REACT_APP_AWS_REGION=$REACT_APP_AWS_REGION&quot; &gt;&gt; /.env<br>        - echo &quot;PUBLIC_URL&quot; &gt;&gt; /.env<br>  artifacts:<br>    baseDirectory: build<br>    files:<br>      - &#39;**/*&#39;<br>  cache:<br>    paths:<br>      - node_modules/**/*</pre><p>As you can see, what we do here is installing dependencies (yarn install)and building our app for production(yarn build), and copying environment variables to the .env file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InvDxTs7trQahbcbNeSk2Q.png" /><figcaption>Environment variables</figcaption></figure><p>In the “Advanced settings” tab key all of your credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiZ6GLZJxu23ZyR6squQ0g.png" /><figcaption>Review</figcaption></figure><p>In the last step review settings and hit the “Save and deploy” button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CJlzEm1PLYqEK2oRiBRWEg.png" /><figcaption>Ta-da!</figcaption></figure><p>Now just wait for build and deploy to finish, and your application will be available at the link provided under the picture.</p><p>Just with few clicks, we have our application hosted, our credentials stored securely, plus we’ve got continuous deployment. Every time we push to the master branch, Amplify will build the app automatically, how cool is that?</p><p>AWS Amplify offers much more - website monitoring, creating alarms on various events, creating deployment notifications, you can create a test environment for your dev branch deployments, add a custom domain, etc.</p><h4>Price</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b5uylQt3T9h__d3sbT-z2g.png" /><figcaption>Moneh</figcaption></figure><p>As you can see, we are charged based on storage, the amount of GB we serve, and durations of or builds.</p><p>During the active development phase, I can see that I used 28 minutes of build and had 0.02 GB stored and served 0.017 GB. The total cost is less than 50 cents per month :O</p><p>One thing to note is that some services are billed additionally to Amplify.</p><p>For example, if you add a custom domain, you will pay for AWS CloudFront, for added build notifications, you’ll pay for AWS SNS, metrics alarms billed under AWS CloudWatch, etc.</p><p>Before adding anything, make sure that you read carefully and understand which service you will be using, so later when receiving your bill statement, you will not be surprised :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dad771ed3cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing AWS API Gateway API]]></title>
            <link>https://g900.medium.com/securing-aws-api-gateway-api-805d4b456cf9?source=rss-6ad12cfb3653------2</link>
            <guid isPermaLink="false">https://medium.com/p/805d4b456cf9</guid>
            <category><![CDATA[aws-api-gateway]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Gaukhar]]></dc:creator>
            <pubDate>Wed, 11 Nov 2020 01:02:30 GMT</pubDate>
            <atom:updated>2022-03-13T09:49:22.049Z</atom:updated>
            <content:encoded><![CDATA[<p>After <a href="https://g900.medium.com/how-to-build-an-api-returning-your-spotify-stats-on-aws-6906183e1761">building API</a> for a personal website, I had a question — how can I secure it? Since Amazon bills me for every API request that was made, what will happen if my API will get attacked?</p><p>As documentation suggests, the basic way of protection is using IAM authentication to control who can invoke an API, and:</p><blockquote>Requests are not charged for authorization and authentication failures.</blockquote><p>This will not defend against DDoS attack, but for sure this defend your credit card :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mkBkcAISdN0o6coq" /><figcaption>Photo by <a href="https://unsplash.com/@yogesh_7?utm_source=medium&amp;utm_medium=referral">Yogesh Pedamkar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Enabling IAM authentication is pretty simple, all you need is to click a few buttons in the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoTdt_koYo1BUxWskXkWTw.png" /><figcaption>Securing</figcaption></figure><p>After saving and deploying API, we can try to access it :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*w9kCrvfeEMUXA1VJxOWc_w.png" /><figcaption>That worked!</figcaption></figure><p>What we need next is to create an IAM user who will be able to invoke API.</p><p>In the IAM console click on Users &gt; Add user, select Programmatic access as access type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0z8uc8LQ1CMhDYKwGx9l9w.png" /><figcaption>Creating User</figcaption></figure><p>In the second step create Group and attach AmazonAPIGatewayInvokeFullAccess policy, don’t forget to add our user to a group by check-marking:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2PRk4kw3KVE1jp7pJpqSw.png" /><figcaption>Granting Permissions</figcaption></figure><p>you may add tags in the next step if you wish. In the last step save credentials, as notification suggests, it is the last time you see it :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fu8_Gev6ETfQjVec06Lz1A.png" /><figcaption>Keys</figcaption></figure><p>Now we can try to access our API with credentials through Postman.</p><p>On the Authorization tab, set <strong>Type</strong> to <strong>AWS Signature</strong>. For <strong>AccessKey</strong> and <strong>SecretKey</strong>, enter credentials from the last step, and set <strong>AWS Region</strong> to a region, where your API is located.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DasHx6l40zGUb1_TUPyaew.png" /><figcaption>Ta-da!</figcaption></figure><p>Now we can stop worrying about the next bill statement :D</p><p>AWS IAM is free of charge, and I think it is a good habit to always enable IAM authentication for every API you create.</p><h4>One more option</h4><p>Another thing I explored while researching, is <a href="https://aws.amazon.com/waf/">AWS Web Application Firewall(WAF)</a>. This service can actually protect your API(and other services) from DDoS attacks.</p><blockquote>You can create rules to allow or block requests from specified IP address ranges, requests from CIDR blocks, requests that originate from a specific country or region, requests that contain malicious SQL code, or requests that contain malicious script.</blockquote><p>I think it is a great service to use if you have a public-facing API</p><p>The description sounds really cool but in my case using this service is redundant. Firstly, because the API I have is private, it handles only GET requests, and the second thing is the price. The minimum cost of AWS WAF is $6 per month. Knowing that cost of API itself approx. $5 per year, paying an extra $72 per year (20 large chicken shawarmas :D) doesn’t spark joy.</p><p>Securing API just with IAM authentication works for me since it protects from unplanned expenses, which was the initial requirement :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=805d4b456cf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build an API returning your Spotify stats on AWS]]></title>
            <link>https://g900.medium.com/how-to-build-an-api-returning-your-spotify-stats-on-aws-6906183e1761?source=rss-6ad12cfb3653------2</link>
            <guid isPermaLink="false">https://medium.com/p/6906183e1761</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-api-gateway]]></category>
            <category><![CDATA[third-party-integrations]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Gaukhar]]></dc:creator>
            <pubDate>Sat, 07 Nov 2020 04:11:36 GMT</pubDate>
            <atom:updated>2020-11-09T08:36:07.137Z</atom:updated>
            <content:encoded><![CDATA[<p>A small introduction: I’m building a personal website where I would like to show some Spotify stats. To do so, I need to call Spotify API with a renewable access token, which expires in 1 hour. Since the website is on React and I don’t have any backend nor database(and hardcoded tokens in the front end sound like a bad idea), I decided to delegate this to AWS. Because it is convenient, secure, and cheap :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5A669GxUuzUYxqT5" /><figcaption>Photo by <a href="https://unsplash.com/@nkachanovskyyy?utm_source=medium&amp;utm_medium=referral">Nikita Kachanovsky</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What you will need:</p><ol><li><a href="https://developer.spotify.com/dashboard/">Spotify Developer Account</a></li><li><a href="https://aws.amazon.com/cli/">AWS CLI</a></li><li>Docker running on your machine (optional)</li></ol><p>The first thing you need is to get access and refresh tokens from Spotify, following <a href="https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow">this</a>. (I assume you are familiar with OAuth 2.0 flow and can use curl or Postman :D)</p><p>Here is how our tiny architecture looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*z2fYszSWabS-G2UdLWzbeQ.png" /><figcaption>Architecture</figcaption></figure><p>As you can see from the diagram, we will use Lambda, API Gateway, and Secrets Manager.</p><h3>AWS Secret Manager</h3><p>Store a new secret with the next parameters: client_id, client_secret, access_token, refresh_token, and expires_at. You should already have all values from Spotify, except of expires_at. Set it to any date in the past</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Htpm3T5GbgSVPFerLAXIw.png" /></figure><p>Name new secret and on the next step disable automatic rotation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXKHTgRnSOEA57QOEXcNuw.png" /></figure><p>Automatic rotation enables the ability to schedule lambda invocations to refresh tokens. Spotify refresh tokens are valid forever until they are manually revoked. So in this case we can disable automatic rotation. But if you are integrating with a service providing expiring refresh tokens, <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/enable-rotation-other.html">this feature</a> can be extremely useful.</p><p>After you created a secret, notice the sample code section, we will need it in the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAcZjzDfIfME16ZHZ9MQKQ.png" /></figure><p>We are done here, we are moving to our lambda function next</p><h3>AWS Lambda. Function</h3><p>I’m most comfortable writing code in Ruby, so the next example will be on it :)</p><p>But you can choose anything from what Lambda offers -Java, Javascript, Go, Python, C#</p><p>Here is the ruby code for our Lambda function</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/954d81f0d369504747e732f13c8b5313/href">https://medium.com/media/954d81f0d369504747e732f13c8b5313/href</a></iframe><p>Time to deploy and test!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oupTw4TpVwJqa2Z8esq3iA.png" /><figcaption>Oh no</figcaption></figure><p>AWS SDK for Ruby doesn’t include httparty gem, so we need to do a bit of extra work. It is possible to use standard Net::HTTP ruby library, but you know, these HTTP gems exist for a reason :D</p><p>This step is relevant to all languages if you have dependencies that are not included in AWS SDK.</p><h3>AWS Lambda. Layer.</h3><p>Lambda layers allow us to use libraries that are not included or run custom runtimes. With layers, we don’t need to include dependencies in the deployment package, which keeps it small.</p><p>First, we need to create a Gemfile with our dependencies on the local machine</p><pre>cd your-directory<br>echo &quot;source &#39;<a href="https://rubygems.org'/">https://rubygems.org&#39;</a><br>gem &#39;httparty&#39;&quot; &gt;&gt; Gemfile</pre><p>Next, with help of Docker, we simulate a lambda environment to create a layer. More info <a href="https://aws.amazon.com/premiumsupport/knowledge-center/lambda-layer-simulated-docker/">here</a></p><pre>docker run --rm -it -v $PWD:/var/gem_build -w /var/gem_build lambci/lambda:build-ruby2.7 bundle install --path=.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*1MUfooivTSAye8aWuCZ5dg.png" /><figcaption>installed gems</figcaption></figure><p>And the final step is to zip our created folder and publish it as a layer</p><pre>zip -r gems.zip ./ruby/ -x ./ruby/2.7.0/cache/\*<br>aws lambda publish-layer-version \<br>         --layer-name gems\<br>         --region ap-southeast-1 \<br>         --compatible-runtimes ruby2.7 \<br>         --zip-file fileb://gems.zip</pre><p>After this, you can click on the “Add a Layer” button and select the newly added layer from Custom Layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuhQSop7XgxvgJtEqKSj_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWgIJNnFWqRSz_DVdiN8tg.png" /></figure><blockquote>Layers are extracted to the /opt directory in the function execution environment. Each runtime looks for libraries in a different location under /opt, depending on the language. <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html?utm_campaign=Email%20-%20Cold%20Start%20web&amp;utm_source=hs_email&amp;utm_medium=email&amp;_hsenc=p2ANqtz-99oxwA0gMsFLPtDvvfH8fpfTButZgO58WQhhW0FZwCUXIwbbtKM_FN47qkZXBNaDO1uT-H#configuration-layers-path">Structure your layer</a> so that function code can access libraries without additional configuration.</blockquote><p>Based on this, we need to set GEM_PATH as /opt/ruby/2.7.0/ in environmental variables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9OrEiHA1ABQbmYrmvfjiA.png" /></figure><h3>AWS Lambda. Permissions</h3><p>Before testing our function, we need to add Lambda permission to access Secret Manager</p><p>Go to Services &gt; IAM &gt; Policies &gt; Create Policy</p><p>And create a policy with the next parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bxNYLgCSUe28L2T6vEuZOA.png" /></figure><p>Under resources specify ARN of Spotify secret stored in Secret Manager.</p><p>After that, navigate to Roles and click on yourLambdaName-role-xxxxx.</p><p>Click on the “Attach policies” and find SpotifySecretPolicy that we just created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWG866z8CrxZue9NhwYDLw.png" /></figure><p>Now we can finally test our lambda :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWQUOCW-5bga7hVir7k7yQ.png" /><figcaption>Yeeeey!</figcaption></figure><p>We are almost there, now we need to make our lambda accessible through API.</p><h3>AWS API Gateway</h3><p>In the “Designer” tab click ton “Add trigger” button and select API Gateway with the next parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0T8WWL3_143wY7Wpmq2mkA.png" /></figure><p>Go to Resources and by clicking on the Actions button add the GET method, with Lambda function as an integration type, and don’t forget to pick your lambda from the dropdown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDd2udY7qjsVZwxI5DZz-w.png" /></figure><p>In the Resources navigation pane, choose Actions. From the Actions drop-down menu, choose Deploy API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*rH0hZWLUOs0EOo5YfX_Ckw.png" /><figcaption>Deploy it</figcaption></figure><p>The last step — add permissions to lambda to be invoked by API.</p><p>Run this command on your local machine:</p><p>Replace <strong>arn:aws:execute-api:region:account-id:api-id/*/GET/lambdasv1 </strong>with the ARN of the API Gateway resource that invokes your function.</p><pre>aws lambda add-permission --function-name <strong>my-function</strong> \<br>--statement-id api-gateway-invoke --action lambda:InvokeFunction \<br>--principal apigateway.amazonaws.com \<br>--source-arn &quot;<strong>arn:aws:execute-api:region:account-id:api-id/*/GET/lambdasv1</strong>&quot;</pre><p>Return back to the API Gateway section. In the Stages navigation pane, click on the GET method and you will see the invoke URL highlighted in blue, click on it, and ta-da!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4l1-UQhwQPm11GDx8Nxxw.png" /><figcaption>Ta-da!</figcaption></figure><p>You’ve got your Spotify stats returned by AWS API, clap-clap!</p><p>Now let’s discuss the most interesting information — the cost :D</p><h3>Cost Estimation</h3><p>Since this API is built for a personal website, I assume there will be humble 1000 requests per month.</p><p>The prices listed are for the Singapore region. Lambda function runs 300ms on average and has 128 MB allocated memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gy6O1K7tgbwr1jkOxsHwfA.png" /><figcaption>Moneh</figcaption></figure><p>As you can see, all the cost is based on the Secret manager price and it costs you less than 5 USD per year! Price of 1 big chicken shawarma in Malaysia (estimations in chicken shawarmas feel more tangible :D)</p><p>In the next post, I’m going to show how to protect your API from DDoS attacks, because the cost of an unprotected API can be unpredictable.</p><p>I hope I didn’t miss anything out and this noob-friendly guide was useful for you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6906183e1761" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>