<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Engineer Mindscape]]></title><description><![CDATA[Explore the intersection of engineering, coding, and professional development. From technical tutorials to personal growth strategies, this blog offers a diverse range of content to help readers navigate their careers]]></description><link>https://blog.engineermindscape.com</link><image><url>https://substackcdn.com/image/fetch/$s_!KteP!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png</url><title>Engineer Mindscape</title><link>https://blog.engineermindscape.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 03 Apr 2026 19:40:10 GMT</lastBuildDate><atom:link href="https://blog.engineermindscape.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Cristian Boarna]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[engineermindscape@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[engineermindscape@substack.com]]></itunes:email><itunes:name><![CDATA[Cristian Boarna]]></itunes:name></itunes:owner><itunes:author><![CDATA[Cristian Boarna]]></itunes:author><googleplay:owner><![CDATA[engineermindscape@substack.com]]></googleplay:owner><googleplay:email><![CDATA[engineermindscape@substack.com]]></googleplay:email><googleplay:author><![CDATA[Cristian Boarna]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Multi-Node Local Spark Cluster Alongside A DevContainer]]></title><description><![CDATA[Run Spark jobs locally with files from your local system or from your data-lake in a "batteries included" reproducible environment.]]></description><link>https://blog.engineermindscape.com/p/multi-node-local-spark-cluster-alongside</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/multi-node-local-spark-cluster-alongside</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Wed, 01 Jan 2025 10:37:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!2Bgx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2Bgx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2Bgx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!2Bgx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!2Bgx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!2Bgx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2Bgx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:653238,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2Bgx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!2Bgx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!2Bgx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!2Bgx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F42128953-92cb-41e5-bbce-f39eb4eaf7a1_1792x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Apache Spark is a powerful distributed computing system that enables large-scale data processing. While most use cases involve deploying Spark on a cloud cluster, setting up a multi-node Spark cluster locally is invaluable for development, testing, and education. Docker Compose streamlines the process of configuring multiple Spark nodes, handling networking automatically. This eliminates the complexity of manual setups and allows you to focus on coding and testing your Spark applications. This blog post explains the steps to set up and run a multi-node Spark cluster locally within a DevContainer using Docker Compose.</p><p>When faced with any Big Data tasks such as MapReduce, Spark Streaming, MLlib (classification, regressions, clusterings, recommendations, feature extractions and others), Graph Processing (GraphX), SparkSQL and others, you usually have to jump through the hoops of accessing a remote Spark cluster to run your code that can range from installing Spark in Google Codelab to setting up an Elastic Map Reduce cluster on AWS. If you are in a sufficiently big company, you may also have internal clusters already running to connect to. </p><p>All of these require a continuous internet connection and a varying amount of setup steps. This Docker &amp; DevContainer approach will show you a powerful alternative for rapid development cycles. In the below image you can see the overall architecture of what we will be doing here where on the developer computer we only have a thin client VSCode connecting to VSCode server within the DevContainer. This in turn communicates with the Spark Master node that deals with the inter-cluster comunication.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9PT3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9PT3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 424w, https://substackcdn.com/image/fetch/$s_!9PT3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 848w, https://substackcdn.com/image/fetch/$s_!9PT3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 1272w, https://substackcdn.com/image/fetch/$s_!9PT3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9PT3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png" width="642" height="1240" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1240,&quot;width&quot;:642,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:530958,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9PT3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 424w, https://substackcdn.com/image/fetch/$s_!9PT3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 848w, https://substackcdn.com/image/fetch/$s_!9PT3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 1272w, https://substackcdn.com/image/fetch/$s_!9PT3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F320a3c2c-2590-4a3f-99dd-1256bae31580_642x1240.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As we can see from the above diagram there are three ways to interface with the containers: VSCode itself, the Spark UI and the mounted volume from the local filesystem.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h5>Note</h5><p>We will not go into excruciating detail on how to setup a Spark cluster, as our purpose is to quickly get it setup and running locally as there are bigger fish to catch.</p><h5>Note 2</h5><p>While the target of this post is to run it all locally, we still want to keep it in line with the feature set existing on the live Spark cluster systems, as such, for the purposes of this post, we will assume the production systems use AWS EMR 7.5.0 and all our installed dependencies such as Python, Spark, Hadoop, Scala, Java JDK will try to adhere to the versions specified in the AWS EMR release <a href="https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-750-release.html">notes</a>.</p><h2>Advantages</h2><ul><li><p>Requires no more internet connection</p><ul><li><p>You can go on a plane with this setup and keep progressing on big data tasks.</p></li><li><p>If you are travelling in low signal areas.</p></li><li><p>Significantly reduce development start-run-complete loops for your tasks as all data would be co-located on same SSD with your cluster.</p></li></ul></li><li><p>Canary release</p><ul><li><p>You can use this setup to quickly test your pipelines work with a new major/minor release of your Spark cluster and dependnecies. It is a lot easier and faster to bump the version in the Dockerfile and run your pipelines than it is to try to deploy a new cluster on a vendor&#8217;s platform, configure it and retarget your existing DEV/QA/Production environments.</p></li></ul></li><li><p>Ease of setup</p><ul><li><p>Using Docker Compose automates the configuration of multiple nodes. It simplifies the networking and avoids manual setup headaches.</p></li></ul></li><li><p>Consistency</p><ul><li><p>DevContainers ensure that the development environment remains consistent across different machines, reducing the classic "works on my machine" problem.</p></li></ul></li><li><p>Cost-effectiveness</p><ul><li><p>A local cluster eliminates the need for cloud resources, making it ideal for development and education purposes.</p></li></ul></li><li><p>Flexibility</p><ul><li><p>You can customize Spark&#8217;s configurations to mimic production environments or test new features without affecting actual clusters.</p></li></ul></li></ul><h2>Disadvantages</h2><ul><li><p>Resource contraints</p><ul><li><p>Running a multi-node cluster locally is resource-intensive and may not accurately represent the performance of real distributed environments. But for ironing out the logic this should not matter as much.</p></li><li><p>If leveraging only a local dataset, you are limited in the amount of data that can be run through your job, but for rapid development and experimentation, you would be leveraging a subset of your data regardless, so this should not be as big of an issue.</p></li></ul></li></ul><h2>Implementation</h2><p>The crux of the magic for this can be found in the docker-compose.yaml file with some shell scripts for setup of the various containers.</p><h3>Prerequisites</h3><ol><li><p>Docker and Docker Compose installed.</p></li><li><p>Visual Studio Code with the DevContainers extension.</p></li><li><p>Basic familiarity with Docker and Spark.</p></li></ol><h3>Step 1: devcontainer.json</h3><p>The main definition file for any DevContainer in VSCode is the <code>.devcontainer/devcontainer.json</code> file which specifies <a href="https://containers.dev/implementors/json_reference/">all</a> of the configuration aspects for your setup.</p><p>We will use a more advanced, &#8220;escape hatch&#8221; approach leveraging Docker Compose for this task, as such we use the <code>&#8220;dockerComposeFile&#8221;</code> and the <code>&#8220;service&#8221; </code>properties in particular to provide more advanced container configuration options.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FL5v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FL5v!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 424w, https://substackcdn.com/image/fetch/$s_!FL5v!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 848w, https://substackcdn.com/image/fetch/$s_!FL5v!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 1272w, https://substackcdn.com/image/fetch/$s_!FL5v!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FL5v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png" width="1456" height="2814" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2814,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2964179,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FL5v!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 424w, https://substackcdn.com/image/fetch/$s_!FL5v!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 848w, https://substackcdn.com/image/fetch/$s_!FL5v!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 1272w, https://substackcdn.com/image/fetch/$s_!FL5v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3ce44d-23b5-4231-8f31-767ea76d73b3_3680x7112.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/bigdata/spark-cluster-local/.devcontainer/devcontainer.json">here</a></figcaption></figure></div><p>The rest of the <code>&#8220;customizations&#8221;</code> category is aimed at configuring VSCode to a <strong>&#8220;batteries included&#8221;</strong> approach for Python Spark development. Adding Scala/Java plugins and configurations would be needed to get it running for both languages.</p><p>Step 2: Docker Compose YAML</p><p>As mentioned above, we are delegating to Docker Compose the exact DevContainer configuration, which allows us to setup not only the container in which VSCode will configure it&#8217;s remote server but also auxiliary containers to augment our development experience, such as a 3-node Spark cluster with a master and two slaves.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pgnu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pgnu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 424w, https://substackcdn.com/image/fetch/$s_!pgnu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 848w, https://substackcdn.com/image/fetch/$s_!pgnu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 1272w, https://substackcdn.com/image/fetch/$s_!pgnu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pgnu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png" width="1456" height="8204" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:8204,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4549345,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pgnu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 424w, https://substackcdn.com/image/fetch/$s_!pgnu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 848w, https://substackcdn.com/image/fetch/$s_!pgnu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 1272w, https://substackcdn.com/image/fetch/$s_!pgnu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe70f9213-7b87-452f-b292-25986f762ae9_2604x14672.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/bigdata/spark-cluster-local/docker/compose.yaml">here</a></figcaption></figure></div><h3>Step 3: Dockerfile</h3><p>The third element of the trio of core files for this exercise is the multi-stage Dockerfile which contains all of the common and shared setup logic for the development and Spark containers.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SAek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SAek!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 424w, https://substackcdn.com/image/fetch/$s_!SAek!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 848w, https://substackcdn.com/image/fetch/$s_!SAek!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 1272w, https://substackcdn.com/image/fetch/$s_!SAek!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SAek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png" width="1456" height="6196" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:6196,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:5709163,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SAek!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 424w, https://substackcdn.com/image/fetch/$s_!SAek!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 848w, https://substackcdn.com/image/fetch/$s_!SAek!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 1272w, https://substackcdn.com/image/fetch/$s_!SAek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48b9be6e-31b6-4276-bae7-e0c1f2b49137_3680x15660.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/bigdata/spark-cluster-local/docker/Dockerfile">here</a></figcaption></figure></div><h3>Step 4: PySpark test harness</h3><p>Now we need some simple code that can be submitted as a Spark job to verify that all the wiring is done properly, cluster communication is working and that the execution completes successfully.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!h1ao!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!h1ao!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 424w, https://substackcdn.com/image/fetch/$s_!h1ao!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 848w, https://substackcdn.com/image/fetch/$s_!h1ao!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 1272w, https://substackcdn.com/image/fetch/$s_!h1ao!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!h1ao!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png" width="1456" height="783" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:783,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:898699,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!h1ao!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 424w, https://substackcdn.com/image/fetch/$s_!h1ao!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 848w, https://substackcdn.com/image/fetch/$s_!h1ao!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 1272w, https://substackcdn.com/image/fetch/$s_!h1ao!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36ce1480-b3e8-4597-9c24-795468d57653_3516x1892.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/bigdata/spark-cluster-local/pipelines/main.py">here</a></figcaption></figure></div><h3>Step 5: VSCode Task run configuration</h3><p>In order to easily run the code without having to copy paste from anywhere or remember &#8220;Yet-Another-Command&#8221;, we can create task run configurations to be invoked with <code>&#8220;SHIFT + &#8984; + P&#8221; &gt; &#8220;Tasks: Run Task&#8221;</code></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RMVZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RMVZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 424w, https://substackcdn.com/image/fetch/$s_!RMVZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 848w, https://substackcdn.com/image/fetch/$s_!RMVZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!RMVZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RMVZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png" width="1456" height="855" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:855,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1028693,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RMVZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 424w, https://substackcdn.com/image/fetch/$s_!RMVZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 848w, https://substackcdn.com/image/fetch/$s_!RMVZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!RMVZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dabb64a-a3aa-4a4c-9350-648b31a30b13_3680x2160.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/bigdata/spark-cluster-local/.vscode/tasks.json">here</a></figcaption></figure></div><h3>Step 6: Execute PySpark job</h3><p>We can now run the above task and receive the following successful output:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Qelx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Qelx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 424w, https://substackcdn.com/image/fetch/$s_!Qelx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 848w, https://substackcdn.com/image/fetch/$s_!Qelx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 1272w, https://substackcdn.com/image/fetch/$s_!Qelx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Qelx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png" width="1456" height="596" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:596,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:346404,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Qelx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 424w, https://substackcdn.com/image/fetch/$s_!Qelx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 848w, https://substackcdn.com/image/fetch/$s_!Qelx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 1272w, https://substackcdn.com/image/fetch/$s_!Qelx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F67bea547-3e5f-47eb-a4f0-dbe96bbc3a18_2376x972.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>It has read the public transport CSV file downloaded from <a href="https://bustime.mta.info/wiki/Developers/ArchiveData">here</a> and placed in <code>&#8220;/workspace/data/B63.csv&#8221;</code> and outputted the top values from the DataFrame in the console, as expected.</p><p>We can also go to <a href="http://localhost:9090">http://localhost:9090</a> to view the SparkUI and see the app &#8220;bustime-app&#8221; executed successfully.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5_Qp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5_Qp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 424w, https://substackcdn.com/image/fetch/$s_!5_Qp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 848w, https://substackcdn.com/image/fetch/$s_!5_Qp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 1272w, https://substackcdn.com/image/fetch/$s_!5_Qp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5_Qp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png" width="1456" height="535" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:535,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:293172,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5_Qp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 424w, https://substackcdn.com/image/fetch/$s_!5_Qp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 848w, https://substackcdn.com/image/fetch/$s_!5_Qp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 1272w, https://substackcdn.com/image/fetch/$s_!5_Qp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F09bdc8b9-b997-485c-8040-9eb0c8ea92a1_2816x1034.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Step 7: Use Jupyter Notebook (Optional)</h3><p>As any data scientist will know, running an entire end-to-end pipeline may take a very long time and as our purpose here is to have as fast as possible development &amp; feedback cycles, we can create a .ipynb file, connect it to the installed Python kernel and run individual jobs from there.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PETv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PETv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 424w, https://substackcdn.com/image/fetch/$s_!PETv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 848w, https://substackcdn.com/image/fetch/$s_!PETv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 1272w, https://substackcdn.com/image/fetch/$s_!PETv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PETv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png" width="1456" height="888" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:888,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:342620,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PETv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 424w, https://substackcdn.com/image/fetch/$s_!PETv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 848w, https://substackcdn.com/image/fetch/$s_!PETv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 1272w, https://substackcdn.com/image/fetch/$s_!PETv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75142230-821a-4de0-9ced-d23d2d71b198_2584x1576.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/bigdata/spark-cluster-local/pipelines/scratchpad.ipynb">here</a></figcaption></figure></div><p>We can also confirm using the Spark UI that the job has been submitted and executed properly on the cluster by verifying the existence of the &#8220;SparkConnectivityTest&#8221; job in the list.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RTUI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RTUI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 424w, https://substackcdn.com/image/fetch/$s_!RTUI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 848w, https://substackcdn.com/image/fetch/$s_!RTUI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 1272w, https://substackcdn.com/image/fetch/$s_!RTUI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RTUI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png" width="1456" height="564" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:564,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:319668,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RTUI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 424w, https://substackcdn.com/image/fetch/$s_!RTUI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 848w, https://substackcdn.com/image/fetch/$s_!RTUI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 1272w, https://substackcdn.com/image/fetch/$s_!RTUI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff344aec1-cf82-43e4-b8c5-12e6abe18d53_2810x1088.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>Conclusion</h1><p>Setting up a local multi-node Spark cluster using Docker Compose and DevContainers provides a practical environment for development and testing. While it&#8217;s resource-limited compared to production, it&#8217;s an excellent tool for learning and debugging. By following the steps in this guide, you can create a Spark cluster that&#8217;s easy to manage, reproducible, and flexible.</p><p>Experiment with different configurations and integrate additional tools to enrich your development experience. The combination of Docker Compose and DevContainers ensures your environment is consistent, cost-effective, and aligned with best practices. While we skipped over some of the tertiary files part of this setup, you can find the entire repository for this post <a href="https://github.com/crisboarna/blog/tree/main/bigdata/spark-cluster-local">here</a>.</p>]]></content:encoded></item><item><title><![CDATA[Redirecting legacy URL's to new domains using AWS Application Load Balancer and Nginx]]></title><description><![CDATA[Seamlessly migrate legacy environment URL`s to new cloud estate while keeping the lights on with no interruptions]]></description><link>https://blog.engineermindscape.com/p/redirecting-legacy-urls-to-new-domains</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/redirecting-legacy-urls-to-new-domains</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Mon, 29 Apr 2024 18:58:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!FSyX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FSyX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FSyX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!FSyX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!FSyX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!FSyX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FSyX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:637266,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FSyX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!FSyX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!FSyX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!FSyX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ca5550c-cb18-415f-b396-3ba09c831b8a_1792x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Due to a variety of reasons, we can find ourselves wanting to do a 0 downtime migration from a legacy URL or domain (legacydomain.com) to a new one (newdomain.com) without any clients noticing the change and in this post we will do just that. As the legacy environment is to be decommissioned ASAP while the legacy URL&#8217;s are still to be used by clients for the foreseeable months due to low change velocity at their end, we will need to do a few extra steps in the migration.</p><p>We will do this while touching upon several important topics that might cause unexpected gotcha&#8217;s to happen during your digital transformation which could hamper your smooth transition if not careful:</p><ul><li><p>How to redirect website URL&#8217;s where the first request is always a HTTP GET.</p></li><li><p>How to redirect API URL&#8217;s where requests are isolated and can be any HTTP verb.</p></li><li><p>Gotcha&#8217;s with Authentication headers and redirects.</p></li><li><p>HTTP 30x redirect codes and details of each.</p></li><li><p>Move all traffic over from legacy environment to new location and completely shut off the legacy environment, effectively serving all traffic, both traffic going to the old domain and traffic going to the new domain, from the new environment.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p>In essence, we will go from this where users reach your <code>legacy.com</code> domain</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f2-Y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f2-Y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 424w, https://substackcdn.com/image/fetch/$s_!f2-Y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 848w, https://substackcdn.com/image/fetch/$s_!f2-Y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 1272w, https://substackcdn.com/image/fetch/$s_!f2-Y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f2-Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png" width="1402" height="1056" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1056,&quot;width&quot;:1402,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:105565,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f2-Y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 424w, https://substackcdn.com/image/fetch/$s_!f2-Y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 848w, https://substackcdn.com/image/fetch/$s_!f2-Y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 1272w, https://substackcdn.com/image/fetch/$s_!f2-Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a97fc4-e72d-4909-9092-be8ea0f09463_1402x1056.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>To this where users access your <code>legacy.com</code> domain but end up accessing<code> new.com</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HoRT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HoRT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 424w, https://substackcdn.com/image/fetch/$s_!HoRT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 848w, https://substackcdn.com/image/fetch/$s_!HoRT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 1272w, https://substackcdn.com/image/fetch/$s_!HoRT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HoRT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png" width="1456" height="954" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:954,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:104648,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HoRT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 424w, https://substackcdn.com/image/fetch/$s_!HoRT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 848w, https://substackcdn.com/image/fetch/$s_!HoRT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 1272w, https://substackcdn.com/image/fetch/$s_!HoRT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60e19306-f1eb-46ce-a46a-ea13eb669a17_1514x992.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As we can see, we must go in the DNS registrar and update our entry for <code>legacy.com </code>to point to the same <code>A</code>/<code>CNAME</code> as the <code>new.com</code> entry so we can handle both legacy redirects and proper application traffic from the same load balancer, removing entirely any traffic or dependency to the old environment, allowing us to decommission the entire infrastructure of legacy while still serving legacy URL traffic.</p><h2>1. Redirect website applications</h2><p>To first complete the low hanging fruits of this migration, we configure the AWS Application Load Balancer HTTPS Listener to redirect based on <code>Host Header </code>from <code>legacy.com</code> domain to <code>new.com</code> domain. As AWS ALB only supports HTTP 301 &amp; 302 redirect, we will use the <code>301</code> code, as that is <code>Permanent Redirect</code>, allowing browsers to cache the resolution, compared to <code>302</code>, which is a <code>Temporary Redirect</code>. Note you can make 302 cacheable as well using <code>Cache-Control</code> or <code>Expires</code> response headers.</p><p>The sequence diagram for the above actions would be as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!e67E!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!e67E!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 424w, https://substackcdn.com/image/fetch/$s_!e67E!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 848w, https://substackcdn.com/image/fetch/$s_!e67E!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 1272w, https://substackcdn.com/image/fetch/$s_!e67E!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!e67E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png" width="811" height="688" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:688,&quot;width&quot;:811,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45860,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!e67E!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 424w, https://substackcdn.com/image/fetch/$s_!e67E!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 848w, https://substackcdn.com/image/fetch/$s_!e67E!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 1272w, https://substackcdn.com/image/fetch/$s_!e67E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffc4034b2-054a-4841-86ab-0d6cab7de8a9_811x688.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Redirect sequence diagram with HTTP 301 for websites</figcaption></figure></div><h2>2. Redirect API applications</h2><p>With the less than 5 minutes that it takes for the above, armed with enthusiasm and confidence in solving the entire task in less than 10 minutes, we go ahead and attempt the same exact <code>Host Header </code>redirect on the ALB. </p><p>Once we attempt to access a fictional URL at an API hosted on <code>https://api.legacy.com/api/v1/data</code> on an API server that only serves <code>POST</code> requests there, we will encounter a <code>404 Not Found</code> error.</p><p>The sequence of events of this would look as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3Btz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3Btz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 424w, https://substackcdn.com/image/fetch/$s_!3Btz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 848w, https://substackcdn.com/image/fetch/$s_!3Btz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 1272w, https://substackcdn.com/image/fetch/$s_!3Btz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3Btz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png" width="811" height="688" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:688,&quot;width&quot;:811,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:53048,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3Btz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 424w, https://substackcdn.com/image/fetch/$s_!3Btz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 848w, https://substackcdn.com/image/fetch/$s_!3Btz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 1272w, https://substackcdn.com/image/fetch/$s_!3Btz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F150b8392-e1fe-4e37-a5e5-470f974b0512_811x688.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Redirect sequence diagram with HTTP 301 for API&#8217;s</figcaption></figure></div><p>The first time I tried the API and saw the 404 Not Found error I was confused as to what was happening, why the 404 given that I know my API has POST, I checked the Listener rules which were correct. Upon investigating the API logs I saw the request reaching the <code>new.com</code> domain was a HTTP GET which led me down the rabbit hole to investigate HTTP Redirect codes in detail, as the knowledge up to then of 30x codes being all redirects did not suffice any longer. This research spike led me to discover the following distilled information:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KNOR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KNOR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 424w, https://substackcdn.com/image/fetch/$s_!KNOR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 848w, https://substackcdn.com/image/fetch/$s_!KNOR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 1272w, https://substackcdn.com/image/fetch/$s_!KNOR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KNOR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png" width="1456" height="785" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:785,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:136629,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KNOR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 424w, https://substackcdn.com/image/fetch/$s_!KNOR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 848w, https://substackcdn.com/image/fetch/$s_!KNOR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 1272w, https://substackcdn.com/image/fetch/$s_!KNOR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b43dbdb-491c-4463-9175-ce50c3514e0b_1684x908.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">HTTP 30x main redirect codes mind map</figcaption></figure></div><p>The original <code>HTTP 1.0</code> spec did not have <code>307 Temporary Redirect</code> and <code>308 Permanent Redirect</code>, as these roles were meant to be filled by<code> 301 Moved Permanently</code> and <code>302 Found</code>.</p><p>However, as most clients changed the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">HTTP request method</a> from POST to GET for <code>301</code> and <code>302</code> redirect responses, despite the HTTP specification not allowing the clients to do so. This behavior necessitated the introduction of the stricter <code>307 Temporary Redirect</code> and <code>308 Permanent Redirect</code><strong> </strong>status codes in the <a href="https://tools.ietf.org/html/rfc2616#section-10.3.8">HTTP/1.1 update</a>.</p><p>I then did a quick and easy test to confirm using curl with verbose logging to see the steps taken by the client:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QqHW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QqHW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 424w, https://substackcdn.com/image/fetch/$s_!QqHW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 848w, https://substackcdn.com/image/fetch/$s_!QqHW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 1272w, https://substackcdn.com/image/fetch/$s_!QqHW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QqHW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png" width="1456" height="2961" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2961,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1312132,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QqHW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 424w, https://substackcdn.com/image/fetch/$s_!QqHW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 848w, https://substackcdn.com/image/fetch/$s_!QqHW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 1272w, https://substackcdn.com/image/fetch/$s_!QqHW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc35c3f4a-458a-4772-95e2-0e376dd026eb_1612x3278.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Verbose cURL to view steps taken by client</figcaption></figure></div><p>As we can see in the above verbose curl logging statement, our request get altered based on the <code>301</code> code.</p><p>Therefore, we can easily fix the <code>404 Not Found</code> by leveraging <code>308</code> response code to achieve the following sequence of events:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jxjk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jxjk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 424w, https://substackcdn.com/image/fetch/$s_!Jxjk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 848w, https://substackcdn.com/image/fetch/$s_!Jxjk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 1272w, https://substackcdn.com/image/fetch/$s_!Jxjk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jxjk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png" width="811" height="688" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:688,&quot;width&quot;:811,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:57394,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jxjk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 424w, https://substackcdn.com/image/fetch/$s_!Jxjk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 848w, https://substackcdn.com/image/fetch/$s_!Jxjk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 1272w, https://substackcdn.com/image/fetch/$s_!Jxjk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b5a6b7-7368-4657-befc-d8e2c434f48c_811x688.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Redirect sequence diagram with HTTP 308</figcaption></figure></div><p>Finding the cause and solution to the redirect is not the end of our troubles as the AWS ALB only supports HTTP 301 and HTTP 302 as per the <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_RedirectActionConfig.html#API_RedirectActionConfig_Contents">documentation</a>.</p><p>For various reasons AWS has elected to not permit more fine grained redirect codes effectively requiring us to roll out our own load balancer to satisfy all cases or to simply host a minimum <code>.25 CPU</code> Fargate <code>Nginx</code> container to perform the <code>HTTP 308 </code>redirects.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mlH3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mlH3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 424w, https://substackcdn.com/image/fetch/$s_!mlH3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 848w, https://substackcdn.com/image/fetch/$s_!mlH3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 1272w, https://substackcdn.com/image/fetch/$s_!mlH3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mlH3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png" width="1040" height="714" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:714,&quot;width&quot;:1040,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:238698,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mlH3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 424w, https://substackcdn.com/image/fetch/$s_!mlH3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 848w, https://substackcdn.com/image/fetch/$s_!mlH3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 1272w, https://substackcdn.com/image/fetch/$s_!mlH3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45dede4a-079d-49e9-8d0f-81c01faedbf8_1040x714.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Nginx configuration. GitHub <a href="https://github.com/crisboarna/blog/blob/main/redirects/docker/nginx/redirect.nginx.conf">source</a>.</figcaption></figure></div><p>For which we will need a minimal <code>Nginx</code> <code>Dockerfile</code> to load this custom configuration from the environment variables, perform base64 decoding on it and place it at the expected location so we can have the same base image running on all environments:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jhXF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jhXF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 424w, https://substackcdn.com/image/fetch/$s_!jhXF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 848w, https://substackcdn.com/image/fetch/$s_!jhXF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 1272w, https://substackcdn.com/image/fetch/$s_!jhXF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jhXF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png" width="1456" height="801" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:801,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:402845,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jhXF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 424w, https://substackcdn.com/image/fetch/$s_!jhXF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 848w, https://substackcdn.com/image/fetch/$s_!jhXF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 1272w, https://substackcdn.com/image/fetch/$s_!jhXF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80f14ee4-dba4-4d96-9a35-2db77afae4ba_1704x938.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">nginx.Dockerfile adding custom entrypoint script docker-entrypoint.sh. GitHub <a href="https://github.com/crisboarna/blog/blob/main/redirects/nginx.Dockerfile">source</a></figcaption></figure></div><p>With the following <code>docker-entrypoint.sh</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JjLE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JjLE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 424w, https://substackcdn.com/image/fetch/$s_!JjLE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 848w, https://substackcdn.com/image/fetch/$s_!JjLE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 1272w, https://substackcdn.com/image/fetch/$s_!JjLE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JjLE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png" width="1456" height="620" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:620,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:251489,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JjLE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 424w, https://substackcdn.com/image/fetch/$s_!JjLE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 848w, https://substackcdn.com/image/fetch/$s_!JjLE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 1272w, https://substackcdn.com/image/fetch/$s_!JjLE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08e6b9f2-2de3-49bf-8bf9-79fc461a52c9_1466x624.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Dockerfile entrypoint script taking NGINX_CONF environment variable doing base64 decoding and placing file for Nginx to pickup. GitHub <a href="https://github.com/crisboarna/blog/blob/main/redirects/docker/nginx/docker-entrypoint.sh">source</a>.</figcaption></figure></div><p>With all of this new routing in place, we test our verbose curl once more, and we can see a successful response.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XdGa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XdGa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 424w, https://substackcdn.com/image/fetch/$s_!XdGa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 848w, https://substackcdn.com/image/fetch/$s_!XdGa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 1272w, https://substackcdn.com/image/fetch/$s_!XdGa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XdGa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png" width="1456" height="2961" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2961,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1317093,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XdGa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 424w, https://substackcdn.com/image/fetch/$s_!XdGa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 848w, https://substackcdn.com/image/fetch/$s_!XdGa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 1272w, https://substackcdn.com/image/fetch/$s_!XdGa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F430cc736-5d0a-4d12-a35b-e73bca0d91be_1612x3278.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Verbose cURL which reaches API correctly</figcaption></figure></div><p>We can notice that while now we stopped getting <code>404</code> , we are now getting <code>403</code>, which is expected, as this is an authenticated endpoint that is expecting an <code>Authorization</code> header.  We easily add it to the request but we still notice that the redirected request has no Authorization header:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pce9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pce9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 424w, https://substackcdn.com/image/fetch/$s_!Pce9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 848w, https://substackcdn.com/image/fetch/$s_!Pce9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 1272w, https://substackcdn.com/image/fetch/$s_!Pce9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pce9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png" width="1456" height="3055" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3055,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1404120,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Pce9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 424w, https://substackcdn.com/image/fetch/$s_!Pce9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 848w, https://substackcdn.com/image/fetch/$s_!Pce9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 1272w, https://substackcdn.com/image/fetch/$s_!Pce9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb95c698-1bcd-4b3f-a902-1c9a7b17bcdf_1648x3458.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Verbose cURL with no Authorization header present</figcaption></figure></div><p>This prompted a new research spike to investigate the cause of it, which resulted in the conclusion that due to security concerns when doing a redirect from one domain to another which could be exploited for malicious purposes, clients drop the Authorization header in HTTP 30x requests.</p><p>In order to work with this security limitation, we have to drop the &#8220;redirect&#8221; concept entirely as it is unfit for purpose, we must perform a seamless transition while not adding in security vulnerabilities therefore our <code>Nginx </code>server is taking on a greater role, that of a <code>forwarding proxy </code>from legacy URL&#8217;s to the new URL&#8217;s with the following configuration:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RMbr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RMbr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 424w, https://substackcdn.com/image/fetch/$s_!RMbr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 848w, https://substackcdn.com/image/fetch/$s_!RMbr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 1272w, https://substackcdn.com/image/fetch/$s_!RMbr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RMbr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png" width="1048" height="758" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:758,&quot;width&quot;:1048,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:260886,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RMbr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 424w, https://substackcdn.com/image/fetch/$s_!RMbr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 848w, https://substackcdn.com/image/fetch/$s_!RMbr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 1272w, https://substackcdn.com/image/fetch/$s_!RMbr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ae1d12c-f96b-4f51-821e-9e66f8a341d4_1048x758.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">NGINX proxy configuration. GitHub <a href="https://github.com/crisboarna/blog/blob/main/redirects/docker/nginx/forward.nginx.conf">source</a>.</figcaption></figure></div><p>Now the <code>Nginx </code>server acts as a proxy from the old to the new, acting as a bridge linking the two worlds.</p><h2>3. Conclusion</h2><p>In conclusion, leveraging AWS Application Load Balancer for URL redirects offers a powerful solution for seamlessly transitioning users from legacy URLs to new URLs, mainly if it for website servers only. While ALB's built-in HTTP 301/302 redirects are ideal and suffice for websites, additional considerations are needed for APIs, where custom <code>Nginx</code> servers can ensure the correct HTTP actions are maintained post-redirect along with the correct, complete header set. By following these guidelines, you can effectively manage URL redirections and enhance user experience across your applications with seamless migrations.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Fully automating certificate based AWS Client VPN deployments]]></title><description><![CDATA[Remove any manual step from the rollout of a Client VPN setup with the help of a script to automate the laborious tasks and include it in your AWS CDK stack]]></description><link>https://blog.engineermindscape.com/p/fully-automating-certificate-based</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/fully-automating-certificate-based</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Wed, 13 Mar 2024 10:26:36 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Wyih!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Wyih!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Wyih!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!Wyih!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!Wyih!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!Wyih!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Wyih!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:681074,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Wyih!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!Wyih!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!Wyih!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!Wyih!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05848d0c-e7a1-4223-8692-65a8bfc53253_1792x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As engineers we constantly strive to automate and simplify the dull and repetitive tasks as much as possible, especially the laborious and long-winded ones that are more of an annoyance than anything else. And as I rollout many small proof of concept projects both for myself and for clients, it becomes necessary for my mental sanity to automate even those steps that for most is a once in a blue moon nuisance, such as the configuration of a self-signed certificate based AWS VPC Client VPN setup.</p><h2>Advantages</h2><ul><li><p>Running &#8220;<code>npx cdk deploy&#8221;</code> is truly all that is needed to get the entire environment deployed.</p></li><li><p>No need to constantly reference documentation for all the commands needed to rollout a self-signed Certificate Authority (CA), client certificates, upload them to AWS Certificate Manager (ACM), copy the newly imported certificate ID&#8217;s into my CDK code and deploy.</p></li><li><p>Becomes a blueprint for all projects.</p></li></ul><p>The overall architecture of what we will be building is identical to what we covered in this post where I highlighted the benefits of the AWS Client VPN in more detail:</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;b22e3794-c52b-46d9-ad0d-ff4c711e74b2&quot;,&quot;caption&quot;:&quot;As a closing to this series of post related to accessing isolated networks inside AWS, I will cover the approach of using the AWS Client VPN. This is a managed client-based VPN service that enables you to securely access your AWS resources and your on-premises network via a managed VPN link.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Accessing isolated network estate on AWS: Part 4 - AWS Client VPN&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:73361062,&quot;name&quot;:&quot;Cristian Boarna&quot;,&quot;bio&quot;:&quot;Fullstack Developer specializing on cloud, mobile and backend services.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c261a67-b883-4cc5-91e8-5ffcd0561051_768x1024.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-07-30T22:14:49.028Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://blog.engineermindscape.com/p/accessing-isolated-network-estate-597&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:129762316,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:0,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Engineer Mindscape&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;belowTheFold&quot;:false,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>The architectural diagram is nearly identical to the one in the above post, with the added focus on the appearance of the S3 bucket for storing the raw certificate artifacts created during the first run of our VPC stack and the ACM being used by the Client VPN for the server certificate.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6qku!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6qku!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!6qku!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!6qku!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!6qku!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6qku!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:483056,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6qku!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!6qku!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!6qku!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!6qku!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b0446a-e404-4d1c-8c20-8fa48a29ada6_3840x2160.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Architectural Diagram</figcaption></figure></div><p>While the diagram bears significant similarities to the previous post, the CDK code has several modifications.</p><h2>Step 1: The S3 Stack</h2><p>In order to deterministically assess during each run, regardless of the machine the command is being run on, that we have the certificates generated, we need to leverage a common shared file store, such as S3:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PAnK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PAnK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 424w, https://substackcdn.com/image/fetch/$s_!PAnK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 848w, https://substackcdn.com/image/fetch/$s_!PAnK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!PAnK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PAnK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png" width="1456" height="1172" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1172,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:509249,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PAnK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 424w, https://substackcdn.com/image/fetch/$s_!PAnK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 848w, https://substackcdn.com/image/fetch/$s_!PAnK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!PAnK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a79d6d-15bd-4a52-aef3-b64f71c942ee_1558x1254.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn-auto-certificates/src/lib/s3-stack.ts">here</a></figcaption></figure></div><h2>Step 2: The VPC Stack</h2><p>This bears significant semblance to the previous stack with minor cosmetic changes:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AvKR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AvKR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 424w, https://substackcdn.com/image/fetch/$s_!AvKR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 848w, https://substackcdn.com/image/fetch/$s_!AvKR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 1272w, https://substackcdn.com/image/fetch/$s_!AvKR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AvKR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png" width="1456" height="2306" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2306,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:876055,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AvKR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 424w, https://substackcdn.com/image/fetch/$s_!AvKR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 848w, https://substackcdn.com/image/fetch/$s_!AvKR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 1272w, https://substackcdn.com/image/fetch/$s_!AvKR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37e65b4d-6f1c-444e-88fc-518b0adb41fe_1558x2468.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn-auto-certificates/src/lib/vpc-stack.ts">here</a></figcaption></figure></div><h2>Step 3: The VPN Stack</h2><p>This is where the whole magic happens, we leverage the fact that while the CloudFormation JSON/YAML that CDK synthesizes our code into is declarative, the TypeScript that generates the declarative code is imperative, so we can add some <code>if</code> statements to assess with the help of the <code>aws-sdk</code> for our language of choice, that the conditions hold true (the certificates exist), otherwise we create the certificates, upload them to the S3 bucket and create the SSM parameters, so that the AWS CDK code can find the parameters when the stack is applied.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8l5q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8l5q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 424w, https://substackcdn.com/image/fetch/$s_!8l5q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 848w, https://substackcdn.com/image/fetch/$s_!8l5q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 1272w, https://substackcdn.com/image/fetch/$s_!8l5q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8l5q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png" width="1456" height="6761" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/adb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:6761,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2724694,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8l5q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 424w, https://substackcdn.com/image/fetch/$s_!8l5q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 848w, https://substackcdn.com/image/fetch/$s_!8l5q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 1272w, https://substackcdn.com/image/fetch/$s_!8l5q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fadb86593-8053-4dde-8123-a381c1c1ebbe_1840x8544.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn-auto-certificates/src/lib/vpn-stack.ts">here</a></figcaption></figure></div><h2>Step 4: The Application Stack</h2><p>Now the final element to make this all work together is the entry point for the application, which allows us to guard for the very first deployment against the synthesis of the <code>VPNStack</code>. </p><p>Although we specify the name of the stack to be deployed, there is no way to control through CDK that only the specified stack gets synthesized as well, only way to achieve that would be by creating separate entry points for each stack and invoking them individually. As such, I am adding a latch that is by default open, allowing the creation of the VPN stack as well, but for the first run, it will be set to false, so that the S3 bucket and the VPC are created first, ensuring the <code>VPC.fromLookup</code> will succeed along with the SSM <code>Parameter.valueFromLookup</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PwM6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PwM6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 424w, https://substackcdn.com/image/fetch/$s_!PwM6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 848w, https://substackcdn.com/image/fetch/$s_!PwM6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 1272w, https://substackcdn.com/image/fetch/$s_!PwM6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PwM6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png" width="1456" height="2157" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2157,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:943798,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PwM6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 424w, https://substackcdn.com/image/fetch/$s_!PwM6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 848w, https://substackcdn.com/image/fetch/$s_!PwM6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 1272w, https://substackcdn.com/image/fetch/$s_!PwM6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51c343a6-8d57-4d67-9d05-87f70f5631aa_1666x2468.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn-auto-certificates/src/bin/bastion-vpn-auto-certificates.ts">here</a></figcaption></figure></div><h2>Step 5: The certificate creation script</h2><p>By reading the AWS documentation found <a href="https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/mutual.html">here</a>, I have created the following shell script to automate the process, allowing the above CDK code to create the certificates needed for the mutual authentication automatically:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CRq-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CRq-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 424w, https://substackcdn.com/image/fetch/$s_!CRq-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 848w, https://substackcdn.com/image/fetch/$s_!CRq-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 1272w, https://substackcdn.com/image/fetch/$s_!CRq-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CRq-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png" width="1456" height="3485" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3485,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1754762,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!CRq-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 424w, https://substackcdn.com/image/fetch/$s_!CRq-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 848w, https://substackcdn.com/image/fetch/$s_!CRq-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 1272w, https://substackcdn.com/image/fetch/$s_!CRq-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13dfe50c-a5c3-4fbe-b6a0-e42a4b9f3cbb_1840x4404.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn-auto-certificates/src/utils/certificates.sh">here</a></figcaption></figure></div><p>With this final piece of the lego, we can now see how the <code>VPNStack</code> <code>generateCertificates </code>method is invoking the shell script, and capturing the output, filtering for the &#8220;SERVER_CERT:&#8221; and &#8220;CLIENT_CERT:&#8221; rows to obtain the ACM certificate ARN&#8217;s that are subsequently stored within SSM.</p><h2>Step 6: The two step deployment</h2><p>As mentioned previously, we need to deploy the stack twice, once to create the required S3 &amp; VPC resources and a second time to create the Client VPN leveraging the dependencies:</p><blockquote><pre><code><code>npx cdk deploy --all -c deployVpn=false</code></code></pre></blockquote><p>This first run, with <code>deployVpn=false</code> prevents the VPNStack from being synthesized, allowing the dependencies to be created first, followed by a second run with:</p><blockquote><pre><code><code>npx cdk deploy --all</code></code></pre></blockquote><p>At this point we are finally complete, with a fully functional VPN service, for which we can download the Client VPN configuration, along with the certificates we now have in the &#8220;certificates&#8221; folder can be used to connect to the VPC network.</p><h2>Conclusion</h2><p>In conclusion, the journey through automating the setup of a self-signed certificate-based AWS VPC Client VPN has not only been a testament to the power of automation but also a deep dive into the intricacies of cloud infrastructure management. </p><p>The advantages of this approach are clear: from the ease of deployment with a single command to the creation of a reusable blueprint that can be adapted across various projects, the methodology outlined in this post offers a robust framework for managing VPN configurations. </p><p>As engineers, our goal is to tackle challenges head-on, leveraging technology to our advantage. This blog post serves as a blueprint for those looking to automate their AWS VPC Client VPN setup, offering a comprehensive guide that marries the imperative power of scripting with the declarative nature of infrastructure as code. By embracing these practices, we not only streamline our workflows but also pave the way for more innovative and efficient solutions in the future.</p><p>I hope this post inspires you to explore the possibilities of automation in your own projects and that it encourages a mindset of continuous improvement and innovation. </p><p>As always, you can find the full source code for this project on Github <a href="https://github.com/crisboarna/blog/tree/main/accessing-isolated-networks/bastion-vpn-auto-certificates">here</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Unlocking the Doors: Navigating many AWS ECS Containers with ECS Exec Command]]></title><description><![CDATA[A versatile tool for seamless interactive shell integration in secure isolated environments]]></description><link>https://blog.engineermindscape.com/p/unlocking-the-doors-navigating-many</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/unlocking-the-doors-navigating-many</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Tue, 12 Mar 2024 08:19:05 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!bgTH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bgTH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bgTH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!bgTH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!bgTH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!bgTH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bgTH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:611640,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bgTH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!bgTH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!bgTH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!bgTH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c0340f3-8191-41e9-9592-c769b130dfda_1792x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this post I will showcase a small utility that has proven useful across many projects to quickly gain interactive shell to secure isolated environments that are heavily restricted and monitored with a strong emphasis on having all access audited and tightly controlled through a central authentication and authorization tool, which for these cases, I have steered towards AWS Identity and Access Management (IAM).</p><p>In a previous post I have went over the architecture design and how to implement an isolated network that can be accessed via AWS ECS Exec, so I will refer you to this post an in-depth dive on how to roll it out:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;c4f47479-c341-4f19-a78f-282a490dc114&quot;,&quot;caption&quot;:&quot;We will continue where we left off in the previous post here, by talking about another, more advanced way to reach your private resources within your AWS network estate. Do note that this approach does not require a host exposed in a public subnet which means the need for hardening, auditing a&#8230;&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Accessing isolated network estate on AWS: Part 3 - ECS Fargate Host&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:73361062,&quot;name&quot;:&quot;Cristian Boarna&quot;,&quot;bio&quot;:&quot;Fullstack Developer specializing on cloud, mobile and backend services.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c261a67-b883-4cc5-91e8-5ffcd0561051_768x1024.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-06-19T21:00:15.269Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://blog.engineermindscape.com/p/accessing-isolated-network-estate-692&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:116529077,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:0,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Engineer Mindscape&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;belowTheFold&quot;:false,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p>Given the above foundational work done, I will now cover a useful utility script which with the help of a consistent and predictable naming convention, allows all authorized developers and support personnel to quickly access any service&#8217;s container across any environment.</p><p>Without further ado, the script:</p><pre><code><strong>#!/bin/bash

</strong>set -e

# environment is first argument passed to script
ENV=$1

# service is second argument passed to script
SERVICE=$2

# container name is third argument passed to script
CONTAINER_NAME="${3:-$(echo $SERVICE | tr 'A-Z-' 'a-z_')}"

# region for the service
REGION=${4:-"eu-west-1"}

usage_string="Usage: ./ecs-exec.sh &lt;env&gt; &lt;service&gt; [&lt;container_name&gt;:lower(service)] [&lt;region&gt;:eu-west-1]"

# check if ENV is passed
if [ -z "$ENV" ]; then
  echo "environment not passed in."
  echo $usage_string
  exit 1
fi

# check if SERVICE is passed
if [ -z "$SERVICE" ]; then
  echo "service target is not passed in."
  echo $usage_string
  exit 1
fi

# Check if required commands are available
for cmd in aws; do
  if ! command -v "$cmd" &gt; /dev/null; then
    echo "Error: $cmd is not installed." &gt;&amp;2
    exit 1
  fi
done

CLUSTER_NAME="EngineerMindscape-ECS-$ENV"
SERVICE_NAME="EngineerMindscape-$SERVICE-$ENV"

echo "Cluster Name: $CLUSTER_NAME"
echo "Service Name: $SERVICE_NAME"
echo "Container Name: $CONTAINER_NAME"

TASK_ARN=$(aws ecs list-tasks --region $REGION --cluster $CLUSTER_NAME --service-name $SERVICE_NAME --query 'taskArns[0]' --output text --no-cli-pager)
echo "Task ARN: $TASK_ARN"

aws ecs execute-command --region $REGION --cluster $CLUSTER_NAME --task $TASK_ARN --container $CONTAINER_NAME --command '/bin/sh' --interactive</code></pre><p>We will now discuss this script in the context of a theoretical service named <code>EngineerMindscape-EFS-Util-DEV</code>.</p><h2>Option 1: Basic Example with all Defaults</h2><p>In it&#8217;s simplest form, leveraging all defaults, the script can simply be invoked as such:</p><blockquote><pre><code><code>./ecs-exec.sh DEV EFS-Util</code></code></pre></blockquote><p>where</p><ul><li><p><strong>DEV</strong>: The environment we are targeting, could be any existing environment such as DEV, QA, UAT, INT, PROD, etc.</p></li><li><p><strong>EFS-Util</strong>: This is the name of the ECS Service we are targeting. Note that the container name must follow a strict naming convention, namely, it must be the same as the service, all lowercase, with &#8220;-&#8221; replaced by &#8220;_&#8221;. As you may have noticed, this only works if there is only one, default container. If you have more containers, depending on your needs, the standardization can be extended to include sidecar containers as required. For the scope of this demo, we will keep it to one container, but have mentioned the possibility of one or more sidecar containers nevertheless as part of the script optional parameters for flexibility and extensibility.</p></li></ul><h2>Option 2: Sidecar container present</h2><p>In this slightly more advanced example, we have a sidecar container, for example a Stackdriver container, sending data to a custom Prometheus target:</p><blockquote><pre><code><code>./ecs-exec.sh DEV EFS-Util stackdriver</code></code></pre></blockquote><p>where the first two arguments are the same as before and</p><ul><li><p><strong>stackdriver: </strong>Exact name of the target container to connect to. This parameter can also be the name of the default, essential container within the service if it does not adhere to the expected naming convention due to any reason.</p></li></ul><h2>Option 3: Sidecar container present in another region</h2><p>In this scenario, there is a sidecar container in a service located in another region. Of course the script can be expanded to also make the cluster name configurable to accomodate multiple clusters in the same region or in different ones, but for now, le&#8217;ts focus on the region:</p><blockquote><pre><code><code>./ecs-exec.sh DEV EFS-Util stackdriver us-east-1</code></code></pre></blockquote><p>where the first three arguments are the same as before and</p><ul><li><p><strong>us-east-1</strong>: Exact name of the AWS region to connect to.</p></li></ul><p>As an example of how the terminal session might look like while using this:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dOR1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dOR1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 424w, https://substackcdn.com/image/fetch/$s_!dOR1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 848w, https://substackcdn.com/image/fetch/$s_!dOR1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 1272w, https://substackcdn.com/image/fetch/$s_!dOR1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dOR1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png" width="1456" height="813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a14f65ec-c215-483a-8840-b19280634867_1840x1028.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:813,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:492798,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dOR1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 424w, https://substackcdn.com/image/fetch/$s_!dOR1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 848w, https://substackcdn.com/image/fetch/$s_!dOR1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 1272w, https://substackcdn.com/image/fetch/$s_!dOR1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa14f65ec-c215-483a-8840-b19280634867_1840x1028.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><p>If you have read my other post, namely</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;b17791fc-82aa-44fb-9e7a-23a5a00ec2c0&quot;,&quot;caption&quot;:&quot;In this digital age we live in, where data is the most valuable currency, safeguarding your files and ensuring access in times of crisis is paramount. AWS Elastic File System (EFS) offers organizations a scalable, cloud-native file storage solution that integrates seamlessly with AWS cloud services. However, even with the most advanced systems, the risk&#8230;&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Mastering Emergency Access: How to Configure a Breakglass Fargate Docker Container for Root-Level EFS Access&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:73361062,&quot;name&quot;:&quot;Cristian Boarna&quot;,&quot;bio&quot;:&quot;Fullstack Developer specializing on cloud, mobile and backend services.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c261a67-b883-4cc5-91e8-5ffcd0561051_768x1024.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-03-10T23:03:34.445Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://blog.engineermindscape.com/p/mastering-emergency-access-how-to&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:142374510,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:0,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Engineer Mindscape&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p>You will find an example use case where this script is used. Within the above posts repository, it can be found <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/ecs-exec.sh">here</a>.</p><h2>Conclusion</h2><p>In this brief post, we explored a powerful utility script that streamlines access to containers within secure, isolated AWS environments. Emphasizing stringent access controls and auditing through AWS Identity and Access Management (IAM), this tool is a testament to the importance of security and efficiency in modern cloud infrastructure management. By leveraging AWS ECS Exec, the script enables authorized developers and support staff to swiftly connect to any service container, across various environments, with minimal hassle.</p><p>Whether dealing with a primary service container or navigating through sidecar containers, possibly even across different regions, this utility facilitates essential interactive shell access, thereby enhancing operational flexibility and responsiveness.</p><p>Through practical examples, from basic usage to more complex scenarios involving sidecar containers and different AWS regions, the post demonstrates the script's versatility. This utility not only exemplifies the power of standardized naming conventions but also underscores the critical role of accessible, yet secure, container management in today's cloud-centric landscapes.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Mastering Emergency Access: How to Configure a Breakglass Fargate Docker Container for Root-Level EFS Access]]></title><description><![CDATA[Navigate through crisis: A comprehensive guide to seamlessly access your entire EFS Filesystem in emergency scenarios for investigative purposes.]]></description><link>https://blog.engineermindscape.com/p/mastering-emergency-access-how-to</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/mastering-emergency-access-how-to</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Sun, 10 Mar 2024 23:03:34 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Nin2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Nin2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Nin2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Nin2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Nin2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Nin2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Nin2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2909979,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Nin2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Nin2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Nin2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Nin2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe1ba0a8a-38b5-4dbb-820d-43d0a6725a27_1792x1024.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this digital age we live in, where data is the most valuable currency, safeguarding your files and ensuring access in times of crisis is paramount. AWS Elastic File System (EFS) offers organizations a scalable, cloud-native file storage solution that integrates seamlessly with AWS cloud services. However, even with the most advanced systems, the risk of access disruptions due to technical failures or security breaches remains a tangible threat. This brings us to the concept of a "breakglass" scenario&#8212;a situation where standard access protocols are ineffective or compromised, necessitating an alternative method to gain immediate, secure access to your data. Enter the breakglass EFS Fargate Docker container, a specialized emergency investigatory tool that enables you to quickly access typically locked down and segregated views of a larger filesystem. This blog post delves into the why and how of setting up such a container, ensuring that when the unexpected occurs, you're ready&#8212;not just to react, but to proactively inspect and remediate any issues affecting your vital data.</p><h2>The Why: The Importance of a Breakglass Container in Crisis Management</h2><p>Imagine this: Your primary access controls have failed, or a configuration mishap has left your EFS data unreachable through standard means. The clock is ticking, operational downtime is costing you, and the pressure is mounting. This is where a breakglass EFS Fargate Docker container comes into play. It's your emergency access point, a pre-configured, secure backdoor that allows you to bypass normal access protocols safely and access your raw data as it is directly stored on the filesystem. By spinning up this ephemeral container which has the root of your EFS filesystem mounted, you can quickly investigate and remediate any inconsistent data that is bringing down your application.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h3>Advantages:</h3><ul><li><p><strong>Immediate Access:</strong> When every second counts, having a container ready to deploy ensures you can access your data without the delay of configuring access from scratch. This can be the difference between adhering to your RTO (Recovery Time Objective) and still trying to gain access while it sails past you.</p></li><li><p><strong>Secure Yet Flexible:</strong> Designed with the principle of least privilege in mind, it provides just enough access to manage the crisis without exposing your system to further risk. The task does not exist, only the task definition, so it is running only when it is truly needed.</p></li><li><p><strong>Valuable Investigation Tool:</strong> This tool can be used not only for the worst case scenario, it can also be used for pure investigate purposes.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://blog.engineermindscape.com/subscribe?"><span>Subscribe now</span></a></p><h2>The What: A Step-by-Step Guide to Building a Breakglass Container</h2><p>In order to properly showcase this concept, I will showcase the EFS Breakglass container service  within a minimally configured AWS VPC with an EFS filesystem. In order to apply this into your own ecosystem you only need to copy the AWS ECS EFS Util Service. The Breakglass service will have a desired count of 0 so there are no running containers and if access is needed, it can be set to 1. Once a container boots and stabilizez, we can leverage AWS ECS Exec, which I already covered in a previous post <a href="https://blog.engineermindscape.com/p/accessing-isolated-network-estate-692">here</a>, to land with an interactive shell within the container with the root of the EFS mounted in <code>/mnt/efs</code> .</p><p>The high level architectural diagram of what we are going to build is as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!unHx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!unHx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!unHx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!unHx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!unHx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!unHx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:235524,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!unHx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!unHx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!unHx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!unHx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33b58b4f-a1c4-439e-a2d4-304ee2625367_3840x2160.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Architectural Diagram</figcaption></figure></div><p>Without further ado, let&#8217;s start building it.</p><h2>Prerequisites</h2><p>Before we begin, make sure you have the following prerequisites installed and configured:</p><ul><li><p>AWS CLI <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">[install guide]</a></p></li><li><p>AWS CDK <a href="https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html">[install guide]</a></p></li><li><p>Node.JS and NPM <a href="https://nodejs.org/en/download">[install guide]</a></p></li><li><p>Java [<a href="https://www.oracle.com/java/technologies/javase-jdk17-downloads.html">install guide</a>]</p></li></ul><p>Although the IaC will be written in AWS CDK using Java, the fastest and easiest way to bootstrap the project is by leveraging the <code>cdk</code> CLI directly from NPM.</p><h2>Step 1: Initialize the CDK App</h2><p>First, we need to initialize a new CDK app in your preferred language, for this series, I will go with Java. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>mkdir -p efs-escape-hatch
cd efs-escape-hatch
npx cdk init app --language=java</code></code></pre><p>This will create a new CDK app in Java with the following structure:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-_gD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-_gD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 424w, https://substackcdn.com/image/fetch/$s_!-_gD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 848w, https://substackcdn.com/image/fetch/$s_!-_gD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!-_gD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-_gD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png" width="1194" height="1254" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1254,&quot;width&quot;:1194,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:377665,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-_gD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 424w, https://substackcdn.com/image/fetch/$s_!-_gD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 848w, https://substackcdn.com/image/fetch/$s_!-_gD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!-_gD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6adee74-4558-4379-b850-0b2094391bc5_1194x1254.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 2: Define the VPC Stack</h2><p>In this simple skeleton configuration, the VPC is simple and straightforward. While we could use isolated subnets with no egress, beyond the VPC Endpoints for ECR (to pull containers images), S3 (ECR stores container image data on AWS S3 owned buckets) and SSM ( we will use SSM Exec to obtain an interactive terminal into the Fargate container, more on that later), in order to keep this as simple as possible, we will use the generic public &amp; private with egress subnet configuration.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0_2k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0_2k!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 424w, https://substackcdn.com/image/fetch/$s_!0_2k!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 848w, https://substackcdn.com/image/fetch/$s_!0_2k!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 1272w, https://substackcdn.com/image/fetch/$s_!0_2k!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0_2k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png" width="1456" height="2345" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76274054-744d-4928-bdfe-72552ff78193_1840x2964.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2345,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1063958,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0_2k!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 424w, https://substackcdn.com/image/fetch/$s_!0_2k!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 848w, https://substackcdn.com/image/fetch/$s_!0_2k!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 1272w, https://substackcdn.com/image/fetch/$s_!0_2k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76274054-744d-4928-bdfe-72552ff78193_1840x2964.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/src/main/java/com/engineermindscape/blog/efs/escapehatch/lib/VpcStack.java">here</a></figcaption></figure></div><h2>Step 3: Define the ECS Stack</h2><p>As we aim to have a modular design, in which the ECS stack may very well be maintained by a completely different team, we will define the ECS cluster in its own dedicated stack, with ECS execute command enabled, in a straightforward manner as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6HUs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6HUs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 424w, https://substackcdn.com/image/fetch/$s_!6HUs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 848w, https://substackcdn.com/image/fetch/$s_!6HUs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 1272w, https://substackcdn.com/image/fetch/$s_!6HUs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6HUs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png" width="1456" height="2665" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2665,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1207542,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6HUs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 424w, https://substackcdn.com/image/fetch/$s_!6HUs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 848w, https://substackcdn.com/image/fetch/$s_!6HUs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 1272w, https://substackcdn.com/image/fetch/$s_!6HUs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5f6c8b7d-9808-41af-9a41-c8705cda21be_1840x3368.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/src/main/java/com/engineermindscape/blog/efs/escapehatch/lib/EcsStack.java">here</a></figcaption></figure></div><h2>Step 4: Define the EFS Stack</h2><p>As the purpose of this exercise is to access an EFS file system, we will create a simple and straightforward one now. The only added complexity for the purpose of the demo is to initialize the EFS file system with some folders, in this case, we will use this EFS system for a MySQL / RabbitMQ cluster combo, where both clusters share the same EFS and we are using AWS CDK Custom Resources to trigger a Lambda that will mount the EFS via an Access Point and run a simple inline NodeJS snippet to create the <code>/mysql/data</code> and <code>/rabbitmq/data</code> directories.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q3ek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q3ek!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 424w, https://substackcdn.com/image/fetch/$s_!q3ek!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 848w, https://substackcdn.com/image/fetch/$s_!q3ek!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 1272w, https://substackcdn.com/image/fetch/$s_!q3ek!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q3ek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png" width="1456" height="6511" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:6511,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2347148,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!q3ek!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 424w, https://substackcdn.com/image/fetch/$s_!q3ek!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 848w, https://substackcdn.com/image/fetch/$s_!q3ek!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 1272w, https://substackcdn.com/image/fetch/$s_!q3ek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F450aee26-8e83-4146-9940-5e1bd53301a2_1840x8228.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/src/main/java/com/engineermindscape/blog/efs/escapehatch/lib/EfsStack.java">here</a></figcaption></figure></div><h2>Step 5: Define the EFS Breakglass Stack</h2><p>And now the crux of this article, the service that is by default in cold standby, with 0 active containers, waiting for a signal to be started and mount the EFS filesystem, to which we can connect via AWS ECS Exec to land with a shell directly in the container.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4t8S!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4t8S!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 424w, https://substackcdn.com/image/fetch/$s_!4t8S!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 848w, https://substackcdn.com/image/fetch/$s_!4t8S!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 1272w, https://substackcdn.com/image/fetch/$s_!4t8S!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4t8S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png" width="1456" height="8291" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:8291,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2843228,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4t8S!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 424w, https://substackcdn.com/image/fetch/$s_!4t8S!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 848w, https://substackcdn.com/image/fetch/$s_!4t8S!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 1272w, https://substackcdn.com/image/fetch/$s_!4t8S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0633443d-c44a-4d27-a083-d390f4b8d0a5_1840x10478.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/src/main/java/com/engineermindscape/blog/efs/escapehatch/lib/EcsServicesEfsUtilStack.java">here</a></figcaption></figure></div><h2>Step 6: Define the ECS Exec utility script</h2><p>The final setup step needed now is to configure a lightweight shell script that will allow us to quickly leverage ECS Exec and land within an interactive shell inside the <code>busybox</code> container. This script is done in a such a way that it can be reused to land in any container that respects the container naming convention across any environment name although for this demo purpose, we only have the <code>DEMO</code> environment.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!INmF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!INmF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 424w, https://substackcdn.com/image/fetch/$s_!INmF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 848w, https://substackcdn.com/image/fetch/$s_!INmF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 1272w, https://substackcdn.com/image/fetch/$s_!INmF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!INmF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png" width="1456" height="2238" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2238,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1026878,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!INmF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 424w, https://substackcdn.com/image/fetch/$s_!INmF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 848w, https://substackcdn.com/image/fetch/$s_!INmF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 1272w, https://substackcdn.com/image/fetch/$s_!INmF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11e5a154-4fff-4914-99d6-5105c1f063f9_1840x2828.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/ecs-exec.sh">here</a></figcaption></figure></div><p>As we can see in the above script, we can reap many benefits from adhering to a standardized and predictable naming format across the resources on our entire estate.</p><h2>Step 7: Defining the CDK entrypoint</h2><p>Final step in the AWS CDK setup is to define the entry class for the entire application as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EJbD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EJbD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 424w, https://substackcdn.com/image/fetch/$s_!EJbD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 848w, https://substackcdn.com/image/fetch/$s_!EJbD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 1272w, https://substackcdn.com/image/fetch/$s_!EJbD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EJbD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png" width="1456" height="3662" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3662,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1573750,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EJbD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 424w, https://substackcdn.com/image/fetch/$s_!EJbD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 848w, https://substackcdn.com/image/fetch/$s_!EJbD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 1272w, https://substackcdn.com/image/fetch/$s_!EJbD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F04899b15-3216-4d35-84cf-d2b6a9ec2fda_1840x4628.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Github source <a href="https://github.com/crisboarna/blog/blob/main/efs-escape-hatch/src/main/java/com/engineermindscape/blog/efs/escapehatch/bin/EfsEscapeHatchApp.java">here</a></figcaption></figure></div><h2>Step 8: Deploying the stacks</h2><p>We can deploy all of the above stacks in one go with the following command:</p><blockquote><p><code>npx cdk deploy &#8212;all -c skipDependencies false</code></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KWHu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KWHu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 424w, https://substackcdn.com/image/fetch/$s_!KWHu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 848w, https://substackcdn.com/image/fetch/$s_!KWHu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 1272w, https://substackcdn.com/image/fetch/$s_!KWHu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KWHu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png" width="1194" height="894" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:894,&quot;width&quot;:1194,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:328582,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KWHu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 424w, https://substackcdn.com/image/fetch/$s_!KWHu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 848w, https://substackcdn.com/image/fetch/$s_!KWHu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 1272w, https://substackcdn.com/image/fetch/$s_!KWHu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb92de97-07ac-48cb-92d4-9821dd268b5b_1194x894.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>And now we can finally use ECS Exec and start browsing our EFS file system at will with the following:</p><blockquote><pre><code><code>./ecs-exec.sh DEMO EFS-Util</code></code></pre></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4SZo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4SZo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 424w, https://substackcdn.com/image/fetch/$s_!4SZo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 848w, https://substackcdn.com/image/fetch/$s_!4SZo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 1272w, https://substackcdn.com/image/fetch/$s_!4SZo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4SZo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png" width="1456" height="1206" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1206,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:627895,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4SZo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 424w, https://substackcdn.com/image/fetch/$s_!4SZo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 848w, https://substackcdn.com/image/fetch/$s_!4SZo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 1272w, https://substackcdn.com/image/fetch/$s_!4SZo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3e2e23-a987-4e72-b576-7ee549f95513_1840x1524.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Step 9: Cleanup</h2><p>Now that we have completed this exercise, we can delete all the resources to ensure no nefarious bill hits us at the end of the month !</p><blockquote><pre><code><code>./ecs-exec.sh DEMO EFS-Util</code></code></pre></blockquote><h2>Conclusion: A Stitch in Time</h2><p>The adage "a stitch in time saves nine" holds particularly true in the realm of IT and data management. You're not just setting up a technical solution; you're laying the foundation for countering the unexpected. </p><p>In conclusion, the implementation of a breakglass EFS Fargate Docker container is not merely a technical exercise; it is a critical step towards ensuring operational resilience in the face of unforeseen challenges. By preparing for emergency access scenarios, organizations can significantly reduce the impact of access disruptions, safeguard their data integrity, and maintain business continuity with confidence.</p><p>It helps you stick to and outperform your RTO while keeping calm and collected. In a world where the unexpected is the only certainty, such preparedness is not just beneficial; it's essential for business continuity and client confidence.</p><p>Let this guide serve as a reminder of the power of preparation and the critical role of emergency access solutions in building a robust, resilient IT infrastructure. I encourage you to take the necessary steps to implement this breakglass scenario solution within your organization. By doing so, you're not just protecting your data; you're safeguarding the future of your business.</p><p>Remember, in the world of IT, the unexpected is the only certainty. Equip your organization with the tools and strategies to navigate these uncertainties with confidence. Operational resilience is not just about surviving the storm; it's about thriving in the aftermath. Prepare today to ensure your organization's resilience for tomorrow.</p><p>As always, you can find the full source for this project on my Github repository <a href="https://github.com/crisboarna/blog/tree/main/efs-escape-hatch">here</a>.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://blog.engineermindscape.com/subscribe?"><span>Subscribe now</span></a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[From Zero to Hero: Deploying a Full-Stack monorepo with Web, API, and IaC in Just 5 Minutes]]></title><description><![CDATA[How to quickly rollout a basic 3 layer application repository for quick prototyping in NodeJS with shared code across all layers. From repository creation to being Internet accessible in minimum time.]]></description><link>https://blog.engineermindscape.com/p/from-zero-to-hero-deploying-a-full</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/from-zero-to-hero-deploying-a-full</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Thu, 08 Feb 2024 08:09:27 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fVwb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fVwb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fVwb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!fVwb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!fVwb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!fVwb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fVwb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:689478,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fVwb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!fVwb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!fVwb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!fVwb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F532f34e9-6c04-4bca-93a0-9acb0af3f701_1792x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this post I will share with you the steps I go through for every new project, be it a quick experimentation or professional greenfield project to quickly rollout a basic skeleton for a web front-end, API back-end and AWS CDK (in this example, could also be Azure ARM, Terraform, Pulumi) IaC (Infrastructure-as-Code). The same applies for any permutation of the above with any number of services.</p><p>While it is possible to create a shared code monorepo manually, it would not be complete in 5 minutes and would entail undifferentiated heavy lifting on our part. To avoid such inneficiencies, we will use <a href="https://nx.dev/">Nx</a> for this (could also use Yarn workspaces if scope is limited and small) as it provides <a href="https://nx.dev/plugin-registry">plentiful</a> of plugins for most of the frequently used toolings in the wild (you can use this as a measuring stick for the popularity of some tools, I have discovered some new ones browsing the Nx plugin list). </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>This is the same process I started with when creating my CV, as detailed <a href="https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv">here</a> and <a href="https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv-800">here</a>, so as you can see, this is another powerful tool in your belt, that can be used for the simplest to the most complex setups.</p><p>The Nx CLI is a robust tool that offers a wide range of options and follows specific best practices. To guarantee that our setup remains consistent over time&#8212;whether the commands are executed today, next week, or a year from now&#8212;we will specify a few parameters. This ensures our project configuration remains uniform, regardless of when the commands are run.</p><p>This post is divided into two primary sections:</p><ul><li><p><strong>Project bootstrapping</strong></p><ul><li><p>This involves setting up the initial structure for web, API, and Infrastructure-as-Code (IaC) applications, along with a shared library that these applications will use.</p></li></ul></li><li><p><strong>Coding</strong></p><ul><li><p>This section covers adding minimal code to enhance the modules with essential functionality.</p></li></ul></li></ul><p>In order to better visualize the final relation between the modules, I have ran </p><blockquote><p><code>npx nx graph</code></p></blockquote><p>to view in the browser the dependency relationships between the projects, which looks as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O3zS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O3zS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 424w, https://substackcdn.com/image/fetch/$s_!O3zS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 848w, https://substackcdn.com/image/fetch/$s_!O3zS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 1272w, https://substackcdn.com/image/fetch/$s_!O3zS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O3zS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png" width="838" height="690" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:690,&quot;width&quot;:838,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:67061,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!O3zS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 424w, https://substackcdn.com/image/fetch/$s_!O3zS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 848w, https://substackcdn.com/image/fetch/$s_!O3zS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 1272w, https://substackcdn.com/image/fetch/$s_!O3zS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8f97f3c1-5e85-46a8-a785-b15b5aaf1f33_838x690.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h4>Note</h4><p>The diagram mentioned earlier represents a compile-time dependency graph, created using the graph command. This graph shows the dependencies that are determined during the compilation process. If we were to create a graph illustrating runtime dependencies, it would include an additional arrow pointing from the web to the API. This arrow signifies that the ReactJS front end makes calls to the API to fetch data. This data fetching is facilitated by code that is compiled into the application's binary, using functions imported from the shared library. The concept and its implementation will be more comprehensible when we delve into the code in section 2.</p><p>The architectural view of the deployed solution will look as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d-zE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d-zE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 424w, https://substackcdn.com/image/fetch/$s_!d-zE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 848w, https://substackcdn.com/image/fetch/$s_!d-zE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 1272w, https://substackcdn.com/image/fetch/$s_!d-zE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!d-zE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png" width="1456" height="1102" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1102,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:90550,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!d-zE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 424w, https://substackcdn.com/image/fetch/$s_!d-zE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 848w, https://substackcdn.com/image/fetch/$s_!d-zE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 1272w, https://substackcdn.com/image/fetch/$s_!d-zE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe137eb9d-eaa3-436e-be3a-e3d00f681398_2363x1789.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>1. Project bootstrapping</h1><p>This section is mainly in the CLI so the feedback loop will be fast.</p><h2>1.1. Create Nx Workspace</h2><p>The documentation of the command can be found <a href="https://nx.dev/nx-api/nx/documents/create-nx-workspace">here</a>.</p><blockquote><p><code>npx create-nx-workspace@latest --preset empty --nxCloud skip --packageManager yarn --workspaceType integrated engineeringmindscape</code></p></blockquote><p>where the parameters are as follows:</p><ul><li><p><code>--preset none</code></p><ul><li><p>Creates an empty monorepo project with no dependencies. We will manually populate only what we need in the next steps.</p></li></ul></li><li><p><code>--nxCloud skip</code></p><ul><li><p>No need for cloud build caching for this demo app but it is nice to have otherwise.</p></li></ul></li><li><p><code>--packageManager yarn</code></p><ul><li><p>Personal prefference to use yarn but npm, pnpm are also available.</p></li></ul></li><li><p><code>--workspaceType integrated</code></p><ul><li><p>As I want to highlight the power of the integrated monorepo, we need to ensure we can refer to libs cleanly :).</p></li></ul></li><li><p><code>engineeringmindscape</code></p><ul><li><p>This will be the name of the overall monorepo project and the namespace that will be used for the libraries.</p></li></ul></li></ul><p>The output of the above command looks as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OCyk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OCyk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 424w, https://substackcdn.com/image/fetch/$s_!OCyk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 848w, https://substackcdn.com/image/fetch/$s_!OCyk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 1272w, https://substackcdn.com/image/fetch/$s_!OCyk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OCyk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png" width="1456" height="636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:636,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:395534,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OCyk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 424w, https://substackcdn.com/image/fetch/$s_!OCyk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 848w, https://substackcdn.com/image/fetch/$s_!OCyk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 1272w, https://substackcdn.com/image/fetch/$s_!OCyk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F574b55cb-12d1-46d0-a476-5051adb7468b_1840x804.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><p>Now we can enter the newly created monorepo directory:</p><blockquote><p><code>cd engineeringmindscape</code></p></blockquote><p>The file structure of the generated base monorepo looks as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KuaY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KuaY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 424w, https://substackcdn.com/image/fetch/$s_!KuaY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 848w, https://substackcdn.com/image/fetch/$s_!KuaY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 1272w, https://substackcdn.com/image/fetch/$s_!KuaY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KuaY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png" width="1456" height="600" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!KuaY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 424w, https://substackcdn.com/image/fetch/$s_!KuaY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 848w, https://substackcdn.com/image/fetch/$s_!KuaY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 1272w, https://substackcdn.com/image/fetch/$s_!KuaY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84c06c4d-c3b4-4411-a77e-3767db071e4c_1840x758.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>1.2. Install Nx plugins</h2><p>Now we can add as dev dependency the Nx plugins for NodeJS and AWS CDK and the needed CDK construct plugin.</p><blockquote><p><code>yarn add -D @nx/react @nx/node @nx-iac/aws-cdk @aws-solutions-constructs/aws-apigateway-lambda</code></p></blockquote><ul><li><p><a href="https://nx.dev/nx-api/react">@nx/react</a></p><ul><li><p>This is the plugin that we will use to generate the web application. It has several <a href="https://nx.dev/nx-api/react/generators">generators</a> such as hooks, stories, redux, components, etc but we will only be using the <strong>application</strong> one for now.</p></li></ul></li><li><p><a href="https://nx.dev/nx-api/node">@nx/node</a></p><ul><li><p>We will be using this for the API backend. It also has several <a href="https://nx.dev/nx-api/node/generators">generators</a> from which we will also be using the <strong>application</strong> generator.</p></li></ul></li><li><p>@<a href="https://github.com/joelklint/nx-aws-cdk">nx-iac/aws-cdk</a></p><ul><li><p>This is a custom plugin that will bootstrap our AWS CDK IaC application from which we will need the <strong>app</strong> generator.</p></li></ul></li><li><p><a href="https://docs.aws.amazon.com/solutions/latest/constructs/aws-apigateway-lambda.html">@aws-solutions-constructs/aws-apigateway-lambda</a></p><ul><li><p>AWS provided L3 construct for CDK to generate all the resources required for a API Gateway fronted Lambda with minimal code.</p></li></ul></li></ul><h2>1.3. Create the ReactJS Web App</h2><p>Let us begin bootstrapping the first application of our stack, the ReactJS website with the <a href="https://vitejs.dev/">Vite</a> bundler:</p><blockquote><p><code>npx nx g @nx/react:application --name web --directory apps/web --bundler vite --style css --routing false --e2eTestRunner playwright --minimal true --projectNameAndRootFormat as-provided</code></p></blockquote><ul><li><p><code>--name web</code></p><ul><li><p>The name of the ReactJS web application.</p></li></ul></li></ul><ul><li><p><code>--bundler vite</code></p><ul><li><p>The bundler to use for the ReactJS project, vite or webpack is available. </p></li></ul></li><li><p><code>--style css</code></p><ul><li><p>The stylesheet system to use for the web app, we are keeping it lightweight as possible and not including SASS/LESS/etc.</p></li></ul></li><li><p><code>&#8212;routing false</code></p><ul><li><p>For this basic scenario I do not want to have routing configured as it will be literally a <strong>single</strong> page SPA(Single Page Application)</p></li></ul></li><li><p><code>--e2eTestRunner playwright</code></p><ul><li><p>Each web project gets a side E2E testing project, with options for cypress and playwright. We are going with playwright.</p></li></ul></li><li><p><code>&#8212;minimal true</code></p><ul><li><p>No need for separate test files, let&#8217;s keep it light.</p></li></ul></li><li><p><code>--projectNameAndRootFormat as-provided</code></p><ul><li><p>To keep the structure specifically as I have provided in the <strong>directory </strong>parameter.</p></li></ul></li></ul><p>After running the above command, the following output and files have been created:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j3aC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j3aC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 424w, https://substackcdn.com/image/fetch/$s_!j3aC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 848w, https://substackcdn.com/image/fetch/$s_!j3aC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 1272w, https://substackcdn.com/image/fetch/$s_!j3aC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!j3aC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png" width="1456" height="1955" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1955,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1047613,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!j3aC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 424w, https://substackcdn.com/image/fetch/$s_!j3aC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 848w, https://substackcdn.com/image/fetch/$s_!j3aC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 1272w, https://substackcdn.com/image/fetch/$s_!j3aC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F661f1d8e-2ccc-4587-9de3-59a7f53f6a0d_1840x2470.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>1.4. Create the NodeJS API App</h2><p>We can now leverage the previously installed <code>@nx/node</code> plugin to generate our API application:</p><blockquote><p><code>npx nx g @nx/node:application --name api --bundler esbuild --framework none --projectNameAndRootFormat as-provided --directory apps/api</code></p></blockquote><ul><li><p><code>--name api</code></p><ul><li><p>Name of the application and folder where it will be placed in.</p></li></ul></li><li><p><code>--bundler esbuild</code></p><ul><li><p>The bundler to use for the NodeJS project, esbuild or webpack is available. </p></li></ul></li><li><p><code>--framework none</code></p><ul><li><p>As we will have a basic Request-Response Lambda, we will simply return a canned response with no need for Express/Fastify/Koa.</p></li></ul></li><li><p><code>--directory apps/api</code></p><ul><li><p>We specify concretely the folder to place the new application in.</p></li></ul></li><li><p><code>--projectNameAndRootFormat as-provided</code></p><ul><li><p>To keep the structure specifically as I have provided in the above parameter.</p></li></ul></li></ul><p>The documentation for the command can be found <a href="https://nx.dev/nx-api/node/generators/application">here</a>. After running the above command, this is what we get in the terminal:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!liur!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!liur!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 424w, https://substackcdn.com/image/fetch/$s_!liur!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 848w, https://substackcdn.com/image/fetch/$s_!liur!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 1272w, https://substackcdn.com/image/fetch/$s_!liur!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!liur!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png" width="1456" height="1526" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1526,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:873581,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!liur!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 424w, https://substackcdn.com/image/fetch/$s_!liur!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 848w, https://substackcdn.com/image/fetch/$s_!liur!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 1272w, https://substackcdn.com/image/fetch/$s_!liur!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23ba4d5c-c9df-40e5-8abe-a2b191036ce0_1840x1928.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>1.4. Create the shared NodeJS library</h2><p>In order to fully showcase the power of this monorepo setup, we will create a library that will contain shared definitions, such as the name of the project, that will be used across all of the applications in a visible manner to the end user. For now we will simply bootstrap the library as follows leveraging the same <code>@nx/node</code> plugin:</p><blockquote><p><code>npx nx g @nx/node:library --name shared --directory libs/shared --projectNameAndRootFormat as-provided --testEnvironment node</code></p></blockquote><ul><li><p><code>--name shared</code></p><ul><li><p>The name of the library</p></li></ul></li><li><p><code>--directory libs/shared</code></p><ul><li><p>The directory where to place the new library specifically.</p></li></ul></li><li><p><code>--projectNameAndRootFormat as-provided</code></p><ul><li><p>As before, this tells Nx that I want to specifically have the folder structure I provided, to ensure consistency throughout time.</p></li></ul></li><li><p><code>--testEnvironment node</code></p><ul><li><p>The environment for the testing aspect of the library, node or jsdom are available options.</p></li></ul></li></ul><p>The documentation for generating the library command can be found <a href="https://nx.dev/nx-api/node/generators/library">here</a>. After running the above command, we can see the following in the CLI:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hqUZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hqUZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 424w, https://substackcdn.com/image/fetch/$s_!hqUZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 848w, https://substackcdn.com/image/fetch/$s_!hqUZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 1272w, https://substackcdn.com/image/fetch/$s_!hqUZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hqUZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png" width="1456" height="885" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:885,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:536626,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hqUZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 424w, https://substackcdn.com/image/fetch/$s_!hqUZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 848w, https://substackcdn.com/image/fetch/$s_!hqUZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 1272w, https://substackcdn.com/image/fetch/$s_!hqUZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2f792011-8f1c-4516-b0ce-1829b358e2c4_1840x1118.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>1.5. Create the AWS CDK IaC App</h2><p>As the final bootstrap step, we generate a base AWS CDK application using the second</p><p>installed plugin <code>@nx-iac/aws-cdk:</code></p><blockquote><p><code>npx nx g @nx-iac/aws-cdk:app --name iac --directory apps/iac --projectNameAndRootFormat as-provided</code></p></blockquote><ul><li><p><code>--name iac</code></p><ul><li><p>The name of the application</p></li></ul></li><li><p><code>--directory apps/iac</code></p><ul><li><p>The directory where we are going to place the AWS CDK code.</p></li></ul></li><li><p><code>--projectNameAndRootFormat as-provided</code></p><ul><li><p>We ensure the layout will be as specified in the above directory parameter.</p></li></ul></li></ul><p>The documentation for this custom Nx plugin can be found <a href="https://github.com/joelklint/nx-aws-cdk">here</a>. The output of running the above command is as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QiAT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QiAT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 424w, https://substackcdn.com/image/fetch/$s_!QiAT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 848w, https://substackcdn.com/image/fetch/$s_!QiAT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 1272w, https://substackcdn.com/image/fetch/$s_!QiAT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QiAT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png" width="1456" height="1383" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1383,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:793978,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QiAT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 424w, https://substackcdn.com/image/fetch/$s_!QiAT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 848w, https://substackcdn.com/image/fetch/$s_!QiAT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 1272w, https://substackcdn.com/image/fetch/$s_!QiAT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc374c4af-802b-41e7-a5cc-3e0db49aa8ec_1840x1748.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>1.6. Full monorepo skeleton</h2><p>Now after running the above bootstrap commands for the web, api and IaC apps as well as for the  shared library, with the 18.0.2 version of Nx we get the following files:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QAgK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QAgK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 424w, https://substackcdn.com/image/fetch/$s_!QAgK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 848w, https://substackcdn.com/image/fetch/$s_!QAgK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 1272w, https://substackcdn.com/image/fetch/$s_!QAgK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QAgK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png" width="1430" height="4044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4044,&quot;width&quot;:1430,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1033019,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QAgK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 424w, https://substackcdn.com/image/fetch/$s_!QAgK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 848w, https://substackcdn.com/image/fetch/$s_!QAgK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 1272w, https://substackcdn.com/image/fetch/$s_!QAgK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e64c58e-4636-4565-b815-6c0b0c10c994_1430x4044.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h1>2. Coding</h1><p>Starting from the foundational elements and moving upward, we will enhance the initially bootstrapped files with necessary modifications to showcase the power and speed of our setup.</p><h2>2.1. Shared Library</h2><p>In <code>shared/src/lib/shared.ts</code> we add the following:</p><pre><code><code>export const PROJECT_NAME = "EngineeringMindscape";</code></code></pre><h2>2.2. API App</h2><p>In <code>apps/api/src/main.ts </code>already we can start leveraging the shared code above:</p><pre><code>// this is the imported symbol from the shared library
import { PROJECT_NAME } from '@engineeringmindscape/shared';

export const handler = (event: unknown, context: unknown, callback: (err: null, resp: Record&lt;string, number|string|Record&lt;string, string&gt;&gt;) =&gt; void) =&gt; {
  const response = {
    statusCode: 200,
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
    body: JSON.stringify({
      api: PROJECT_NAME,
    }),
  };

  callback(null, response);
};</code></pre><p>We also need to modify in <code>apps/api/project.json </code></p><blockquote><p><code>&#8220;bundle&#8221;: true</code></p></blockquote><p>as this will ensure the entire code is bundled in a single output file to be used by Lambda.</p><h2>2.3. Web App</h2><p>In <code>apps/web/src/app/app.tsx </code>now we also leverage the shared library directly as well as call the API to receive a JSON payload that will contain the shared content, both of which we will display on the page:</p><pre><code>// eslint-disable-next-line @typescript-eslint/no-unused-vars
import styles from './app.module.css';
// this is the imported symbol from the shared library
import { PROJECT_NAME } from '@engineeringmindscape/shared';
import { useEffect, useState } from 'react';

export function App() {
  const [data, setData] = useState(null);
  useEffect(() =&gt; {
    // this is the environment variable from the .env file, 
    // which we will populate with the API URL after first deployment
    // as that is when we will know the URL of the API
    fetch(`${import.meta.env.VITE_API_URL}`)
      .then(response =&gt; response.json())
      .then(data =&gt; setData(data));
  }, []);

  return (
    &lt;div&gt;
      {PROJECT_NAME}
      {data &amp;&amp; &lt;div&gt;{JSON.stringify(data)}&lt;/div&gt;}
    &lt;/div&gt;
  );
}

export default App;
</code></pre><h4>Note</h4><p>The <code>VITE_API_URL</code> environment variable will be populated with the API's URL after its initial deployment, as that's when the API Gateway's URL becomes known. Ideally, to manage dependencies between stacks, the web application's build and deployment would follow the API's creation. However, prioritizing speed and simplicity, we'll perform the CDK deployment process twice, which will be detailed in section 2.5.</p><h2>2.4 IaC App</h2><p>In <code>apps/iac/cdk/IacApp.ts </code>we update the code of the entrypoint for the CDK app as follows:</p><pre><code>import * as cdk from 'aws-cdk-lib';
import { SampleStack } from './stacks/SampleStack';
// this is the imported symbol from the shared library
import {<em><strong>PROJECT_NAME</strong></em>} from '@engineeringmindscape/shared';

const app = new cdk.App();
new SampleStack(app, <em><strong>PROJECT_NAME</strong></em>, {
  env: {
    account: <em><strong>process</strong></em>.env.CDK_DEFAULT_ACCOUNT,
    region: <em><strong>process</strong></em>.env.CDK_DEFAULT_REGION,
  },
});
</code></pre><p>As well we need to edit the <code>apps/iac/cdk/stacks/SampleStack.ts </code>to actually deploy the appropriate API Gateway, Lambda, Roles, CloudWatch Log Groups, S3 Bucket and bucket deployment Lambda:</p><pre><code>// this is the imported symbol from the shared library
import {PROJECT_NAME} from '@engineeringmindscape/shared';
import { CfnOutput, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
import { ApiGatewayToLambda } from '@aws-solutions-constructs/aws-apigateway-lambda';
import { Construct } from 'constructs';
import * as api from 'aws-cdk-lib/aws-apigateway';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { BucketDeployment, Source } from 'aws-cdk-lib/aws-s3-deployment';

export class SampleStack extends Stack {
  constructor(construct: Construct, id: string, props?: StackProps) {
    super(construct, id, props);

    // AWS provided L3 constructs to deploy API Gateway -&gt; Lambda configuration
    new ApiGatewayToLambda(this, `${PROJECT_NAME}-API-GW-Lambda`, {
      lambdaFunctionProps: {
        functionName: `${PROJECT_NAME}-API-GW-Lambda`,
        runtime: lambda.Runtime.NODEJS_20_X,
        handler: 'main.handler',
        code: lambda.Code.fromAsset(`${__dirname}/../../../../dist/apps/api`),
      },
      apiGatewayProps: {
        restApiName: `${PROJECT_NAME}-API-GW`,
        defaultCorsPreflightOptions: {
          allowOrigins: api.Cors.ALL_ORIGINS,
          allowMethods: api.Cors.ALL_METHODS
        },
        defaultMethodOptions: {
          authorizationType: 'NONE'
        }
      },
    });

    const s3Bucket = new s3.Bucket(this, `${PROJECT_NAME}-S3-Bucket`, {
      removalPolicy: RemovalPolicy.DESTROY,
      bucketName: `${PROJECT_NAME.toLowerCase()}-monorepo-demo`,
      publicReadAccess: true,
      autoDeleteObjects: true,
      websiteIndexDocument: 'index.html',
      websiteErrorDocument: 'index.html',
      // required due to https://aws.amazon.com/about-aws/whats-new/2022/12/amazon-s3-automatically-enable-block-public-access-disable-access-control-lists-buckets-april-2023/
      objectOwnership: s3.ObjectOwnership.OBJECT_WRITER,
      blockPublicAccess: new s3.BlockPublicAccess({
        blockPublicAcls: false,
        ignorePublicAcls: false,
        blockPublicPolicy: false,
        restrictPublicBuckets: false,
      }),
    });

    // deploy web app to s3 bucket
    new BucketDeployment(this, `${PROJECT_NAME}-S3-Deployment`, {
      sources: [Source.asset(`${__dirname}/../../../../dist/apps/web`)],
      destinationBucket: s3Bucket,
      metadata: { ForceRedeployment: Date.now().toString() }
    });

    // output the S3 bucket URL
    new CfnOutput(this, `${PROJECT_NAME}-S3-Url-Output`, {
      value: s3Bucket.bucketWebsiteUrl,
    });
  }
}</code></pre><p>The above CDK stack while not production ready is very short and readable achieving the swiftness and conciseness criteria which are of utmost importance for this current endeavour.</p><h2>2.5. Building and Deploying</h2><p>Now that we have all the code in place, all that is left is to build and deploy:</p><blockquote><p><code>nx build api</code></p></blockquote><blockquote><p><code>nx build web</code></p></blockquote><p>Now to deploy it all (I assume you have an AWS account that is bootstrapped already, otherwise you also need to run the <strong>@nx-iac/aws-cdk:bootstrap </strong>command):</p><blockquote><p><code>nx deploy iac</code></p></blockquote><p>After deploying the whole stack, terminal will output something similar to</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EZp6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EZp6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 424w, https://substackcdn.com/image/fetch/$s_!EZp6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 848w, https://substackcdn.com/image/fetch/$s_!EZp6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 1272w, https://substackcdn.com/image/fetch/$s_!EZp6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EZp6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png" width="1456" height="1562" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1562,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:839942,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EZp6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 424w, https://substackcdn.com/image/fetch/$s_!EZp6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 848w, https://substackcdn.com/image/fetch/$s_!EZp6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 1272w, https://substackcdn.com/image/fetch/$s_!EZp6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35e1cf36-af1e-4658-b43f-3f03fcab1b45_1840x1974.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now as mentioned during the web app editing done in section 2.4, now that we have the <code>Outputs</code> from the stack, we can use the <code>APIGWLambdaRestApiEndpoint </code>value as follows:</p><blockquote><p><code>echo &#8220;&lt;APIGWLambdaRestApiEndpoint value&gt;&#8220; &gt; .env</code></p></blockquote><blockquote><p><code>nx build web</code></p></blockquote><blockquote><p><code>nx deploy iac</code></p></blockquote><p>Now we can finally access the second <code>Outputs</code> value of  <code>S3UrlOutput</code> to view our final result:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FOHw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FOHw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 424w, https://substackcdn.com/image/fetch/$s_!FOHw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 848w, https://substackcdn.com/image/fetch/$s_!FOHw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 1272w, https://substackcdn.com/image/fetch/$s_!FOHw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FOHw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png" width="1456" height="724" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:724,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:304086,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FOHw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 424w, https://substackcdn.com/image/fetch/$s_!FOHw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 848w, https://substackcdn.com/image/fetch/$s_!FOHw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 1272w, https://substackcdn.com/image/fetch/$s_!FOHw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdcf0f6f-28ea-4b3e-91a4-650555d1e1b1_2782x1384.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>When accessing the S3 website URL we are greeted with a plain page with the first row being the shared library <code>PROJECT_NAME</code> imported into the web project and build within the distributable. </p><p>The second row is the API Gateway Lambda response which also contains within the build distributable the shared library value, which we fetched and are displaying directly in the page.</p><p>Finally, the AWS CDK CloudFormation stack itself uses the value in the name of the Lambda, Stack and even in the S3 bucket name, which is visible client side as well by looking at the URL in the browser above.</p><h1>Conclusion</h1><p>In conclusion, the journey from initializing a monorepo with Nx to deploying a fully functional web application stack on AWS demonstrates the power and efficiency of modern development tools and practices. By leveraging Nx for project scaffolding, we benefit from a streamlined development process that integrates seamlessly with various technologies, including React for the front end, Node.js for the API backend, and AWS CDK for infrastructure-as-code management. This approach not only accelerates the setup phase but also ensures consistency and scalability across the entire project lifecycle.</p><p>The shared library concept further exemplifies the advantages of a monorepo setup, facilitating code reuse and maintaining consistency across different parts of the application. By centralizing shared definitions and functionalities, developers can ensure that changes in one area are automatically propagated throughout the project, reducing the risk of discrepancies and bugs.</p><p>Deploying the application stack using AWS CDK showcases the practical benefits of infrastructure-as-code, allowing for reproducible and predictable infrastructure provisioning. This method simplifies the deployment process, making it easier to manage and scale cloud resources efficiently. The integration of AWS solutions constructs further streamlines the creation of cloud resources, enabling developers to focus on building the application logic rather than managing infrastructure.</p><p>This post has outlined a comprehensive yet straightforward approach to kickstarting a web application project, from setup to deployment. By embracing these modern development practices and tools, developers can significantly reduce the time and effort required to bring their projects to life. Whether you're working on a pet project or a professional greenfield project, the methodology described here provides a solid foundation for developing robust, scalable, and maintainable web applications.</p><p>As always, the entire repository code for this solution can be found <a href="https://github.com/crisboarna/blog/tree/main/monorepo-fullstack">here</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Working around the AWS ECS Task Definition 65536 byte limit]]></title><description><![CDATA[How to rollout a container with thousands of environment variables within the service's hard limits]]></description><link>https://blog.engineermindscape.com/p/working-around-the-aws-ecs-task-definition</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/working-around-the-aws-ecs-task-definition</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Mon, 05 Feb 2024 14:00:20 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!94qT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!94qT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!94qT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!94qT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!94qT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!94qT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!94qT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp" width="1456" height="832" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:832,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:505548,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!94qT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!94qT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!94qT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!94qT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F625baca0-7574-4b0c-a9af-5988e1837429_1792x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h1>The problem</h1><p>In a recent project in which I undertook the modernization of a legacy monolithic Java application running on EC2 to modern &#8220;cattle not pets&#8221; in cloud native realm. If you are not familiar with the term, it was coined originally by Microsoft engineer Bill Baker regarding SQL deployments where</p><blockquote><p>Pets</p></blockquote><blockquote><p>Servers get unique names and special treatment. When they&#8217;re &#8220;sick&#8221;, they&#8217;re carefully nursed back to health, often with a significant time and financial investment.</p></blockquote><p>while </p><blockquote><p>Cattle</p></blockquote><blockquote><p>Individual servers are part of an identical group. Numbers, not names, identify them, and they receive no special treatment. When something goes wrong, the server is replaced, not repaired in place.</p></blockquote><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>After a laborious process that is out of scope for this topic, I finally reached the point of attempting to deploy the service on ECS, only to be welcomed by an error related to the task definition being limited to 65536 bytes.</p><p>This was quite the daunting error to encounter at the time as the Java application has gathered nearly a thousand environment variables in the past two decades and overall, due to them, the task definition is over the hard limit of the service. After a brief moment of dread, I set to apply my engineering mindset and find a workaround to this new limitation.</p><p>After a brief investigation I concluded that as the environment variables have all been extracted from a multitude of Spring <code>properties</code> files and injected via Terraform(conversion done via a script of course), the total storage required for the content and all of the final resulting JSON with all it&#8217;s metadata needed for the Task Definition exceeded the 65536 byte hard limit.</p><h1>The basic solution</h1><p>The solution I settled on was to coalesce the property files into fewer, functionality focused, and as part of the Terrafrom deployment, to leverage <a href="https://developer.hashicorp.com/terraform/language/functions/filebase64">filebase64</a> to encode the entire file into a single string that can be stored and keep the Task Definition within the limits. Alternatively, we can also leverage Terraform <code>data.local_file</code> as the .zip does not exist at the initial terraform run point, which would result in an error.</p><p>As the containers all have a custom <code>docker-entrypoint.sh</code> file, part of the boot sequence before <code>exec</code>-ing the main application, as part of the shell script, I take the environment variables, decode and place them in files based on the environment variable name, which follows a preset naming convention. In this way an environment variable named <code>FILE_HYSTRIX_PROPERTIES </code>would have the <code>FILE_</code> prefix dropped, the remainder converted to lower case and &#8220;_&#8221; replacted with &#8220;.&#8221; to yield <code>hystrix.properties</code> file with contents base64 decoded.</p><p>The shell script to achieve this would could look as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MKhO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MKhO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 424w, https://substackcdn.com/image/fetch/$s_!MKhO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 848w, https://substackcdn.com/image/fetch/$s_!MKhO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 1272w, https://substackcdn.com/image/fetch/$s_!MKhO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MKhO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png" width="1456" height="869" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:869,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:460262,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MKhO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 424w, https://substackcdn.com/image/fetch/$s_!MKhO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 848w, https://substackcdn.com/image/fetch/$s_!MKhO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 1272w, https://substackcdn.com/image/fetch/$s_!MKhO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc57179c3-3bf7-45dd-9790-c791ba7b71a3_1722x1028.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Full code at the end of the post</figcaption></figure></div><p>Now having done this we can be in one of the two following scenarions:</p><ol><li><p>Deployment successful, but brittle as we are already near the hard limit of the service and adding an additional trivial amount of variables or simply updating some of them to lengthier values could result in the definition exceeding the limit.</p></li><li><p>Deployment failed, as we are still over the limit even with these optimizations.</p></li></ol><h1>The improved solution</h1><p>As the properties files are just text files, we can obtain further significant storage gains by also doing a compression of the file before performing the <code>filebase64 / data.local_file.zip_file.content_base64</code>. As such, for each of our files we can do</p><pre><code>zip hystrix.zip hystrix.properties</code></pre><p>and reference the &#8220;.zip&#8221; instead of the raw file in the <code>filebase64</code> step.</p><p>This can yield us significant storage gains as below properties file zip showcases:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tkUD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tkUD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 424w, https://substackcdn.com/image/fetch/$s_!tkUD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 848w, https://substackcdn.com/image/fetch/$s_!tkUD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 1272w, https://substackcdn.com/image/fetch/$s_!tkUD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tkUD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png" width="1102" height="534" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:534,&quot;width&quot;:1102,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:194365,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tkUD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 424w, https://substackcdn.com/image/fetch/$s_!tkUD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 848w, https://substackcdn.com/image/fetch/$s_!tkUD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 1272w, https://substackcdn.com/image/fetch/$s_!tkUD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88a8a489-0ae7-4c0c-b616-a968e8487d93_1102x534.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><p>In Terraform these steps would look like the following:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!R5Yd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!R5Yd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 424w, https://substackcdn.com/image/fetch/$s_!R5Yd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 848w, https://substackcdn.com/image/fetch/$s_!R5Yd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!R5Yd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!R5Yd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png" width="1456" height="1064" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/247f51aa-e394-4078-b717-fc492634f255_1840x1344.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1064,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:576650,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!R5Yd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 424w, https://substackcdn.com/image/fetch/$s_!R5Yd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 848w, https://substackcdn.com/image/fetch/$s_!R5Yd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!R5Yd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F247f51aa-e394-4078-b717-fc492634f255_1840x1344.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Full code at the end of the post</figcaption></figure></div><p>This allows us to continue having the raw text files available for editing as opposed to storing them in encoded, zipped format and having to perform</p><ol><li><p>base64 decode </p></li><li><p>unzip </p></li><li><p>edit property</p></li><li><p>zip</p></li><li><p>base64 encode</p></li></ol><p>As we now also have zip files placed in the environment variables, we also need to expand our <code>docker-entrypoint.sh </code>to handle zipped base64 encoded variables.</p><p>The updated scripts looks as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pcmM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pcmM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 424w, https://substackcdn.com/image/fetch/$s_!pcmM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 848w, https://substackcdn.com/image/fetch/$s_!pcmM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 1272w, https://substackcdn.com/image/fetch/$s_!pcmM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pcmM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png" width="1456" height="1766" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1766,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:908753,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pcmM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 424w, https://substackcdn.com/image/fetch/$s_!pcmM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 848w, https://substackcdn.com/image/fetch/$s_!pcmM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 1272w, https://substackcdn.com/image/fetch/$s_!pcmM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83149793-8333-4df1-be8e-28cf5db6b8da_1812x2198.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/ecs-task-definition-limits-size/docker-entrypoint.sh">here</a></figcaption></figure></div><p>These encoded variables can then be referenced in the environment section of the task definition. If you are using the Terraform module for ECS, the code would look as below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!arNY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!arNY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 424w, https://substackcdn.com/image/fetch/$s_!arNY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 848w, https://substackcdn.com/image/fetch/$s_!arNY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!arNY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!arNY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png" width="1456" height="855" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:855,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:436885,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!arNY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 424w, https://substackcdn.com/image/fetch/$s_!arNY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 848w, https://substackcdn.com/image/fetch/$s_!arNY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!arNY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfa6b477-3dd5-4e6b-a2da-43a9b9d047dd_1830x1074.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>And as our container has the <code>docker-entrypoint.sh</code> as showcased above, the file will be decoded, unzipped and placed in the desired directory to be consumed by the application.</p><h1>The optimal solution</h1><p>While the above steps will significantly reduce the task definition size and most likely suffice for must usecases, if you have several large property files, you will still risk reaching the hard limit quickly, as the entirety of the data is still located within the task definition. The best approach would be to hold the data in a different &#8220;container&#8221; somewhere on AWS and only hold references to it within the definition specification.</p><p>It comes naturally then that the best location to hold these encoded variables would be within <strong>SSM Parameter Store</strong>(Systems Manager Parameter Store) as an <strong>Standard</strong>(4KB) or <strong>Advanced</strong>(8KB) parameter or within <strong>Secrets Manager</strong>(10KB). </p><p>The added benefit of this move is that we increase our security posture as we can apply more stringent IAM permissions on the parameters and secrets, denying read/write permission to them for developers while still allowing view/edit of the task definition itself.</p><p>Not only that but the main benefit of this approach is that if we were to have 9 theoretical variables of 8KB in size, the improved solution above would run into the ECS service limit of 65535 bytes. Moving them into SSM as an &#8220;<strong>Advanced</strong>&#8221; parameter, we would circumvent that limitation and be able to store countless more variables.</p><p>Immense gains for a very small change in the Terraform script from above:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mJDU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mJDU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 424w, https://substackcdn.com/image/fetch/$s_!mJDU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 848w, https://substackcdn.com/image/fetch/$s_!mJDU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 1272w, https://substackcdn.com/image/fetch/$s_!mJDU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mJDU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png" width="1456" height="1277" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1277,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:647929,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mJDU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 424w, https://substackcdn.com/image/fetch/$s_!mJDU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 848w, https://substackcdn.com/image/fetch/$s_!mJDU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 1272w, https://substackcdn.com/image/fetch/$s_!mJDU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc5f24ab-19ea-4103-898a-c885d445a94c_1840x1614.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Full GitHub source <a href="https://github.com/crisboarna/blog/blob/main/ecs-task-definition-limits-size/main.tf">here</a></figcaption></figure></div><h1>Conclusion</h1><p>In navigating the complexities of modernizing a legacy Java application for deployment on AWS ECS, the journey from encountering a daunting task definition limit to innovating a viable solution underscores the essence of cloud engineering: adaptability and problem-solving. The initial workaround, involving encoding and compressing environment variables, showcased creative engineering to fit within stringent constraints. However, the true breakthrough came with the optimization of utilizing AWS SSM Parameter Store and Secrets Manager to externalize configuration data, demonstrating a strategic pivot towards leveraging cloud-native services for scalability and efficiency.</p><p>This experience not only illustrates the technical challenges inherent in migrating to cloud-native architectures but also highlights the importance of embracing cloud services to enhance application deployment and management. By moving from a direct embedding of environment variables in the task definition to storing them in AWS's managed services, we not only circumvent the limitations of ECS but also gain the benefits of security, manageability, and scalability provided by AWS.</p><p>Such a journey is a testament to the evolving nature of cloud computing, where limitations are not roadblocks but rather catalysts for innovation. It emphasizes the need for continuous learning, experimentation, and adoption of cloud-native solutions to overcome challenges. As organizations continue to modernize their applications, this example serves as a reminder of the power of cloud services to transform application deployment strategies, ensuring they are both scalable and resilient in the face of changing technical landscapes.</p><p>In conclusion, the path from a constrained legacy application to a streamlined, cloud-native deployment is fraught with challenges. Yet, it is precisely these challenges that drive the innovation and strategic thinking necessary to leverage the full potential of cloud computing. By adopting a mindset that views limitations as opportunities for optimization, organizations can navigate the complexities of modernization with confidence, ensuring their applications are not only compatible with the cloud but are also positioned to take full advantage of its capabilities.</p><p>The example codebase for this can be found <a href="https://github.com/crisboarna/blog/tree/main/ecs-task-definition-limits-size">here</a>. </p><p>It contains a minimal example ECS cluster with a task definition of a custom image built on top of alpine. It copies the custom <code>docker-entrypoint.sh</code> and sets the command that will be executed after the scripts completion, which in our case will be to print the contents of the <code>/tmp/hystrix.properties</code>, which is where we have <code>CONFIG_DIR</code> pointig to (/tmp) and where our local <code>hystrix.properties</code> should be placed. </p><p>You can run it via</p><blockquote><p>terraform init &amp;&amp; terraform apply -auto-approve</p></blockquote><p>Once it completes, we can check the logs which outputs the <code>/tmp/hystrix.properties</code> from the container by running</p><blockquote><p>aws logs tail /aws/ecs/EngineeringMindscape-Task-Limits-DEV/example</p></blockquote><p>which should output the following:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3uTw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3uTw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 424w, https://substackcdn.com/image/fetch/$s_!3uTw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 848w, https://substackcdn.com/image/fetch/$s_!3uTw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 1272w, https://substackcdn.com/image/fetch/$s_!3uTw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3uTw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png" width="1456" height="707" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:707,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:551217,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3uTw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 424w, https://substackcdn.com/image/fetch/$s_!3uTw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 848w, https://substackcdn.com/image/fetch/$s_!3uTw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 1272w, https://substackcdn.com/image/fetch/$s_!3uTw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feac762ed-70b0-4139-9c14-49ca0a774ffc_1840x894.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Building and Deploying a React CV on AWS S3 with TypeScript: A Deep Dive into Headless Chromium with Puppeteer, AWS CDK, Custom Lambda Docker Runtimes and GitHub Actions - Part 2]]></title><description><![CDATA[This is the second part in the series covering my beautifully engineered CV where we will cover the DevOps aspects of the project, namely, the creation of the AWS infrastructure and the CI/CD setup to bind it all together seamlessly.]]></description><link>https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv-800</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv-800</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Tue, 30 Jan 2024 07:30:56 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Xpww!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Xpww!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Xpww!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Xpww!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Xpww!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Xpww!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Xpww!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:160938,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Xpww!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Xpww!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Xpww!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Xpww!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80885b0c-281b-40e3-a96c-72a0785eb798_1024x1024.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is the second part in the series covering my beautifully engineered CV where we will cover the DevOps aspects of the project, namely, the creation of the AWS infrastructure and the CI/CD setup to bind it all together seamlessly.</p><p>In the first part, which you can read <a href="https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv">here</a>, we covered the bootstrapping of the Nx monorepo, the creation of the React CV website and of the Lambda Exporter that leverages headless Chromium orchestrated by Puppeteer to save a PDF of the CV.</p><p>We will be now be using AWS CDK(AWS Cloud Development Kit - a modern Java,NodeJS,Go, .NET interface that gets synthesized to CloudFormation JSON templates and applied as CloudFormation stacks) for the IaC aspects as it allows us to benefit from having the front-end, back-end and IaC in one language, sharing configuration and symbols without having to deal with duplicate code.</p><p></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://blog.engineermindscape.com/subscribe?"><span>Subscribe now</span></a></p><h1>1. Infrastructure</h1><p>While having it all run locally is great, unfortunately it is not visible to the rest of the world, so we need to deploy it somewhere the world can access it, which for us is on AWS S3 with a CloudFront CDN(Content Delivery Network).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!b5yx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!b5yx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!b5yx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!b5yx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!b5yx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!b5yx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!b5yx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!b5yx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!b5yx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!b5yx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4f74b61c-6320-4c10-8cfd-9ed01a256def_3840x2160.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">AWS Architectural Diagram</figcaption></figure></div><p>There are 3 main component stacks for this setup:</p><ul><li><p>ECR</p><ul><li><p>Simple and straightforward stack that creates the Elastic Container Registry that will hold our Lambda Docker Runtime image and that the Lambda service will pull from.</p></li></ul></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MkdI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MkdI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 424w, https://substackcdn.com/image/fetch/$s_!MkdI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 848w, https://substackcdn.com/image/fetch/$s_!MkdI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 1272w, https://substackcdn.com/image/fetch/$s_!MkdI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MkdI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png" width="1456" height="1306" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1306,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:588530,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MkdI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 424w, https://substackcdn.com/image/fetch/$s_!MkdI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 848w, https://substackcdn.com/image/fetch/$s_!MkdI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 1272w, https://substackcdn.com/image/fetch/$s_!MkdI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb80cd31f-0d7e-45a0-b507-8cdd2de53154_1648x1478.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/apps/infra/src/lib/ecr/EcrStack.ts">here</a></figcaption></figure></div><p>As I am not expecting any advanced and complicated use-case scenarios, I am keeping it simple, with only <code>latest</code> tag and lifecycle rule to only have one image thus reducing costs.</p><ul><li><p>Lambda Exporter function</p><ul><li><p>Lightweight stack centered around a <code>DockerImageFunction</code>, which is the L3 AWS CDK construct (higher level CDK language object providing more error checking, configurations and resource interconnection) equivalent of a CloudFormation <code>AWS::Lambda::Function</code> with code pointing to the above ECR image registry, with versioning and aliasing alongside a role with minimal permissions configuration.</p></li></ul></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-Yvw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Yvw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 424w, https://substackcdn.com/image/fetch/$s_!-Yvw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 848w, https://substackcdn.com/image/fetch/$s_!-Yvw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 1272w, https://substackcdn.com/image/fetch/$s_!-Yvw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Yvw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png" width="1456" height="4532" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4532,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1789879,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-Yvw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 424w, https://substackcdn.com/image/fetch/$s_!-Yvw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 848w, https://substackcdn.com/image/fetch/$s_!-Yvw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 1272w, https://substackcdn.com/image/fetch/$s_!-Yvw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1285ee10-9a75-4fba-9630-de1310725b6e_1776x5528.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/apps/infra/src/lib/exporter/ExporterStack.ts">here</a></figcaption></figure></div><ul><li><p>React Web</p><ul><li><p>This is more involved compared to the other two as it also deals with <a href="https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html">ACM</a> certificates, S3 bucket with it&#8217;s policies, CDN, WAF, S3 deployment of website bundle and of PDF via CloudFormation Custom Resource.</p></li><li><p>On each run of the <code>WebStack </code>deployment, the web bundle is deployed via the <code>BucketDeployment</code> construct, the <code>CustomResource</code> is triggered which runs the Lambda to export the latest deployed website bundle as a PDF to be readily available for download for anybody browsing the deployed website.</p></li></ul></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6qdQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6qdQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 424w, https://substackcdn.com/image/fetch/$s_!6qdQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 848w, https://substackcdn.com/image/fetch/$s_!6qdQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 1272w, https://substackcdn.com/image/fetch/$s_!6qdQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6qdQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png" width="1456" height="8541" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:8541,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3127936,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!6qdQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 424w, https://substackcdn.com/image/fetch/$s_!6qdQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 848w, https://substackcdn.com/image/fetch/$s_!6qdQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 1272w, https://substackcdn.com/image/fetch/$s_!6qdQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e944b2d-1241-4383-b244-b1b6e5bffeb4_1840x10794.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub Source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/apps/infra/src/lib/web/WebStack.ts">here</a></figcaption></figure></div><p>These can be run directly with the <code>cdk</code> CLI(Command Line Interface) with a few extra parameters being required due to the monorepo context resulting in the below mouthful:</p><blockquote><p><code>cdk synth -q -a 'npx ts-node --prefer-ts-exts -P apps/infra/tsconfig.app.json -r tsconfig-paths/register -r dotenv/config apps/infra/src/bin/&lt;ECR|Exporter|Web&gt;.ts</code></p></blockquote><p>or by creating utility Nx scripts to bring it down to a more memorable</p><blockquote><p><code>nx deploy infra</code></p></blockquote><p>which seems more memorable and easier to type.</p><p>This of course has the precursor dependency of having to obtain a domain, have a hosted zone for it AWS <a href="https://aws.amazon.com/route53/">Route53</a>. The domain can be either directly purchased there or with a custom Hosted Zone to which you direct the <code>NS </code>in your registrar of choice.</p><h1>2. GitHub Actions CI/CD</h1><p>The fourth and final step in the story, which enables us to edit our CV&#8217;s JSON files, run <code>git commit</code>, <code>git push</code> and have the linting, testing, building, deploying, semversioning and releasing done automatically is by setting up our GitHub Actions pipelines. We will have two pipelines, one triggered by a pull request which only does the evaluation of the validity of our commit and another for merges on main, which does the full suite of evaluation, building &amp; deploying.</p><h2>2.1 Pull Requests</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LLHq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LLHq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 424w, https://substackcdn.com/image/fetch/$s_!LLHq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 848w, https://substackcdn.com/image/fetch/$s_!LLHq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 1272w, https://substackcdn.com/image/fetch/$s_!LLHq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LLHq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png" width="1456" height="3342" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3342,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1363468,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LLHq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 424w, https://substackcdn.com/image/fetch/$s_!LLHq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 848w, https://substackcdn.com/image/fetch/$s_!LLHq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 1272w, https://substackcdn.com/image/fetch/$s_!LLHq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e92c830-327a-4cb1-8b1e-c38313af0c4f_1840x4224.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/.github/workflows/pull_request.yaml">here</a></figcaption></figure></div><p>The step names are self-explanatory and all adhere to the single responsibility principle, they do only one thing, be it setup a a dependency or running a process. </p><p>This <code>verify </code>ensures any new pull request has passed linting, testing, building of web, exporter, exporter Docker image and of all the AWS CDK stacks by chaining the builds from the root repository</p><blockquote><p><code>yarn build</code> </p></blockquote><p>to </p><blockquote><p><code>nx run-many --all --target=build</code></p></blockquote><p>Same principle applies to <code>lint</code> and <code>test</code>.</p><h3>Note</h3><p>Although we do not do any deploying in this step, we have here the &#128273; AWS Credentials step as the CDK build does a synthesis of the CloudFormation stacks, which requires authenticated access to the target account.</p><p>The &#129520; Setup QEMU and &#129520; Setup Docker BuildX are needed to be able to run docker build via the <code>docker/build-push-action@v5</code> action.</p><h2>2.2 Merging to main</h2><p>Merging to main pipeline has the same verify job (you can get code on a branch through other means besides that of a pull requests :) ) with an added deploy job, which has the same setup steps as the <code>verify</code> job, with the added deployment steps of:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0XAf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0XAf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 424w, https://substackcdn.com/image/fetch/$s_!0XAf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 848w, https://substackcdn.com/image/fetch/$s_!0XAf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 1272w, https://substackcdn.com/image/fetch/$s_!0XAf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0XAf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png" width="1456" height="3094" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3094,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1302283,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0XAf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 424w, https://substackcdn.com/image/fetch/$s_!0XAf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 848w, https://substackcdn.com/image/fetch/$s_!0XAf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 1272w, https://substackcdn.com/image/fetch/$s_!0XAf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff2ba2022-7037-438e-9b11-7743369c40cd_1840x3910.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/.github/workflows/merge_main.yaml">here</a></figcaption></figure></div><p>As I have ensured all the steps can be run from local first before I spent time in setting up any pipeline, it makes sense that most of the content of the pipeline definition is simply delegating the work to the appropriate Yarn and Nx scripts that trigger AWS CDK CloudFormation synthesis with the addition of injecting the appropriate environment variables.</p><p>The cherry on top of the cake is the &#128640; Release step which runs </p><blockquote><pre><code>semantic-release</code></pre></blockquote><p>that reads all of the commits from the last tag to <code>HEAD</code> and based on <a href="https://www.conventionalcommits.org/en/v1.0.0/">conventional commits</a> message formatting increments <code>MAJOR</code>.<code>MINOR</code>.<code>PATCH</code> version appropriately.</p><p>To ensure the commit messages always follow a pattern that <code>semantic-release</code> can parse, we use <code>husky</code> to setup git <code>commit-msg </code>hook to run</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!W9Nn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!W9Nn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 424w, https://substackcdn.com/image/fetch/$s_!W9Nn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 848w, https://substackcdn.com/image/fetch/$s_!W9Nn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 1272w, https://substackcdn.com/image/fetch/$s_!W9Nn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!W9Nn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png" width="1040" height="624" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5413c49-fac0-489e-a78a-19357246610d_1040x624.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:624,&quot;width&quot;:1040,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:203207,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!W9Nn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 424w, https://substackcdn.com/image/fetch/$s_!W9Nn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 848w, https://substackcdn.com/image/fetch/$s_!W9Nn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 1272w, https://substackcdn.com/image/fetch/$s_!W9Nn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5413c49-fac0-489e-a78a-19357246610d_1040x624.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>with <code>cz-conventional-changelog</code> plugin. In this manner we can be sure that we never push a commit that does not adhere to the standard.</p><h1>Conclusion</h1><p>Over the course of this two-part series, we've embarked on a comprehensive journey through the development and deployment of a modern, dynamic CV. From the initial bootstrapping of the Nx monorepo and crafting a React-based CV in part one, to the intricate DevOps orchestration involving AWS infrastructure and CI/CD pipelines in part two, this project has been a testament to the power of combining cutting-edge web development with robust DevOps practices.</p><h3>Key Takeaways</h3><ul><li><p><strong>Streamlined Development:</strong> By leveraging tools like AWS CDK and GitHub Actions, we've demonstrated how complex infrastructure and deployment processes can be streamlined, making them more efficient and less prone to error.</p></li><li><p><strong>Rapid Deployment and Scalability:</strong> The use of Docker, CloudFront CDN, and serverless technologies ensures that our applications are not only rapidly deployable but also scalable to meet varying demands.</p></li><li><p><strong>Automated Workflows:</strong> The integration of CI/CD pipelines exemplifies the automation of testing, building, and deployment processes, significantly reducing manual effort and enhancing productivity.</p></li></ul><p>The methodologies and technologies employed in this project are not confined to personal CV development. They can be seamlessly adapted to a wide range of applications, from e-commerce websites to complex enterprise-level solutions. The principles of automation, scalability, and efficient deployment are universally applicable, offering a blueprint for future projects that demand high availability, rapid scalability, and continuous integration/delivery.</p><p>I'm curious to hear about your experiences. Have you undertaken a project that combines web development, backend event driven processes with DevOps in a similar manner? What challenges did you face, and how did you overcome them? Additionally, I welcome any suggestions or insights you might have. Perhaps there's an aspect of DevOps or a particular technology you've found particularly useful or challenging? Let's start a conversation in the comments below and learn from each other's experiences in this ever-evolving field of web development, backend development and DevOps.</p><p>You can find the entire code for this series <a href="https://github.com/crisboarna/react-cv">here</a> and the final product <a href="https://cv.crisboarna.com">here</a>.</p><p></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://blog.engineermindscape.com/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item><item><title><![CDATA[Building and Deploying a React CV on AWS S3 with TypeScript: A Deep Dive into Headless Chromium with Puppeteer, AWS CDK, Custom Lambda Docker Runtimes and GitHub Actions - Part 1]]></title><description><![CDATA[Building and updating a beautiful CV locally with Nx Monorepos, React, Puppeteer, Headless Chromium and Docker.]]></description><link>https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/building-and-deploying-a-react-cv</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Mon, 29 Jan 2024 14:38:25 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!gfdf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gfdf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gfdf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 424w, https://substackcdn.com/image/fetch/$s_!gfdf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 848w, https://substackcdn.com/image/fetch/$s_!gfdf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!gfdf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gfdf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg" width="724" height="724" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:724,&quot;bytes&quot;:143661,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gfdf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 424w, https://substackcdn.com/image/fetch/$s_!gfdf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 848w, https://substackcdn.com/image/fetch/$s_!gfdf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!gfdf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa68c948b-e1fa-485a-97cb-3e3f2ab35620_1024x1024.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this two-part series, I'll detail how I transformed my CV into a dynamic, automated, and easily accessible digital asset. Usually when you think of getting your CV you have to go to Drive, iCloud, Dropbox or Office 365 to export the latest PDF. Additionally, while writing the CV, you not only have to wrangle with the content but also with the layout, having to deal with every indentation block, image alignment and column header. </p><p>A popular solution for the second option is to use tools such as LaTeX, a tool which is used extensively in the academic world for this exact purpose. But even so, the first issue is still present, your CV is not readily available to be handed over.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>To fix the above pain points and more, as an engineer, I have done what engineers do and I went and engineered a solution to my problem and here I will outline the steps I have gone through to attain this goal. At the end of it, the CV is be versioned, linted, tested, has IaC, is CDN hosted, has CI/CD and is available for download at a click of button. The end result is available at <a href="https://cv.crisboarna.com">cv.crisboarna.com</a>.</p><p>The steps I have to follow now to update my CV are as follows:</p><ol><li><p>Open .json file containing relevant section of my CV.</p></li><li><p>Perform relevant edits.</p></li><li><p><code>git commit</code></p></li><li><p><code>git push</code></p></li><li><p>???</p></li><li><p>Profit!</p></li></ol><p>The CI/CD pipeline takes cares of the rest and the website cv.crisboarna.com and downloadable PDF are available within 5 minutes with no further input from me. I even get an email to notify me of the latest version being published.</p><p>To obtain the end result I am using <a href="https://nx.dev/">Nx</a> monorepo with 3 apps. As there are several components that all share common symbols, such as the name of the file and all services are written in the same language, I am leveraging a powerful tool, Nx, to bootstrap and increase my development agility. Nx is similar to Lerna and Yarn workspaces in that it handles the wiring between microservices but excels beyond the competition in DevEx and bootstrapping capabilities for different use cases. There are 4 main services that coalesce to achieve the end result hosted at the above link:</p><ul><li><p>@nx/react CV website </p><ul><li><p>This is the actual CV, written in React</p></li></ul></li><li><p>Exporter Lambda Function</p><ul><li><p>This is the CloudFormation Custom Resource Lambda leveraging Docker Custom Runtime with Puppeteer driven Chromium headless browser for PDF exporting</p></li></ul></li><li><p>Infrastructure code</p><ul><li><p>AWS CDK NodeJS IaC(Infrastructure-as-Code) for ECR(Docker image hosting), Lambda(above exporter), S3 bucket(website distributable hosting), CloudFront CDN(web front to serve files)</p></li></ul></li><li><p>GitHub Actions</p><ul><li><p>Glue that binds all of the above together to lint, test, build, deploy on every pull request and merge to main.</p></li></ul></li></ul><p>The first two development focused points are the subject of this post and the last two DevOps focused points are the subject of the next post.</p><p>I have done this many years ago but after revisiting and updating all of the dependencies, I have run into a couple of issues that prompted a more involved refactor, the result of which is detailed here.</p><p>The Functions-as-a-Service (FaaS) offerings have been a godsend that have significantly reduced the boilerplate needed to run one-time applications in an event-driven context but sometimes you need an escape hatch to perform more advanced actions.</p><p>One such scenario is when you want to have Puppeteer orchestrate a headless Chromium browser in order to perform a PDF export of a specific web page. I have done this historically using the <a href="https://www.npmjs.com/package/chrome-aws-lambda">chrome-aws-lambda</a> NPM package that contains a pre-built binary of Chromium leveraging default AWS provided NodeJS Lambda runtimes. Unfortunately this package has since seemingly been abandoned with no support for versions of NodeJS &gt;=16 combined with AWS deprecating the AWS Lambda NodeJS 14 runtime, the impetus has been given to search for alternative solutions.</p><p>While there now exists <a href="https://www.npmjs.com/package/@sparticuz/chromium">@sparticuz/chromium</a> to carry on the torch of this, with a well defined lockstep with latest Chromium Testing versions, the local testing solution suggested does not an ensure apple-to-apples comparison between the local and Lambda results which resulted in PDF&#8217;s that looked vastly different between local and Lambda.</p><p>Another issue is the above mentioned AWS deprecation of runtime versions which would manifest itself in the future for NodeJS 20.x as it has now for NodeJS 14.x at an inappropriate moment.</p><p>As such given the above, I have set to leverage the provided &#8220;escape hatch&#8221; provided by AWS and create my own custom AWS Lambda Runtime Docker image.</p><h2>1. CV Website</h2><p>This is a standard <code>@nx/react</code> bootstraped website with TypeScript and CSS modules and Webpack bundling. The content of my CV is stored within JSON files for each section and in similar vein to LaTeX, I just write the content and React deals with laying it out on the page.</p><p>There are some particularities of course as I have a 2 page A4 CV, there is special care needed at the page break so it does not cut the text midway.</p><p>The web application code can be found <a href="https://github.com/crisboarna/react-cv/tree/master/apps/web">here</a>. You can also run it locally or via Docker:</p><blockquote><p><code>nx serve web</code> </p></blockquote><blockquote><p><code>docker compose up web</code> </p></blockquote><h2>2. Exporter Lambda Function</h2><p>This is the Lambda that runs a headless Chromium browser using <a href="https://pptr.dev/">Puppeteer</a> to load the web application and create a PDF export of it. It passes query parameters that hide the top Download and GitHub buttons for the PDF to only contain the CV itself.</p><p>The code itself is straightforward but custom enough to not be able to directly leverage a Puppeteer Docker image.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d4QW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d4QW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 424w, https://substackcdn.com/image/fetch/$s_!d4QW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 848w, https://substackcdn.com/image/fetch/$s_!d4QW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 1272w, https://substackcdn.com/image/fetch/$s_!d4QW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!d4QW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png" width="1456" height="4311" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4311,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1497243,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!d4QW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 424w, https://substackcdn.com/image/fetch/$s_!d4QW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 848w, https://substackcdn.com/image/fetch/$s_!d4QW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 1272w, https://substackcdn.com/image/fetch/$s_!d4QW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3bb9103d-837b-4ddc-872b-09dbe8fe4018_1594x4720.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/apps/exporter/src/main.ts">here</a></figcaption></figure></div><p>This code is built leveraging <code>esbuild</code> which creates similarly to webpack a bundle of the code and all third party dependnecies into a single main.js as this will be shipped in the Docker image for Lambda to run, so it does not need any splitting. </p><p>Due to the <code>@sparticuz/chromium</code> dependency containing binary elements, it is ignored from the bundle and installed directly within the container.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sjqG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sjqG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 424w, https://substackcdn.com/image/fetch/$s_!sjqG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 848w, https://substackcdn.com/image/fetch/$s_!sjqG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 1272w, https://substackcdn.com/image/fetch/$s_!sjqG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sjqG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png" width="1456" height="751" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:751,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:334529,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sjqG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 424w, https://substackcdn.com/image/fetch/$s_!sjqG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 848w, https://substackcdn.com/image/fetch/$s_!sjqG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 1272w, https://substackcdn.com/image/fetch/$s_!sjqG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9995553-1067-4547-a92a-c9efd8897e5a_1558x804.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/v1.7.0/apps/exporter/Dockerfile">here</a></figcaption></figure></div><p>At this point the Web and Exporter services can come together locally with the help of a simple docker-compose.yaml to be able to view the end result CV PDF saved on the repository root.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Gf3l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Gf3l!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 424w, https://substackcdn.com/image/fetch/$s_!Gf3l!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 848w, https://substackcdn.com/image/fetch/$s_!Gf3l!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 1272w, https://substackcdn.com/image/fetch/$s_!Gf3l!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Gf3l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png" width="1456" height="1704" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1704,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:724755,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Gf3l!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 424w, https://substackcdn.com/image/fetch/$s_!Gf3l!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 848w, https://substackcdn.com/image/fetch/$s_!Gf3l!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 1272w, https://substackcdn.com/image/fetch/$s_!Gf3l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01acf19f-d199-420d-b347-b000c2c8a123_1840x2154.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/react-cv/blob/4d172956f61e4cd3ac293551df4cbe784b285e95/docker-compose.yaml">here</a></figcaption></figure></div><h3>Troubleshooting</h3><p>A particular stumbling block that I encountered due to being on an ARM64 CPU running Chromium: </p><blockquote><p><code>qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory</code></p></blockquote><p>Upon investigating I realized that only now is the Chrome team starting to roll out ARM builds for Chrome and the container having Linux ARM64 architecture would error out elusively with the above message which can easily be solved by adding </p><p>&#8220;<em>platform: linux/amd64</em>&#8221; to your compose file.</p><p>If you are to run it now, you will get a new error, namely:  </p><blockquote><p><code>qemu: uncaught target signal 11 (Segmentation fault) - core dumped </code></p></blockquote><p>which is even <strong>more</strong> elusive than the last. To cut the store short, the solution to this is to enable</p><blockquote><p>Docker Desktop &gt; Features in development &gt; Use Rosetta for x86/amd64 emulation on Apple Silicon.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iHQ1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iHQ1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 424w, https://substackcdn.com/image/fetch/$s_!iHQ1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 848w, https://substackcdn.com/image/fetch/$s_!iHQ1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!iHQ1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iHQ1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png" width="1456" height="803" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:803,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:351448,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iHQ1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 424w, https://substackcdn.com/image/fetch/$s_!iHQ1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 848w, https://substackcdn.com/image/fetch/$s_!iHQ1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 1272w, https://substackcdn.com/image/fetch/$s_!iHQ1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F665cc6f4-fbcb-4b72-9608-03fabfee82b2_2438x1344.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Docker Desktop Settings</figcaption></figure></div><p>These last few items only apply if you are on a M-Series Mac of course.</p><p>Now we are ready to start the web and the exporter services up and view our publishable CV website and downloadable CV PDF locally through the following 3 commands in 3 separate terminals:</p><blockquote><p><code>nx serve:docker web</code></p></blockquote><blockquote><p><code>nx serve:docker exporter</code></p></blockquote><blockquote><p><code>curl "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'</code></p></blockquote><p>The first two commands start the services and the last one invokes the Lambda runtime with an empty payload to trigger our handler which will access the CV website within the Docker network on <strong>&#8216;http://cv_web:4200&#8217;</strong>, as that is the configured <strong>hostname</strong> we have given the React service container and we have configured webpack for <strong>&#8216;0.0.0.0&#8217;</strong> to listen on all adapters and accept connections from &#8216;<strong>all&#8217;.</strong></p><h1>Conclusion</h1><p>I have described above how we can leverage the power of Nx monorepos to manage React &amp; NodeJS applications and used Docker to create a custom AWS Lambda Runtime image. We also encountered and resolved issues related to running Chromium on an ARM64 CPU.</p><p>In the next part of this blog post series, we will delve into the details of setting up the Infrastructure-as-Code (IaC) using AWS CDK NodeJS and how I used GitHub Actions to automate the process of linting, testing, building, and deploying our applications. We will also discuss how I managed to host our Docker image on ECR, set up our Lambda function, and host our website distribution on an S3 bucket with CloudFront CDN. </p><p>This is a clean and beautiful approach to solving the discoverability issue of our CV while applying true and tested techniques for linting, testing, versioning and showcasing our abilities.</p><p>Please share your suggestions and opinions on my approach to solving this, I am curious to see what ideas other have and how this can be improved upon !</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Locally Testing Custom AWS Lambda Runtime Containers with Runtime Emulator Sidecar]]></title><description><![CDATA[Invoke Lambda's without adding the Lambda Runtime Interface Emulator locally or in the container]]></description><link>https://blog.engineermindscape.com/p/locally-testing-custom-aws-lambda</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/locally-testing-custom-aws-lambda</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Sun, 28 Jan 2024 07:25:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!cVLn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cVLn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cVLn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!cVLn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!cVLn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!cVLn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cVLn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1639286,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cVLn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!cVLn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!cVLn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!cVLn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a30827b-47c1-4f77-9c43-4312a79ecbd1_1024x1024.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Sharing the volume is caring.</figcaption></figure></div><p>Given that we are living in the 2020&#8217;s, having to install various small utility packages in order to interact with applications and tooling software is quite old fashioned, error prone and non-reproducable.</p><p>This has been solved historically with writing documentation that may go out of date / sync with the code or small scripts that achieve the goal but leave artifacts laying around. Not to mention that with the advent of </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>One such scenario I have encountered recently is when trying to create a custom AWS Lambda Runtime using an custom base image that requires installing <a href="https://docs.aws.amazon.com/lambda/latest/dg/nodejs-image.html#nodejs-image-clients">aws-lambda-ric</a> and testing it out locally.</p><p>Based on the above, on AWS&#8217;s recommendation, we need to download and make available the executable of the <a href="https://github.com/aws/aws-lambda-runtime-interface-emulator">aws-lambda-rie</a>, an emulator that allows us to invoke via <code>curl</code> the Lambda.</p><p>Now the trick is to create a lightweight Docker container with the executable, under the same architecture as your Lambda:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kIPS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kIPS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 424w, https://substackcdn.com/image/fetch/$s_!kIPS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 848w, https://substackcdn.com/image/fetch/$s_!kIPS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 1272w, https://substackcdn.com/image/fetch/$s_!kIPS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kIPS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png" width="1456" height="1098" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1098,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:655398,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kIPS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 424w, https://substackcdn.com/image/fetch/$s_!kIPS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 848w, https://substackcdn.com/image/fetch/$s_!kIPS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 1272w, https://substackcdn.com/image/fetch/$s_!kIPS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2fe88bcd-35d0-4d40-948a-ce9be6c0d02b_1840x1388.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/lambda-custom-runtime/rie.Dockerfile">here</a>.</figcaption></figure></div><p>The above will then be leveraged in a local <code>docker-compose.yaml</code> as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Gx7w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Gx7w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 424w, https://substackcdn.com/image/fetch/$s_!Gx7w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 848w, https://substackcdn.com/image/fetch/$s_!Gx7w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 1272w, https://substackcdn.com/image/fetch/$s_!Gx7w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Gx7w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png" width="1456" height="1348" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1348,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:615578,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Gx7w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 424w, https://substackcdn.com/image/fetch/$s_!Gx7w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 848w, https://substackcdn.com/image/fetch/$s_!Gx7w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 1272w, https://substackcdn.com/image/fetch/$s_!Gx7w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54d74cc3-a76a-419d-9f44-ee10b4941f14_1840x1704.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/lambda-custom-runtime/docker-compose.yaml">here</a>.</figcaption></figure></div><p>The most interesting part to see is that in the above Dockerfile we unpackage and set the executable in <code>/rie-bin</code>, which is a mounted Docker volume on the same path in the <code>docker-compose.yaml</code>. This is then shared at the same time with the Lambda container on the same path, effectively sharing the executable across the containers.</p><p>The Lambda container is based on the AWS example <a href="https://docs.aws.amazon.com/lambda/latest/dg/nodejs-image.html#nodejs-image-clients">here</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!uWpN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!uWpN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 424w, https://substackcdn.com/image/fetch/$s_!uWpN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 848w, https://substackcdn.com/image/fetch/$s_!uWpN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 1272w, https://substackcdn.com/image/fetch/$s_!uWpN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!uWpN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png" width="1456" height="2124" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/be3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2124,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:870922,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!uWpN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 424w, https://substackcdn.com/image/fetch/$s_!uWpN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 848w, https://substackcdn.com/image/fetch/$s_!uWpN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 1272w, https://substackcdn.com/image/fetch/$s_!uWpN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe3df2ae-23b2-47a2-93d1-1427b425670e_1630x2378.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/lambda-custom-runtime/lambda.Dockerfile">here</a>.</figcaption></figure></div><p>Which contains a simple NodeJS Lambda handler:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!p-H7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!p-H7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 424w, https://substackcdn.com/image/fetch/$s_!p-H7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 848w, https://substackcdn.com/image/fetch/$s_!p-H7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 1272w, https://substackcdn.com/image/fetch/$s_!p-H7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!p-H7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png" width="1248" height="714" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:714,&quot;width&quot;:1248,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:264178,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!p-H7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 424w, https://substackcdn.com/image/fetch/$s_!p-H7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 848w, https://substackcdn.com/image/fetch/$s_!p-H7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 1272w, https://substackcdn.com/image/fetch/$s_!p-H7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8877fb19-d3a3-4512-b107-16bbf220de55_1248x714.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">GitHub source <a href="https://github.com/crisboarna/blog/blob/main/lambda-custom-runtime/main.js">here</a>.</figcaption></figure></div><p>And it all comes together for a &#8216;no straggler left behind&#8217; approach as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FP2z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FP2z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 424w, https://substackcdn.com/image/fetch/$s_!FP2z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 848w, https://substackcdn.com/image/fetch/$s_!FP2z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 1272w, https://substackcdn.com/image/fetch/$s_!FP2z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FP2z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png" width="1456" height="423" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:423,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:267389,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FP2z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 424w, https://substackcdn.com/image/fetch/$s_!FP2z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 848w, https://substackcdn.com/image/fetch/$s_!FP2z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 1272w, https://substackcdn.com/image/fetch/$s_!FP2z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F063aaebb-1541-48a5-85ff-9017036b6eb5_1840x534.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal 1 output.</figcaption></figure></div><p>Now from a separate terminal we can use <code>curl </code>to invoke the function:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N6hE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N6hE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 424w, https://substackcdn.com/image/fetch/$s_!N6hE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 848w, https://substackcdn.com/image/fetch/$s_!N6hE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 1272w, https://substackcdn.com/image/fetch/$s_!N6hE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N6hE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png" width="1456" height="407" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:407,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:235533,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!N6hE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 424w, https://substackcdn.com/image/fetch/$s_!N6hE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 848w, https://substackcdn.com/image/fetch/$s_!N6hE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 1272w, https://substackcdn.com/image/fetch/$s_!N6hE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8c75776-5341-4ddf-9121-bba3e691ff28_1776x496.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal 2 output.</figcaption></figure></div><p>As we can see we invoked the function on the AWS Lambda standard path and got the response returned from the Lambda once it completes execution. In Terminal 1 where the Lambda is running, we can see the same output we see in CloudWatch Logs when viewing the output:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BLwZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BLwZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 424w, https://substackcdn.com/image/fetch/$s_!BLwZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 848w, https://substackcdn.com/image/fetch/$s_!BLwZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 1272w, https://substackcdn.com/image/fetch/$s_!BLwZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BLwZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png" width="1456" height="1206" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1206,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:868201,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!BLwZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 424w, https://substackcdn.com/image/fetch/$s_!BLwZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 848w, https://substackcdn.com/image/fetch/$s_!BLwZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 1272w, https://substackcdn.com/image/fetch/$s_!BLwZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd3641e16-1ed9-4874-aa22-806d5470c525_1840x1524.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal 1 output after function invocation.</figcaption></figure></div><p>This is a brief yet powerful example on how to configure sidecars for any dependencies that you require </p><p>The full code for having a AWS Lambda Runtime Interface Emulator Sidecar with a custom Lambda Docker runtime can be found <a href="https://github.com/crisboarna/blog/tree/main/lambda-custom-runtime">here</a>.</p><p>While this example is entirely in NodeJS, there is nothing stoping you from having the Lambda container use Go, Rust or any other language with custom configured dependencies.</p><p>In conclusion, the use of Docker containers and AWS Lambda Runtime Interface Emulator provides a robust and efficient solution for managing dependencies and testing out custom AWS Lambda Runtimes locally. </p><p>This approach not only ensures reproducibility but also eliminates the need for installing multiple utility packages, thereby reducing potential errors. The flexibility of this method allows for the use of various programming languages, making it a versatile tool for any developer's toolkit. </p><p>Remember, the key to this process is the effective sharing of the executable across containers using Docker volumes. As we continue to innovate and streamline our development processes, such practices pave the way for more efficient and error-free coding environments.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Accessing isolated network estate on AWS: Part 4 - AWS Client VPN]]></title><description><![CDATA[No servers, no containers, full network access from localhost inside VPC]]></description><link>https://blog.engineermindscape.com/p/accessing-isolated-network-estate-597</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/accessing-isolated-network-estate-597</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Sun, 30 Jul 2023 22:14:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!oWPm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oWPm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oWPm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!oWPm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!oWPm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!oWPm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oWPm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:492491,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oWPm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!oWPm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!oWPm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!oWPm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4209a96-3f7e-49d6-a51e-b89abfd6a97d_3840x2160.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Accessing isolated network estate on AWS: AWS Client VPN</figcaption></figure></div><p>As a closing to this series of post related to accessing isolated networks inside AWS, I will cover the approach of using the AWS Client VPN. This is a managed client-based VPN service that enables you to securely access your AWS resources and your on-premises network via a managed VPN link.</p><p>The overall advantage of this solution is that it greatly simplifies the network and resources required to achieve the audited and authenticated access to the system.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>How it works</h2><p>This solution leverages a mutual authentication OpenVPN based link using certificates that you provide along with the possibility to setup a self-service certificate vending dashboard for users if you have Active Directory/SAML based auth.</p><h2>Use Cases</h2><h2>Advantages</h2><ul><li><p><strong>Consistent Access</strong>: Utilizes a consistent method of access that is public and widely used, regardless of the underlying service. This is in contrast to services like ECS Exec and Instance Connect, which are specific to certain AWS services.</p></li><li><p><strong>Reduced overhead</strong>: The VPN endpoint is AWS managed and only some ENI are placed within your target subnets, removing any management need.</p></li><li><p><strong>Self-Service Certificates</strong>: A management portal can be configured to enable self-service for users to obtain the connection credentials, further removing operational steps.</p></li><li><p><strong>Scalable</strong>: Scales based on number of users and traffic thus reducing situations where corporate VPN is slow or fails due to load.</p></li><li><p><strong>Security</strong>: This uses OpenVPN, which is an industry-standard VPN protocol, that provides a high level of security. EC2 instances in comparison use SSH keys, which can be vulnerable if keys are not managed properly, although Instance Connect mitigates this issue.</p></li><li><p><strong>Centralized Control</strong>: Centrally managed access to your AWS resources from a single access endpoint. This is of similar vein to the ECS Exec and Instance Connect, where you can limit the user via IAM by granting/blocking the core permission for the action. It also allows live monitoring and termination of active connections. </p></li><li><p><strong>No VPC endpoints: </strong>Allows the creation of an isolated network with no Internet Gateway, without requiring VPC endpoints.</p></li></ul><h2>Disadvantages</h2><ul><li><p><strong>Cost</strong>: Client VPN can be more expensive than other solutions, especially for large numbers of users or heavy data usage. This is ideal if you are mainly looking for access for a certain number of users on an ad-hoc basis such as developers / QA accessing the environment for investigations or testing.</p></li><li><p><strong>Complexity</strong>: Setting up Client VPN can be complex, especially if you're not familiar with VPNs or networking. But hopefully this will cover the basics of it ;)</p></li><li><p><strong>Limited Protocol Support</strong>: Client VPN only supports the OpenVPN protocol. If you need to use a different protocol, you'll need to look at other solutions.</p></li></ul><h2>Example</h2><p>As the VPN does not require any further resources to be functional and is completely self-contained with just the VPC and VPN constructs, these are the only ones showcased below. As once the VPN connection is established, all resources contained within the private network that have a reachable route defined in the route tables of the subnets where the VPN endpoints are placed, are reachable from the local PC.</p><h2>Step 1: Initialize the CDK App</h2><p>First, we need to initialize a new CDK app in your preferred language, which for me is currently TypeScript. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>mkdir -p accessing-isolated-network/bastion-vpn
cd accessing-isolated-network-access/bastion-vpn
npx cdk init app --language=typescript</code></code></pre><p>This will create a new CDK app in TypeScript with the following structure</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nQj5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nQj5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 424w, https://substackcdn.com/image/fetch/$s_!nQj5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 848w, https://substackcdn.com/image/fetch/$s_!nQj5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 1272w, https://substackcdn.com/image/fetch/$s_!nQj5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nQj5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png" width="1456" height="783" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:783,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:350126,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nQj5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 424w, https://substackcdn.com/image/fetch/$s_!nQj5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 848w, https://substackcdn.com/image/fetch/$s_!nQj5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 1272w, https://substackcdn.com/image/fetch/$s_!nQj5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa6bc7e52-ecd2-4ae7-accc-c510b9ee4e35_1840x990.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 2: Define the VPC Stack</h2><p>Next, we define the VPC stack where the Client VPN Elastic Network Interface will be deployed.</p><p>Open up the <code>lib</code> folder and create a new file called <code>vpc-stack.ts</code>. We will only need private isolated subnets.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q1nO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q1nO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 424w, https://substackcdn.com/image/fetch/$s_!q1nO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 848w, https://substackcdn.com/image/fetch/$s_!q1nO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 1272w, https://substackcdn.com/image/fetch/$s_!q1nO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q1nO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png" width="1212" height="1530" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1530,&quot;width&quot;:1212,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:485362,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!q1nO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 424w, https://substackcdn.com/image/fetch/$s_!q1nO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 848w, https://substackcdn.com/image/fetch/$s_!q1nO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 1272w, https://substackcdn.com/image/fetch/$s_!q1nO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c66665e-54ac-41e0-aff4-27b0f05a4f06_1212x1530.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn/lib/vpc-stack.ts">GitHub Source</a></figcaption></figure></div><h2>Step 3: Define the VPN Stack</h2><p>We now create the VPN setup for the service. Open up the <code>lib</code> folder and create a new file called <code>vpn-stack.ts</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RsST!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RsST!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 424w, https://substackcdn.com/image/fetch/$s_!RsST!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 848w, https://substackcdn.com/image/fetch/$s_!RsST!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 1272w, https://substackcdn.com/image/fetch/$s_!RsST!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RsST!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png" width="1456" height="2529" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2529,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1225904,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RsST!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 424w, https://substackcdn.com/image/fetch/$s_!RsST!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 848w, https://substackcdn.com/image/fetch/$s_!RsST!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 1272w, https://substackcdn.com/image/fetch/$s_!RsST!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68664d52-7629-4468-ac2b-7ef0de5cc0b3_1840x3196.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn/lib/vpn-stack.ts">GitHub Source</a></figcaption></figure></div><p>As we are taking the mutual authentication path, we need to generate a base pair of certificates for the server and the client. This process is not as hands-off as the Active Directory / federated path with self-service portal, but it achieves the same target goal. The steps to generate the certificate pair is eloquently described <a href="https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/mutual.html">here</a>. Once you have completed the linked steps, you will have a pair of certificates in ACM that we need to pass the id&#8217;s of here under `<code>vpcCert</code>`.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wlr5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wlr5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 424w, https://substackcdn.com/image/fetch/$s_!wlr5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 848w, https://substackcdn.com/image/fetch/$s_!wlr5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 1272w, https://substackcdn.com/image/fetch/$s_!wlr5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wlr5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png" width="1456" height="379" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:379,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:139157,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wlr5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 424w, https://substackcdn.com/image/fetch/$s_!wlr5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 848w, https://substackcdn.com/image/fetch/$s_!wlr5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 1272w, https://substackcdn.com/image/fetch/$s_!wlr5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46c276a4-6237-4071-a10d-e645a3bfc24c_2368x616.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">AWS Console ACM view</figcaption></figure></div><p>They can be found in ACM here, assuming you followed the pattern of vpn.&lt;domain&gt;.com for server certificate and &lt;user&gt;.vpn.&lt;domain&gt;.com for client certificate.</p><h2>Step 4: Define the App Stack</h2><p>Deploying this stack is done via the main of:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NY91!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NY91!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 424w, https://substackcdn.com/image/fetch/$s_!NY91!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 848w, https://substackcdn.com/image/fetch/$s_!NY91!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 1272w, https://substackcdn.com/image/fetch/$s_!NY91!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NY91!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png" width="1212" height="1126" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1126,&quot;width&quot;:1212,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:404416,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NY91!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 424w, https://substackcdn.com/image/fetch/$s_!NY91!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 848w, https://substackcdn.com/image/fetch/$s_!NY91!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 1272w, https://substackcdn.com/image/fetch/$s_!NY91!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6bfd489-66f9-443a-83da-21ea1c06d98c_1212x1126.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-vpn/bin/bastion-vpn.ts">GitHub Source</a></figcaption></figure></div><h2>Step 5: Deploy app</h2><p>The cleanest way to pass the newly created certificates is via the CDK context construct directly from the terminal.</p><pre><code><code>&gt; npx cdk deploy --profile=&lt;profile&gt; --all -c serverCert=&lt;cert_id&gt; -c clientCert=&lt;cert_id&gt;</code></code></pre><p>This will take a few minutes as the deployment of the VPN endpoints and the authorizations are not instantaneous.</p><p>Once deployment is complete, you need to download the client configuration for the VPN application, which can be found in <code>AWS Console &gt; VPC &gt; Client VPN endpoints.</code></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WfHj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WfHj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 424w, https://substackcdn.com/image/fetch/$s_!WfHj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 848w, https://substackcdn.com/image/fetch/$s_!WfHj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 1272w, https://substackcdn.com/image/fetch/$s_!WfHj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WfHj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png" width="1456" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:62448,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WfHj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 424w, https://substackcdn.com/image/fetch/$s_!WfHj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 848w, https://substackcdn.com/image/fetch/$s_!WfHj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 1272w, https://substackcdn.com/image/fetch/$s_!WfHj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3e3c720e-f120-464b-94fd-a4c1509d397c_2452x216.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">AWS Console view</figcaption></figure></div><p>Once that is downloaded, and you have installed the VPN <a href="https://aws.amazon.com/vpn/client-vpn-download/">client</a>, you can open the application, </p><p><code>File &gt; Manage Profiles &gt; Add Profile</code></p><p>Select the downloaded file, give it a name, confirm, confirm.</p><p>Now you are ready to click on <code>Connect</code> and be welcomed by this view:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vb8C!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vb8C!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 424w, https://substackcdn.com/image/fetch/$s_!vb8C!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 848w, https://substackcdn.com/image/fetch/$s_!vb8C!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 1272w, https://substackcdn.com/image/fetch/$s_!vb8C!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vb8C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png" width="658" height="320" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:320,&quot;width&quot;:658,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:40934,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vb8C!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 424w, https://substackcdn.com/image/fetch/$s_!vb8C!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 848w, https://substackcdn.com/image/fetch/$s_!vb8C!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 1272w, https://substackcdn.com/image/fetch/$s_!vb8C!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6b0833a-f2c8-4683-a7af-d580c145e0ee_658x320.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">AWS VPN Client is connected to our network.</figcaption></figure></div><h2>Step 6: Cleanup</h2><p>Now that we have created all the needed resources and have gained access within the estate, time to delete all the resources to avoid accruing unwanted charges to our account:</p><pre><code><code>&gt; npx cdk destroy --all</code></code></pre><h2>Conclusion</h2><p>The strategic implementation of a managed VPN solution, with dynamic scaling based on usage, self-service capabilities is an invaluable asset in our technological toolkit that paves the way for a fully automated, secure and audited access pattern into cloud and on-premises networks.</p><p>This solution, characterized by its ability to maintain complete isolation from the internet while retaining global accessibility to all of the resources present within the private network that have a reachable route from the subnet where the VPN endpoints are placed, represents a significant advancement in our infrastructure capabilities.</p><p>In conjunction with the AWS SSM Session Manager, especially that of ECS Exec, offer a comprehensive approach to managing scenarios where both ad-hoc and continuous access to components of applications running on AWS is required.</p><p>As always, I invite you to explore the complete codebase for the aforementioned example, available in my GitHub repository, linked <a href="http:///accessing-isolated-networks/bastion-vpn">here</a>.</p><p>I hope this 4 part series has proved useful and helped you in making a decision regarding the route you want to take in accessing your isolated networks on AWS. If you know of any other practical or esoteric and interesting solutions to achieve the goal of connecting to isolated networks, do comment or send me a message on it, I am keen to learn !</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Accessing isolated network estate on AWS: Part 3 - ECS Fargate Host]]></title><description><![CDATA[Serverless bastion host based on Docker]]></description><link>https://blog.engineermindscape.com/p/accessing-isolated-network-estate-692</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/accessing-isolated-network-estate-692</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Mon, 19 Jun 2023 21:00:15 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!rrs0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rrs0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rrs0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!rrs0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!rrs0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!rrs0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rrs0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:496854,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rrs0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!rrs0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!rrs0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!rrs0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb9002fc-64a2-471c-b08c-993fe06cfabc_3840x2160.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Accessing isolated network estate on AWS: ECS Fargate Bastion</figcaption></figure></div><p>We will continue where we left off in the previous post <a href="https://blog.engineermindscape.com/p/accessing-isolated-network-estate-9d0">here</a>, by talking about another, more advanced way to reach your private resources within your AWS network estate. </p><p>Do note that this approach does not require a host exposed in a public subnet which means the need for hardening, auditing and strict compliance measures that you would have to take with normal bastions does not apply as stringently to this method as it is significantly harder for bad actors to use it as a spring board to wreck chaos on your platform. This is the second post where we cover the methods that do not require exposed network connectivity which will greatly reduce the security exposure of your solution, especially if it has no web or API component. The first method not requiring any internet access for accessing the bastion can be found here:</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;a392f549-ddd1-4c59-80cc-d951b9a5cfc7&quot;,&quot;caption&quot;:&quot;In this post we will talk about creating a bastion host that can be used as a jump box but with an added twist, it is not reachable and has no access to the internet. We will be accessing it solely through the AWS Systems Manager Session Manager. Let&#8217;s get directly into the advantages:&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Accessing isolated network estate on AWS: Part 2 - AWS Systems Manager Session Manager&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:73361062,&quot;name&quot;:&quot;Cristian Boarna&quot;,&quot;bio&quot;:&quot;Fullstack Developer specializing on cloud, mobile and backend services.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c261a67-b883-4cc5-91e8-5ffcd0561051_768x1024.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-06-18T19:10:49.886Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://blog.engineermindscape.com/p/accessing-isolated-network-estate-9d0&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:129082855,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:0,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Engineer Mindscape&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;belowTheFold&quot;:false,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><h2>Advantages</h2><ul><li><p>No servers to manage. </p><ul><li><p>No EC2, no EBS, no instance profile, AMI, lifecycle resources to worry about and manage manually yourself. While it is not a true &#8220;serverless&#8221; concept, as you still have potentially long-running processes, this pushes the undifferentiated heavy lifting across the <a href="https://aws.amazon.com/compliance/shared-responsibility-model/">shared responsibility model</a> into AWS&#8217;s court, releasing you from all of this operational burden.</p></li></ul></li><li><p>Easier to compose the final image.</p><ul><li><p>There are significantly more individuals that know how to write Dockerfile images than Packer, Chef or Ansible. While it is recommended for somebody with experience in creating hardened images, especially ones that are publicly available and configuring them well, this lowers the bar, allowing more hands to participate and quickly iterate.</p><ol><li><p>This also reduces the complexity of building a golden image due to the simplified build process.</p></li></ol></li></ul></li><li><p>Reduces net total resource count to be managed.</p><ul><li><p>Especially if you are using AWS CDK, there are L3 constructs that allow the creation of the entire resource stack with less than 50 lines of code.</p></li></ul></li><li><p>Cost savings.</p><ul><li><p>With AWS ECS Fargate, you only pay for the resources you use. Fargate allows you to specify the amount of CPU and memory required for your container, and you are only billed for the amount of resources that your container uses, rounded up to the nearest second.</p><p>This means that if you only need a bastion host for a short period, such as during an incident response, you can launch a Fargate task with a smaller instance size, and only pay for the exact amount of resources that you use.</p></li></ul></li></ul><h2>Disadvantages</h2><ul><li><p>More configuration needed.</p><ul><li><p>If we are comparing the basic resources and configuration items needed to get a EC2 running compared to a Fargate task, then the Fargate route is a much more involved and knowledge intensive process.</p></li><li><p>This difference is offset once we start discussing scalability with auto scaling, cost savings with Spot instances, load distribution with load balancers of course.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div></li></ul><h3>Note</h3><p>When discussing this with colleagues it has been brought up that boot time is longer for the Fargate option which I see as being more nuanced as opposed to a clear cut disadvantage.</p><p>As with any architectural design, the presence of our dear friend &#8216;it depends&#8217; is felt due to the variety of elements that can affect the total boot time that we need to take into account:</p><h4>Fargate</h4><ol><li><p>Task definition size</p><ol><li><p>The size of the task definition can impact boot time. Larger task definitions may take longer to load into memory, which can increase the time it takes for the task to start.</p></li></ol></li><li><p>Container image size</p><ol><li><p>The size of the container image can also impact boot time. Larger images take longer to download and extract, which can delay the start of the container.</p></li></ol></li><li><p>Resource allocation</p><ol><li><p>If your task requires a large amount of CPU or memory, it may take longer to provision the resources needed to start the task.</p></li></ol></li></ol><h4>EC2</h4><ol><li><p>Instance type</p><ol><li><p>The instance type you choose can impact boot time. Larger instances may take longer to provision and start up.</p></li></ol></li><li><p>AMI size</p><ol><li><p>The size of the AMI can also impact boot time. Larger AMIs may take longer to load into memory and start up.</p></li></ol></li><li><p>Boot volume type</p><ol><li><p>The type of boot volume you choose can also impact boot time. For example, an instance with an EBS-backed boot volume may take longer to start than an instance with an instance-store backed boot volume.</p></li></ol></li><li><p>User data scripts</p><ol><li><p>If you are running user data scripts on your instance, they can impact boot time. Long-running scripts or scripts that perform complex tasks can delay the instance startup.</p></li></ol></li></ol><p>Of particular note in the factors above is the juxtaposition of the resource allocation versus the instance type which, while both are configurable, if the requested instance type pool is exhausted, your server request is not getting processed. Whereas for Fargate, as long as you have not requested the higher end 8/16 vCPU, your request will be processed in a timely manner.</p><h2>Example</h2><h3>Note</h3><p>This is an optimized implementation that references an image from ECR and uses VPC Endpoints to completely lock down the bastion network and disallow any WAN access to avoid possibility of exfiltration of data.</p><p>While we are optimizing for simplicity here, there is still a lot of &#8220;supporting&#8221; implementation needed, to achieve the locked down environment in ECS Fargate is the focus of my other blog post:</p><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;ad75c52f-110a-4e1e-8ad6-70221385c4b4&quot;,&quot;caption&quot;:&quot;In a typical setup, compute nodes such as AWS Fargate tasks within an Amazon ECS cluster require internet access to pull container images, push logs, and other tasks. However, in certain scenarios, you might want to restrict internet access due to security or compliance requirements. This is where a Fargate ECS cluster &#8230;&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;size&quot;:&quot;lg&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;Isolated network workloads in AWS: ECS Fargate&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:73361062,&quot;name&quot;:&quot;Cristian Boarna&quot;,&quot;bio&quot;:&quot;Fullstack Developer specializing on cloud, mobile and backend services.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c261a67-b883-4cc5-91e8-5ffcd0561051_768x1024.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-06-19T20:44:57.677Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://blog.engineermindscape.com/p/isolated-network-workloads-in-aws&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:129514064,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:0,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;Engineer Mindscape&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><p>Let&#8217;s now go through the code needed to launch a simple bastion host on AWS ECS Fargate using AWS CDK. </p><p>Do note that I will not be using the &#8216;<code>@aws-cdk/aws-ecs-patterns&#8217; QueueProcessingFargateService </code>or <code>ScheduledFargateTask </code>L3 construct as I want to keep it as simple and straightforward as possible to digest. </p><p>Of course you should strive to leverage the full suite of tools offered by AWS for scalability and resiliency, but for our use case, conciseness is of greater value and I have mentioned the L3 construct above as a guidance towards what you should be looking for when trying to scale up this approach for your use case.</p><h2>Step 1: Initialize the CDK App</h2><p>First, we need to initialize a new CDK app in our preferred language, which for me is currently TypeScript. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>&gt; mkdir -p accessing-isolated-network/bastion-fargate

&gt; cd accessing-isolated-network-access/bastion-fargate

&gt; npx cdk init app --language=typescript</code></code></pre><p>This will create a new CDK app in TypeScript with the following structure</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MqRn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MqRn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 424w, https://substackcdn.com/image/fetch/$s_!MqRn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 848w, https://substackcdn.com/image/fetch/$s_!MqRn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!MqRn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MqRn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png" width="1040" height="1074" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1074,&quot;width&quot;:1040,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:323713,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MqRn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 424w, https://substackcdn.com/image/fetch/$s_!MqRn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 848w, https://substackcdn.com/image/fetch/$s_!MqRn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!MqRn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdbfd46ae-62fa-49b0-91ce-35011d471d8d_1040x1074.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 2: Define the VPC Stack</h2><p>Next, we define the VPC stack where Fargate will place the container ENI.</p><p>Open up the <code>lib</code> folder and create a new file called <code>vpc-stack.ts</code>. Add the following code to create a new VPC with a private subnet and the required 6 VPC Endpoints:</p><ul><li><p><strong>ECR-API</strong></p></li><li><p><strong>ECR-Docker</strong></p></li><li><p><strong>S3</strong></p></li><li><p><strong>SSM</strong></p></li><li><p><strong>SSM-Messages</strong></p></li><li><p><strong>EC2-Messages</strong></p></li><li><p><strong>Logs</strong> </p></li></ul><p>The <strong>ECR-API</strong>, <strong>ECR-Docker</strong> &amp; <strong>S3</strong> endpoints are needed for pulling the image, <strong>SSM, SSM-Messages </strong>and<strong> EC2-Messages </strong>are needed for remote accessing while <strong>Logs</strong> &amp; <strong>S3 </strong>is needed to send audit data to target system.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pt-w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pt-w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 424w, https://substackcdn.com/image/fetch/$s_!pt-w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 848w, https://substackcdn.com/image/fetch/$s_!pt-w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 1272w, https://substackcdn.com/image/fetch/$s_!pt-w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pt-w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png" width="1456" height="6772" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:6772,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1991052,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pt-w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 424w, https://substackcdn.com/image/fetch/$s_!pt-w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 848w, https://substackcdn.com/image/fetch/$s_!pt-w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 1272w, https://substackcdn.com/image/fetch/$s_!pt-w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe40ab35d-0ebe-45b4-91af-2558e9a0fe61_1558x7246.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-fargate/lib/vpc-stack.ts">GitHub Source</a></figcaption></figure></div><h2>Step 3: Define the Fargate Bastion Stack</h2><p>Now create a file named <code>fargate-stack.ts</code> with the below snippets pertaining to the setup of ECS &amp; ECS Exec of content. The full code can be found linked in the caption and at the end in GitHub. The explanation of the locked down ECS Fargate foundation setup is linked above in my other blog post.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Cdas!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Cdas!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 424w, https://substackcdn.com/image/fetch/$s_!Cdas!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 848w, https://substackcdn.com/image/fetch/$s_!Cdas!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 1272w, https://substackcdn.com/image/fetch/$s_!Cdas!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Cdas!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png" width="1456" height="6759" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:6759,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2068569,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Cdas!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 424w, https://substackcdn.com/image/fetch/$s_!Cdas!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 848w, https://substackcdn.com/image/fetch/$s_!Cdas!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 1272w, https://substackcdn.com/image/fetch/$s_!Cdas!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1def2834-4e5b-4e9d-9a98-19af0e5c857a_1648x7650.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-fargate/lib/fargate-stack.ts">GitHut Source</a></figcaption></figure></div><p>Here we are defining the Fargate Service that will launch the container in the private subnets and will communicate only with the required AWS services via the VPC Endpoints.</p><h2>Step 4: Define the App Stack</h2><p>Deploying this stack is done via the main of:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!T5pF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!T5pF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 424w, https://substackcdn.com/image/fetch/$s_!T5pF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 848w, https://substackcdn.com/image/fetch/$s_!T5pF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 1272w, https://substackcdn.com/image/fetch/$s_!T5pF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!T5pF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png" width="1138" height="856" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:856,&quot;width&quot;:1138,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:318234,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!T5pF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 424w, https://substackcdn.com/image/fetch/$s_!T5pF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 848w, https://substackcdn.com/image/fetch/$s_!T5pF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 1272w, https://substackcdn.com/image/fetch/$s_!T5pF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa3f45904-f926-423c-ae3b-c1e3da412ed8_1138x856.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-fargate/bin/fargate.ts">Github Source</a></figcaption></figure></div><h2>Step 5: Deploy app</h2><pre><code><code>&gt; AWS_PROFILE=&lt;profile&gt; npx cdk deploy --all</code></code></pre><p>Do note that in-between the &#8220;<strong>VpcStack</strong>&#8221; and &#8220;<strong>BastionFargateStack</strong>&#8221; ideally you should also populate the ECR repository with the image from DockerHub as we do not have any WAN access to pull it from there.</p><p>As such you should run the following commands in the terminal</p><pre><code><code>&gt; export REGION=&lt;region&gt; &amp;&amp; export ACCOUNT_ID=&lt;account_id&gt;

&gt; docker pull amazonlinux:2023.0.20230607.0

&gt; docker tag amazonlinux:2023.0.20230607.0  $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/bastion-fargate:latest

&gt; aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com

&gt; docker push $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/bastion-fargate:latest</code></code></pre><p>After the ECR repository is populated with the "<em>amazonlinux&#8221;</em> image, we can proceed with the second stack deployment:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TnM6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TnM6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 424w, https://substackcdn.com/image/fetch/$s_!TnM6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 848w, https://substackcdn.com/image/fetch/$s_!TnM6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 1272w, https://substackcdn.com/image/fetch/$s_!TnM6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TnM6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png" width="1456" height="1139" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1139,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:616878,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!TnM6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 424w, https://substackcdn.com/image/fetch/$s_!TnM6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 848w, https://substackcdn.com/image/fetch/$s_!TnM6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 1272w, https://substackcdn.com/image/fetch/$s_!TnM6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8b39f98a-b884-40d0-8078-f01914c3e8f3_1840x1440.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>All commands in this terminal session will be recorded and logged in Cloudwatch as configured. </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Jd8A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jd8A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 424w, https://substackcdn.com/image/fetch/$s_!Jd8A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 848w, https://substackcdn.com/image/fetch/$s_!Jd8A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 1272w, https://substackcdn.com/image/fetch/$s_!Jd8A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jd8A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png" width="1456" height="120" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:120,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:84234,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Jd8A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 424w, https://substackcdn.com/image/fetch/$s_!Jd8A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 848w, https://substackcdn.com/image/fetch/$s_!Jd8A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 1272w, https://substackcdn.com/image/fetch/$s_!Jd8A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0f7936a1-0474-46ea-8148-acaa1d9cb02a_2350x194.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">CloudWatch Logs audit entry</figcaption></figure></div><p>Any command you enter in the terminal will be logged to the target log group. You can send logs to CloudWatch and/or S3 for future data mining and monitoring.</p><p>This is a clean and simple way to ensure that any &#8220;break-glass&#8221; done that reaches into an application container or a bastion jump host is logged, audited and alarms can be triggered based on this data stream.</p><h2>Step 6: Cleanup</h2><p>Now that we have created all the needed resources and have gained access within the estate, time to delete all the resources to avoid accruing unwanted charges to our account:</p><pre><code><code>&gt; npx cdk destroy --all</code></code></pre><p>In the following post I will cover a similar approach using AWS Client VPN which removes any running server requirement and links your local machine to the AWS private VPC network representing the smallest footprint and management overhead option.</p><h2>Conclusion</h2><p>The strategic implementation of a serverless bastion host, capable of dynamic scaling to optimize cost efficiency that leverages Spot instances to potentially reduce operational expenses by up to 70%, is an invaluable asset in our technological toolkit. </p><p>This solution, characterized by its definition in user-friendly Dockerfiles and its unique ability to maintain complete isolation from the internet while retaining global accessibility, represents a significant advancement in our infrastructure capabilities.</p><p>In conjunction with the AWS Client VPN, which will be the focus of my next post, these two solution offer a comprehensive approach to managing scenarios where ad-hoc access to components of applications running on AWS is required.</p><p>For a deeper understanding and practical application, I invite you to explore the complete codebase for the aforementioned example, available in my GitHub repository, linked <a href="http:///accessing-isolated-networks/bastion-fargate">here</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Isolated network workloads in AWS: ECS Fargate]]></title><description><![CDATA[Serverless workload cluster with no internet connectivity]]></description><link>https://blog.engineermindscape.com/p/isolated-network-workloads-in-aws</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/isolated-network-workloads-in-aws</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Mon, 19 Jun 2023 20:44:57 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hT8K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hT8K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hT8K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!hT8K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!hT8K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!hT8K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hT8K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:491227,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hT8K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!hT8K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!hT8K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!hT8K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F52a0b74e-29ef-48a4-baef-c6772b23b09c_3840x2160.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Compute cluster with no WAN access</figcaption></figure></div><p>In a typical setup, compute nodes such as AWS Fargate tasks within an Amazon ECS cluster require internet access to pull container images, push logs, and other tasks. However, in certain scenarios, you might want to restrict internet access due to security or compliance requirements. This is where a Fargate ECS cluster with no internet connectivity comes into play.</p><p>In this post, we leverage VPC endpoints, which allow private connectivity between your VPC and supported AWS services. This means your Fargate tasks can communicate with necessary AWS services without requiring access to the public internet to the point where there is no network traffic that leaves your private VPC network beyond reaching out to integrations via PrivateLink endpoints.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Use Cases</h2><ol><li><p><strong>Regulated Industries</strong>: For industries like finance (PCI DSS) or healthcare (HIPAA), where data security is paramount, this setup provides an additional layer of security by eliminating unnecessary internet access.</p></li><li><p><strong>Data-Intensive Applications</strong>: For applications that require high-throughput, low-latency access to AWS services, using VPC endpoints can provide performance benefits.</p></li><li><p><strong>Multi-Tier Applications</strong>: For applications with strict network segmentation requirements, you can use this setup to enforce network boundaries between tiers.</p></li></ol><h2>Advantages</h2><ul><li><p><strong>Enhanced Security</strong>: </p><ul><li><p>By eliminating the need for internet access, you reduce the attack surface that bad actors can leverage. This setup is particularly beneficial for sensitive workloads that require stringent security controls such as PCI DSS compliant systems.</p></li></ul></li><li><p><strong>Network Performance</strong>: </p><ul><li><p>VPC endpoints enable private connectivity to AWS services, which can lead to lower latency and higher throughput compared to internet-based connections as they do not leave the AWS backbone network and follow the shortest possible path to target servers.</p></li></ul></li><li><p><strong>Cost Optimization</strong>: </p><ul><li><p>Data transfer costs for VPC endpoints within the same region are typically lower than data transfer costs over the public internet.</p></li></ul></li></ul><h2>Disadvantages</h2><ul><li><p><strong>Complexity</strong>: </p><ul><li><p>This of course comes with the added complexity of setting up more resources that are more laborious and knowledge intensive resulting in a more complex network architecture.</p></li></ul></li><li><p><strong>Service Limitations</strong>: </p><ul><li><p>Not all AWS services support VPC endpoints. You'll need to ensure that the services your tasks depend on can be accessed via VPC endpoints for this to be a viable approach for you.</p></li></ul></li><li><p><strong>Cost</strong>: </p><ul><li><p>While you can save on data transfer costs, there are costs associated with using VPC endpoints, unless you are only using S3/DynamoDB which will can add a pretty penny to your bill.</p></li></ul></li></ul><h2>Example</h2><p>In this example we will create a simple ECS Fargate service that is auto-scaled across AZ, which pulls it&#8217;s image from a private ECR repository and logs data to CloudWatch logs, without any network connectivity.</p><h2>Step 1: Initialize the CDK App</h2><p>First, we need to initialize a new CDK app in our preferred language, which for me is currently TypeScript. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>&gt; mkdir -p isolated-network-workloads/fargate

&gt; cd isolated-network-workloads/fargate

&gt; npx cdk init app --language=typescript</code></code></pre><p>This will create a new CDK app in TypeScript with the following structure</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VL7-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VL7-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 424w, https://substackcdn.com/image/fetch/$s_!VL7-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 848w, https://substackcdn.com/image/fetch/$s_!VL7-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 1272w, https://substackcdn.com/image/fetch/$s_!VL7-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VL7-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png" width="1040" height="856" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:856,&quot;width&quot;:1040,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:246713,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VL7-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 424w, https://substackcdn.com/image/fetch/$s_!VL7-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 848w, https://substackcdn.com/image/fetch/$s_!VL7-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 1272w, https://substackcdn.com/image/fetch/$s_!VL7-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6100969d-8a50-43d4-8ca7-de68a886b853_1040x856.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 2: Define the VPC Stack</h2><p>Next, we define the VPC stack where Fargate will place the container ENI.</p><p>Open up the <code>lib</code> folder and create a new file called <code>vpc-stack.ts</code>. Add the following code to create a new VPC with a private subnet and the required 4 VPC Endpoints:</p><ul><li><p><strong>ECR-API</strong></p></li><li><p><strong>ECR-Docker</strong></p></li><li><p><strong>S3</strong></p></li><li><p><strong>Logs</strong> </p></li></ul><p>The <strong>ECR-API</strong>, <strong>ECR-Docker</strong> &amp; <strong>S3</strong> endpoints are needed for pulling the image and <strong>Logs</strong> is needed to send logs to CloudWatch.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UwpC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UwpC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 424w, https://substackcdn.com/image/fetch/$s_!UwpC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 848w, https://substackcdn.com/image/fetch/$s_!UwpC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 1272w, https://substackcdn.com/image/fetch/$s_!UwpC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UwpC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png" width="1456" height="5060" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:5060,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1484402,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UwpC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 424w, https://substackcdn.com/image/fetch/$s_!UwpC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 848w, https://substackcdn.com/image/fetch/$s_!UwpC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 1272w, https://substackcdn.com/image/fetch/$s_!UwpC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd679c86a-0180-4ec7-81e3-269e5aa20afb_1502x5220.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/isolated-network-workloads/fargate/lib/vpc-stack.ts">GitHub Source</a></figcaption></figure></div><h2>Step 3: Define the Fargate Workload Stack</h2><p>In this stack we will create the log group, security group, security group rules, cluster and service definition.</p><p>Create a file named <code>fargate-stack.ts</code> with the following content:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0KQg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0KQg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 424w, https://substackcdn.com/image/fetch/$s_!0KQg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 848w, https://substackcdn.com/image/fetch/$s_!0KQg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 1272w, https://substackcdn.com/image/fetch/$s_!0KQg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0KQg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png" width="1456" height="6282" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:6282,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1609860,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0KQg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 424w, https://substackcdn.com/image/fetch/$s_!0KQg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 848w, https://substackcdn.com/image/fetch/$s_!0KQg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 1272w, https://substackcdn.com/image/fetch/$s_!0KQg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69488ab0-124b-40e1-8664-77d370866c3b_1502x6480.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/isolated-network-workloads/fargate/lib/fargate-stack.ts">GitHub Source</a></figcaption></figure></div><h2>Step 4: Define the App Stack</h2><p>Deploying this stack is done via the main of:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tiBj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tiBj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 424w, https://substackcdn.com/image/fetch/$s_!tiBj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 848w, https://substackcdn.com/image/fetch/$s_!tiBj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 1272w, https://substackcdn.com/image/fetch/$s_!tiBj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tiBj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png" width="1194" height="1126" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1126,&quot;width&quot;:1194,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:426393,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tiBj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 424w, https://substackcdn.com/image/fetch/$s_!tiBj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 848w, https://substackcdn.com/image/fetch/$s_!tiBj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 1272w, https://substackcdn.com/image/fetch/$s_!tiBj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b7e320d-e711-4609-84a4-a2a1d8db7b7e_1194x1126.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/isolated-network-workloads/fargate/bin/fargate.ts">GitHub Source</a></figcaption></figure></div><h2>Step 5: Deploy app</h2><pre><code><code>&gt; AWS_PROFILE=&lt;profile&gt; npx cdk deploy --all</code></code></pre><p>Do note that in-between the &#8220;VpcStack&#8221; and &#8220;FargateStack&#8221; ideally you should also populate the ECR repository with the image from DockerHub as we do not have any WAN access to pull it from there.</p><p>As such you should run the following commands in the terminal</p><pre><code><code>&gt; export REGION=&lt;region&gt; &amp;&amp; export ACCOUNT_ID=&lt;account_id&gt;

&gt; docker pull amazonlinux:2023.0.20230607.0

&gt; docker tag amazonlinux:2023.0.20230607.0  $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/workload-service:latest

&gt; aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com

&gt; docker push $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/workload-service:latest</code></code></pre><p>After the ECR repository is populated with the "<em>amazonlinux&#8221;</em> image, we can proceed with the second stack deployment:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qN8X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qN8X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 424w, https://substackcdn.com/image/fetch/$s_!qN8X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 848w, https://substackcdn.com/image/fetch/$s_!qN8X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 1272w, https://substackcdn.com/image/fetch/$s_!qN8X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qN8X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png" width="1456" height="570" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:570,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:301110,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qN8X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 424w, https://substackcdn.com/image/fetch/$s_!qN8X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 848w, https://substackcdn.com/image/fetch/$s_!qN8X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 1272w, https://substackcdn.com/image/fetch/$s_!qN8X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3708537c-00b2-41f7-be81-468d2d2645f3_1840x720.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><p>Now we can see in the ECS console the running task processing our workload.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1LG9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1LG9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 424w, https://substackcdn.com/image/fetch/$s_!1LG9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 848w, https://substackcdn.com/image/fetch/$s_!1LG9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 1272w, https://substackcdn.com/image/fetch/$s_!1LG9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1LG9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png" width="1456" height="527" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:527,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:141550,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1LG9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 424w, https://substackcdn.com/image/fetch/$s_!1LG9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 848w, https://substackcdn.com/image/fetch/$s_!1LG9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 1272w, https://substackcdn.com/image/fetch/$s_!1LG9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d0a05c3-6a75-411f-bbef-61355d61dbd1_2000x724.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>And this task is running completely disconnected from the internet on a compute cluster that can easily be configured to scale, react to inputs and process varying payloads in isolation.</p><h2>Step 6: Cleanup</h2><p>Now that we have created all the needed resources and have gained access within the estate, time to delete all the resources to avoid accruing unwanted charges to our account:</p><pre><code><code>&gt; npx cdk destroy --all</code></code></pre><h2>Conclusion</h2><p>Running a Fargate ECS cluster with no internet connectivity is a powerful strategy for enhancing security and performance. However, it's not a one-size-fits-all solution. As with any architectural decision, it's crucial to weigh the benefits against the potential drawbacks and costs.</p><p>Remember, the goal is not to apply every possible security measure, but to apply the right measures for your specific use case. As always, keep your business requirements, regulatory landscape, and risk tolerance in mind when making these decisions.</p><p>I hope this deep dive has provided you with valuable insights into this advanced networking setup. As always, I'm here to answer any questions you might have. Let's continue to push the boundaries of what's possible with AWS!</p><p>You can find the entire codebase for the above example in my GitHub repo <a href="https://github.com/crisboarna/blog/tree/main/isolated-network-workloads/fargate">here</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Accessing isolated network estate on AWS: Part 2 - AWS Systems Manager Session Manager]]></title><description><![CDATA[Secure and audited bastion solution]]></description><link>https://blog.engineermindscape.com/p/accessing-isolated-network-estate-9d0</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/accessing-isolated-network-estate-9d0</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Sun, 18 Jun 2023 19:10:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!nE3h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nE3h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nE3h!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!nE3h!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!nE3h!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!nE3h!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nE3h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:507236,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nE3h!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!nE3h!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!nE3h!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!nE3h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b8e8d2d-8eff-4ce6-bf1e-c3a46c67e18c_3840x2160.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Accessing isolated network estate on AWS: EC2 Session Manager Bastion</figcaption></figure></div><p>In this post we will talk about creating a bastion host that can be used as a jump box but with an added twist, it is not reachable and has no access to the internet. We will be accessing it solely through the AWS Systems Manager Session Manager. </p><p>Let&#8217;s get directly into the advantages:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Advantages</h2><ul><li><p>Reduced operational complexity</p><ul><li><p>No more need to manage SSH keys and their lifecycle. No requirement to add/remove people from SSH agent when they join/leave. No need to worry about them being compromised.</p></li></ul></li><li><p><strong>Enhanced Security</strong></p><ul><li><p>Leverages AWS Identity and Access Management (IAM) for access control. To start a session with an instance, a user needs IAM permissions. This model integrates well with your existing policies and procedures for IAM.</p></li><li><p>Without internet connectivity, our Bastion Host is insulated from potential external attacks. The access via Session Manager further fortifies its security, as it negates the need for managing SSH keys.</p></li><li><p>The security footprint is smaller as there is no WAN port that is continously scanned with failed login attempts spamming the server logs.</p></li></ul></li><li><p><strong>Audit and Compliance</strong></p><ul><li><p>AWS Systems Manager Session Manager logs all session activity, making it easier to maintain an audit trail and comply with governance and regulatory requirements. This means every connection and command is audited and logged in CloudWatch/S3/CloudTrail as configured by you.</p></li></ul></li><li><p><strong>Cost-Effective</strong></p><ul><li><p>Since there is no need for an Elastic IP or an Load Balancer, we save on costs associated with them, which is non-trivial given the usual 24/7 running of these resources. As you can see in the above architectural diagram, besides the VPC Endpoints and the EC2 instance, there are no other resources needed for a MVP. Ideally for more advanced, stable setups you would use a Spot Fleet to ensure the livelyness of the bastion host.</p></li></ul></li></ul><h2>Disadvantages</h2><ul><li><p><strong>Dependency</strong></p><ul><li><p>This relies exclusively on AWS Systems Manager, making us susceptible to potential service disruptions when there are issues on AWS with the service.</p></li></ul></li><li><p><strong>Limited Network Testing</strong></p><ul><li><p>Lack of internet connectivity may limit certain network diagnostic capabilities. But if this is needed on an ad-hoc basis, it can be added in and removed once done.</p></li></ul></li></ul><h2>How it works</h2><p>In order to get this working, we need any Linux distribution that supports the SSM Session Manager agent to be installed. Alternatively, you can use a more recent AMI that has the agent already baked in such as a recent ECS-Optimized AWS managed AMI.</p><p>The way Session Manager works is by establishing a secure, bidirectional, and authenticated channel for communications between our terminal and the managed instance, without the need for an open inbound port or to maintain SSH keys via the agent.</p><p>The SSM Agent process runs on the EC2 instances and communicates with the Systems Manager service. When a Session Manager session is initiated, the SSM Agent establishes a WebSocket connection with the Systems Manager service, facilitated by the Amazon Message Delivery Service. The WebSocket connection acts as a conduit for command-and-control (C2) interactions, enabling you to run commands, scripts, or even PowerShell cmdlets interactively on the instance.</p><p>All the data transmitted during a Session Manager session is encrypted using Transport Layer Security (TLS) 1.2. The communications traverse through the Amazon network backbone, eliminating exposure to the public internet.</p><p>You need to install the Session Manager plugin on your local machine so the AWS CLI can leverage it when setting up the connection. The installation steps can be found <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html">here</a>.</p><h2>Example</h2><h2>Step 1: Initialize the CDK App</h2><p>First, we need to initialize a new CDK app in our preferred language, which for me is currently TypeScript. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>mkdir -p accessing-isolated-network/bastion-ssm
cd accessing-isolated-network-access/bastion-ssm
npx cdk init app --language=typescript</code></code></pre><p>This will create a new CDK app in TypeScript with the following structure</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Zw1v!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zw1v!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 424w, https://substackcdn.com/image/fetch/$s_!Zw1v!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 848w, https://substackcdn.com/image/fetch/$s_!Zw1v!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 1272w, https://substackcdn.com/image/fetch/$s_!Zw1v!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zw1v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png" width="1040" height="856" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:856,&quot;width&quot;:1040,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:251524,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Zw1v!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 424w, https://substackcdn.com/image/fetch/$s_!Zw1v!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 848w, https://substackcdn.com/image/fetch/$s_!Zw1v!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 1272w, https://substackcdn.com/image/fetch/$s_!Zw1v!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe60f65a1-00c2-418a-83b2-4643f5874eec_1040x856.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 2: Define the VPC Stack</h2><p>Next, we define the VPC stack where the EC2 instance will be deployed.</p><p>Open up the <code>lib</code> folder and create a new file called <code>vpc-stack.ts</code>. We will only need a single public subnet. Of course for actual use-cases you will have more subnets and ideally many of them private ;) but for simplicity we will only focus on the topic at hand.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Dd3W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Dd3W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 424w, https://substackcdn.com/image/fetch/$s_!Dd3W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 848w, https://substackcdn.com/image/fetch/$s_!Dd3W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 1272w, https://substackcdn.com/image/fetch/$s_!Dd3W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Dd3W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png" width="1448" height="3646" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3646,&quot;width&quot;:1448,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1100963,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Dd3W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 424w, https://substackcdn.com/image/fetch/$s_!Dd3W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 848w, https://substackcdn.com/image/fetch/$s_!Dd3W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 1272w, https://substackcdn.com/image/fetch/$s_!Dd3W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb25197f1-f040-41c2-9894-0af8555e37e2_1448x3646.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-ssm/lib/vpc-stack.ts">GitHub Source</a></figcaption></figure></div><p>As you can see we create VPC Endpoint for SSM, SSM-Messages and EC2-Messages. This is required as the SSM Session Manager requires to communicate with all 3 endpoints in order for the connection to function properly.</p><h2>Step 3: Define the Bastion EC2 Stack</h2><p>We now create the standard EC2 instance running Amazon Linux 3 (see supported operating systems <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html">here</a>.)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gkYb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gkYb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 424w, https://substackcdn.com/image/fetch/$s_!gkYb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 848w, https://substackcdn.com/image/fetch/$s_!gkYb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 1272w, https://substackcdn.com/image/fetch/$s_!gkYb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gkYb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png" width="1456" height="3924" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3924,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1407038,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gkYb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 424w, https://substackcdn.com/image/fetch/$s_!gkYb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 848w, https://substackcdn.com/image/fetch/$s_!gkYb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 1272w, https://substackcdn.com/image/fetch/$s_!gkYb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe627f062-5f00-4a39-9abb-4bac2163a67a_1720x4636.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-ssm/lib/bastion-stack.ts">Github Source</a></figcaption></figure></div><h3>Note</h3><p>Depending on the configurations done to your account, the following error may occur:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZYMK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZYMK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 424w, https://substackcdn.com/image/fetch/$s_!ZYMK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 848w, https://substackcdn.com/image/fetch/$s_!ZYMK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 1272w, https://substackcdn.com/image/fetch/$s_!ZYMK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZYMK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png" width="1456" height="549" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:549,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:296287,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZYMK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 424w, https://substackcdn.com/image/fetch/$s_!ZYMK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 848w, https://substackcdn.com/image/fetch/$s_!ZYMK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 1272w, https://substackcdn.com/image/fetch/$s_!ZYMK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76bcc299-1f70-4759-a4c4-c84fcb537292_1794x676.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>To fix this you need to go and disable Systems Manager &gt; Session Manager &gt; Preferences &gt; Edit &gt; &#8220;Enable Run As support for Linux instances&#8221; in the AWS Console for the target account.</p><h2>Step 4: Define the App Stack</h2><p>Deploying this stack is done via the main of:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wDb5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wDb5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 424w, https://substackcdn.com/image/fetch/$s_!wDb5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 848w, https://substackcdn.com/image/fetch/$s_!wDb5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!wDb5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wDb5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png" width="1338" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1338,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:422687,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wDb5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 424w, https://substackcdn.com/image/fetch/$s_!wDb5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 848w, https://substackcdn.com/image/fetch/$s_!wDb5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!wDb5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd81dc48f-af29-476c-9256-aada7f1e9caa_1338x1080.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/main/accessing-isolated-networks/bastion-ssm/bin/bastion-ssm.ts">GitHub Source</a></figcaption></figure></div><h2>Step 5: Deploy app</h2><pre><code><code>&gt; AWS_PROFILE=&lt;profile&gt; npx cdk deploy --all</code></code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KD1A!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KD1A!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 424w, https://substackcdn.com/image/fetch/$s_!KD1A!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 848w, https://substackcdn.com/image/fetch/$s_!KD1A!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 1272w, https://substackcdn.com/image/fetch/$s_!KD1A!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KD1A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png" width="1456" height="928" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:928,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:371302,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KD1A!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 424w, https://substackcdn.com/image/fetch/$s_!KD1A!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 848w, https://substackcdn.com/image/fetch/$s_!KD1A!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 1272w, https://substackcdn.com/image/fetch/$s_!KD1A!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F751f9401-1d4b-4538-8872-7202c2ca35d6_1484x946.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><p>Now any command in this terminal session will be recorded and logged in S3/Cloudwatch if configured in <strong>Systems Manager &gt; Session Manager &gt; Preferences &gt; Edit &gt; CloudWatch/S3 logging.</strong></p><h2>Step 6: Cleanup</h2><p>Now that we have created all the needed resources and have gained access within the estate, time to delete all the resources to avoid accruing unwanted charges to our account:</p><pre><code><code>&gt; npx cdk destroy --all</code></code></pre><p>In the following post we will use a more advanced, &#8220;serverless&#8221; offering from AWS where we will leverage Docker containers for our bastion operating system and ECS Fargate for hosting and running. More details regarding the benefits for this feature in the next post.</p><p>You can find the entire codebase for the above example in my GitHub repo <a href="https://github.com/crisboarna/blog/tree/main/accessing-isolated-networks/bastion-ssm">here</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Accessing isolated network estate on AWS: Part 1 - Bastion Host]]></title><description><![CDATA[The classic Bastion host on EC2]]></description><link>https://blog.engineermindscape.com/p/accessing-isolated-network-estate</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/accessing-isolated-network-estate</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Sat, 17 Jun 2023 20:59:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hm1S!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hm1S!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hm1S!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!hm1S!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!hm1S!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!hm1S!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hm1S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:487725,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hm1S!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 424w, https://substackcdn.com/image/fetch/$s_!hm1S!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 848w, https://substackcdn.com/image/fetch/$s_!hm1S!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!hm1S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2590e6fb-07cd-4eb5-850e-a4652392cf3e_3840x2160.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Accessing isolated network estate on AWS: EC2 Bastion</figcaption></figure></div><p>Regardless of your profile, whether you're responsible for hands-on implementation or focused on the business aspects of a project, it's essential to have a solid understanding of how to best protect and secure your venture. This knowledge is important for everyone involved in the project, regardless of their technical expertise or business acumen.</p><p>I want to emphasize that for any project, regardless of its size, there will come a time when you need access to the underlying components of the system, such as databases, caches, pipelines and other processes. However, in an isolated network, such as an AWS VPC, this can be challenging, as opening up the network leaves it vulnerable to security threats and bad actors. As most systems with a non-trivial complexity are not hosted on SaaS services such as Netlify or Vercel as having access to the underlying infrastructure is essential for developmental, operational and support reasons. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>In the following blog posts, we'll focus on how we can setup in a matter of minutes with just a few commands a variety of access patterns with varying levels of complexity and security guarantees with the help of AWS CDK (Cloud Development Kit) to provide secure access points to your private instances in a VPC, enabling you to manage your infrastructure safely and efficiently.</p><p>In brief, the access patterns that we will cover in this blog series will cover:</p><ul><li><p>EC2 Bastion Host</p><ul><li><p>A special-purpose instance that acts as a proxy server for connecting to other instances in your VPC. It provides secure access using SSH or Remote Desktop Protocol (RDP). Simplest, most involved, requires instance hardening, monitoring, patching, further configuration to setup all additional processes &amp; services (Terraform/Chef/Puppet for example), is a single point of failure.</p></li></ul></li><li><p>AWS Systems Manager Session Manager</p><ul><li><p>Safer but more complex to configure, unless you use an AMI with it baked in ;). Main advantage compared to above options is that the instance does not require to be directly reachable from the internet, greatly reducing the threat profile. As long as there is a network path to AWS Systems Manager from your end and the target AWS EC2, the instance can function securely, providing an additional layer of protection to your infrastructure.</p></li></ul></li><li><p>ECS Fargate Service Bastion Host</p><ul><li><p>Similar to an EC2 bastion host, but by leveraging ECS Fargate we can push the responsibility of base patching down to AWS, which reduces our overall threat surface to manage. By using this approach, we can ensure that our infrastructure is more secure, and we can focus our efforts on other critical areas. It is also potentially easier to replace and scale as most configuration can be contained in the task image Dockerfile.</p></li></ul></li><li><p>AWS Client VPN</p><ul><li><p>Completely eliminates the need for a proxy bastion instance by granting the device we are VPN-ing in from access to the network within the VPC directly via the VPN tunnel. This not only simplifies the setup process but also eliminates the need to harden, monitor, patch or maintain a separate bastion host while minimizing the operational overhead for all parties involved.</p></li></ul></li></ul><div><hr></div><p>For the remainder of this blog post we will focus on the first method of connecting, via an EC2 bastion host.</p><h5>Note:</h5><p>This is for demonstrative purposes, this blog posts bastion host design has no scalability or recovery mechanisms  added for clarity and straightforwardness. For real workloads, please take into account the possibility that the EC2 instance may fail and needs replacing, look into EC2 Spot Fleet or the other posts in this blog series for alternatives.</p><h2>Prerequisites:</h2><p>Before we begin, make sure you have the following prerequisites installed and configured:</p><ul><li><p>AWS CLI <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">[install guide]</a></p></li><li><p>AWS CDK <a href="https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html">[install guide]</a></p></li><li><p>Node.JS and NPM <a href="https://nodejs.org/en/download">[install guide]</a></p></li></ul><h2>Step 1: Initialize the CDK App</h2><p>First, we need to initialize a new CDK app in our preferred language, which for me is currently TypeScript. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>mkdir -p accessing-isolated-network/bastion-ec2
cd accessing-isolated-network/bastion-ec2
npx cdk init app --language=typescript</code></code></pre><p>This will create a new CDK app in TypeScript with the following structure</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Tok3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Tok3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 424w, https://substackcdn.com/image/fetch/$s_!Tok3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 848w, https://substackcdn.com/image/fetch/$s_!Tok3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 1272w, https://substackcdn.com/image/fetch/$s_!Tok3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Tok3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png" width="1040" height="1028" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1028,&quot;width&quot;:1040,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:313777,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Tok3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 424w, https://substackcdn.com/image/fetch/$s_!Tok3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 848w, https://substackcdn.com/image/fetch/$s_!Tok3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 1272w, https://substackcdn.com/image/fetch/$s_!Tok3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30df9e4d-e629-4ea4-a518-9acd8f37ed4f_1040x1028.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 2: Define the VPC Stack</h2><p>Next, we need to define the VPC stack that our EC2 bastion host will be a part of. While this can all be done in one stack, it is best practice to separate the constructs as the layers of an onion, each layer building on top of the previous one, reducing potential blast radius for any change and reducing the number of resources that need to be touched for any one change.</p><p>Open up the <code>lib</code> folder and create a new file called <code>vpc-stack.ts</code>. Add the following code to create a new VPC with a public subnet:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-Q6u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Q6u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 424w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 848w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1272w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png" width="1456" height="1318" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1318,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:543390,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-Q6u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 424w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 848w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1272w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/accessing-isolated-networks-part-1/accessing-isolated-networks/ec2-bastion/app/lib/vpc-stack.ts">GitHub Source</a></figcaption></figure></div><h2>Step 3: Define the Bastion Stack</h2><p>Now create a file named <code>bastion-stack.ts</code> with the following contents:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zmUO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zmUO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 424w, https://substackcdn.com/image/fetch/$s_!zmUO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 848w, https://substackcdn.com/image/fetch/$s_!zmUO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 1272w, https://substackcdn.com/image/fetch/$s_!zmUO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zmUO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png" width="1456" height="2203" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2203,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1144541,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zmUO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 424w, https://substackcdn.com/image/fetch/$s_!zmUO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 848w, https://substackcdn.com/image/fetch/$s_!zmUO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 1272w, https://substackcdn.com/image/fetch/$s_!zmUO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c5bce8c-2f45-4dfc-ae6b-4cba2e473ebe_1840x2784.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/accessing-isolated-networks-part-1/accessing-isolated-networks/ec2-bastion/app/lib/bastion-stack.ts">GitHub Source</a></figcaption></figure></div><h2>Step 4: Define the App Stack</h2><p>The glue to tie the two stacks together is:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mLVc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mLVc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 424w, https://substackcdn.com/image/fetch/$s_!mLVc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 848w, https://substackcdn.com/image/fetch/$s_!mLVc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 1272w, https://substackcdn.com/image/fetch/$s_!mLVc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mLVc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png" width="1456" height="671" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:671,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:404234,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mLVc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 424w, https://substackcdn.com/image/fetch/$s_!mLVc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 848w, https://substackcdn.com/image/fetch/$s_!mLVc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 1272w, https://substackcdn.com/image/fetch/$s_!mLVc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F60534ba8-b66e-4e3e-ae54-7c76895009e5_1840x848.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/accessing-isolated-networks-part-1/accessing-isolated-networks/ec2-bastion/app/bin/app.ts">GitHub Source</a></figcaption></figure></div><p>Which you can now run with </p><pre><code><code>&gt; AWS_PROFILE=&lt;profile&gt; npx cdk deploy --all</code></code></pre><p>followed by the sequence of commands provided in the output of the command above, as can be seen below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fb2g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fb2g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 424w, https://substackcdn.com/image/fetch/$s_!fb2g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 848w, https://substackcdn.com/image/fetch/$s_!fb2g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 1272w, https://substackcdn.com/image/fetch/$s_!fb2g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fb2g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png" width="1456" height="1348" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1348,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:792045,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fb2g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 424w, https://substackcdn.com/image/fetch/$s_!fb2g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 848w, https://substackcdn.com/image/fetch/$s_!fb2g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 1272w, https://substackcdn.com/image/fetch/$s_!fb2g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F629c858c-5dad-4e86-aeb2-885972cda070_1840x1704.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h2>Step 5: Cleanup</h2><p>Now that we have created all the needed resources and have gained access within the estate, time to delete all the resources to avoid accruing unwanted charges to our account:</p><pre><code><code>&gt; npx cdk destroy --all</code></code></pre><p>Now while we could have used the classic process of uploading a long-lived SSH Key to AWS and referencing that when creating the bastion host, I chose for this example to highlight the newer approach using the AWS Instance Connect API which uploads using the &#8220;<strong>aws ec2-instance-connect send-ssh-public-key&#8221; </strong>to the EC2 Metadata service. This key is ephemeral and available for 60 seconds to perform the ssh connection after which it is deleted from AWS and you need to upload it once more. You can read more about the advantages and disadvantages of this method in my previous post</p><div class="embedded-post-wrap" data-attrs="{&quot;id&quot;:115114744,&quot;url&quot;:&quot;https://blog.engineermindscape.com/p/aws-ec2-key-pairs-versus-ec2-instance&quot;,&quot;publication_id&quot;:1103562,&quot;publication_name&quot;:&quot;Engineer Mindscape&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;title&quot;:&quot;AWS EC2 Key Pairs versus EC2-Instance-Connect&quot;,&quot;truncated_body_text&quot;:&quot;When it comes to managing secure shell (SSH) access to Amazon Elastic Compute Cloud (EC2) instances, there are two primary methods: AWS EC2 Key Pairs SSH AWS Instance Connect. Both methods provide secure and convenient ways to access EC2 instances, but they have different pros and cons that make them suitable for different use c&#8230;&quot;,&quot;date&quot;:&quot;2023-04-22T03:47:45.021Z&quot;,&quot;like_count&quot;:0,&quot;comment_count&quot;:0,&quot;bylines&quot;:[{&quot;id&quot;:73361062,&quot;name&quot;:&quot;Cristian Boarna&quot;,&quot;previous_name&quot;:null,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/bb07a9ac-d15e-41f9-8658-77a981a6cef0_144x144.png&quot;,&quot;bio&quot;:&quot;Fullstack Developer specializing on cloud, mobile and backend services.&quot;,&quot;profile_set_up_at&quot;:&quot;2022-09-25T17:59:16.548Z&quot;,&quot;publicationUsers&quot;:[{&quot;id&quot;:1053904,&quot;user_id&quot;:73361062,&quot;publication_id&quot;:1103562,&quot;role&quot;:&quot;admin&quot;,&quot;public&quot;:true,&quot;is_primary&quot;:false,&quot;publication&quot;:{&quot;id&quot;:1103562,&quot;name&quot;:&quot;Engineer Mindscape&quot;,&quot;subdomain&quot;:&quot;crisboarna&quot;,&quot;custom_domain&quot;:&quot;blog.engineermindscape.com&quot;,&quot;custom_domain_optional&quot;:false,&quot;hero_text&quot;:&quot;Explore the intersection of engineering, coding, and professional development. From technical tutorials to personal growth strategies, this blog offers a diverse range of content to help readers navigate their careers&quot;,&quot;logo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png&quot;,&quot;author_id&quot;:73361062,&quot;theme_var_background_pop&quot;:&quot;#BAA049&quot;,&quot;created_at&quot;:&quot;2022-09-25T18:03:52.449Z&quot;,&quot;rss_website_url&quot;:null,&quot;email_from_name&quot;:null,&quot;copyright&quot;:&quot;Cristian Boarna&quot;,&quot;founding_plan_name&quot;:null,&quot;community_enabled&quot;:true,&quot;invite_only&quot;:false,&quot;payments_state&quot;:&quot;disabled&quot;}}],&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;utm_campaign&quot;:null,&quot;belowTheFold&quot;:true,&quot;type&quot;:&quot;newsletter&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="EmbeddedPostToDOM"><a class="embedded-post" native="true" href="https://blog.engineermindscape.com/p/aws-ec2-key-pairs-versus-ec2-instance?utm_source=substack&amp;utm_campaign=post_embed&amp;utm_medium=web"><div class="embedded-post-header"><img class="embedded-post-publication-logo" src="https://substackcdn.com/image/fetch/$s_!KteP!,w_56,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F952b5627-f81f-4c38-809c-3a1a944d2fd3_500x500.png" loading="lazy"><span class="embedded-post-publication-name">Engineer Mindscape</span></div><div class="embedded-post-title-wrapper"><div class="embedded-post-title">AWS EC2 Key Pairs versus EC2-Instance-Connect</div></div><div class="embedded-post-body">When it comes to managing secure shell (SSH) access to Amazon Elastic Compute Cloud (EC2) instances, there are two primary methods: AWS EC2 Key Pairs SSH AWS Instance Connect. Both methods provide secure and convenient ways to access EC2 instances, but they have different pros and cons that make them suitable for different use c&#8230;</div><div class="embedded-post-cta-wrapper"><span class="embedded-post-cta">Read more</span></div><div class="embedded-post-meta">3 years ago &#183; Cristian Boarna</div></a></div><p>Regardless of your preferred connection approach, gaining access to your AWS estate be it for development, break-glass emergency production access or anything in-between, it is good to know what your options are.</p><p>In the following post I will cover a similar approach using AWS Systems Manager Session Manager instead of conventional EC2 self-managed servers.</p><p>You can find the entire codebase for the above example in my GitHub repo <a href="https://github.com/crisboarna/blog/tree/main/accessing-isolated-networks/bastion-ec2">here</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[AWS EC2 Key Pairs versus EC2-Instance-Connect]]></title><description><![CDATA[Push SSH server access and RBAC into IAM and get rid of Key Management tooling]]></description><link>https://blog.engineermindscape.com/p/aws-ec2-key-pairs-versus-ec2-instance</link><guid isPermaLink="false">https://blog.engineermindscape.com/p/aws-ec2-key-pairs-versus-ec2-instance</guid><dc:creator><![CDATA[Cristian Boarna]]></dc:creator><pubDate>Sat, 22 Apr 2023 03:47:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!B97x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B97x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B97x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!B97x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!B97x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!B97x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B97x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp" width="576" height="576" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:576,&quot;bytes&quot;:174624,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!B97x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!B97x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!B97x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!B97x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F393faf47-f0f1-4bbd-8f55-bf089b1c91ce_1024x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Securely access your data</figcaption></figure></div><p>When it comes to managing secure shell (SSH) access to Amazon Elastic Compute Cloud (EC2) instances, there are two primary methods:  </p><ul><li><p>AWS EC2 Key Pairs SSH</p></li><li><p>AWS Instance Connect. </p></li></ul><p>Both methods provide secure and convenient ways to access EC2 instances, but they have different pros and cons that make them suitable for different use cases. In this blog post, I'll briefly explain, compare and contrast between the two options highlighting which may suit your needs best. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>EC2 Key Pairs</h2><p>AWS EC2 Key Pairs SSH is the conventional method of SSH access to servers from times immemorial. With this method, users generate a key pair consisting of a public key that is uploaded to AWS, and a private key that must be kept safe, in a Key Management tool for example.</p><h4>How it works</h4><p>You either upload the SSH key to AWS as a Key Pair and reference it during instance creation for AWS to set it up for you or you leverage the <code>User data </code>property at AMI boot (if plain EC2) to download and configure it yourself. </p><p>If you are using ECS Fargate / Kubernetes, the process varies according to preferences.</p><h4>Pros:</h4><ul><li><p>Wide usage and familiarity among users spanning back decades meaning there are many resources available to help with key pair management. </p></li><li><p>Plentiful of SSH clients and tooling around it.</p></li></ul><h4>Cons:</h4><ul><li><p>Keys must be stored securely</p></li><li><p>Distribution to authorized users is an operationally cumbersome process</p></li><li><p>A compromised key requires updating all associated instances which can be quite an involved and lengthy process</p></li><li><p>Keys must be uploaded into AWS EC2 Key Pairs before starting an instance</p></li></ul><h4>Example</h4><h5>Step 1: Initialize the CDK App</h5><p>First, we need to initialize a new CDK app in our preferred language, which for me is currently TypeScript. Let&#8217;s open up a terminal and run the following commands to get started:</p><pre><code><code>mkdir -p ec2-access-ssh
cd ec2-access-ssh
npx cdk init app --language=typescript</code></code></pre><h5>Step 2: Define the VPC Stack</h5><p>Next, we need to define the VPC stack that our EC2 server will be a part of. While this can all be done in one stack, it is best practice to separate the constructs as the layers of an onion, each layer building on top of the previous one, reducing potential blast radius for any change and reducing the number of resources that need to be touched for any one change (blast radius for lower layers is greater than that of higher layers, but you still get reduces deployment time).</p><p>Open up the <code>lib</code> folder and create a new file called <code>vpc-stack.ts</code>. Add the following code to create a new VPC with a public subnet:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-Q6u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Q6u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 424w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 848w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1272w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png" width="1456" height="1318" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1318,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:543390,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!-Q6u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 424w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 848w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1272w, https://substackcdn.com/image/fetch/$s_!-Q6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e57b72e-3500-41d9-ad72-80a647a411a5_1584x1434.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/ec2-access-ssh/ec2-access-ssh/lib/vpc-stack.ts">GitHub Source</a></figcaption></figure></div><h5>Step 3: Define the EC2 Stack</h5><p>Now create a file named <code>ec2-stack.ts</code> with the following contents:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VwiB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VwiB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 424w, https://substackcdn.com/image/fetch/$s_!VwiB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 848w, https://substackcdn.com/image/fetch/$s_!VwiB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 1272w, https://substackcdn.com/image/fetch/$s_!VwiB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VwiB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png" width="1456" height="2254" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2254,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1045876,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!VwiB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 424w, https://substackcdn.com/image/fetch/$s_!VwiB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 848w, https://substackcdn.com/image/fetch/$s_!VwiB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 1272w, https://substackcdn.com/image/fetch/$s_!VwiB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68afaffa-e322-4481-b18f-a8f1cbe27b59_1740x2694.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/ec2-access-ssh/ec2-access-ssh/lib/ec2-stack.ts">GitHub Source</a></figcaption></figure></div><h6>Note </h6><p>The SSH key found in the example source code has been created using </p><pre><code><code>&gt; ssh-keygen -t rsa -f ec2_rsa_key</code></code></pre><p>and the key is committed into source to have a fully running example. You should use the command above to generate your own secure key and keep it safe. If you are within an enterprise organization, there surely are established processes for keeping the key safe.</p><h5>Step 4: Define the App Stack</h5><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2PRr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2PRr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 424w, https://substackcdn.com/image/fetch/$s_!2PRr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 848w, https://substackcdn.com/image/fetch/$s_!2PRr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 1272w, https://substackcdn.com/image/fetch/$s_!2PRr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2PRr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png" width="1412" height="804" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:804,&quot;width&quot;:1412,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:348689,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2PRr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 424w, https://substackcdn.com/image/fetch/$s_!2PRr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 848w, https://substackcdn.com/image/fetch/$s_!2PRr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 1272w, https://substackcdn.com/image/fetch/$s_!2PRr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d1e5782-a699-4f25-ae5c-688eba3407dc_1412x804.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/ec2-access-ssh/ec2-access-ssh/bin/app.ts">GitHub Source</a></figcaption></figure></div><p>Which you can now run with </p><pre><code><code>&gt; npx cdk deploy --all</code></code></pre><p>followed by the ssh command provided in the output of the command above, that is contained in the <code>Ec2Stack</code> class, as can be seen below:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!H6Lw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!H6Lw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 424w, https://substackcdn.com/image/fetch/$s_!H6Lw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 848w, https://substackcdn.com/image/fetch/$s_!H6Lw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 1272w, https://substackcdn.com/image/fetch/$s_!H6Lw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!H6Lw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png" width="1456" height="1989" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d6462f76-3955-4561-8bd8-199854042183_1840x2514.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1989,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:932236,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!H6Lw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 424w, https://substackcdn.com/image/fetch/$s_!H6Lw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 848w, https://substackcdn.com/image/fetch/$s_!H6Lw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 1272w, https://substackcdn.com/image/fetch/$s_!H6Lw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6462f76-3955-4561-8bd8-199854042183_1840x2514.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h5>Step 5: Cleanup</h5><p>Now that we have created all the needed resources and have gained SSH access, it is time to delete all the resources to avoid accruing unwanted charges to our account:</p><pre><code><code>&gt; npx cdk destroy --all</code></code></pre><h2>EC2 Instance Connect</h2><p>AWS Instance Connect provides a more streamlined approach to SSH access management. With Instance Connect, you don't need to manage SSH keys at all or configure the SSH daemon yourself. Instead you can use the AWS Management Console, AWS CLI, or SDKs to initiate a one-time use SSH connection to an instance using the Instance Connect client installed on the server. The client comes already installed on AWS AMI&#8217;s based on </p><ul><li><p><code>Amazon Linux 2</code> 2.0.20190618 or later </p></li><li><p><code>Ubuntu 20.04</code> or later</p></li></ul><h4>How it works</h4><p>This method relies on you creating an ephemeral 60 seconds short-lived SSH key and pushing it to the EC2 Metadata Service. </p><p>As the Instance Connect client is registered in the SSH daemon config file located in <code>/etc/ssh/sshd_config</code> for the:</p><ul><li><p><code>AuthorizedKeysCommand</code> </p></li><li><p><code>AuthorizedKeysCommandUser</code> </p></li></ul><p>hooks, when you initiate a SSH connection it will leverage the EC2 Metadata service to verify your ephemeral key.</p><p>To achieve this simplified secure connection you can either use:</p><ul><li><p><code>mssh</code></p><ul><li><p>This is the AWS provided Instance Connect CLI utility that automatically generates the SSH key and publishes it to the EC2 Metadata service to be used for the next 60 seconds abstracting away the entire process from you. Install process can be found <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html">here</a>.</p></li></ul></li><li><p><code>aws</code> cli</p><ul><li><p>Use the standard aws cli to perform the connection. This is a two step process as you first need to create a key to be pushed. Herein lies part of the abstraction performed by the <code>mssh </code>option above.</p></li></ul></li></ul><h4>How to do it</h4><p>In order to limit who can connect to a specific instance, here is an example IAM policy that would grant access to <code>exampleuser</code> to a specific instance:</p><pre><code><code>{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "ec2-instance-connect:SendSSHPublicKey",
            "Resource": "arn:aws:ec2:eu-west-1:111122223333:instance/i-0123456789abcdefg",
            "Condition": {
                "StringEquals": {
                    "ec2:osuser": "exampleuser"
                }
            }
        }
    ]
}</code></code></pre><p>In order to connect, you can either use </p><pre><code><code>mssh &lt;instance-id&gt;</code></code></pre><p>or</p><pre><code><code>ssh-keygen -t rsa -f ephemeral_key

aws ec2-instance-connect send-ssh-public-key \
    --region &lt;region&gt; \
    --availability-zone &lt;az&gt; \
    --instance-id &lt;instance-id&gt; \
    --instance-os-user &lt;ec2-user/ubuntu&gt; \
    --ssh-public-key file://ephemeral_key.pub

ssh -o "IdentitiesOnly=yes" -i ephemeral_key &lt;user&gt;@&lt;instance-dns&gt;</code></code></pre><h4>Pros:</h4><ul><li><p>Removes need for a Key Management infrastructure and run-book process for creating, distributing, maintaining, and rotating.</p></li><li><p>User does not need to download key to their local machine and removes risk of it being extracted if user machine is compromised.</p></li><li><p>Granular RBAC to instances is pushed into the already existing IAM role distribution policy of the company. To provide access you need to grant </p><ul><li><p><code>ec2-instance-connect:SendSSHPublicKey</code></p></li><li><p><code>ec2:DescribeInstances</code></p></li></ul></li><li><p>Generates audit trail in CloudTrail for each key push performed</p></li><li><p>You do not need to contact somebody to see which key is compatible, you generate it on the spot</p></li></ul><h4>Cons:</h4><ul><li><p>Requires additional software package to be installed on servers unless running AMI which already contains it. This may entail generating a new AMI golden image through Packer or whichever may be the company&#8217;s standard golden image generating flow.</p></li><li><p>Users need to be educated on this new process flow ( should be straightforward though).</p></li><li><p>Vendor specific access flow</p></li></ul><h4>Example</h4><p>In order to get a basic EC2 configured for access, you can follow the example code from the EC2 Key Pairs section above, with the following to the <code>ec2-stack.ts</code> file so we do not have any SSH key loaded by AWS into the instance at boot time:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!InhC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!InhC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 424w, https://substackcdn.com/image/fetch/$s_!InhC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 848w, https://substackcdn.com/image/fetch/$s_!InhC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 1272w, https://substackcdn.com/image/fetch/$s_!InhC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!InhC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png" width="1456" height="1953" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1953,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1073403,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!InhC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 424w, https://substackcdn.com/image/fetch/$s_!InhC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 848w, https://substackcdn.com/image/fetch/$s_!InhC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 1272w, https://substackcdn.com/image/fetch/$s_!InhC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F933d3a8d-2656-4487-9d69-e91834ace461_1840x2468.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://github.com/crisboarna/blog/blob/ec2-access-ssh/ec2-access-ssh/lib/ec2-stack-instance-connect.ts">GitHub Source</a></figcaption></figure></div><p>Once you have the EC2 instance running, you can use the commands in the &#8216;How to do it&#8217; section above to connect, conveniently outputted by the deploy command:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5HpY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5HpY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 424w, https://substackcdn.com/image/fetch/$s_!5HpY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 848w, https://substackcdn.com/image/fetch/$s_!5HpY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 1272w, https://substackcdn.com/image/fetch/$s_!5HpY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5HpY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png" width="1456" height="1491" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1491,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:840090,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5HpY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 424w, https://substackcdn.com/image/fetch/$s_!5HpY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 848w, https://substackcdn.com/image/fetch/$s_!5HpY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 1272w, https://substackcdn.com/image/fetch/$s_!5HpY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5f6aa00-c62b-41ae-8847-a170f132b217_1840x1884.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Terminal output</figcaption></figure></div><h6>Note</h6><p>This assumes you are using a recent, compatible AMI that has the EC2 Instance Connect agent already installed. For images that do not contain it, you can find the installation steps <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html#ec2-instance-connect-configure-IAM-role">here</a>.</p><h2>Conclusion</h2><p>Ultimately, the decision between EC2 key pairs and AWS Instance Connect will depend on your specific use case and requirements. It is up to you to decide what best fits your organization&#8217;s needs but if your conditions allow, the standardized RBAC and greatly simplified key maintenance and connection process can help in keeping a team nimble and productive.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.engineermindscape.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Engineer Mindscape! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>