<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fabien Townsend</title>
    <description>The latest articles on DEV Community by Fabien Townsend (@fabientownsend).</description>
    <link>https://dev.to/fabientownsend</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F28242%2F27f12cc9-5b8c-4ca5-b206-ae54907f47fb.jpeg</url>
      <title>DEV Community: Fabien Townsend</title>
      <link>https://dev.to/fabientownsend</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fabientownsend"/>
    <language>en</language>
    <item>
      <title>Setup Node and NVM with Fish Shell</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Mon, 29 Jan 2024 19:12:58 +0000</pubDate>
      <link>https://dev.to/fabientownsend/setup-node-and-nvm-with-fish-shell-5f3</link>
      <guid>https://dev.to/fabientownsend/setup-node-and-nvm-with-fish-shell-5f3</guid>
      <description>&lt;p&gt;Here is how to quickly install NVM with Fish Shell. I do assume here that you have fish shell installed and bew. If you don't have fish shell installed, you can follow my other tutorial here: &lt;a href="https://dev.to/fabientownsend/tldr-setup-fish-shell-macos-2ee2"&gt;TL;DR setup Fish Shell MacOS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1: Install nvm with brew&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;nvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2: Install &lt;code&gt;bass&lt;/code&gt; for Fish Shell&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;omf install bass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3: Configure Fish shell&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ~/.config/fish/config.fish&lt;/span&gt;

...

&lt;span class="k"&gt;function &lt;/span&gt;nvm
  bass &lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;brew &lt;span class="nt"&gt;--prefix&lt;/span&gt; nvm&lt;span class="o"&gt;)&lt;/span&gt;/nvm.sh &lt;span class="nt"&gt;--no-use&lt;/span&gt; &lt;span class="s1"&gt;';'&lt;/span&gt; nvm &lt;span class="nv"&gt;$argv&lt;/span&gt;
end

&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; NVM_DIR ~/.nvm
nvm use default &lt;span class="nt"&gt;--silent&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it, you are good to go, you can install node now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--lts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>node</category>
      <category>nvm</category>
      <category>fish</category>
      <category>shell</category>
    </item>
    <item>
      <title>Empowering Your Team with CLI Tools: A Quick Guide using Node.js</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Fri, 26 Jan 2024 09:38:24 +0000</pubDate>
      <link>https://dev.to/fabientownsend/empowering-your-team-with-cli-tools-a-quick-guide-using-nodejs-120n</link>
      <guid>https://dev.to/fabientownsend/empowering-your-team-with-cli-tools-a-quick-guide-using-nodejs-120n</guid>
      <description>&lt;p&gt;In the dynamic landscape of technology, the ability to create Command-Line Interface (CLI) tools is a valuable skill that can significantly enhance your team's efficiency. CLI tools empower teams to streamline the execution of repetitive tasks, debug user issues by pulling relevant data, and monitor the health of systems, among other applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with Node.js
&lt;/h2&gt;

&lt;p&gt;Creating a CLI tool with Node.js is a straightforward process. Follow these quick steps to have a functional CLI tool up and running in no time:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Set Up a New Project
&lt;/h3&gt;

&lt;p&gt;Initiate a new Node.js project with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm config &lt;span class="nb"&gt;set type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create Your Script File
&lt;/h3&gt;

&lt;p&gt;Create an &lt;code&gt;index.js&lt;/code&gt; file for your CLI tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the file as executable with the following shebang:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env node&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make the file executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Update &lt;code&gt;package.json&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Add a "bin" entry to your &lt;code&gt;package.json&lt;/code&gt; to specify the command associated with your CLI tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"bin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"whatever-cmd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./index.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Create a Symbolic Link
&lt;/h3&gt;

&lt;p&gt;Link your CLI tool globally using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;link&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With these simple steps, you've created a basic structure for a Node.js CLI tool. Now, you can build upon this foundation by adding custom code to execute specific tasks. Whether it's automating routine processes, extracting data for debugging, or monitoring system health, your CLI tool is ready to empower your team's workflow.&lt;/p&gt;

&lt;p&gt;Remember, the versatility of CLI tools extends beyond these examples, allowing you to tailor solutions to the unique needs of your tech environment. By mastering this skill, you contribute to the efficiency and effectiveness of your team's development processes. So, dive in, experiment, and witness the transformative impact of CLI tools in your tech arsenal.&lt;/p&gt;

</description>
      <category>node</category>
      <category>cli</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Setup tmux on MacOS</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Tue, 05 Dec 2023 10:24:56 +0000</pubDate>
      <link>https://dev.to/fabientownsend/setup-tmux-on-macos-3fhi</link>
      <guid>https://dev.to/fabientownsend/setup-tmux-on-macos-3fhi</guid>
      <description>&lt;p&gt;In a previous post, I discussed how I swiftly set up &lt;a href="https://dev.to/fabientownsend/tldr-setup-fish-shell-macos-2ee2"&gt;Fish Shell&lt;/a&gt; on my new MacOS.&lt;/p&gt;

&lt;p&gt;Now, let's delve into the setup process for &lt;a href="https://github.com/tmux/tmux/wiki" rel="noopener noreferrer"&gt;tmux&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why tmux?
&lt;/h2&gt;

&lt;p&gt;Tmux is crucial for maintaining my sanity while navigating between different projects. It allows me to have a distinct session for each project, and within each session, I can manage various windows to perform tasks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running the project&lt;/li&gt;
&lt;li&gt;Executing tests&lt;/li&gt;
&lt;li&gt;Opening another related project&lt;/li&gt;
&lt;li&gt;And more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For installation, ensure that you have &lt;code&gt;brew&lt;/code&gt; installed by running:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

brew &lt;span class="nb"&gt;install &lt;/span&gt;tmux


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To configure the minimal settings and make sure &lt;code&gt;fish&lt;/code&gt; is used by default, create a &lt;code&gt;tmux.conf&lt;/code&gt; file with the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; ~/.tmux.conf
&lt;span class="nv"&gt;$ &lt;/span&gt;vim ~/.tmux.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add the following line to the file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; default-shell /opt/homebrew/bin/fish


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;If you're unsure about the fish path, type &lt;code&gt;whereis fish&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, if you want new Terminals to use tmux by default, follow these steps:&lt;br&gt;
&lt;code&gt;Terminal &amp;gt; Settings... &amp;gt; Profiles &amp;gt; Startup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5fiv07wak2ctl31c5x3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5fiv07wak2ctl31c5x3.png" alt="Term2 Configuration"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>I messed up with AWD CDK, so you don't have to make the same mistake</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Sat, 02 Dec 2023 13:56:08 +0000</pubDate>
      <link>https://dev.to/fabientownsend/i-messed-up-with-awd-cdk-so-you-dont-have-to-make-the-same-mistake-1adc</link>
      <guid>https://dev.to/fabientownsend/i-messed-up-with-awd-cdk-so-you-dont-have-to-make-the-same-mistake-1adc</guid>
      <description>&lt;p&gt;In my previous post, I discussed my choice of &lt;a href="https://dev.to/fabientownsend/why-i-picked-aws-cdk-33gg"&gt;AWS CDK&lt;/a&gt;. As a newcomer to this solution, I followed various tutorials that provided basic solutions for quickly setting up different components. However, as I added more elements—multiple DynamoDB tables, several Lambdas, and a new public endpoint for the API Gateway—to a single file, I encountered two significant challenges:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigation became difficult.&lt;/li&gt;
&lt;li&gt;There was an increased likelihood of merge conflicts when multiple people edited the same file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Anticipating these issues, I knew that refactoring and isolating responsibilities would be necessary. However, dealing with infrastructure is not as straightforward as working with regular code.&lt;/p&gt;

&lt;p&gt;When attempting to extract database creation code to a separate file, I faced unexpected challenges. With CDK, removing something from the code also removes it from the infrastructure. While this works seamlessly for stateless entities like Lambdas, it creates complications for resources like DynamoDB.&lt;/p&gt;

&lt;p&gt;In the case of DynamoDB, moving code to another file results in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Removal from the infrastructure, though the database remains intact in AWS; however, CDK considers it deleted.&lt;/li&gt;
&lt;li&gt;Attempted recreation of the database, leading to an error stating that it already exists.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ParentFile&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;...&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dynamodbTable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TableV2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;tableName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;partitionKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sessionID&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AttributeType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;sortKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;timestamp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AttributeType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ParentFile&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;...&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;helloWithCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AnotherFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HelloHitCounter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{});&lt;/span&gt;

    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AnotherFile&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;...&lt;/span&gt; 

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dynamodbTable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TableV2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;tableName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;partitionKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sessionID&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AttributeType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;sortKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;timestamp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AttributeType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This leaves us in a situation where the database exists in AWS but not in CDK.&lt;/p&gt;

&lt;p&gt;There are two alternative solutions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Import the Database:&lt;/strong&gt;&lt;br&gt;
You can achieve this with code like &lt;code&gt;dynamodb.TableV2.fromTableName(scope, id, "aName");&lt;/code&gt;. This limits you to read-only operations such as allowing to grant access to Lambdas but .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Import Existing AWS Resources to CDK:&lt;/strong&gt;&lt;br&gt;
Reference the DynamoDB creation code in the same way you initially created it and run &lt;code&gt;cdk import&lt;/code&gt;. This approach reimports everything, giving you full control over the database.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The steps would be as follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remove the reference to the dynamoDB (&lt;strong&gt;make sure that it retains the DB in AWS&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;run &lt;code&gt;cdk deploy&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add the reference you deleted to your new file&lt;/li&gt;
&lt;li&gt;run &lt;code&gt;cdk import&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To summarize: avoid consolidating everything in a single file. If, like me, you hastily combined components, you can now refactor your CDK stack by performing a soft delete to keep resources in AWS while excluding them from AWS CDK. Subsequently, reimport them to regain full control.&lt;/p&gt;

&lt;p&gt;Resource: &lt;br&gt;
&lt;a href="https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk/README.md#cdk-import"&gt;Find here an example step by step from AWS&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cdk</category>
      <category>node</category>
    </item>
    <item>
      <title>TL;DR setup Fish Shell MacOS</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Mon, 27 Nov 2023 14:57:00 +0000</pubDate>
      <link>https://dev.to/fabientownsend/tldr-setup-fish-shell-macos-2ee2</link>
      <guid>https://dev.to/fabientownsend/tldr-setup-fish-shell-macos-2ee2</guid>
      <description>&lt;p&gt;Here is TL;DR (too long; didn't read) summary of how to set Fish Shell on your MacOS to get that result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fobsgts7a5tzhhinma8rl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fobsgts7a5tzhhinma8rl.png" alt="Example of Fish Shell on MacOS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the commands that I used:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 bash
$ brew install fish
$ curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish
$ omf install bobthefish
$ set -g theme_nerd_fonts yes
$ brew tap homebrew/cask-fonts
$ brew install font-hack-nerd-font --cask


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The next step will "fix" the font now being properly displayed:&lt;/p&gt;

&lt;p&gt;Open your term2 profile:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4c0w0hvmaxoks47uel2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4c0w0hvmaxoks47uel2.png" alt="term2 profile"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Edit the font used:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lem6qhr6bi1v3vdzdwk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lem6qhr6bi1v3vdzdwk.png" alt="term2 edition font"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshoot 1
&lt;/h2&gt;

&lt;p&gt;I had an issue where &lt;code&gt;bobthefish&lt;/code&gt; theme wouldn't work out, for that I followed the following steps:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 bash
functions fish_promp


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And then delete the file it pointed out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remove omf and fish installation
&lt;/h2&gt;

&lt;p&gt;I initially messed up with my installation, the following command enables me to clean up &lt;code&gt;fish&lt;/code&gt;/&lt;code&gt;omf&lt;/code&gt; to start from the beginning:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 bash
$ omf remove bobthefish
$ omf destroy
$ brew uninstall fish
$ rm -rf opt/homebrew/etc/fish                                


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>macos</category>
      <category>cli</category>
      <category>fish</category>
      <category>shell</category>
    </item>
    <item>
      <title>How to set and delete AWS CLI profile</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Thu, 23 Nov 2023 09:55:00 +0000</pubDate>
      <link>https://dev.to/fabientownsend/how-to-set-and-delete-aws-cli-profile-4822</link>
      <guid>https://dev.to/fabientownsend/how-to-set-and-delete-aws-cli-profile-4822</guid>
      <description>&lt;p&gt;In this article, I will briefly explain how to add an AWS profile to your AWS CLI and how to delete it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to add a profile
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AWS Console
&lt;/h3&gt;

&lt;p&gt;From the top right of your screen, click on &lt;code&gt;Security credentials&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwre8yqk0kouuef5st6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwre8yqk0kouuef5st6g.png" alt="AWS Console menu"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then scroll down to the &lt;code&gt;Access keys&lt;/code&gt; and click on &lt;code&gt;Create access key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdkr0i5bopoz7sj5vxrog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdkr0i5bopoz7sj5vxrog.png" alt="AWS Console Access keys section"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then select &lt;code&gt;Command Line Interface (cli)&lt;/code&gt;, check the tick box, and click on &lt;code&gt;Next&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pm238mord9sv5ubal2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2pm238mord9sv5ubal2o.png" alt="AWS Console creation step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, you will be asked to &lt;code&gt;Description tag value&lt;/code&gt; which is optional, on the following page you will be provided with the &lt;code&gt;Access key&lt;/code&gt; and &lt;code&gt;Secret access key&lt;/code&gt; required for configure your CLI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmw1hlzn5dt64ptfcrac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmw1hlzn5dt64ptfcrac.png" alt="AWS Console aws cli access key and secret access key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we can pass to the CLI the required steps&lt;/p&gt;

&lt;h3&gt;
  
  
  CLI
&lt;/h3&gt;

&lt;p&gt;You can start by typing the following command which will show you the current list of your AWS profile: &lt;code&gt;aws configure list-profiles&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will now need to type the following command, where &lt;code&gt;test&lt;/code&gt; is the name of the profile that you want&lt;br&gt;
&lt;code&gt;aws configure --profile test&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 cli
AWS Access Key ID [None]: AKIA2INPZLWEZ2RAZ37Q
AWS Secret Access Key [None]: ****
Default region name [None]: eu-west-1
Default output format [None]: 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now if you type again &lt;code&gt;aws configure list-profiles&lt;/code&gt; you will see you new profile.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to delete a profile
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AWS Console
&lt;/h3&gt;

&lt;p&gt;From the &lt;code&gt;Access keys&lt;/code&gt; section of the &lt;code&gt;Security credentials&lt;/code&gt; page of your profile, you can click on &lt;code&gt;Action&lt;/code&gt; &amp;gt; &lt;code&gt;Delete&lt;/code&gt; and follow the steps described&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljdftsdhoy0zptkb65w7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljdftsdhoy0zptkb65w7.png" alt="AWS Console deletion cli profile"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have deleted the profile from your AWS Console, you can follow the steps for your CLI&lt;/p&gt;

&lt;h3&gt;
  
  
  CLI
&lt;/h3&gt;

&lt;p&gt;You have two files in your system &lt;code&gt;credentials&lt;/code&gt; and &lt;code&gt;config&lt;/code&gt;, you can find them in the following path for MacOS:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 cli
~/.aws/credentials
~/.aws/config


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So in each of them, you will need to delete the related information to your profile which will be right below &lt;code&gt;[test]&lt;/code&gt; where &lt;code&gt;test&lt;/code&gt; is the name of your profile&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cli</category>
    </item>
    <item>
      <title>Set up your authentication with Next.js and AWS Cognito</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Sun, 19 Nov 2023 12:25:37 +0000</pubDate>
      <link>https://dev.to/fabientownsend/set-up-your-authentication-with-nextjs-and-aws-cognito-2f08</link>
      <guid>https://dev.to/fabientownsend/set-up-your-authentication-with-nextjs-and-aws-cognito-2f08</guid>
      <description>&lt;p&gt;In the realm of Next.js applications hosted on Vercel with an AWS infrastructure, establishing robust authentication becomes a pivotal task. After careful consideration of various options, including an in-house solution, Auth0, and Clerk, the decision was made to leverage AWS Cognito due to its seamless integration with AWS services.&lt;/p&gt;

&lt;p&gt;The journey began with a glance at the existing in-house implementation, which fell short in handling advanced features such as email confirmation and password reset. While Auth0 and Clerk were considered, concerns about pricing and specific requirements like HIPAA compliance led to the selection of AWS Cognito.&lt;/p&gt;

&lt;p&gt;Despite AWS Cognito's reputation for complex documentation, the benefits of integration with API Gateway and AppSync made it an attractive choice. The AWS CDK file presented below outlines the crucial steps in configuring AWS Cognito:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// *-stack.ts
    const userPool = new cognito.UserPool(this, "MyUserPool", {
      userPoolName: "my-next-auth-app-user-pool",
      selfSignUpEnabled: true,
      signInAliases: { email: true },
    });

    userPool.addDomain("MyUserPoolDomain", {
      cognitoDomain: {
        domainPrefix: "my-custom-domain-prefix",
      },
    });

    new cognito.UserPoolClient(
      this,
      "MyUserPoolClient",
      {
        userPool,
        userPoolClientName: "my-next-auth-app-client",
        authFlows: {
          userSrp: true,
          userPassword: true,
        },
      }
    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the front-end, the following configuration using AWS Amplify is recommended:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws-amplify/ui-react/styles.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Amplify&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aws-amplify&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;WithAuthenticatorProps&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws-amplify/ui-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;withAuthenticator&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws-amplify/ui-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;Amplify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;Auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Cognito&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;userPoolId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your user pool id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;userPoolClientId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your user pool client id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;signUpVerificationMethod&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;code&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;loginWith&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;oauth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;domain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;you domain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;scopes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;phone&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;profile&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;openid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aws.cognito.signin.user.admin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="na"&gt;redirectSignIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:3000/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="na"&gt;redirectSignOut&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:3000/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="na"&gt;responseType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;code&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// or 'token', note that REFRESH token will only be generated when the responseType is code&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Amplify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getConfig&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;Amplify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentConfig&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;signOut&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;WithAuthenticatorProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;signOut&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;withAuthenticator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In conclusion, while this implementation serves as an illustrative example rather than a production-ready solution, it fills a void in resources for those seeking guidance on "AWS CDK + Next.js + Cognito." It's worth noting that the provided approach utilizes Amplify's configuration and UI for the login flow without relying on their CLI.&lt;/p&gt;

</description>
      <category>cdk</category>
      <category>cws</category>
      <category>cognito</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Why I picked AWS CDK?</title>
      <dc:creator>Fabien Townsend</dc:creator>
      <pubDate>Thu, 16 Nov 2023 11:33:02 +0000</pubDate>
      <link>https://dev.to/fabientownsend/why-i-picked-aws-cdk-33gg</link>
      <guid>https://dev.to/fabientownsend/why-i-picked-aws-cdk-33gg</guid>
      <description>&lt;p&gt;Title: Choosing AWS CDK for Infrastructure Improvement: A Practical Approach&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article, I'll detail the reasoning behind my choice of AWS CDK (Cloud Development Kit) based on a real-life scenario. Drawing from my extensive experience as a software consultant and product engineer for start-ups, I'll walk you through the decision-making process and share insights gained from working on projects with demanding automated testing requirements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau9nup9s7rgvsahezhhn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau9nup9s7rgvsahezhhn.png" alt="High level issue with software" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identifying the Challenge&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The challenge at hand involved a software system plagued by reliability issues. This system was hosted on an EC2 server and deployed manually through FTP, resulting in a user-experience problem where the server frequently lost user states, forcing a restart of user journeys from the beginning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approaching the Issue&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My initial approach was twofold: comprehensively understand the problematic features and their expectations. Once I had a clear understanding, I considered two potential strategies:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Work with the existing legacy code and fix identified issues.&lt;/li&gt;
&lt;li&gt;Reimplement the feature from scratch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Choosing between these options was contingent on a case-by-case evaluation, with the understanding that "just rewriting it" shouldn't be the default solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Considering Solutions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When addressing problems, I habitually explore diverse solutions and weigh their trade-offs. This might involve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implementing a straightforward fix.&lt;/li&gt;
&lt;li&gt;Implementing a temporary hotfix while planning a comprehensive solution.&lt;/li&gt;
&lt;li&gt;Opting for a complete rewrite.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Decision to Improve&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this particular case, with a tight deadline for the fix and an opportunity to enhance the team's workflow, I chose not only to address the issue by rewriting the code but also to improve infrastructure and deployment processes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choosing AWS CDK&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Considering various tools like AWS CloudFormation, Terraform, Serverless framework, and AWS CDK, I opted for AWS CDK. This decision was influenced by my limited experience with AWS CloudFormation and Terraform, as well as the consideration that their learning curves might not align with the team's proficiency. Comparing Serverless and AWS CDK, I leaned towards AWS CDK due to its flexibility and the fact that our infrastructure was entirely on AWS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqk9d4z6qz2j3s36lxm57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqk9d4z6qz2j3s36lxm57.png" alt="AWS CDK logo" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Factors for Choosing AWS CDK&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Familiarity with AWS infrastructure.&lt;/li&gt;
&lt;li&gt;Flexibility required for the project.&lt;/li&gt;
&lt;li&gt;Quick decision-making, prioritizing agility over extensive research.&lt;/li&gt;
&lt;li&gt;Positive experiences with ChatGPT-generated insights for implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Implementation and Results&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Deploying and testing AWS Lambda + AWS API Gateway with the refactored functionality proved successful in addressing the reliability issue. The outcome includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Migration of one service from an EC2 server to a Lambda function.&lt;/li&gt;
&lt;li&gt;Enhanced understanding of the service.&lt;/li&gt;
&lt;li&gt;Streamlined code updates and deployments through the CLI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft01qa1ha0wwo5atfowb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft01qa1ha0wwo5atfowb0.png" alt="High level representation of the solution" width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AWS CDK has proven to be an impressive tool, facilitating swift infrastructure deployment and code updates. Its user-friendly approach aligns well with our need to move rapidly and adapt to evolving requirements. The decision-making process, though expedited, remains open to future adjustments, recognizing the potential for evolving needs and associated costs.&lt;/p&gt;

</description>
      <category>cdk</category>
      <category>startup</category>
      <category>aws</category>
      <category>lambda</category>
    </item>
  </channel>
</rss>
