<?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: Masafumi Saito</title>
    <description>The latest articles on DEV Community by Masafumi Saito (@tofu1216).</description>
    <link>https://dev.to/tofu1216</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%2F3322472%2Fb92c3fb6-bfc1-4626-a00a-199dcc7a1bbc.jpeg</url>
      <title>DEV Community: Masafumi Saito</title>
      <link>https://dev.to/tofu1216</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tofu1216"/>
    <language>en</language>
    <item>
      <title>Python Testing and Debugging for beginners</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Sat, 12 Jul 2025 06:56:08 +0000</pubDate>
      <link>https://dev.to/tofu1216/python-testing-and-debugging-for-beginners-4b9g</link>
      <guid>https://dev.to/tofu1216/python-testing-and-debugging-for-beginners-4b9g</guid>
      <description>&lt;h2&gt;
  
  
  Python Testing and Debugging
&lt;/h2&gt;

&lt;p&gt;Today, I want to share some thoughts on errors and debugging that we encounter all the time when writing programs, plus some strategies to prevent them.&lt;/p&gt;




&lt;h3&gt;
  
  
  Specifications, Testing, and Debugging
&lt;/h3&gt;

&lt;p&gt;First, let's clarify some terms.&lt;/p&gt;

&lt;h4&gt;
  
  
  Specification
&lt;/h4&gt;

&lt;p&gt;A specification is what you want to achieve by writing your program.&lt;/p&gt;

&lt;h4&gt;
  
  
  Testing
&lt;/h4&gt;

&lt;p&gt;Testing means actually running your program to see if it meets the specification. The input and expected output pairs you use for testing are called test cases.&lt;/p&gt;

&lt;h4&gt;
  
  
  Debugging
&lt;/h4&gt;

&lt;p&gt;Sometimes when you test your program, it doesn't work as specified. We call these issues bugs, and the process of fixing them is called debugging.&lt;/p&gt;

&lt;h4&gt;
  
  
  Development Flow
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Analyze the specification&lt;/li&gt;
&lt;li&gt;Write the program&lt;/li&gt;
&lt;li&gt;Test it&lt;/li&gt;
&lt;li&gt;Debug it&lt;/li&gt;
&lt;li&gt;Test again...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You keep repeating steps 1-4 in a loop.&lt;/p&gt;




&lt;h3&gt;
  
  
  Useful Statements for Debugging
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;assert&lt;/code&gt; Statement
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;assert&lt;/code&gt; statement is super useful for testing and debugging.&lt;/p&gt;

&lt;p&gt;It declares that the condition following &lt;code&gt;assert&lt;/code&gt; should be &lt;code&gt;True&lt;/code&gt;. If it's false, you get an &lt;code&gt;AssertionError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here's what happened when I triggered an AssertionError in my terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fjecmwgimhh66uh0mln2u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fjecmwgimhh66uh0mln2u.png" alt="Terminal showing AssertionError when assert condition fails" width="800" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;assert&lt;/code&gt; statement stays quiet when conditions are met, but throws an error when they're not. This makes it perfect for checking preconditions in your program.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;print&lt;/code&gt; Statement
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;print&lt;/code&gt; statement is your next best friend.&lt;/p&gt;

&lt;p&gt;It's super handy for checking what's happening inside functions during execution. Local variables (variables defined inside functions) can't be accessed from outside the function, so &lt;code&gt;print&lt;/code&gt; statements help you peek inside.&lt;/p&gt;

&lt;p&gt;Let's look at an example with a function that takes x, y, z arguments and swaps x and y:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fzo9wz47pek3mg4pc9kfl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fzo9wz47pek3mg4pc9kfl.png" alt="Terminal output showing variable values using print statements for debugging" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;AssertionError&lt;/code&gt; tells us something's wrong, but it's hard to figure out exactly what. That's where &lt;code&gt;print&lt;/code&gt; statements come to the rescue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fnwnahx7grcxajehkzh6z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fnwnahx7grcxajehkzh6z.png" alt=" " width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;print&lt;/code&gt; statements, we can see that after the first &lt;code&gt;if&lt;/code&gt; statement, the local variable values got messed up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ffc05lq1qwe6khh9jzmce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ffc05lq1qwe6khh9jzmce.png" alt=" " width="753" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By adding a local variable, we can get the intended behavior and make the &lt;code&gt;AssertionError&lt;/code&gt; disappear.&lt;/p&gt;




&lt;h3&gt;
  
  
  Types of Errors
&lt;/h3&gt;

&lt;p&gt;There are basically three types of errors.&lt;/p&gt;

&lt;h4&gt;
  
  
  Syntax Errors
&lt;/h4&gt;

&lt;p&gt;Syntax errors happen when your code doesn't follow Python's rules.&lt;/p&gt;

&lt;p&gt;Common examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Forgetting to close quotes or brackets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fjc35q08lukwj4oka1n0v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fjc35q08lukwj4oka1n0v.png" alt="Python SyntaxError: EOL while scanning string literal - missing quote" width="800" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Forgetting colons &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fv7a0qgwlalkinkevzqkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fv7a0qgwlalkinkevzqkk.png" alt="Python SyntaxError: invalid syntax - missing colon after if statement" width="800" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Messed up indentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftzjq9u5qgxqs0x53o5l9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftzjq9u5qgxqs0x53o5l9.png" alt="Python IndentationError: expected an indented block" width="800" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Syntax errors don't happen during program execution - they prevent the program from running at all.&lt;/p&gt;

&lt;h4&gt;
  
  
  Runtime Errors
&lt;/h4&gt;

&lt;p&gt;Runtime errors occur when you're actually running the program.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using undefined variables or functions → &lt;code&gt;NameError&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Trying to reference a local variable as if it were global → &lt;code&gt;UnboundLocalError&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Dividing by zero → &lt;code&gt;ZeroDivisionError&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Runtime errors have specific, descriptive names. Reading the error messages carefully often helps you fix them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Logic Errors
&lt;/h4&gt;

&lt;p&gt;Logic errors happen when your program runs fine but doesn't do what you intended. This isn't really an error with the program itself - it's a mistake made by the programmer.&lt;/p&gt;

&lt;p&gt;Most bugs are actually logic errors.&lt;/p&gt;

&lt;p&gt;This is where &lt;code&gt;assert&lt;/code&gt; statements shine again. By adding assertions to check preconditions, you can convert logic errors into &lt;code&gt;AssertionError&lt;/code&gt;s, making them easier to spot.&lt;/p&gt;

&lt;p&gt;Combining &lt;code&gt;assert&lt;/code&gt; and &lt;code&gt;print&lt;/code&gt; statements gives you the basics of debugging.&lt;/p&gt;




&lt;p&gt;Keep struggling (and enjoying) your Python learning journey!&lt;/p&gt;

&lt;p&gt;See you later! 👋&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>basic</category>
      <category>testing</category>
    </item>
    <item>
      <title>Python Beginner's Take on Software 3.0</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Fri, 11 Jul 2025 15:01:23 +0000</pubDate>
      <link>https://dev.to/tofu1216/a-python-beginners-take-on-software-30-55af</link>
      <guid>https://dev.to/tofu1216/a-python-beginners-take-on-software-30-55af</guid>
      <description>&lt;h1&gt;
  
  
  A Python Beginner's Take on Software 3.0
&lt;/h1&gt;

&lt;p&gt;Today I tried to think through &lt;strong&gt;Andrej Karpathy: Software Is Changing (Again)&lt;/strong&gt;&lt;a href="https://youtu.be/LCEmiRjPEtQ?si=cc4WYlH3Jj3U3RnD" rel="noopener noreferrer"&gt;https://youtu.be/LCEmiRjPEtQ?si=cc4WYlH3Jj3U3RnD&lt;/a&gt; and figure out my learning path going forward.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Evolution of Software
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Software 1.0
&lt;/h3&gt;

&lt;p&gt;Humans write code and give instructions to computers. Like writing if statements and for loops.&lt;/p&gt;

&lt;h3&gt;
  
  
  Software 2.0
&lt;/h3&gt;

&lt;p&gt;Instead of humans writing code, we train neural networks through datasets and optimization using neural network weights.&lt;/p&gt;

&lt;h3&gt;
  
  
  Software 3.0
&lt;/h3&gt;

&lt;p&gt;Programming LLMs using natural language (English). This will gradually replace code written in Software 1.0 and 2.0.&lt;/p&gt;




&lt;h2&gt;
  
  
  Coding Beginner's Honest Opinion
&lt;/h2&gt;

&lt;p&gt;I'm just a coding beginner - didn't study computer science or anything. I do vibe coding sometimes, using natural language to code. But here's the thing - I can't properly evaluate what gets generated. There might be security issues, tests might pass but maybe they're not designed well... I'm always worried about stuff like that. That's why I started learning from scratch.&lt;/p&gt;

&lt;p&gt;I think the future work for people in software boils down to three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building stuff using AI&lt;/li&gt;
&lt;li&gt;Setting up environments so AI can work smoothly&lt;/li&gt;
&lt;li&gt;Giving proper feedback to AI systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's exactly why I think mastering Software 1.0 and 2.0 is crucial in the Software 3.0 era.&lt;/p&gt;

&lt;p&gt;When you think of AI as a team member, everyone needs to play a manager-like role - removing blockers so AI can do its thing effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Being able to code × Management skills × Some other strength&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's all about this multiplication. That's what I want to figure out.&lt;/p&gt;




&lt;p&gt;What do you think about that? What should we focus on in this new era?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>vibecoding</category>
      <category>python</category>
    </item>
    <item>
      <title>Python Learning Progress for a Japanese Beginner</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Thu, 10 Jul 2025 13:18:48 +0000</pubDate>
      <link>https://dev.to/tofu1216/python-learning-progress-for-a-japanese-beginner-1obg</link>
      <guid>https://dev.to/tofu1216/python-learning-progress-for-a-japanese-beginner-1obg</guid>
      <description>&lt;h1&gt;
  
  
  Python Learning Progress for a Japanese Beginner
&lt;/h1&gt;

&lt;p&gt;I decided to use the University of Tokyo's Python lecture materials (&lt;a href="https://utokyo-ipp.github.io/IPP_textbook.pdf" rel="noopener noreferrer"&gt;https://utokyo-ipp.github.io/IPP_textbook.pdf&lt;/a&gt;) to build my Python fundamentals before diving into the Pymodbus library.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Did I Pick the University of Tokyo Materials?
&lt;/h2&gt;

&lt;p&gt;At first, I was thinking about using &lt;strong&gt;Automate the Boring Stuff with Python&lt;/strong&gt; (&lt;a href="https://automatetheboringstuff.com/" rel="noopener noreferrer"&gt;https://automatetheboringstuff.com/&lt;/a&gt;), which is recommended on Python's official beginner guide (&lt;a href="https://wiki.python.org/moin/BeginnersGuide/NonProgrammers" rel="noopener noreferrer"&gt;https://wiki.python.org/moin/BeginnersGuide/NonProgrammers&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Automate the Boring Stuff with Python&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;English&lt;/li&gt;
&lt;li&gt;Free web version&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  University of Tokyo Python Lecture Materials
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Japanese&lt;/li&gt;
&lt;li&gt;Covers the absolute basics&lt;/li&gt;
&lt;li&gt;Available in HTML, Google Colab, and printable PDF versions - all completely free&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why I Went with the Japanese Materials
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I wanted to learn in Japanese (my native language) so I could really understand everything properly&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - From experience, I learn way better when I can read from paper
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Today's Progress
&lt;/h2&gt;

&lt;p&gt;Today I studied basic arithmetic operations and fundamental variable declaration and assignment.&lt;/p&gt;

&lt;p&gt;Two things really stuck with me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Division operators&lt;/strong&gt;: The clear difference between regular division &lt;code&gt;/&lt;/code&gt; and integer division &lt;code&gt;//&lt;/code&gt; was a nice refresher&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assignment statements&lt;/strong&gt;: When you define variables using &lt;code&gt;=&lt;/code&gt;, it's called an "assignment statement," and executing it is called "assignment." The assignment statement takes the result from the right side and assigns it to the left side. But this is totally different from the mathematical &lt;code&gt;=&lt;/code&gt;, which represents substitution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm planning to take it slow and make sure I really get it.&lt;/p&gt;

&lt;p&gt;Catch you later! 👋&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Modbus Protocol - A Python Beginner's Summary</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Wed, 09 Jul 2025 13:26:52 +0000</pubDate>
      <link>https://dev.to/tofu1216/modbus-protocol-a-python-beginners-summary-4phk</link>
      <guid>https://dev.to/tofu1216/modbus-protocol-a-python-beginners-summary-4phk</guid>
      <description>&lt;h1&gt;
  
  
  Modbus Protocol - A Python Beginner's Summary
&lt;/h1&gt;

&lt;p&gt;I work in Tokyo as a B2B sales rep for wastewater treatment equipment. Recently, there's been growing demand not just for automated equipment itself, but also for remote monitoring and IoT integration of facilities.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;How can I respond to these needs?&lt;/strong&gt;&lt;/em&gt; This question is what motivated me to start learning Python, AWS, AI, and ML.&lt;/p&gt;

&lt;p&gt;Today, I want to leave some notes about the Modbus Protocol, which is the foundation of Python's Pymodbus library, from a beginner's perspective.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is the Modbus Protocol?
&lt;/h2&gt;

&lt;p&gt;The Modbus Protocol is a set of communication rules for industrial machines to talk to each other. Originally developed by Modicon (a PLC manufacturer) in 1979.&lt;/p&gt;

&lt;p&gt;The protocol specifications are publicly available and anyone can use it commercially for free.&lt;/p&gt;

&lt;p&gt;Due to its simplicity, many industrial devices support the Modbus Protocol.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Modbus Protocol Communication Works
&lt;/h2&gt;

&lt;p&gt;Modbus Protocol uses a master/slave communication method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Master&lt;/strong&gt; (Client): PC, monitoring systems&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Slave&lt;/strong&gt; (Server): Sensors, actuators, PLCs&lt;/p&gt;

&lt;p&gt;The actual process works like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Master sends a command (request)&lt;/li&gt;
&lt;li&gt;Only the specified slave executes that command&lt;/li&gt;
&lt;li&gt;Slave sends back the result (response)&lt;/li&gt;
&lt;li&gt;Master receives the result&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Internal Structure of Modbus-Compatible Devices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Memory Space (Data Areas)
&lt;/h3&gt;

&lt;p&gt;Modbus Protocol-compatible devices have 4 types of memory spaces for storing information, just like PC memory. These are called data areas.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Coil&lt;/strong&gt;: Stores digital values (ON/OFF or True/False), read/write access&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Discrete Input&lt;/strong&gt;: Stores digital values (ON/OFF or True/False), read-only access&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Input Register&lt;/strong&gt;: Stores analog values (numerical data), read-only access&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Holding Register&lt;/strong&gt;: Stores analog values (numerical data), read/write access&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Digital Values&lt;/th&gt;
&lt;th&gt;Analog Values&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Nature&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Discrete (ON/OFF)&lt;/td&gt;
&lt;td&gt;Continuous (numerical)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Representation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;True/False, 1/0&lt;/td&gt;
&lt;td&gt;0~65535 numbers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Size&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1 bit&lt;/td&gt;
&lt;td&gt;16 bits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Use Cases&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Switches, relays, LEDs&lt;/td&gt;
&lt;td&gt;Temperature, pressure, flow, voltage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modbus Data Areas&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;• Coil&lt;br&gt;• Discrete Input&lt;/td&gt;
&lt;td&gt;• Input Register&lt;br&gt;• Holding Register&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Key Point
&lt;/h4&gt;

&lt;p&gt;Each manufacturer and model stores different things in different areas, so you must always check the manual.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Temperature Controller&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Data Area&lt;/th&gt;
&lt;th&gt;Data Type&lt;/th&gt;
&lt;th&gt;Access&lt;/th&gt;
&lt;th&gt;Stored Information&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Coil&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Digital&lt;/td&gt;
&lt;td&gt;Read/Write&lt;/td&gt;
&lt;td&gt;Heater control, alarm reset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Discrete Input&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Digital&lt;/td&gt;
&lt;td&gt;Read-only&lt;/td&gt;
&lt;td&gt;Alarm status, operation status&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Input Register&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Analog&lt;/td&gt;
&lt;td&gt;Read-only&lt;/td&gt;
&lt;td&gt;Current temperature, sensor values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Holding Register&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Analog&lt;/td&gt;
&lt;td&gt;Read/Write&lt;/td&gt;
&lt;td&gt;Set temperature, control parameters&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Types of Modbus Communication
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Communication Method&lt;/th&gt;
&lt;th&gt;Data Format&lt;/th&gt;
&lt;th&gt;Connection&lt;/th&gt;
&lt;th&gt;Features&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modbus RTU&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Serial communication&lt;/td&gt;
&lt;td&gt;Binary&lt;/td&gt;
&lt;td&gt;RS-485 cable&lt;/td&gt;
&lt;td&gt;• Most common&lt;br&gt;• Fast &amp;amp; efficient&lt;br&gt;• Compact data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modbus ASCII&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Serial communication&lt;/td&gt;
&lt;td&gt;ASCII characters&lt;/td&gt;
&lt;td&gt;RS-485 cable&lt;/td&gt;
&lt;td&gt;• Human-readable format&lt;br&gt;• Easy to debug&lt;br&gt;• Double data volume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modbus TCP/IP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Ethernet&lt;/td&gt;
&lt;td&gt;Binary&lt;/td&gt;
&lt;td&gt;LAN cable&lt;/td&gt;
&lt;td&gt;• LAN cable connection&lt;br&gt;• Internet capable&lt;br&gt;• High-speed, long-distance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Modern PLCs (Mitsubishi Electric, Omron, Keyence, etc.) have standard support for Modbus TCP/IP communication, making it mainstream for new systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;I didn't get to write much code today, but I gained some fundamental knowledge about the technology that supports IoT.&lt;/p&gt;

&lt;p&gt;Next time, I want to try writing actual Modbus communication code using the Pymodbus library.&lt;/p&gt;

&lt;p&gt;See you tomorrow! 👋&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>iot</category>
      <category>plc</category>
    </item>
    <item>
      <title>AWS CLI and CDK Setup Journey - Part 2</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Tue, 08 Jul 2025 16:24:15 +0000</pubDate>
      <link>https://dev.to/tofu1216/aws-cli-and-cdk-setup-journey-part-2-11p6</link>
      <guid>https://dev.to/tofu1216/aws-cli-and-cdk-setup-journey-part-2-11p6</guid>
      <description>&lt;h1&gt;
  
  
  AWS CLI and CDK Setup Journey - Part 2
&lt;/h1&gt;

&lt;p&gt;Continuing from yesterday, I'm diving deeper into AWS CLI and CDK setup today!&lt;br&gt;
Yesterday's post 👇&lt;br&gt;
&lt;a href="https://dev.to/tofu1216/setting-up-aws-cli-and-cdk-2onp"&gt;https://dev.to/tofu1216/setting-up-aws-cli-and-cdk-2onp&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Still following this awesome AWS official documentation:&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cdk/v2/guide/hello-world.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cdk/v2/guide/hello-world.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's my real experience going through Steps 5-12, including the bumps I hit along the way.&lt;/p&gt;


&lt;h2&gt;
  
  
  Step 5: Check Your CDK Stack List
&lt;/h2&gt;

&lt;p&gt;Yesterday I got AWS CDK and local bootstrap all set up, so we're ready to deploy! &lt;br&gt;
Let's check what Stacks we have (Stacks are basically how CDK groups and manages AWS resources together).&lt;/p&gt;

&lt;p&gt;Run this command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You should see just one Stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HelloCdkStack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 6: Define Your Lambda Function
&lt;/h2&gt;

&lt;p&gt;Time to update &lt;code&gt;lib/hello-cdk-stack.ts&lt;/code&gt; with this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-cdk-lib&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;Construct&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="s1"&gt;constructs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Import the Lambda module&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-cdk-lib/aws-lambda&lt;/span&gt;&lt;span class="dl"&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;HelloCdkStack&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="kr"&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="c1"&gt;// Define the Lambda function resource&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myFunction&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;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Function&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;HelloWorldFunction&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;runtime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODEJS_20_X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Provide any supported Node.js runtime&lt;/span&gt;
      &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;index.handler&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromInline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`
        exports.handler = async function(event) {
          return {
            statusCode: 200,
            body: JSON.stringify('Hello World!'),
          };
        };
      `&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;As Claude explained to me:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Constructs are basically AWS resources (like Lambda or S3) represented as TypeScript classes.
Think of them as blueprints that include settings and dependencies.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This Function construct needs three key arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;scope&lt;/strong&gt;: Where to place this function in the parent hierarchy
(I'm still wrapping my head around this one - someone please help! 🤲)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;id&lt;/strong&gt;: Unique identifier for this function&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;props&lt;/strong&gt;: The actual function settings

&lt;ul&gt;
&lt;li&gt;runtime: The language and version Lambda runs on&lt;/li&gt;
&lt;li&gt;handler: Which function to execute&lt;/li&gt;
&lt;li&gt;code: The actual function code&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 7: Define the Lambda Function URL
&lt;/h2&gt;

&lt;p&gt;We'll use the &lt;code&gt;Function&lt;/code&gt; construct's &lt;code&gt;addFunctionUrl&lt;/code&gt; helper method to create a Lambda function URL. To output this URL value when we deploy, we'll create an AWS CloudFormation output using the &lt;code&gt;CfnOutput&lt;/code&gt; construct. (Still figuring this part out too, but apparently Lambda needs a URL to run!)&lt;/p&gt;

&lt;p&gt;Add this code to &lt;code&gt;lib/hello-cdk-stack.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&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;HelloCdkStack&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="kr"&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="c1"&gt;// Define the Lambda function resource&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;

    &lt;span class="c1"&gt;// Define the Lambda function URL resource&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myFunctionUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;myFunction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addFunctionUrl&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;authType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FunctionUrlAuthType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NONE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// Define a CloudFormation output for your URL&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CfnOutput&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;myFunctionUrlOutput&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;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;myFunctionUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&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;h2&gt;
  
  
  Step 8: Synthesize the CloudFormation Template
&lt;/h2&gt;

&lt;p&gt;Now let's run this command to convert our TypeScript code into a CloudFormation template:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If successful, you'll see the CloudFormation template output like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Resources:
  HelloWorldFunctionServiceRole&amp;lt;unique-identifier&amp;gt;:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Statement:
          - Action: sts:AssumeRole
            Effect: Allow
            Principal:
              Service: lambda.amazonaws.com
        Version: &lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;
      ManagedPolicyArns:
        - Fn::Join:
            - &lt;span class="s2"&gt;""&lt;/span&gt;
            - - &lt;span class="s2"&gt;"arn:"&lt;/span&gt;
              - Ref: AWS::Partition
              - :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
    Metadata:
      aws:cdk:path: HelloCdkStack/HelloWorldFunction/ServiceRole/Resource
  HelloWorldFunction&amp;lt;unique-identifier&amp;gt;:
    Type: AWS::Lambda::Function
    Properties:
      Code:
        ZipFile: &lt;span class="s2"&gt;"

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;       exports.handler = async function(event) {

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;         return {

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;           statusCode: 200,

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;           body: JSON.stringify('Hello World!'),

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;         };

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;       };

          &lt;/span&gt;&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="s2"&gt;     "&lt;/span&gt;
      Handler: index.handler
      Role:
        Fn::GetAtt:
          - HelloWorldFunctionServiceRole&amp;lt;unique-identifier&amp;gt;
          - Arn
      Runtime: nodejs20.x
    DependsOn:
      - HelloWorldFunctionServiceRole&amp;lt;unique-identifier&amp;gt;
    Metadata:
      aws:cdk:path: HelloCdkStack/HelloWorldFunction/Resource
  HelloWorldFunctionFunctionUrl&amp;lt;unique-identifier&amp;gt;:
    Type: AWS::Lambda::Url
    Properties:
      AuthType: NONE
      TargetFunctionArn:
        Fn::GetAtt:
          - HelloWorldFunction&amp;lt;unique-identifier&amp;gt;
          - Arn
    Metadata:
      aws:cdk:path: HelloCdkStack/HelloWorldFunction/FunctionUrl/Resource
  HelloWorldFunctioninvokefunctionurl&amp;lt;unique-identifier&amp;gt;:
    Type: AWS::Lambda::Permission
    Properties:
      Action: lambda:InvokeFunctionUrl
      FunctionName:
        Fn::GetAtt:
          - HelloWorldFunction&amp;lt;unique-identifier&amp;gt;
          - Arn
      FunctionUrlAuthType: NONE
      Principal: &lt;span class="s2"&gt;"*"&lt;/span&gt;
    Metadata:
      aws:cdk:path: HelloCdkStack/HelloWorldFunction/invoke-function-url
  CDKMetadata:
    Type: AWS::CDK::Metadata
    Properties:
      Analytics: v2:deflate64:&amp;lt;unique-identifier&amp;gt;
    Metadata:
      aws:cdk:path: HelloCdkStack/CDKMetadata/Default
    Condition: CDKMetadataAvailable
Outputs:
  myFunctionUrlOutput:
    Value:
      Fn::GetAtt:
        - HelloWorldFunctionFunctionUrl&amp;lt;unique-identifier&amp;gt;
        - FunctionUrl
Parameters:
  BootstrapVersion:
    Type: AWS::SSM::Parameter::Value&amp;lt;String&amp;gt;
    Default: /cdk-bootstrap/&amp;lt;unique-identifier&amp;gt;/version
    Description: Version of the CDK Bootstrap resources &lt;span class="k"&gt;in &lt;/span&gt;this environment, automatically retrieved from SSM Parameter Store. &lt;span class="o"&gt;[&lt;/span&gt;cdk:skip]
Rules:
  CheckBootstrapVersion:
    Assertions:
      - Assert:
          Fn::Not:
            - Fn::Contains:
                - - &lt;span class="s2"&gt;"1"&lt;/span&gt;
                  - &lt;span class="s2"&gt;"2"&lt;/span&gt;
                  - &lt;span class="s2"&gt;"3"&lt;/span&gt;
                  - &lt;span class="s2"&gt;"4"&lt;/span&gt;
                  - &lt;span class="s2"&gt;"5"&lt;/span&gt;
                - Ref: BootstrapVersion
        AssertDescription: CDK bootstrap stack version 6 required. Please run &lt;span class="s1"&gt;'cdk bootstrap'&lt;/span&gt; with a recent version of the CDK CLI.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we're ready to deploy!&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 9: Deploy the CDK Stack
&lt;/h2&gt;

&lt;p&gt;Let's deploy our CDK stack! This takes the CloudFormation template we just generated and deploys it through AWS CloudFormation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk deploy &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ Don't forget to specify your --profile!&lt;/p&gt;

&lt;p&gt;Once it's done, head over to the AWS Console and check out your resources in both Lambda and CloudFormation.&lt;/p&gt;

&lt;p&gt;Lambda&lt;br&gt;
&lt;a href="https://media2.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%2F7xtts84vz3x0fsfu32rf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7xtts84vz3x0fsfu32rf.png" alt=" " width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;CloudFormation&lt;br&gt;
&lt;a href="https://media2.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%2Frvkum8s2is06u38kr65h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Frvkum8s2is06u38kr65h.png" alt=" " width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  How CloudFormation Templates and CDK Work Together 🔍
&lt;/h3&gt;

&lt;p&gt;Let me break down what's happening behind the scenes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a CloudFormation Template?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;file&lt;/strong&gt; written in &lt;strong&gt;JSON/YAML format&lt;/strong&gt; that describes AWS resource configurations&lt;/li&gt;
&lt;li&gt;Think of it as a blueprint that tells AWS "how to build what"&lt;/li&gt;
&lt;li&gt;AWS CloudFormation service reads this and creates the actual resources&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is CloudFormation?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;service&lt;/strong&gt; that reads JSON/YAML files and &lt;strong&gt;provisions&lt;/strong&gt; actual AWS resources&lt;/li&gt;
&lt;li&gt;It's like a "converter/execution engine"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How CDK Works:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;CDK is a &lt;strong&gt;tool that includes&lt;/strong&gt; CloudFormation service&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write code&lt;/strong&gt; in TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cdk synth&lt;/code&gt;&lt;/strong&gt; converts your program code into CloudFormation template (JSON/YAML format)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;cdk deploy&lt;/code&gt;&lt;/strong&gt; uses CloudFormation to deploy
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your CDK Code (TypeScript)
        ↓ cdk synth
CloudFormation Template (JSON)
        ↓ cdk deploy
CloudFormation Service (AWS)
        ↓ executes
Actual AWS Resources (Lambda, etc.)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 10: Test Your Application
&lt;/h2&gt;

&lt;p&gt;Use the URL that was displayed when you ran the &lt;code&gt;cdk deploy&lt;/code&gt; command to test your function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://&amp;lt;api-id&amp;gt;.lambda-url.&amp;lt;Region&amp;gt;.on.aws/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's my actual execution - it worked perfectly! 👌&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F3u4qh0axxt70cbmtaoqf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F3u4qh0axxt70cbmtaoqf.png" alt=" " width="800" height="26"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 11: Make Changes to Your Application
&lt;/h2&gt;

&lt;p&gt;Let's modify our Lambda code a bit. I changed &lt;code&gt;myFunction&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Define the Lambda function resource&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myFunction&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;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Function&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;HelloWorldFunction&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;runtime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODEJS_20_X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Provide any supported Node.js&lt;/span&gt;
  &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;index.handler&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromInline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`
    exports.handler = async function(event) {
      return {
        statusCode: 200,
        body: JSON.stringify('Hello CDK I'm AWS Lambda!!'),
      };
    };
  `&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 preview your changes, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk diff &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then deploy again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk deploy &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And test the URL again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://&amp;lt;api-id&amp;gt;.lambda-url.&amp;lt;Region&amp;gt;.on.aws/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But here's where I hit a snag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Internal Server Error%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I checked the Lambda function logs in CloudWatch and found a syntax error!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fizkk99rx135pzskuf6uk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fizkk99rx135pzskuf6uk.png" alt=" " width="800" height="64"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Turns out the culprit was the apostrophe in &lt;code&gt;I'm&lt;/code&gt;! Since I was using single quotes to wrap the string, the &lt;code&gt;'&lt;/code&gt; in &lt;code&gt;I'm&lt;/code&gt; was being interpreted as the end of the string, causing a syntax error. Changed it to &lt;code&gt;I am&lt;/code&gt; and everything worked perfectly! ⭕️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F89pwx8sq3b2556zy3lml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F89pwx8sq3b2556zy3lml.png" alt=" " width="800" height="24"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 12: Clean Up Your Application
&lt;/h2&gt;

&lt;p&gt;Finally, let's clean up. This command will delete all the resources we created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk destroy &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the command and check the AWS Console. The Lambda function should be gone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fh2ix5wc70l4oq6m5zg20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fh2ix5wc70l4oq6m5zg20.png" alt=" " width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In CloudFormation, you'll notice the stack is still there. Apparently this is normal behavior. If you're not using CDK anymore, you might want to delete it manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fx01qbdteasb7xxs97b9t.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fx01qbdteasb7xxs97b9t.webp" alt=" " width="800" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you do delete it, you can always bring it back with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk bootstrap &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Wrap Up
&lt;/h2&gt;

&lt;p&gt;That's it! AWS CDK setup is complete. Now if I set up CDK in other environments within IAM Identity Center, I can easily switch between environments using command line profiles.&lt;/p&gt;

&lt;p&gt;This is incredibly convenient!!&lt;/p&gt;

&lt;p&gt;See you tomorrow! 👋&lt;/p&gt;

</description>
      <category>aws</category>
      <category>beginners</category>
      <category>cli</category>
      <category>programming</category>
    </item>
    <item>
      <title>Setting up AWS CLI and CDK</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Mon, 07 Jul 2025 15:54:33 +0000</pubDate>
      <link>https://dev.to/tofu1216/setting-up-aws-cli-and-cdk-2onp</link>
      <guid>https://dev.to/tofu1216/setting-up-aws-cli-and-cdk-2onp</guid>
      <description>&lt;h1&gt;
  
  
  Setting up AWS CLI and CDK
&lt;/h1&gt;

&lt;p&gt;Yesterday, I set up AWS IAM Identity Center. You can check out my previous post here:&lt;br&gt;
&lt;a href="https://dev.to/tofu1216/why-use-aws-iam-identity-center-2jko"&gt;https://dev.to/tofu1216/why-use-aws-iam-identity-center-2jko&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today, I want to connect my local VS Code environment with AWS CLI and CDK.&lt;/p&gt;


&lt;h2&gt;
  
  
  What Makes AWS CLI and CDK So Convenient?
&lt;/h2&gt;

&lt;p&gt;Let me recap what AWS CLI and CDK bring to the table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS CLI&lt;/strong&gt; lets you operate from the terminal, so you don't have to manually click through AWS console settings anymore.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS CDK&lt;/strong&gt; allows you to write infrastructure using programming languages instead of hand-writing YAML files.&lt;/li&gt;
&lt;li&gt;This theoretically enables someone like me (an individual) to build enterprise-level infrastructure. (Though I still have a lot to learn! 🔥)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Setting up AWS CLI
&lt;/h2&gt;

&lt;p&gt;I followed this official AWS documentation for the CLI setup: &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign in to AWS access portal using your IAM Identity Center username and password.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Access keys&lt;/strong&gt; for your account and copy the SSO start URL and SSO region information.&lt;/li&gt;
&lt;li&gt;Run the following command in your local VS Code terminal:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws configure sso
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;You'll be prompted to enter information as follows:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SSO session name (Recommended)&lt;/td&gt;
&lt;td&gt;Set freely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSO start URL&lt;/td&gt;
&lt;td&gt;URL copied from previous step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSO region&lt;/td&gt;
&lt;td&gt;Region copied from previous step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSO registration scopes&lt;/td&gt;
&lt;td&gt;Enter &lt;code&gt;sso:account:access&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;A browser will launch for authentication. After completing authentication, enter the remaining items in the terminal:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;There are n AWS accounts available to you.&lt;/td&gt;
&lt;td&gt;Select the account you want to use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;There are n roles available to you.&lt;/td&gt;
&lt;td&gt;Select the role you want to use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CLI default client Region&lt;/td&gt;
&lt;td&gt;For example, Tokyo is &lt;code&gt;ap-northeast-1&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CLI default output format&lt;/td&gt;
&lt;td&gt;Press Enter (json will be set as default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CLI profile name&lt;/td&gt;
&lt;td&gt;Enter any name for your configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  What is a profile name?
&lt;/h3&gt;

&lt;p&gt;A profile name is what you use to save and identify your CLI session settings (from login to logout). You can create multiple profiles, which is convenient because it allows you to work in parallel with different permissions.&lt;/p&gt;


&lt;h2&gt;
  
  
  Setting up AWS CDK
&lt;/h2&gt;

&lt;p&gt;I followed this official AWS documentation for CDK setup: &lt;a href="https://docs.aws.amazon.com/cdk/v2/guide/hello-world.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cdk/v2/guide/hello-world.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the key points I encountered while doing steps 1-3:&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Create a CDK project
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a new CDK project by running this command in your terminal:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;hello-cdk &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;hello-cdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Initialize the project (prepare it for execution) with this command. I followed the tutorial default and used TypeScript:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk init app &lt;span class="nt"&gt;--language&lt;/span&gt; typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Configure AWS environment
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;To get your AWS account ID, run this command in the terminal. &lt;strong&gt;Make sure to use the &lt;code&gt;--profile&lt;/code&gt; option&lt;/strong&gt; to specify your profile name:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws sts get-caller-identity &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"Account"&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;⚠️ I got multiple errors when I ran this command without specifying --profile, so be careful!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To get your AWS region name, run this command in the terminal. &lt;strong&gt;Make sure to use the &lt;code&gt;--profile&lt;/code&gt; option&lt;/strong&gt; to specify your profile name:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws configure get region &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;⚠️ I got multiple errors when I ran this command without specifying --profile, so be careful😅&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your project files and edit &lt;strong&gt;bin/hello-cdk.ts&lt;/strong&gt;. Replace the &lt;strong&gt;env&lt;/strong&gt; information with your own account ID and region:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;source-map-support/register&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="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-cdk-lib&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;HelloCdkStack&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="s1"&gt;../lib/hello-cdk-stack&lt;/span&gt;&lt;span class="dl"&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;app&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;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;HelloCdkStack&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;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HelloCdkStack&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;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;account&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;123456789012&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;us-east-1&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;⚠️ The env is initially commented out, so you need to remove the // from //env. &lt;br&gt;
⚠️ Don't forget to save with Shift + S after making changes!&lt;/p&gt;


&lt;h3&gt;
  
  
  Step 3: Bootstrap your AWS environment
&lt;/h3&gt;
&lt;h4&gt;
  
  
  What is bootstrapping?
&lt;/h4&gt;

&lt;p&gt;Bootstrapping is &lt;strong&gt;preparing the foundational resources&lt;/strong&gt; that AWS CDK needs to perform deployment operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The following are automatically created in your AWS environment:
├ S3 bucket (for storing CDK assets)
├ IAM roles (permissions used by CDK)
├ ECR repository (for Docker images)
└ SSM parameters (configuration information)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Bootstrapping before/after
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS environment: Empty state
└ CDK deploy → Error (no workspace available)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS environment:
├ CDKToolkit-S3Bucket (asset storage)
├ CDKToolkit-IAMRole (deployment permissions)
└ CDK ready
    └ CDK deploy → Success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Why is this necessary?
&lt;/h4&gt;

&lt;p&gt;When CDK &lt;strong&gt;converts code to AWS resources&lt;/strong&gt;, it follows this process (my buddy Claude taught me this! 🎓):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Compile TypeScript and other code&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Store generated files in S3&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create resources with CloudFormation&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;=&amp;gt; This workflow requires &lt;strong&gt;dedicated S3 buckets and IAM roles&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to bootstrap
&lt;/h4&gt;

&lt;p&gt;Run this command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cdk bootstrap &lt;span class="nt"&gt;--profile&lt;/span&gt; your-profile-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ I got multiple errors when I ran this command without specifying --profile, so be careful😭&lt;/p&gt;

&lt;p&gt;Tomorrow I'll actually follow the tutorial and create Lambda resources!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>aws</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Why Use AWS IAM Identity Center?</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Sun, 06 Jul 2025 12:14:35 +0000</pubDate>
      <link>https://dev.to/tofu1216/why-use-aws-iam-identity-center-2jko</link>
      <guid>https://dev.to/tofu1216/why-use-aws-iam-identity-center-2jko</guid>
      <description>&lt;h1&gt;
  
  
  Why Use AWS IAM Identity Center?
&lt;/h1&gt;

&lt;p&gt;While researching how to integrate AWS with VS Code, I discovered that AWS IAM Identity Center was the recommended service. This got me thinking about why this service is so valuable.&lt;/p&gt;




&lt;p&gt;I had already set up environment separation using AWS Organizations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Root 
├── Infrastructure
│   ├── Development(dev@)
│   └── Demo(demo@)
├── Production
│   └── Production(prod@)
└── Security
    └── Admin (admin@)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, I was manually creating IAM users in each environment, making password management increasingly difficult. (I should have researched this sooner!)&lt;/p&gt;

&lt;p&gt;While AWS Organizations allows you to group AWS accounts under the same organization, IAM users and roles created in each account aren't connected across the organization. This means AWS Organizations alone cannot provide centralized access management. To switch environments, I had to sign out and log back into different accounts.&lt;/p&gt;




&lt;p&gt;This is where &lt;strong&gt;AWS IAM Identity Center&lt;/strong&gt; becomes incredibly useful.&lt;/p&gt;

&lt;p&gt;It allows you to create &lt;strong&gt;IAM Identity Center users&lt;/strong&gt; that can access IAM roles across all environments. From a single user account, you can create, assign, and switch between IAM roles in different environments.&lt;/p&gt;

&lt;p&gt;This enables centralized access management at the organizational level. You only need to manage one password for the IAM Identity Center user.&lt;/p&gt;

&lt;p&gt;(Seriously, I wish I had discovered this earlier!)&lt;/p&gt;




&lt;h2&gt;
  
  
  Setup Summary
&lt;/h2&gt;

&lt;h3&gt;
  
  
  IAM Users vs IAM Identity Center Users
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;IAM Users&lt;/th&gt;
&lt;th&gt;IAM Identity Center Users&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Management&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Individual per AWS account&lt;/td&gt;
&lt;td&gt;Centralized in management account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Separate login per account&lt;/td&gt;
&lt;td&gt;Single Sign-On (SSO)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Password Management&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Multiple passwords&lt;/td&gt;
&lt;td&gt;Single password for all accounts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Access Method&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Direct login to each account&lt;/td&gt;
&lt;td&gt;Role switching via AWS Access Portal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Permission Management&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Individual setup per account&lt;/td&gt;
&lt;td&gt;Centralized via permission sets&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Before / After Comparison
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Before (Manual Setup)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Independent Account Structure with IAM Users:
├ aws-admin@ (Management): admin-saito
├ aws-dev@ (Development): dev-admin
├ aws-demo@ (Demo): demo-admin
└ aws-prod@ (Production): prod-admin

Challenges:
- Managing 4 different passwords
- Re-authentication for each environment switch
- Individual permission changes in each account
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  After (IAM Identity Center)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Centralized Management:
Management Account (aws-admin@)
├ IAM Identity Center User: admin
├ Group: MyGroup-Administrators
├ Permission Set: AdministratorAccess
└ Access Settings:
    ├ aws-dev@ / AdministratorAccess
    ├ aws-demo@ / AdministratorAccess
    ├ aws-prod@ / AdministratorAccess
    └ aws-admin@ / AdministratorAccess

Improvements:
- Single password for all environments
- Seamless environment switching via AWS Access Portal
- Centralized permission management
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is remarkable – from managing multiple passwords and constant re-authentication to a single, streamlined access experience across all AWS environments.&lt;/p&gt;

&lt;p&gt;Tomorrow, I'll try AWS CDK.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>aws</category>
    </item>
    <item>
      <title>Git &amp; GitHub Basics: A Beginner's Guide</title>
      <dc:creator>Masafumi Saito</dc:creator>
      <pubDate>Sat, 05 Jul 2025 12:17:27 +0000</pubDate>
      <link>https://dev.to/tofu1216/git-github-basics-a-beginners-guide-3i36</link>
      <guid>https://dev.to/tofu1216/git-github-basics-a-beginners-guide-3i36</guid>
      <description>&lt;h1&gt;
  
  
  Git &amp;amp; GitHub Basics: A Beginner's Guide
&lt;/h1&gt;

&lt;p&gt;I keep forgetting these steps every time I ask AI, so I'm documenting them for future reference. Here's how to connect your local development environment with GitHub repositories using Git and GitHub - the essential basics of these convenient code version management tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git&lt;/strong&gt; is version control software that runs on your local computer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt; is a web service that manages Git repositories in the cloud&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Creating an Account
&lt;/h2&gt;

&lt;p&gt;GitHub URL: &lt;a href="https://github.com/" rel="noopener noreferrer"&gt;https://github.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Detailed getting started documentation: &lt;a href="https://docs.github.com/en/get-started/onboarding/getting-started-with-your-github-account" rel="noopener noreferrer"&gt;https://docs.github.com/en/get-started/onboarding/getting-started-with-your-github-account&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2A. Creating a Repository on GitHub First
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use terminal commands on your local computer&lt;/span&gt;
&lt;span class="c"&gt;# 1. Clone the GitHub repository to your local PC (first time only)&lt;/span&gt;
git clone https://github.com/username/repository-name.git

&lt;span class="c"&gt;# 2. Navigate to the cloned folder&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;repository-name

&lt;span class="c"&gt;# 3. Create and edit files&lt;/span&gt;
&lt;span class="c"&gt;# (Create index.html or other files here)&lt;/span&gt;

&lt;span class="c"&gt;# 4. Add changed files to "staging"&lt;/span&gt;
&lt;span class="c"&gt;# (Staging = commit preparation area)&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;# ↑ "." means "all files in the current folder"&lt;/span&gt;

&lt;span class="c"&gt;# 5. "Commit" the files in staging&lt;/span&gt;
&lt;span class="c"&gt;# (Commit = save changes as a record)&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit"&lt;/span&gt;
&lt;span class="c"&gt;# ↑ Text after -m is the commit message (description of changes)&lt;/span&gt;

&lt;span class="c"&gt;# 6. Upload local changes to GitHub (remote)&lt;/span&gt;
git push origin main
&lt;span class="c"&gt;# ↑ origin = GitHub repository, main = main branch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2B. Creating Local Files First
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Initialize current folder as a Git repository&lt;/span&gt;
git init
&lt;span class="c"&gt;# ↑ Make an empty folder "manageable by Git"&lt;/span&gt;

&lt;span class="c"&gt;# 2. Link GitHub repository with local folder&lt;/span&gt;
git remote add origin https://github.com/username/repository-name.git
&lt;span class="c"&gt;# ↑ origin = alias for GitHub repository&lt;/span&gt;
&lt;span class="c"&gt;# ↑ remote add = set "this local folder connects to this GitHub"&lt;/span&gt;

&lt;span class="c"&gt;# 3. Create and edit files&lt;/span&gt;
&lt;span class="c"&gt;# (Create index.html or other files here)&lt;/span&gt;

&lt;span class="c"&gt;# 4. Add changed files to "staging"&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;# ↑ Specify created files to "include in next commit"&lt;/span&gt;

&lt;span class="c"&gt;# 5. "Commit" the files in staging&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit"&lt;/span&gt;
&lt;span class="c"&gt;# ↑ Save changes as a record (still local only)&lt;/span&gt;

&lt;span class="c"&gt;# 6. Upload local changes to GitHub (remote)&lt;/span&gt;
git push origin main
&lt;span class="c"&gt;# ↑ main = branch name (default main branch)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. Summary of Creation Methods
&lt;/h2&gt;

&lt;p&gt;Methods A and B achieve the same result but in different order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Method A&lt;/strong&gt;: Create GitHub repository → Clone to local&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Method B&lt;/strong&gt;: Create local files → Link to GitHub repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For beginners, &lt;strong&gt;Method A (git clone) is recommended&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Creating Branches
&lt;/h2&gt;

&lt;p&gt;When making major feature changes or UI design modifications during development, I recommend using the &lt;strong&gt;branch&lt;/strong&gt; feature.&lt;/p&gt;

&lt;p&gt;GitHub allows you to create parallel working environments. These working environments are called branches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Branch concept:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- main branch (default)
- feature-login branch (code implementing login functionality)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good practice: Use &lt;strong&gt;main&lt;/strong&gt; for production environment (shouldn't break) and &lt;strong&gt;feature&lt;/strong&gt; for experimental code (okay to break).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create branches:&lt;/strong&gt;&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;# 1. Check current branch&lt;/span&gt;
git branch
&lt;span class="c"&gt;# ↑ Current branch is marked with "*" (usually main)&lt;/span&gt;

&lt;span class="c"&gt;# 2. Create and switch to new branch&lt;/span&gt;
git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; feature/login-form
&lt;span class="c"&gt;# ↑ feature/login-form = branch name (commonly includes feature name)&lt;/span&gt;
&lt;span class="c"&gt;# ↑ -b = create new + switch simultaneously&lt;/span&gt;

&lt;span class="c"&gt;# 3. Work on the new branch&lt;/span&gt;
&lt;span class="c"&gt;# (Create and edit login form here)&lt;/span&gt;

&lt;span class="c"&gt;# 4. Commit changes&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add login form feature"&lt;/span&gt;

&lt;span class="c"&gt;# 5. Push new branch to GitHub&lt;/span&gt;
git push origin feature/login-form
&lt;span class="c"&gt;# ↑ First push of new branch&lt;/span&gt;

&lt;span class="c"&gt;# 6. Return to main branch&lt;/span&gt;
git checkout main
&lt;span class="c"&gt;# ↑ or git switch main&lt;/span&gt;

&lt;span class="c"&gt;# 7. Update main branch to latest&lt;/span&gt;
git pull origin main
&lt;span class="c"&gt;# ↑ Prepare for potential changes by others&lt;/span&gt;

&lt;span class="c"&gt;# 8. Merge new branch into main&lt;/span&gt;
git merge feature/login-form
&lt;span class="c"&gt;# ↑ Integrate feature/login-form changes into main&lt;/span&gt;

&lt;span class="c"&gt;# 9. Delete merged branch (optional)&lt;/span&gt;
git branch &lt;span class="nt"&gt;-d&lt;/span&gt; feature/login-form
&lt;span class="c"&gt;# ↑ Remove unnecessary branch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Give it a try, everyone!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
    </item>
  </channel>
</rss>
