<?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 Adrien Mornet on Medium]]></title>
        <description><![CDATA[Stories by Adrien Mornet on Medium]]></description>
        <link>https://medium.com/@adrien.mornet?source=rss-530ccd9d0e65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QVX_u04OBgzoPS9G5MRxJA.jpeg</url>
            <title>Stories by Adrien Mornet on Medium</title>
            <link>https://medium.com/@adrien.mornet?source=rss-530ccd9d0e65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:23:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adrien.mornet/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[More secure Python Docker images with Amazon Linux ]]></title>
            <link>https://faun.pub/more-secure-python-docker-images-with-amazon-linux-8094beb1df40?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/8094beb1df40</guid>
            <category><![CDATA[amazon-linux]]></category>
            <category><![CDATA[amazon-linux-2023]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Tue, 21 May 2024 14:24:35 GMT</pubDate>
            <atom:updated>2024-05-26T15:58:02.339Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xD28UCYkf7g9TrfTGEsYwA.jpeg" /></figure><p>Amazon Linux is a Linux distribution provided by AWS specifically optimized for running workloads on AWS Cloud. This distribution, entirely managed by Amazon teams, offers very high standards in terms of security. In this article I’ll explain why I prefer a Docker image based on Amazon Linux rather than Debian to run a python workload in the cloud.</p><h3>Debian based Python Docker image</h3><p>Let’s say you want to create a Docker image to run Python code in version 3.9. Your first choice will probably be to start with a Docker image coming from Docker Hub python:3.9 right? I would have done the same, it’s the easiest way.</p><p>Most of the images on the Docker Hub are based on Debian and this is the case for python.</p><p>Your Dockerfile would probably look like this :</p><pre>FROM python:3.9<br><br>WORKDIR /usr/src/app<br><br>COPY requirements.txt ./<br><br>RUN pip install --no-cache-dir -r requirements.txt<br><br>COPY . .<br><br>CMD [ &quot;python&quot;, &quot;./your-daemon-or-script.py&quot; ]</pre><p>Let’s build and push this Docker image to an ECR registry with “Scan on push” enabled. The “Scan on push” feature will run a security scan on your Docker image and see if there are any CVEs in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*2af6Tkt3w584W5FN.png" /></figure><p>Here is the result of the security scan :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qhyNG3vYKVcRyaYd.png" /></figure><p>That’s a lot for a fresh image containing only Debian libraries and a bit of python code, isn’t it?</p><h3>Amazon Linux 2023 based Docker Image</h3><p>Let’s create a python Docker image now based on amazonlinux:2023 :</p><pre>FROM amazonlinux:2023<br><br>ENV PYTHON_VERSION=3.9<br><br>RUN --mount=type=cache,target=/var/cache/dnf \<br>    dnf -y update &amp;&amp; \<br>    dnf install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-pip shadow-utils git-all findutils awscli tar &amp;&amp; \<br>    update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 20 &amp;&amp; \<br>    update-alternatives --set python /usr/bin/python${PYTHON_VERSION} &amp;&amp; \<br>    dnf clean all<br><br>WORKDIR /usr/src/app<br><br>COPY requirements.txt ./<br><br>RUN pip install --no-cache-dir -r requirements.txt<br><br>COPY . .<br><br>CMD [ &quot;python&quot;, &quot;./your-daemon-or-script.py&quot; ]</pre><p>Here is the result of it’s Security Scan :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lSN4TiNfDW-9ZBDs.png" /></figure><p>Much better!</p><h3>Why is there less CVEs in the Amazon Linux image?</h3><p>The differences in how Debian and Amazon Linux are developed and maintained contribute to the feeling that Debian-based Docker images are less frequently patched and therefore have more unpatched CVEs.</p><p>Debian is a community-driven distribution. Security updates for Debian are generally reliable, but the frequency and speed at which they are released can vary because it relies heavily on volunteering contributions.</p><p>Python image on Docker Hub is also maintained by community which means that two different communities will have to patch a CVE: the Debian community and the python docker image community</p><p>Amazon Linux is a distribution maintained by AWS. Amazon has a dedicated team that prioritizes security updates and patches, often releasing them quickly to ensure that their customers’ systems remain secure.</p><p>Amazon’s centralized model and commercially driven approach to maintaining Amazon Linux ensures more consistent and rapid security updates which is why I think it’s better to use docker images based from Amazon Linux instead of Debian.</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pFTfqv1Up_aWY9aJ.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8094beb1df40" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/more-secure-python-docker-images-with-amazon-linux-8094beb1df40">More secure Python Docker images with Amazon Linux 🔐</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing database migrations in ArgoCD ]]></title>
            <link>https://faun.pub/managing-database-migrations-in-argocd-b54d2a29a554?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/b54d2a29a554</guid>
            <category><![CDATA[argo-cd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 15:52:25 GMT</pubDate>
            <atom:updated>2024-03-10T19:21:38.158Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0RHygavlNJCgW1za6u6uQ.jpeg" /></figure><p>ArgoCD is a fantastic tool for doing GitOps in Kubernetes. Most of modern backend frameworks comes with a system that allows to version control database schema definition which is named migrations (e.g. <a href="https://laravel.com/docs/master/migrations">Laravel</a>, <a href="https://docs.djangoproject.com/en/5.0/topics/migrations/">Django</a> …). This system is very powerful because it allows the code for a new feature to be versioned together with the database schema required for the feature to function correctly. This can be used, for example, to create a table, add a column, etc. But how to handle these migrations in ArgoCD ? That’s what we’ll be looking at in this article.</p><h3>What a roll-out looks like</h3><p>In the context of a Kubernetes cluster whose deployments are automated by ArgoCD, Argo will be responsible for synchronising the desired state of the Kubernetes cluster described in the Kubernetes manifest with the actual state of the cluster. The desired state is stored on Git and contains the exact version of the Docker image (via its SHA or tag) which contains your application. When you’ll want to deploy a new version of the Docker image, you will push to the Manifest the new image version. The flow of the roll-out will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y4nRCLzPXTpM1OfP.png" /></figure><h3>ArgoCD Resource Hooks</h3><p>ArgoCD comes with a hook mechanism that enables actions to be taken during synchronisation, i.e. when it detects a difference between the state described in Git stored Kubernetes manifest and the actual state of the cluster. These actions are called <a href="https://argo-cd.readthedocs.io/en/stable/user-guide/resource_hooks/">Resource Hooks</a> and take the form of Kubernetes jobs.</p><p>As we want our migrations to be executed just before the new version of the code is deployed, we will use the PreSync hook to run a job just before the synchronisation operation. Our new deployment flow will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DYD90C2xUp40jq0P.png" /></figure><h3>The implementation</h3><p>Here is an example of a Kubernetes Job that subscribe to ArgoCD PreSync hook that will run Laravel migrations:</p><pre>---<br>apiVersion: batch/v1<br>kind: Job<br>metadata:<br>  generateName: my-app-migration-<br>  annotations:<br>    argocd.argoproj.io/hook: &quot;PreSync&quot;<br>    argocd.argoproj.io/hook-delete-policy: &quot;BeforeHookCreation&quot;<br>    argocd.argoproj.io/job-cleanup: &quot;keep&quot;<br>spec:<br>  template:<br>    spec:<br>      containers:<br>      - name: my-laravel-app<br>        image: my-laravel-docker-image:new-tag<br>        command:<br>          - &quot;php&quot;<br>          - &quot;artisan&quot;<br>          - &quot;migrate&quot;<br>      restartPolicy: Never<br>  backoffLimit: 0</pre><p>This Kubernetes job will be launched when ArgoCD detect a change in the Manifest. ArgoCD will wait the completion of the job (exit code 0) before syncing the rest of your application.</p><h3>Conclusion</h3><p>In summary, ArgoCD’s Resource Hooks, especially the PreSync hook, streamline the execution of database migrations before deploying new code versions, ensuring seamless synchronization between application code and database schema. This approach enhances version control and consistency, offering a good solution for Kubernetes roll-out.</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*NxLrmut9J0Ku_tdx.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b54d2a29a554" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/managing-database-migrations-in-argocd-b54d2a29a554">Managing database migrations in ArgoCD 🐙</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Effortless & Serverless File Uploading: Unleashing the Power of AWS S3 presigned urls with Lambda…]]></title>
            <link>https://blog.devops.dev/effortless-serverless-file-uploading-unleashing-the-power-of-aws-s3-presigned-urls-with-lambda-4e6e66098676?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e6e66098676</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Sun, 04 Feb 2024 18:42:02 GMT</pubDate>
            <atom:updated>2024-02-05T17:25:56.938Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*v8TQ2mtQz8w_aF6f.jpg" /></figure><h3>Effortless &amp; Serverless File Uploading: Unleashing the Power of AWS S3 presigned urls with Lambda 📂</h3><p>Today I’m going to present how you can build a robust file upload system through AWS S3 using an HTTP(S) endpoint and S3 presigned urls. We are going to use a Lambda function with a function URL to expose the HTTP(S) endpoint.</p><p>The idea is to provide a fixed url to our user to let him upload a file to it. This fixed url (or HTTP(S) endpoint) will be a <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html">Lambda function url</a>. Once the lambda has been launched, the function will generate an <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html">AWS S3 presigned url</a> and redirect the user request transparently to it. We need to use an HTTP 307 code to make the redirect working with HTTP PUT method because this specific code <em>“guarantees that the method and the body will not be changed when the redirected request is made”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kxeif2xMw3VlAJxm.png" /></figure><p>With all this in place, our user will be able to upload a file with a simple curl : curl -LX PUT -T &quot;<em>/path/to/file</em>&quot; &quot;<em>LAMBDA_FUNCTION_URL</em>&quot;.</p><p>To do all this, we’ll need to:</p><ol><li>create an S3 bucket</li><li>create a Lambda Function with an HTTP(S) endpoint</li><li>grant S3 Access to the Lambda function</li><li>make the Lambda creating the presigned url</li></ol><h3>Create an AWS S3 bucket to save files</h3><p>Let’s create an S3 bucket my-files-uploaded-with-lambda-and-presigned-urls :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xapDvVOGZxmZra-R.png" /></figure><h3>Create an AWS Lambda Function with an HTTP(S) endpoint</h3><p>Let’s create a python AWS Lambda Function called file-uploads :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GGpNrLcAlvTwjRAZ.png" /></figure><p>and enable function URL without authentication :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W7hYZ1MkE5WNz0tB.png" /></figure><p>Our Lambda is now created and available on the function url :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YW5VHBAl5PRX7Ez-.png" /></figure><h3>Grant S3 Access to the Lambda function</h3><p>As “<a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html"><em>a presigned URL is limited by the permissions of the user who creates it</em></a><em>“, </em>we have to grant our Lambda to put a file in the bucket. Let’s edit the policy of the role assumed by the lambda (role can be found in Configuration -&gt; Permissions -&gt; Execution role) :</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: &quot;logs:CreateLogGroup&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:logs:us-east-1:ACCOUNT_ID:*&quot;<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;logs:CreateLogStream&quot;,<br>        &quot;logs:PutLogEvents&quot;<br>      ],<br>      &quot;Resource&quot;: [<br>        &quot;arn:aws:logs:us-east-1:ACCOUNT_ID:log-group:/aws/lambda/file-uploads:*&quot;<br>      ]<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: &quot;s3:PutObject&quot;,<br>      &quot;Resource&quot;: [<br>        &quot;arn:aws:s3:::my-files-uploaded-with-lambda-and-presigned-urls&quot;,<br>        &quot;arn:aws:s3:::my-files-uploaded-with-lambda-and-presigned-urls/*&quot;<br>      ]<br>    }<br>  ]<br>}</pre><h3>Make the Lambda creating the presigned url</h3><p>Here is the code I used to generate the presigned url and redirect the client with a HTTP 307 to it :</p><pre>import boto3<br><br>def lambda_handler(event, context):<br>   <br>    # Generate a presigned URL for the S3 object<br>    s3_client = boto3.client(&#39;s3&#39;)<br>    <br>    presigned_url = s3_client.generate_presigned_url(https://medium.com/&#39;put_object&#39;,%20Params={%3Cbr%3E%20%20%20%20%20%20&#39;Bucket&#39;:%20&#39;my-files-uploaded-with-lambda-and-presigned-urls&#39;,%3Cbr%3E%20%20%20%20%20%20&#39;Key&#39;:%20&#39;my_upload.txt&#39;,%3Cbr%3E%20%20%20%20%20%20&quot;Expires&quot;:%203600%3Cbr%3E%20%20%20%20},%20HttpMethod=&quot;put&quot;)<br>    <br>    # Build the redirect response<br>    response = {<br>        &#39;statusCode&#39;: 307,  # HTTP status code for PUT redirect<br>        &#39;headers&#39;: {<br>            &#39;Location&#39;: presigned_url  # Set the Location header to the presigned URL<br>        }<br>    }<br>    # Return the response to trigger the redirect<br>    return response</pre><h3>Upload a file</h3><p>Let’s test uploading a file with a simple curl request curl -LX PUT -T &quot;<em>/path/to/file</em>&quot; &quot;<em>LAMBDA_FUNCTION_URL</em>&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kxGL699wtxcBn74Y.png" /></figure><p>We can see the file in the bucket :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x1WJEVanRrsltnJw.png" /></figure><p>Well done 🥳</p><h3>To go further</h3><p>This article gives a simple overview of what can be done with lambda and S3 presigned urls. Of course, we could also add an authentication layer to prevent anyone from uploading to the URL with Cognito and/or API Gateway. You could also use a custom url with your custom domain name with API Gateway.The naming of the uploaded file could also be more elaborate.</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e6e66098676" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/effortless-serverless-file-uploading-unleashing-the-power-of-aws-s3-presigned-urls-with-lambda-4e6e66098676">Effortless &amp; Serverless File Uploading: Unleashing the Power of AWS S3 presigned urls with Lambda…</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Say Goodbye to Ugly Error Pages with Cloudfront ]]></title>
            <link>https://faun.pub/say-goodbye-to-ugly-error-pages-with-cloudfront-3cab5ab3ab05?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cab5ab3ab05</guid>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Sun, 05 Nov 2023 18:13:51 GMT</pubDate>
            <atom:updated>2023-11-11T13:32:42.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*do1ruFa8McNUgYPxJFCtTg.jpeg" /></figure><p>Who has never found themselves in the middle of surfing the internet when faced with an ugly error page ? These kind of pages are the default error pages of web servers like Apache or Nginx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*0ka6YxnzhN6yAZn8.png" /></figure><p>More recently, you may also come across the Cloudfront default errors :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MwDIaePzPN5WLLwS.png" /></figure><p>Nothing could be worse in terms of user experience, could it? These generic error pages can be frustrating, uninformative, and can make users question the reliability of a website. In the world of DevOps, where continuous deployment and high availability are key objectives, the last thing you want is to present your users with a subpar experience during moments of downtime or unexpected errors.</p><p>In a modern website architecture using a Content Delivery Network, the CDN is the last component capable of catching underlying errors and saving the day :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*A1EPy9hKiDUnWXJMoDNFFQ.png" /></figure><p>Let’s configure AWS Cloudfront to catch errors from underlying components (and even an error in Cloudfront itself) !</p><p>We’re going to do this in just a few steps :</p><ol><li>Create a pretty HTML error page</li><li>Deploy the error page with AWS S3 static website hosting</li><li>Add S3 static website as Cloudfront origin</li><li>Set up Cloudfront error pages</li></ol><h3>Create a pretty HTML error page</h3><p>Let’s ask ChatGPT to create a nice error page for us 😏</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X7b49xCFG5EVElxQ.png" /></figure><h3>Deploy the error page with AWS S3 static website hosting</h3><p>Amazon S3, Amazon Web Services’ object storage service, offers a really simple way to deploy static HTML pages which we are going to use. To make this simpler, we’re going to do it via click ops on the AWS console.</p><p>Create a public S3 bucket with public access :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I-ktOHJntzHDsbeb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1vQB4oYx4zd-Zt-A.png" /></figure><p>Go to your bucket, click <em>upload</em> button and upload your index.html file :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hsB_L1y9m_d1LL94.png" /></figure><p>Go to <em>properties &gt; Static website</em> hosting and enable static website hosting for your bucket :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m7l_cbldVlKUx3Qv.png" /></figure><p>You will now have an HTTP endpoint to access your website :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TUZIM29ReNtCXPNB.png" /></figure><p>Go to<em> permissions &gt; Bucket policy</em> and allow everyone to get your files :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w6fVO_k3gpSkpNvc.png" /></figure><p>Now you should be able to access your index.html with the static url of your S3 bucket (demo-error-page.s3-website-us-east-1.amazonaws.com in my case) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8kdZUfmZLrSAcWSC.png" /></figure><h3>Add S3 static website as Cloudfront origin</h3><p>I’m going to assume here that you already have a working Cloudfront distribution with at least one origin :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nRisJd37w_BDVquz.png" /></figure><p>Let’s add our S3 website endpoint (the url which contains <em>s3-website</em>, not the bucket endpoint) as a new Cloudfront origin :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bLtNQp-JiSc670Wb.png" /></figure><p>Now we can add a new behavior for our Cloudfront distribution on a custom path :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vjQrNqqF8tXYNEA3.png" /></figure><p>In this way, requests whose path matches <em>/cloudfront-catched-errors-demo/*</em> will be sent to our bucket :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tr0f8upLAUFec0gf.png" /></figure><h3>Set up Cloudfront error pages</h3><p>We are now going to configure our distribution so that it catches errors and redirects them invisibly for the user. To do this, Cloudfront offers an “Error Pages” section where we can configure custom error response :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KOJgI-1o-1-HHCZ4.png" /></figure><p>Let’s create a custom error response :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tLLflNWEDKdpvDXg.png" /></figure><p>By doing that, we are going to catch all 502 HTTP errors and show our pretty HTML error page by setting “Response page path” to <em>/cloudfront-catched-errors-demo/index.html</em>. Let me show you!</p><p>Before :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ojUyLlktLFhVvLkt.png" /></figure><p>After :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EKo7bKstKhrEpCWt.png" /></figure><h3>To go further</h3><p>I recommend that you catch at least HTTP 500, 501, 502, 503 and 504 errors via Cloudfront error pages because they concern server-side errors and are not managed by the application server. For 4xx errors, as they concern errors made by the customer, this is more debatable. If the error is handled correctly by the application, you might as well leave this role to it (this is very often the case for 404 errors, which are handled by web mode frameworks).</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0rM_F_9XoS3sP5GW.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cab5ab3ab05" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/say-goodbye-to-ugly-error-pages-with-cloudfront-3cab5ab3ab05">Say Goodbye to Ugly Error Pages with Cloudfront 👋</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running a Web Application with 100% AWS Fargate Spot Containers ]]></title>
            <link>https://faun.pub/running-a-web-application-with-100-aws-fargate-spot-containers-ec2a7041461b?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec2a7041461b</guid>
            <category><![CDATA[fargate]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Sun, 15 Oct 2023 13:56:04 GMT</pubDate>
            <atom:updated>2023-11-11T13:32:24.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kJfZBUbJNsVWYi3oFVcHg.png" /></figure><p>One of the major advantages of using the Cloud is its Pay-Per-Use model. To make the most of this model, the challenge is to find the computing capacity at the best price that matches your workload. I’m going to explain in this article how I could run a web application in 100% Fargate Spot containers.</p><h3>EC2 vs Fargate vs Fargate Spot</h3><p>AWS offers several compute capacity options for running containers orchestrated by ECS :</p><ul><li>EC2 : the good old on-demand compute service for servers on which you can install the ECS container agent</li><li>Fargate : a serverless compute engine that lets you run ECS containers without having to manage EC2 servers</li></ul><p>Both of EC2 and Fargate offer spot deals. I have chosen AWS Fargate over EC2 for running containers to achieve cost savings and operational simplicity, as Fargate eliminates the need to manage EC2 instances and offers significant pricing advantages with Fargate Spot.</p><h3>Having a fault tolerant application</h3><p>The most important thing to manage when using spot capacity is that your ECS task can be interrupted by AWS at any time. In concrete terms, a SIGTERM system signal is sent to your containers in your ECS task and they have 120 seconds to stop before being hard-killed. Your application must therefore be able to shut down properly before these 120 seconds. The overwhelming majority of web applications take a few seconds to respond, don’t they? So the 120 seconds are not a block. If you configure your ECS services to run at least a count of 2 desired task, this won’t be a problem if only one task is running for a few seconds while the orchestrator starts a second task.</p><p>I explain in a little more detail in another article <a href="https://adrien-mornet.tech/handling-graceful-shutdown-of-your-docker-cron-containers/">“Handling graceful shutdown of your Docker Cron containers”</a>.</p><h3>Manage unavailability of Fargate Spot capacity</h3><p>As written in the AWS documentation, during periods of extremely high demand, Fargate Spot capacity might be unavailable. In concrete terms, if your ECS service is set up to execute tasks in 100% Spot, there is a risk of running out of capacity. A <a href="https://www.npmjs.com/package/@wheatstalk/fargate-spot-fallback">workaround</a> has been created in the hope that one day this <a href="https://github.com/aws/containers-roadmap/issues/852">issue</a> will be implemented by the AWS team. This workaround allows you to set up two ECS services :</p><blockquote><em>“a primary with only spot capacity and a fallback with only on demand capacity. When the primary emits a task placement error a lambda sets the desired count on the fallback service. When the primary emits a steady state event a lambda sets the fallback desired count to zero.”</em></blockquote><h3>My experience with Fargate Spot</h3><p>In my experience, I was able to run 4 microservices in production with 100% Fargate Spot capacity. The microservice responsible for the frontend supported around 2000 different users per day. At no point during one year we have run out of Fargate Spot capacity. When one task received an interrupt signal, another started within a few seconds, with virtually no effect on response times. The savings we have been able to make thanks to Fargate Spot are considerable and it was a really good choice.</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0rM_F_9XoS3sP5GW.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec2a7041461b" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/running-a-web-application-with-100-aws-fargate-spot-containers-ec2a7041461b">Running a Web Application with 100% AWS Fargate Spot Containers 🤘</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authenticating your GitLab CI runner to an AWS ECR registry using Amazon ECR Docker Credential…]]></title>
            <link>https://faun.pub/authenticating-your-gitlab-ci-runner-to-an-aws-ecr-registry-using-amazon-ecr-docker-credential-b4604a9391eb?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4604a9391eb</guid>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 12:19:31 GMT</pubDate>
            <atom:updated>2023-07-03T17:18:52.540Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ez7GkLDMmYfqWZp7Z6nfQ.jpeg" /></figure><h3>Authenticating your GitLab CI runner to an AWS ECR registry using Amazon ECR Docker Credential Helper 🔑</h3><p>GitLab CI allows you to run your CI/CD jobs in separate and isolated Docker containers. For maximum flexibility, you may need to run your jobs from a self-created Docker image tailored to your project’s specific needs. You can store this self-created and private Docker image in an AWS ECR registry. In this tutorial I will explain how to set up automatic authentication from your GitLab runner to your registry with Amazon ECR Docker Credential Helper.</p><h3>GitLab CI job</h3><p>Create a GitLab CI job which uses your Docker image saved in a private AWS ECR registry :</p><pre>phpunit:<br>  stage: testing<br>  image: <br>    name: 123456789123.dkr.ecr.us-east-1.amazonaws.com/php-gitlabrunner:latest<br>    entrypoint: [&quot;&quot;]<br>  script:<br>    - php ./vendor/bin/phpunit --coverage-text --colors=never</pre><h3>Create and configure your runner to access AWS ECR registry</h3><ul><li>Create an EC2 instance and <a href="https://docs.gitlab.com/runner/install/">install GitLab Runner</a></li><li><a href="https://docs.gitlab.com/runner/register/">Register your runner with Docker executor</a></li><li>Install the <a href="https://github.com/awslabs/amazon-ecr-credential-helper">AWS ECR Docker Credential Helper</a> in your runner</li><li>Create a /root/.docker/config.json file and add :</li></ul><pre>{<br> &quot;credsStore&quot;: &quot;ecr-login&quot;<br>}</pre><ul><li>Create an IAM User with CLI access and attach arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly policy</li><li>Paste CLI credentials to /home/gitlab-runner/.aws/credentials file on your GitLab runner :</li></ul><pre>[default]<br>aws_access_key_id = YOUR_ACCESS_KEY<br>aws_secret_access_key = YOUR SECRET KEY</pre><ul><li>Configure AWS Region in /root/.aws/config :</li></ul><pre>[default]<br>region = YOUR REGION</pre><ol><li>Edit your /etc/gitlab-runner/config.toml to add in <a href="https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runners-section">the [[runners]] section</a> the following line environment = [&quot;DOCKER_AUTH_CONFIG={ \&quot;credsStore\&quot;: \&quot;ecr-login\&quot; }&quot;] :</li></ol><pre>[[runners]]<br>  name = &quot;gitlab-runner&quot;<br>  url = &quot;https://gitlab.com/&quot;<br>  executor = &quot;docker&quot;<br>  [runners.custom_build_dir]<br>  [runners.cache]<br>    MaxUploadedArchiveSize = 0<br>    [runners.cache.s3]<br>    [runners.cache.gcs]<br>    [runners.cache.azure]<br>  [runners.docker]<br>    image = &quot;php:8-cli&quot;<br>    privileged = false<br>    disable_entrypoint_overwrite = false<br>    oom_kill_disable = false<br>    disable_cache = false<br>    volumes = [&quot;/cache&quot;, &quot;/var/run/docker.sock:/var/run/docker.sock&quot;, &quot;/builds:/builds&quot;]<br>    shm_size = 0<br>    environment = [&quot;DOCKER_AUTH_CONFIG={ \&quot;credsStore\&quot;: \&quot;ecr-login\&quot; }&quot;]</pre><p>Now your GitLab runner can automatically authenticate to your ECR registry 🙂</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*O37lSOj7KfLupry9.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4604a9391eb" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/authenticating-your-gitlab-ci-runner-to-an-aws-ecr-registry-using-amazon-ecr-docker-credential-b4604a9391eb">Authenticating your GitLab CI runner to an AWS ECR registry using Amazon ECR Docker Credential…</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices to protect an RDS MySQL Database ✅]]></title>
            <link>https://faun.pub/best-practices-to-protect-an-rds-mysql-database-825b611d00c7?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/825b611d00c7</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[rds]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Mon, 17 Apr 2023 11:26:57 GMT</pubDate>
            <atom:updated>2023-04-19T11:48:33.438Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stjdiLiybQKCJjDF0SLsZg.jpeg" /></figure><p>Amazon RDS is a very popular choice for creating MySQL databases in the cloud. Many modern companies use it to store their business data. However, as with any other database, securing these databases requires special attention to protect against potential threats and vulnerabilities.</p><p>In this article, we will explore 10 best practices for securing your AWS RDS MySQL database instance.</p><h3>1. Use strong passwords and rotate them</h3><p>The use of strong passwords is an essential measure to protect your database instance. A strong password consists of a random combination of upper and lower case letters, numbers and special characters. It should be at least 20 characters long.</p><p>It is also important to change your password regularly. Passwords should be changed at regular intervals, for example every 60 to 90 days.</p><p>Use the MySQL <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Concepts.PasswordValidationPlugin.html">validate_password</a> plugin, which provides additional security like password expiration, password reuse restrictions or password failure tracking.</p><h3>2. Keep MySQL Updated</h3><p>One of the major advantages of the managed services offered by AWS is that you don’t have to manage them and can activate automatic updates! It would be silly to do without this… Granted, it doesn’t protect against 0-day flaws, but it’s already very good to protect against known (and patched!) flaws.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q0PCKqiMhDXsmlpH.png" /></figure><h3>3. Change default port</h3><p>This good practice protects against bots that regularly scan the internet for instances that are not sufficiently protected. It is very basic but it would be a shame to do without it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jf8XOmxQHcLtavq9.png" /></figure><h3>4. Use different users with different permissions</h3><p>A user should be created for each use. For example, if we have a script that makes backups of our application, we will not use the same user as the application. A read-only user is sufficient here. The root user should only be used to administer the instance, not to use it!</p><h3>5. Disconnect your RDS instance from the internet</h3><p>If you have the luxury of being able to disconnect your instance from the internet and make it accessible only from within its VPC network, do it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dt9VMi35DXBYVLzy.png" /></figure><h3>6. Use a Firewall</h3><p>AWS Security Group can be used to allow only certain IP addresses to connect to your instance’s port :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ekCBp_heDskqY3WC.png" /></figure><h3>7. Use MySQL engine host check</h3><p>Instead of creating your MySQL users like this CREATE USER &#39;new_user&#39;@&#39;%&#39; IDENTIFIED BY &#39;password‘; , use MySQL engine host check :</p><pre># Fixed IP address<br>CREATE USER &#39;new_user&#39;@&#39;123.123.123.123/255.255.255.255&#39; IDENTIFIED BY &#39;password&#39;;</pre><pre># Private IP range from your subnet<br>CREATE USER &#39;new_user&#39;@&#39;192.168.0.0/255.255.255.0&#39; IDENTIFIED BY &#39;password&#39;;</pre><h3>8. Use SSL</h3><p>Implement encryption in transit using SSL :</p><pre>ALTER USER &#39;new_user&#39;@&#39;123.123.123.123/255.255.255.255&#39; REQUIRE SSL;</pre><h3>9. Grant desired privileges to desired databases</h3><p>Instead of granting your MySQL user privileges like this GRANT ALL PRIVILEGES ON * . * TO &#39;new_user&#39;@&#39;123.123.123.123/255.255.255.255&#39;; grant desired privileges to desired databases :</p><pre>GRANT SELECT, INSERT, UPDATE, DELETE ON my_db.* TO &#39;some_user&#39;@&#39;123.123.123.123/255.255.255.255&#39;;</pre><h3>10. Use 2FA or 3FA</h3><p>MySQL 8.0.27 and higher supports<a href="https://dev.mysql.com/doc/refman/8.0/en/create-user.html#create-user-multifactor-authentication"> multifactor authentication</a> (MFA), such that accounts can have up to three authentication methods. IAM authentication can also enable multi-factor authentication.</p><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0pKPTM0z_R4ssqBM.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=825b611d00c7" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/best-practices-to-protect-an-rds-mysql-database-825b611d00c7">Best Practices to protect an RDS MySQL Database ✅</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Run a Shell on ECS Fargate Containers ]]></title>
            <link>https://awstip.com/how-to-run-a-shell-on-ecs-fargate-containers-c9f84b687cbb?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9f84b687cbb</guid>
            <category><![CDATA[ecs-fargate]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[fargate]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Mon, 20 Mar 2023 16:08:20 GMT</pubDate>
            <atom:updated>2023-03-25T16:24:44.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnu-_J3F4eQpou2OHMdmUw.jpeg" /></figure><p>If you need to troubleshoot or debug your ECS Fargate containers, you may want to open a terminal on them. There are two options available to open a shell on an ECS container: with SSH or using the ECS CLI, a command-line tool provided by AWS. The first option may create potential drawbacks and security concerns: opening SSH port an managing private and public SSH keys. The second option doesn’t require you to enable SSH access or open any additional ports because it relies on IAM authentication and AWS Session Manager.</p><p>In my opinion, using the ECS CLI to access a terminal on ECS Fargate is generally more secure than enabling SSH access because the ECS CLI doesn’t require opening any additional ports or enabling direct access to your ECS containers, which can reduce the potential risk for security vulnerabilities.</p><p>In this article I will explain how to open a shell on an ECS container via the AWS CLI.</p><h3>Install AWS CLI</h3><p><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">Install AWS CLI depending on the architecture of your computer</a>. For Linux x86 :</p><pre>curl &quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot; -o &quot;awscliv2.zip&quot;<br>unzip awscliv2.zip<br>sudo ./aws/install</pre><h3>Install Session Manager Plugin</h3><p><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">Install the Session Manager plugin for the AWS CLI</a>. For Linux x86 :</p><pre>curl &quot;https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm&quot; -o &quot;session-manager-plugin.rpm&quot;<br>sudo yum install -y session-manager-plugin.rpm</pre><h3>Attach the necessary IAM policy</h3><p>Create an IAM policy ECSFargateAllowExecuteCommand and attach it to your ECS Task execution role :</p><pre>{<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: [<br>                &quot;ssmmessages:CreateControlChannel&quot;,<br>                &quot;ssmmessages:CreateDataChannel&quot;,<br>                &quot;ssmmessages:OpenControlChannel&quot;,<br>                &quot;ssmmessages:OpenDataChannel&quot;<br>            ],<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ],<br>    &quot;Version&quot;: &quot;2012-10-17&quot;<br>}</pre><h3>Open a Shell</h3><p>AWS CLI command ecs execute-command requires 3 arguments :</p><ul><li>The ECS cluster name</li><li>The ECS task id</li><li>The container name</li></ul><p>Open your ECS task on the ECS Console and retrieve the following information :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*q01WmZyu2Cctb9Zy.png" /></figure><p>Use the information retrieved for the ECS CLI command :</p><pre>aws ecs execute-command \<br>  --region us-east-1 \<br>  --cluster ECS_CLUSTER_NAME \<br>  --task ECS_TASK_ID \<br>  --container CONTAINER_NAME \<br>  --command &quot;/bin/bash&quot; \<br>  --interactive</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*WGZ4-m83b837AA-W.png" /></figure><p><strong><em>If you liked this post, you can find more on my blog </em></strong><a href="https://adrien-mornet.tech/"><strong><em>https://adrien-mornet.tech/</em></strong></a><strong><em> 🚀</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9f84b687cbb" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/how-to-run-a-shell-on-ecs-fargate-containers-c9f84b687cbb">How to Run a Shell on ECS Fargate Containers 💻</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring Nuxt.js app with Datadog ]]></title>
            <link>https://faun.pub/monitoring-nuxt-js-app-with-datadog-aa8c109db482?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa8c109db482</guid>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[datadog]]></category>
            <category><![CDATA[nuxtjs]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 07:27:02 GMT</pubDate>
            <atom:updated>2023-03-16T21:31:26.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*pZec_7BvfWarZJ60.jpg" /></figure><p>During the last weeks, I have been able to deepen Datadog. If you’re using Nuxt.js to build your web application, you know how important it is to keep an eye on your app’s performance and behavior. That’s where monitoring tools like Datadog come in handy. With Datadog, you can easily monitor your Nuxt.js app and get insights into how it’s performing in real-time.</p><p>In this blog post, I’ll show you how to set up Datadog to monitor your Nuxt.js app and what metrics to monitor. By the end of this article, you’ll have a better understanding of how to optimize your Nuxt.js app for performance and make sure it’s running smoothly for your users. So, let’s dive in!</p><h3>Nuxt.js</h3><p>Nuxt.js is a popular open-source framework for building server-side rendered (SSR) applications. It is built on top of Vue.js. In a Nuxt.js application, the frontend and backend are tightly coupled. This means that the performance of your application is dependent on both the frontend and the backend working together seamlessly.</p><p>On the frontend side, you need to monitor things like page load times (Core Web Vitals), browser errors, resource usage (APIs), and user interactions to ensure that your application is providing a fast and responsive user experience. If the frontend is slow, users may experience lag, and this can result in a poor user experience.</p><p>On the backend side, you need to monitor things like server response times, server errors, database queries, and network requests to ensure that your application is performing well and can handle high traffic loads. If the backend is slow, it can cause delays in loading content on the frontend and impact user experience.</p><p>Monitoring both the frontend and backend of your Nuxt.js application is crucial to identify potential performance bottlenecks and prevent them from affecting your users. By collecting and analyzing performance metrics from both sides, you can optimize your application for speed and reliability, ensuring a smooth user experience.</p><h3>Frontend : Real User Monitoring (RUM)</h3><p>Datadog Real User Monitoring (RUM) is a tool that allows you to monitor the performance of your web application from the perspective of real users. RUM tracks user interactions, page load times, and other frontend metrics to provide you with insights into how your application is performing for your users.</p><h3>Setup</h3><p>1. Install <a href="https://www.npmjs.com/package/@datadog/browser-rum">@Datadog/browser-rum</a> : npm i @datadog/browser-rum</p><p>2. Create plugins/datadog.client.js file and initialize it :</p><pre>import { datadogRum } from &#39;@datadog/browser-rum&#39;;<br><br>export default ({$config: { ddApplicationId, ddApplicationToken, ddVersion, ddEnv } }) =&gt; {<br>    datadogRum.init({<br>        applicationId: ddApplicationId,<br>        clientjeToken: ddApplicationToken,<br>        site: &#39;datadoghq.com&#39;,<br>        service:&#39;nuxt-front&#39;,<br>        version: ddVersion,<br>        env: ddEnv,<br>        sessionSampleRate: 100,<br>        sessionReplaySampleRate: 100,<br>        trackUserInteractions: true,<br>        trackResources: true,<br>        trackLongTasks: true,<br>        defaultPrivacyLevel:&#39;mask-user-input&#39;<br>    });<br>    datadogRum.startSessionReplayRecording();<br>}</pre><p>3. Import the plugin in nuxt.config.js :</p><pre>require(&#39;dotenv&#39;).config();<br><br>export default {<br>    buildModules: [<br>        &#39;@nuxtjs/dotenv&#39;,<br>    ],<br>    [...]<br>    plugins: [<br>        &#39;~/plugins/datadog.client.js&#39;,<br>    ],<br>}</pre><p>4. Pass environment variables in nuxt.config.js :</p><pre>require(&#39;dotenv&#39;).config();<br><br>export default {<br>    buildModules: [<br>        &#39;@nuxtjs/dotenv&#39;,<br>    ],<br>    [...]<br>    plugins: [<br>        &#39;~/plugins/datadog.client.js&#39;,<br>    ],<br>    [...]<br>    publicRuntimeConfig: {<br>        ddApplicationId: process.env.DD_APPLICATION_ID,<br>        ddApplicationToken: process.env.DD_CLIENT_TOKEN,<br>        ddVersion: process.env.DD_VERSION,<br>        ddEnv: process.env.DD_ENV,<br>    }<br>}</pre><p>5. In Datadog, navigate to the <a href="https://app.datadoghq.com/rum/list">RUM Applications page</a> and click the New Application button. Enter a name for your application and click Generate Client Token. This generates a clientToken and an applicationId for your application. Choose the installation type for the RUM Browser SDK with npm.</p><p>6. Create / add to your .env file Datadog configuration :</p><pre>DD_APPLICATION_ID=&lt;DATADOG_APPLICATION_ID&gt;<br>DD_CLIENT_TOKEN=&lt;DATADOG_CLIENT_TOKEN&gt;<br>DD_VERSION=&quot;1.0.0&quot;<br>DD_ENV=&quot;production&quot;</pre><h3>Monitor your customers’ browsers</h3><h4>Track errors</h4><p>Monitor the ongoing bugs and issues and track them over time and versions :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HVuy6QmHoNNScLdF.png" /></figure><h4>User analytics</h4><p>Understand who is using your application (country, device, OS), monitor individual users journeys, and analyze how users interact with your application (most common page visited, clicks, interactions, and feature usage) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GWTFpTrCZ44p3oBv.png" /></figure><h4>Performances</h4><p>Track the performance of your front-end Nuxt.js code with key metrics like Core Web Vitals :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*98a6oeXFd7iT2hQm.png" /></figure><h4>Ressource usage</h4><p>Visualize which and how resources are being loaded :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-PFXhF_RBk61smoA.png" /></figure><h4>Sessions replay</h4><p>Record and replay individual user sessions to gain deeper insights into user behavior and identify any issues or errors they may have encountered during their session. With Session Replay, you can visualize user interactions and see exactly how they navigated through your application, providing valuable information for troubleshooting and optimization purposes :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZNYNxXpS1iAmYbQz.png" /></figure><h3>Backend : Application Performance Monitoring (APM)</h3><p>Datadog Application Performance Monitoring (APM) is a tool that allows you to monitor the performance of your web application from the backend perspective. With Datadog APM, you can track metrics such as response time, error rate, and throughput, as well as identify the root cause of performance issues in your application. The tool also provides detailed tracing of individual requests, allowing you to see how each component of your application is performing and how requests are flowing through it</p><h3>Setup</h3><p>1. Install and configure the Datadog Agent depending of your environment : <a href="https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/nodejs/?tab=containers#configure-the-datadog-agent-for-apm">https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/nodejs/?tab=containers#configure-the-datadog-agent-for-apm</a></p><p>2. Install the Datadog Tracing library : npm install dd-trace --save</p><p>3. Run your Nuxt.js app loading and initializing the tracing library : node --require dd-trace/init /app/node_modules/nuxt/bin/nuxt.js start</p><h3>Monitor your Nuxt.js server</h3><h4>Trace your application requests</h4><p>Traces are detailed records of requests that flow through your application :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iP4GFIkUaD1hKCr_.png" /></figure><h4>Track errors</h4><p>Keep a close eye on any existing bugs and issues, and maintain a record of their progress across various versions and over time :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0uZ1I5uZAi19yEAz.png" /></figure><h4>Database</h4><p>Monitor databases by collecting and analyzing performance metrics such as reads, writes, and deletes, as well as memory usage, network latency, and other key performance indicators :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DFy3e6y9PwPBixsd.png" /></figure><h3>Conclusion</h3><p>In conclusion, monitoring your Nuxt.js application with Datadog is important to ensure optimal performance and a smooth user experience. By using Datadog’s Real User Monitoring (RUM) and Application Performance Monitoring (APM), you can gain insights into how your application is performing on both the frontend and backend, and quickly identify and resolve any issues.</p><p>Together, RUM and APM provide a comprehensive view of your Nuxt.js application’s performance, making it easier to detect and resolve issues, optimize your code, and improve the overall user experience. Datadog’s centralized platform for monitoring RUM and APM data makes it easy to correlate frontend and backend performance metrics and gain deeper insights into how your application is behaving.</p><p>So, if you’re looking to build web applications with Nuxt.js, monitoring with Datadog is an excellent choice. Try it out and see how it can help you improve your application’s performance!</p><p><em>If you liked this post, you can find more on my blog </em><a href="https://adrien-mornet.tech/"><em>https://adrien-mornet.tech/</em></a><em> 🚀</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*xneArlByN-5_GOzw.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa8c109db482" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/monitoring-nuxt-js-app-with-datadog-aa8c109db482">Monitoring Nuxt.js app with Datadog 🔍</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing your AWS Load Balancer with Cognito Authentification: A Step-by-Step Guide for Cloud…]]></title>
            <link>https://awstip.com/securing-your-aws-load-balancer-with-cognito-authentification-a-step-by-step-guide-for-cloud-8eb2337ab5e5?source=rss-530ccd9d0e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/8eb2337ab5e5</guid>
            <category><![CDATA[cognito]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Adrien Mornet]]></dc:creator>
            <pubDate>Tue, 14 Feb 2023 12:37:20 GMT</pubDate>
            <atom:updated>2023-02-21T16:06:29.235Z</atom:updated>
            <content:encoded><![CDATA[<h3>Securing your AWS Load Balancer with Cognito Authentification: A Step-by-Step Guide for Cloud Engineers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*BTlKaMyMeNlHBfaR.jpg" /></figure><p>In the cloud age, it’s common to expose applications running on containers or virtual machines through a load balancer. By doing that, cloud engineers can ensure high availability, reliability, and scalability for their services. The load balancer acts as a single point of contact for users and automatically routes incoming traffic to the most available and capable instances.</p><p>This single point of contact seems to be perfect for authenticating users accessing the underlying services, no? In this article I will explain how to set up an authentication layer on an AWS Application Load Balancer with Cognito.</p><h3>What is Cognito ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Be7OuUSAJSV2Y-sV.png" /></figure><p>Amazon Cognito is a managed service offered by AWS that provides authentication, authorization, and user management for your web and mobile apps. With Cognito, you can easily add sign-up and sign-in functionality to your app, as well as manage access to your app’s resources. Think of it as a helper that takes care of all the complex stuff related to user management so you can focus on building your app.</p><h3>Architecture</h3><p>Let’s take a basic example with a Web Server running on an EC2 server behind an Application Load Balancer :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rpt-6x3-z8DpgJUd.png" /></figure><p>We will just add here a Cognito authentification on the Load Balancer before being able to access EC2 server.</p><h3>Implementation</h3><h4>1. EC2 instance</h4><p>For the demonstration, I created an EC2 instance publicly accessible from the internet on which I installed Apache :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/0*78YkA6rl_Q2iCgfH.png" /></figure><p>I then created a target group with the previously created EC2 as the target. Finally, I created an application load balancer redirecting all traffic to my target group.</p><p>I can now browse with HTTPS my EC2 from the DNS hostname of the load balancer :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YMRF9ni8cUHErCN0.png" /></figure><h4>2. Create a Cognito user pool</h4><p>Let’s open Cognito console and create a user pool :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R16XRR9Q5dxbPF_T.png" /></figure><p>Keep Cognito’s default password configuration :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q-PEA0GCwtBAYTqi.png" /></figure><p>Disable MFA :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u0TKQGPf1-Ta7AzB.png" /></figure><p>Configure sign-up experience :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RVz4QiZs-CnJUrOH.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LiVFpZUGzpowClaW.png" /></figure><p>Configure message delivery :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OBVDj2AbgHy7rcQp.png" /></figure><p>Integrate your app :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QFcL15ioNgh1wIpT.png" /></figure><p>Create a cognito domain :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4JnfOxIgTa8KjHti.png" /></figure><p>Create an app client as public client, generate a client secret and add your load balancer url + /oauth2/idpresponse as allowed callback url :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YMKrvmtcapSQprij.png" /></figure><p>Finally, create the user pool :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UNiUAYtZyV83z277.png" /></figure><h4>3. Configure the load balancer to authenticate users via Cognito</h4><p>Open your Load Balancer and edit the rule to add an “Authenticate” action :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ezPk0mMIy3-aJFfD.png" /></figure><h3>Demonstration</h3><p>Now open your Load Balancer url and find that you are asked to authenticate yourself :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/0*vpTkV2r6U5T5hJiv.png" /></figure><p>You can now create an account from the registration link (can be easily disabled) or via the Cognito console. Then you just need to log in to access the EC2. Cool and easy, right?</p><h3>To go further</h3><h4>Easy Two Factor Authentication</h4><p>Amazon Cognito is useful for implementing two-factor authentication (2FA). With 2FA, users are required to provide two forms of identification to verify their identity, which can include something they know (such as a password), something they have (such as a one-time code sent to their phone), or something they are (such as biometric authentication like a fingerprint or facial recognition).</p><p>Cognito provides built-in support for 2FA via time-based one-time passwords (TOTP) and SMS-based multi-factor authentication (MFA). This makes it easy to add 2FA to your application without having to build the infrastructure yourself.</p><h4>SAML &amp; OIDC</h4><p>Cognito supports federated authentication, allowing users to authenticate through a third-party identity provider such as SAML or OIDC, rather than having to create and manage a separate set of credentials for your application. It enables your users to authenticate with their existing corporate credentials (Google Workspace for example) or social media accounts, making it easier and faster for them to sign in to your application.</p><h4>Lambda triggers</h4><p>Amazon cognito provide a powerful lambda integration : it integrates it’s workflows with <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html">Lambda triggers</a>. A Lambda function can be created and activated during user pool operations such as sign-up, confirmation, and sign-in through the use of a Lambda trigger. This allows for the implementation of authentication challenges, user migration, and customization of verification messages. This allowed me to check that the users registered to my user pool were from a single email domain.</p><p><em>If you liked this post, you can find more on my blog </em><a href="https://adrien-mornet.tech/"><em>https://adrien-mornet.tech/</em></a><em> 🚀</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8eb2337ab5e5" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/securing-your-aws-load-balancer-with-cognito-authentification-a-step-by-step-guide-for-cloud-8eb2337ab5e5">Securing your AWS Load Balancer with Cognito Authentification: A Step-by-Step Guide for Cloud…</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>