<?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: Rajit Paul</title>
    <description>The latest articles on DEV Community by Rajit Paul (@rajitpaul).</description>
    <link>https://dev.to/rajitpaul</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%2F599923%2F80fcd0d3-e299-44a5-b109-43d522211510.png</url>
      <title>DEV Community: Rajit Paul</title>
      <link>https://dev.to/rajitpaul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajitpaul"/>
    <language>en</language>
    <item>
      <title>Enhance your Code Security with Amazon Inspector</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Sun, 27 Jul 2025 15:47:03 +0000</pubDate>
      <link>https://dev.to/aws-builders/enhance-your-code-security-with-amazon-inspector-45no</link>
      <guid>https://dev.to/aws-builders/enhance-your-code-security-with-amazon-inspector-45no</guid>
      <description>&lt;p&gt;As a latest addition to the vulnerability scanning capabilities of Amazon Inspector across multiple AWS services, it now supports scanning of your application source code, dependencies and Infrastructure as Code (IAC). It has a native integration with your SCMs - GitHub and GitLab and it helps you build a shift left security approach while taking proactive decisions securing your SDLC.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let's Get Up and Running&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Currently Amazon Inspector Code Security scan is available in 10 AWS Regions, you can get the full list &lt;a href="https://docs.aws.amazon.com/inspector/latest/user/inspector_regions.html#ins-regional-feature-availability" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&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%2Fdtsfkyo90302xcdrv580.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%2Fdtsfkyo90302xcdrv580.png" alt=" " width="800" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Considering you are in one of the listed regions and have activated Inspector, select Code Security on the left pane.&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%2Fjl8q1v6h9lt14hmubu8a.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%2Fjl8q1v6h9lt14hmubu8a.png" alt=" " width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once I click on ConnectTo, I get two options. As I am using GitHub as my SCM, I select it and proceed.&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%2Ffu3kw36adyelv9ry1u86.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%2Ffu3kw36adyelv9ry1u86.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can choose the default scan configuration or customise it according to your usecase. I will create a custom scan configuration for now.&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%2Fbgnivioqyxfn12s0sarl.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%2Fbgnivioqyxfn12s0sarl.png" alt=" " width="800" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In here you fix a scan frequency, I chose change based and periodic scanning which means whenever you create a pull or merge request or push new code a scan will be triggered. Alongside you can set weekly or monthly periodic scans, and in weekly scans you can choose the day you want the scan to run, this could be based off of your release cycles. &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%2F13lx89ofninopnmwaff4.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%2F13lx89ofninopnmwaff4.png" alt=" " width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, you choose the scope of the scan analysis, in my case I need all the three options enabled, so I will keep things as it is and create the scan configuration.&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%2Fj84uyy86dp1ba3xdgr75.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%2Fj84uyy86dp1ba3xdgr75.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I will provide a name to my configuration and connect to Github.&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%2F798ujxeh5ddefyudjbgh.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%2F798ujxeh5ddefyudjbgh.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will use the link mentioned in the pop up screen to authorize to GitHub.&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%2Fcsh8hcv77ygxakt9gp8z.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%2Fcsh8hcv77ygxakt9gp8z.png" alt=" " width="800" height="735"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Accept the authorization&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%2Fbk3rhva6b22rqukfhnd8.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%2Fbk3rhva6b22rqukfhnd8.png" alt=" " width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once authorized, I got a message on the top of Inspector Console asking me to visit the GitHub connections page&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%2Fklp5a0h0dotf4z20xqgj.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%2Fklp5a0h0dotf4z20xqgj.png" alt=" " width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will install a new GitHub App&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%2Ffzj44x7m0b4e8ayvdlwb.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%2Ffzj44x7m0b4e8ayvdlwb.png" alt=" " width="632" height="974"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Installed the app with a selected repository from my personal account.&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%2F3qcefcipsm5kno7cs168.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%2F3qcefcipsm5kno7cs168.png" alt=" " width="800" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have a successful GitHub connection.&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%2Fktlbzamp9v3sx6fgjj2m.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%2Fktlbzamp9v3sx6fgjj2m.png" alt=" " width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I pushed a commit to Master to trigger a scan.&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%2Fqf7jo0loih7xlz3i7w86.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%2Fqf7jo0loih7xlz3i7w86.png" alt=" " width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the analysis is concluded (it might take some time), you can see the Scan status as Active against your Code Repositories.&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%2F54vegdwsk1xz3sqyt0fg.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%2F54vegdwsk1xz3sqyt0fg.png" alt=" " width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Findings section you can see all the vulnerabilities in your code and you can get assisted remediation and fix with other details when you select the particular vulnerability. Also you can filter out the vulnerabilites based on SCM provider, severity, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Testing Terraform IAC&lt;/strong&gt;
&lt;/h2&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%2F76fed9g78pd3m9ewdjz7.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%2F76fed9g78pd3m9ewdjz7.png" alt=" " width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Added one more repo with Terraform code to my GitHub application and it is listed in Code Security Console but pending inital scan, let's push a commit to the repository.&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%2Fcy82yesp9rbohcfqhfl8.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%2Fcy82yesp9rbohcfqhfl8.png" alt=" " width="800" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code Security scanned the newly added repo and flagged issues in the code and also suggested remediation with code fixes which is super useful.&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%2Fmherupvctg3i1nlxqdr9.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%2Fmherupvctg3i1nlxqdr9.png" alt=" " width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I created a seperate branch in my newly added repository and updated the Terraform code. Post which I created a PR to merge the changes with main, which triggered a CodeSecurity Scan on the GitHub console and once concluded it highlighted the code snippets that needed to be checked and stated the reason for flagging those with severity.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;On-Demand Scan&lt;/strong&gt;
&lt;/h2&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%2Fwux28qzv85n9n095rswy.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%2Fwux28qzv85n9n095rswy.png" alt=" " width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I added a third repository to my GitHub Application, and it is listed in my Code Security console. This time instead of pushing some code or creating a PR, I will generate an On-Demand Scan for the repository.&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%2Fw6asg21460prd4xwtpso.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%2Fw6asg21460prd4xwtpso.png" alt=" " width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I get a message saying that the On-Demand Scan generation is successful.&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%2Fivt1v1fccerkvyvr74hp.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%2Fivt1v1fccerkvyvr74hp.png" alt=" " width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Within sometime I see findings generated :)&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Lets Talk About Pricing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You are charged for each scan and each scan type 0.15 USD, against a single repository.&lt;/p&gt;

&lt;p&gt;So a scan of a single repository with all three scan types enabled would cost 1*0.15*3 = 0.45 USD&lt;/p&gt;

&lt;p&gt;If your repository does not contain IAC, you should create a new scanning configuration with IAC disabled to save costs.&lt;/p&gt;

&lt;p&gt;Also there is an option in your scanning configuration to disable scanning when code is changed or disable periodic scanning if you want to save further costs and just rely on On-Demand scans, but this will not let you utilize the full potential of this tool. &lt;/p&gt;

&lt;p&gt;More details related to pricing &lt;a href="https://aws.amazon.com/inspector/pricing/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Wrapping Up&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I feel this feature is a great addition to the current capabilities of Amazon Inspector by helping find code vulnerabilities and misconfigurations early in the development lifecycle and I hope this blog will help you get started with Code Security 🤘&lt;/p&gt;

</description>
      <category>aws</category>
      <category>security</category>
      <category>vulnerabilities</category>
      <category>devsecops</category>
    </item>
    <item>
      <title>Elevating Security with Amazon GuardDuty Runtime Monitoring</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Sat, 25 Jan 2025 07:12:46 +0000</pubDate>
      <link>https://dev.to/aws-builders/enhanced-runtime-monitoring-for-ecs-with-amazon-guardduty-4d16</link>
      <guid>https://dev.to/aws-builders/enhanced-runtime-monitoring-for-ecs-with-amazon-guardduty-4d16</guid>
      <description>&lt;p&gt;With the majority of our applications now being cloud-native and containerized, ensuring security has become paramount. While static security measures, such as &lt;a href="https://community.aws/content/2pk8NbSgCTL3lL8nR60LaqHdbq5" rel="noopener noreferrer"&gt;image scanning with Amazon Inspector&lt;/a&gt;, play a crucial role, monitoring container security during runtime is equally important. This is where ECS Runtime Monitoring with &lt;a href="https://aws.amazon.com/guardduty/" rel="noopener noreferrer"&gt;Amazon GuardDuty&lt;/a&gt; comes into play. GuardDuty Runtime Monitoring, now over a year in general availability, has proven its effectiveness in detecting runtime security threats across EC2 instances, ECS Clusters, and EKS Clusters. In this blog, we'll walk through enabling runtime monitoring for your ECS Cluster, generating GuardDuty findings, and setting up alerts for both runtime monitoring health and GuardDuty Findings to enhance your security posture. &lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon GuardDuty: Advanced Threat Detection for AWS Security
&lt;/h2&gt;

&lt;p&gt;Amazon GuardDuty is a fully managed threat detection service that continuously monitors your AWS environment for suspicious activity. By analyzing vast amounts of data from sources like AWS Cloudtrail, VPC Flow Logs, and DNS logs, GuardDuty detects threats such as unauthorized access, data exfiltration, or compromised instances engaging in malicious activity.&lt;/p&gt;

&lt;p&gt;Leveraging AI, machine learning, and threat intelligence , GuardDuty identifies anomalies such as unusual login attempts, unexpected changes to resources, or attempts to disable security controls helping you respond before threats escalate. It provides automated analysis and actionable insights without the need for complex security infrastructure, making it an efficient and scalable solution for cloud security.&lt;/p&gt;

&lt;p&gt;GuardDuty offers specialized protection across AWS Services including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;S3 Protection - Detects unauthorized access and data theft from S3 Buckets.&lt;/li&gt;
&lt;li&gt;EKS Protection - Monitor Kubernetes workloads for suspicious activity.&lt;/li&gt;
&lt;li&gt;Runtime Monitoring - Identifies real time threats in compute environments.&lt;/li&gt;
&lt;li&gt;Malware Protection - Scans Amazon EC2 and S3 for malware threats.&lt;/li&gt;
&lt;li&gt;RDS Protection - Guards against database related security risks.&lt;/li&gt;
&lt;li&gt;Lambda Protection - Monitors serverless workloads for anomalies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By automating threat detection and reducing manual security efforts, GuardDuty helps businesses safeguard their AWS infrastructure with minimal operational overhead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enabling the fully managed GuardDuty Agent
&lt;/h2&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%2Fku1aie6zl7964wdllkea.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%2Fku1aie6zl7964wdllkea.png" alt="Enabling the GuardDuty Agent" width="800" height="421"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;When we deploy the GuardDuty security agent, GuardDuty will create a VPC Endpoint for the security agent to deliver runtime security events to GuardDuty. Alongside it will also create a new security group that will control the traffic that's allowed to reach the resources using inbound rules of the security group and will adapt to vpc cidr range changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  ECS Cluster
&lt;/h2&gt;

&lt;p&gt;I started with an existing ECS Cluster with a single task running on AWS Fargate.&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%2Fxvi5kdbl9g3q06bz9bwl.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%2Fxvi5kdbl9g3q06bz9bwl.png" alt="ECS Fargate Cluster" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Within the task configuration, you'll notice two containers running:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Main Application Container&lt;/li&gt;
&lt;li&gt;Sidecar Container launched by AWS to run the Amazon GuardDuty agent&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%2Fr1a26u422baj2v0prh3s.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%2Fr1a26u422baj2v0prh3s.png" alt="ECS Task Configuration" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GuardDuty actively monitoring the ECS Cluster&lt;/strong&gt;&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%2Fscb24uw9ht39wpla1h1b.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%2Fscb24uw9ht39wpla1h1b.png" alt="GuardDuty Runtime Monitoring" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  GuardDuty Runtime Monitoring Alerts
&lt;/h2&gt;

&lt;p&gt;It is essential to configure alerts for when GuardDuty Runtime Monitoring enters an unhealthy state or when a Runtime Monitoring Finding is detected.&lt;/p&gt;

&lt;p&gt;To achieve this, I have configured EventBridge rules with Amazon SNS as the target to trigger email notifications for both.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GuardDuty Runtime Monitoring Unhealthy State Alert&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I manually scaled down the ECS service from 1 to 0, so that the GuardDuty agent is no longer able to communicate with Amazon GuardDuty and the Runtime Monitoring status is pushed to an unhealthy state, upon which the Eventbridge Rule is triggered and a SNS notification is generated.&lt;/p&gt;

&lt;p&gt;Event Pattern for Eventbridge Rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "source": ["aws.guardduty"],
  "detail-type": ["GuardDuty Runtime Protection Unhealthy"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fybuc181938hfg9xuu83e.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%2Fybuc181938hfg9xuu83e.png" alt="Unhealthy GuardDuty Runtime Monitoring" width="800" height="335"&gt;&lt;/a&gt;&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%2Fe7mxm2mijffwv6mjxw14.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%2Fe7mxm2mijffwv6mjxw14.png" alt="Unhealthy Runtime Monitoring Notification" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GuardDuty Runtime Monitoring Findings Alert&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I &lt;a href="https://docs.aws.amazon.com/guardduty/latest/ug/sample_findings.html" rel="noopener noreferrer"&gt;generated sample findings in GuardDuty&lt;/a&gt; to test and validate the alerting mechanism.&lt;/p&gt;

&lt;p&gt;Event Pattern for Eventbridge Rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "source": ["aws.guardduty"],
  "detail": {
    "type": ["Backdoor:Runtime/C&amp;amp;CActivity.B", "PrivilegeEscalation:Runtime/DockerSocketAccessed"]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find the full list of GuardDuty Runtime Monitoring Finding Types &lt;a href="https://docs.aws.amazon.com/guardduty/latest/ug/findings-runtime-monitoring.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Findings Generated&lt;/strong&gt;&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%2F7z6i21hoezffn6sxta4l.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%2F7z6i21hoezffn6sxta4l.png" alt="Sample Findings" width="800" height="431"&gt;&lt;/a&gt;&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%2Fdgl303nxi0f2gjm6v0pq.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%2Fdgl303nxi0f2gjm6v0pq.png" alt="Alerts on Runtime Findings" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using an Encrypted SNS Topic
&lt;/h2&gt;

&lt;p&gt;If you would like to encrypt your SNS Messages before saving them in it's data centers in order to comply with a certain compliance, there are a few things you need to ensure so that your GuardDuty alerts don't fail to deliver.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Firstly, you need to use a CMK(Customer Managed Key) instead of a default SNS Encryption key to encrypt your SNS Topic.&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%2Fh7a6wh2c3nvc975h2nkb.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%2Fh7a6wh2c3nvc975h2nkb.png" alt="Image description" width="800" height="291"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secondly the Eventbridge rule should have the necessary permission to invoke your KMS key to decrypt the data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While you are creating the Eventbridge rule note down the IAM role that is being created by default and you can later add the necessary permissions to it.&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%2Fuc0ck5mfrkoqhol5qwye.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%2Fuc0ck5mfrkoqhol5qwye.png" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Effect": "Allow",
    "Action": [
      "kms:GenerateDataKey",
      "kms:Decrypt"
    ],
    "Resource": [
      "arn:aws:kms:ap-south-1:123456734:key/53c1b423-3a5e-1234-1111-eda13df344de"               ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace your kms key arn!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Third, you need to add the necessary &lt;a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-encryption-key-policy.html" rel="noopener noreferrer"&gt;permission&lt;/a&gt; in your KMS policy to authorize Eventbridge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you see the messages not getting delivered, it means you failed to satisfy any of the above three pointers and for further troubleshooting you can also refer [this].(&lt;a href="https://repost.aws/knowledge-center/sns-not-getting-eventbridge-notification" rel="noopener noreferrer"&gt;https://repost.aws/knowledge-center/sns-not-getting-eventbridge-notification&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this blog serves as a great starting point for exploring this exciting feature. Below, I've compiled a few additional resources that will help you dive deeper and make the most of it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/blogs/security/using-amazon-guardduty-ecs-runtime-monitoring-with-fargate-and-amazon-ec2/" rel="noopener noreferrer"&gt;Using Amazon GuardDuty ECS runtime monitoring with Fargate and Amazon EC2&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_settingup.html#setup-sns" rel="noopener noreferrer"&gt;GuardDuty Alerting using Eventbridge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/guardduty/latest/ug/runtime-monitoring.html" rel="noopener noreferrer"&gt;GuardDuty Runtime Monitoring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/guardduty/latest/ug/what-is-guardduty.html" rel="noopener noreferrer"&gt;GuardDuty Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devsecops</category>
      <category>aws</category>
      <category>security</category>
      <category>containers</category>
    </item>
    <item>
      <title>Optimize Cost Savings using AWS EC2 Spot Instances as your EKS Worker Nodes</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Sun, 20 Aug 2023 09:29:26 +0000</pubDate>
      <link>https://dev.to/aws-builders/optimize-cost-savings-using-aws-ec2-spot-instances-as-your-eks-worker-nodes-2b6f</link>
      <guid>https://dev.to/aws-builders/optimize-cost-savings-using-aws-ec2-spot-instances-as-your-eks-worker-nodes-2b6f</guid>
      <description>&lt;p&gt;To optimize cost-savings while deploying dev/test workloads on EKS you can utilize Amazon EC2 Spot Instances and run them as your EKS Nodes.&lt;/p&gt;

&lt;p&gt;Amazon EC2 Spot Instances let you take advantage of unused EC2 capacity in the AWS cloud. Spot Instances are available at up to a 90% discount compared to On-Demand prices. [Source: &lt;a href="https://aws.amazon.com/ec2/spot/" rel="noopener noreferrer"&gt;AWSDocs&lt;/a&gt;]&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An AWS Account&lt;/li&gt;
&lt;li&gt;An IAM user with administrator access and a EC2 Role with administrator access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are going to deploy an EKS Cluster using eksctl from an EC2 Instance which is going to be our launchpad, you can do the same from your local machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Launch an EC2 Instance and install necessary packages
&lt;/h2&gt;

&lt;p&gt;We shall be launching an EC2 using the Amazon Linux 2023 AMI, with t3a.small instance type and keeping the rest of the settings default, if you wish you can change them based on your requirements. I've kept the SSH Access allowed for anywhere for the sake of this demo, highly recommend you to opt granular access for the same using MyIP.&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%2Fhe5l3aowohcydnbuna15.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%2Fhe5l3aowohcydnbuna15.png" alt="Image description" width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing eksctl&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For Unix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# for ARM systems, set ARCH to: `arm64`, `armv6` or `armv7`
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH

curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"

# (Optional) Verify checksum
curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check

tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp &amp;amp;&amp;amp; rm eksctl_$PLATFORM.tar.gz

sudo mv /tmp/eksctl /usr/local/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source: &lt;a href="https://eksctl.io/introduction/#installation" rel="noopener noreferrer"&gt;eksctl docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing kubectl&lt;/strong&gt;&lt;br&gt;
As we shall be launching the latest version of EKS (1.27) for amd64 based architecture, we will run the below commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.1/2023-04-19/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin &amp;amp;&amp;amp; cp ./kubectl $HOME/bin/kubectl &amp;amp;&amp;amp; export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' &amp;gt;&amp;gt; ~/.bashrc
kubectl version --short --client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source: &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html" rel="noopener noreferrer"&gt;AWS Docs&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Launching an EKS Cluster with spot instances using eksctl
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;ClusterConfig:&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;---
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
    name: my-eks-cluster
    region: ap-south-1
    version: "1.27"

vpc:
  subnets:
    private:
      private-ap-south-1a: 
        id: "xxxxxxx"
      private-ap-south-1b: 
        id: "xxxxxxx"
      private-ap-south-1c: 
        id: "xxxxxxx"

managedNodeGroups:
    - name: spot-nodegroup
      ami: ami-016931097ac39b652
      amiFamily: AmazonLinux2
      overrideBootstrapCommand: |
        #!/bin/bash
        /etc/eks/bootstrap.sh my-eks-cluster --container-runtime containerd
      privateNetworking: true
      minSize: 1
      maxSize: 3
      desiredCapacity: 1
      instanceTypes: ["t3.medium","t3.small","t3a.small","t3a.medium"]
      spot: true
      subnets:
      - private-ap-south-1a
      - private-ap-south-1b
      - private-ap-south-1c
      labels: {node: spot}
      ssh:
        publicKeyName: yourkeypairname
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additionally we have to create an Admin Role for our EKS LaunchPad Server and attach it&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%2Fpe23ich0dvcb7led8woj.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%2Fpe23ich0dvcb7led8woj.png" alt="Image description" width="800" height="362"&gt;&lt;/a&gt;&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%2Frsxxo6p01j5z1patztrx.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%2Frsxxo6p01j5z1patztrx.png" alt="Image description" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To create the cluster, run &lt;code&gt;eksctl create cluster -f cluster.yaml&lt;/code&gt;&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%2Fcjif00nq9fgge2lsrxte.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%2Fcjif00nq9fgge2lsrxte.png" alt="Image description" width="800" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we create the cluster using eksctl, AWS launches two CloudFormation Stacks in the backend, one to create the control plane with additional infrastructure and the other to create the nodegroups.&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%2Fygzgwi3k12xn6spykego.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%2Fygzgwi3k12xn6spykego.png" alt="Image description" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It shall take from 20-25 mins to launch the cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  EKS Cluster Successfully Launched with Spot Instance NodeGroup
&lt;/h2&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%2Fuaxswm1xomz25hti139i.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%2Fuaxswm1xomz25hti139i.png" alt="Image description" width="800" height="195"&gt;&lt;/a&gt;&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%2F01f4fo1t87y8l9u9f1od.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%2F01f4fo1t87y8l9u9f1od.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&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%2Fpu2lwrwqkbl26b7c3l6l.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%2Fpu2lwrwqkbl26b7c3l6l.png" alt="Image description" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean-Up
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Delete the cluster&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;eksctl delete cluster -f cluster.yaml&lt;/code&gt;&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%2Fy5tgzbgjlrfndgh4iy12.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%2Fy5tgzbgjlrfndgh4iy12.png" alt="Image description" width="800" height="78"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Terminate the EC2 Instance&lt;/strong&gt;&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%2Fr84akg00z96z7qr7se8q.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%2Fr84akg00z96z7qr7se8q.png" alt="Image description" width="800" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>containers</category>
    </item>
    <item>
      <title>Access AWS Secrets Manager from your container using AWS SDK</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Sat, 19 Aug 2023 12:03:33 +0000</pubDate>
      <link>https://dev.to/aws-builders/access-aws-secrets-manager-from-your-container-using-aws-sdk-1018</link>
      <guid>https://dev.to/aws-builders/access-aws-secrets-manager-from-your-container-using-aws-sdk-1018</guid>
      <description>&lt;p&gt;In case you need to store your credentials securely at a place and not in your application code, AWS Secrets Manager can become your ideal choice. &lt;/p&gt;

&lt;p&gt;AWS Secrets Manager helps you manage, retrieve, and rotate database credentials, application credentials, OAuth tokens, API keys, and other secrets throughout their lifecycles. &lt;br&gt;
[Source: &lt;a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html" rel="noopener noreferrer"&gt;AWS Docs&lt;/a&gt;] &lt;/p&gt;

&lt;p&gt;Today, we are going to look into how to fetch a secret from AWS Secrets Manager inside your container using AWS SDK, we shall be using the Python SDK (boto3). I shall be going ahead with a dummy secret for this demo but you can use the same process to fetch DB Passwords, Application Credentials or other critical tokens that you should not hardcode onto your application source code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An AWS Account&lt;/li&gt;
&lt;li&gt;An user with full access to AWS Secrets Manager and EC2&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creating a secret in the Secret Manager
&lt;/h2&gt;

&lt;p&gt;We shall be going ahead with other type of secrets but in your case you can go ahead and store secrets if you are using AWS Native Databases services as well.&lt;br&gt;
We have chosen aws/secretsmanager as the Encryption Key, you can have a Customer Managed KMS Key to encrypt yoru secret based on your requirement.&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%2F72rhibsj2hbm30wimosx.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%2F72rhibsj2hbm30wimosx.png" alt="Image description" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next window, you shall be asked to provide a secret name in our case we have provided &lt;strong&gt;test/mysecret&lt;/strong&gt;, you can leave the rest of the options as default.&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%2Figy3gv0sqxj5pvn72vpy.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%2Figy3gv0sqxj5pvn72vpy.png" alt="Image description" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on next, and if you wish to enable automatic rotation you can do so in this window, this would also require a lambda function that will rotate the secret.&lt;/p&gt;

&lt;p&gt;Click next and in the Review section you shall be getting a code snippet for multiple languages, according to your needs you can choose one, in this case I shall be going ahead with Python3 and we shall use that later.&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%2Fgqqcqdnomq9nnpq5xqxx.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%2Fgqqcqdnomq9nnpq5xqxx.png" alt="Image description" width="800" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Launching an EC2 Instance and installing Docker
&lt;/h2&gt;

&lt;p&gt;Create an instance providing the name and selecting the instance type.&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%2F3j6r9m7jgthuveslr0i8.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%2F3j6r9m7jgthuveslr0i8.png" alt="Image description" width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose an instance type and your keypair, if you don't have a keypair you can create one using the create keypair option.&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%2Fj406cm6yczm6dbu8ubve.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%2Fj406cm6yczm6dbu8ubve.png" alt="Image description" width="644" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can keep the network settings as default, for this demo I'm keeping the SSH Access open from anywhere, it's recommended to keep restricted access from the same.&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%2Fuja4kfefpitu16r9jcrc.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%2Fuja4kfefpitu16r9jcrc.png" alt="Image description" width="800" height="865"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the instance is launched you can ssh into the instance and install docker&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%2Falz05k9chs8fnzk1t3db.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%2Falz05k9chs8fnzk1t3db.png" alt="Image description" width="800" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start the docker service&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%2Fnyxlm3rmyk1c2an1m0uv.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%2Fnyxlm3rmyk1c2an1m0uv.png" alt="Image description" width="712" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating an IAM Role for EC2 to access Secrets Manager
&lt;/h2&gt;

&lt;p&gt;Select EC2 as the trusted entity type&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%2F3itfi2kw2w30mdnvxdxo.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%2F3itfi2kw2w30mdnvxdxo.png" alt="Image description" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choosing the SecretsManager R/W Permission, in your case you can choose a granular permission&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%2Fm5nrzi5k161ezx5p28jx.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%2Fm5nrzi5k161ezx5p28jx.png" alt="Image description" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Provide a role name and create the role&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%2Fq6eig45pc0gjythbn2ae.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%2Fq6eig45pc0gjythbn2ae.png" alt="Image description" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Attach the role to your EC2 Instance&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%2Fdbo359brdqyneolgbe9m.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%2Fdbo359brdqyneolgbe9m.png" alt="Image description" width="800" height="163"&gt;&lt;/a&gt;&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%2Fx96a3bn1cnrl2k43dwam.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%2Fx96a3bn1cnrl2k43dwam.png" alt="Image description" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Launch an Ubuntu Container and Access Secrets Manager
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;sudo docker run -it ubuntu /bin/bash&lt;/code&gt;&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%2Fe4ycqquovh2b4ibady9m.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%2Fe4ycqquovh2b4ibady9m.png" alt="Image description" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install Python3 and boto3 in the container&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt update &amp;amp;&amp;amp; apt install python3 -y&lt;/code&gt;&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%2Fdb4a8gqpvxzfyn869or8.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%2Fdb4a8gqpvxzfyn869or8.png" alt="Image description" width="800" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;apt install python3-pip -y&lt;/code&gt;&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%2Fst2hvpomdmoqidm9eo6m.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%2Fst2hvpomdmoqidm9eo6m.png" alt="Image description" width="746" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip3 install boto3&lt;/code&gt;&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%2Fy27en2pq4jablx461ij1.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%2Fy27en2pq4jablx461ij1.png" alt="Image description" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We shall also install vim in the container using - &lt;code&gt;apt install vim -y&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Access Secrets Manager inside the container using a Python Script
&lt;/h2&gt;

&lt;p&gt;We shall use the code snippet we got while creating the secret and add a command to print the secret, and subsequently a call statement to call the get_secret method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://raw.githubusercontent.com/RajitPaul11/AWS-Security/main/access-secrets-manager-using-boto3.py" rel="noopener noreferrer"&gt;https://raw.githubusercontent.com/RajitPaul11/AWS-Security/main/access-secrets-manager-using-boto3.py&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Output
&lt;/h2&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%2Fcq4su9hodv9yedgf6gvw.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%2Fcq4su9hodv9yedgf6gvw.png" alt="Image description" width="664" height="81"&gt;&lt;/a&gt;&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%2Fulgz2gqwgrosirf5bcqv.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%2Fulgz2gqwgrosirf5bcqv.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CleanUp
&lt;/h2&gt;

&lt;p&gt;Terminate the EC2 Instance and schedule deletion for the secret, the minimum duration is 7 days.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>containers</category>
      <category>cloud</category>
      <category>devops</category>
    </item>
    <item>
      <title>Monitor and Visualize Nginx Ingress Controller Metrics on Amazon EKS with Prometheus &amp; Grafana</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Thu, 25 May 2023 12:17:59 +0000</pubDate>
      <link>https://dev.to/aws-builders/monitor-and-visualize-nginx-ingress-controller-metrics-on-amazon-eks-with-prometheus-grafana-5gn7</link>
      <guid>https://dev.to/aws-builders/monitor-and-visualize-nginx-ingress-controller-metrics-on-amazon-eks-with-prometheus-grafana-5gn7</guid>
      <description>&lt;p&gt;In today’s digital landscape, it is very necessary to figure out trends in our data and act accordingly to ensure high availability of our application. Monitoring helps us to stay on top of the game and get insights on our product environment. An Ingress Controller acts as a bridge between Kubernetes Service and the external world and can be considered as a specialized load balancer for Kubernetes. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A Kubernetes Cluster (&lt;a href="https://dev.to/aws-builders/creating-an-amazon-eks-cluster-from-scratch-using-eksctl-540i"&gt;Create an EKS Cluster from scratch&lt;/a&gt;) &lt;/li&gt;
&lt;li&gt;Helm V3 (&lt;a href="https://helm.sh/docs/intro/install/" rel="noopener noreferrer"&gt;Helm Install Docs&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Install Kube-Prometheus-Stack using Helm
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 
helm repo update 
helm install --create-namespace --namespace monitoring \
my-k8s-prom-stack prometheus-community/kube-prometheus-stack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have the stack installed you should have Prometheus, Grafana and AlertManager installed onto your cluster. &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%2Flki9rlbmwl7qfkrt0fc7.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%2Flki9rlbmwl7qfkrt0fc7.png" alt="Kube Prometheus Stack" width="800" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Nginx Ingress Controller
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx 
helm repo update 
helm install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespace \
--set controller.metrics.enabled=true \
--set controller.metrics.serviceMonitor.enabled=true \
--set controller.metrics.serviceMonitor.additionalLabels.release="my-k8s-prom-stack" \
--version=4.5.2 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Along with installing the ingress controller we are setting the controller metrics as true which will populate an additional metrics service and creating a service monitor for that service which will feed data onto Prometheus, the additional Label would be as per the selector you have set on the Prometheus Operator, follow the later part for more details on this.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can check the Service Monitor selector on your Prometheus Operator using:  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl get prometheus --namespace monitoring prometheus-svc-name –oyaml&lt;/code&gt; (lookout for the section below on the manifest) &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%2Fo67owwmj0k8lbwclyt5o.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%2Fo67owwmj0k8lbwclyt5o.png" alt="Service Monitor Selector on Prom Operator" width="529" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once Nginx controller is installed you can verify the services that are spawned using: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl get svc --namespace ingress-nginx&lt;/code&gt;&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%2F22cupf64pg4ejovr01qn.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%2F22cupf64pg4ejovr01qn.png" alt="Ingress Controller Services" width="800" height="198"&gt;&lt;/a&gt;&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%2Fn56aepy2ev5amzvlc84w.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%2Fn56aepy2ev5amzvlc84w.png" alt="Service Monitor" width="800" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitor and Visualize Nginx Controller Metrics
&lt;/h2&gt;

&lt;p&gt;To access the Prometheus and Grafana you can set ingress objects &lt;br&gt;
Sample Ingress Manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:    
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-body-size: 5m  
  name: prometheus-ingress
  namespace: monitoring
spec:
  rules:
  - host: prom.mydomain.com
    http:
      paths:
      - backend:
          service:
            name: my-k8s-prom-stack-kube-pro-prometheus
            port:
              number: 9090
        path: /
        pathType: ImplementationSpecific
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate some load on the Ingress Controller by hitting the Ingress Endpoints.&lt;/p&gt;

&lt;p&gt;Access Prometheus and Grafana to query and visualize the controller metrics:&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%2Fko8zkdgdagjyy9sw5kfl.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%2Fko8zkdgdagjyy9sw5kfl.png" alt="Prometheus Console" width="800" height="310"&gt;&lt;/a&gt;&lt;br&gt;
Prom Query to check the number of 200 requests on ingress:&lt;br&gt;
&lt;code&gt;nginx_ingress_controller_requests{status=~'2..'}&lt;/code&gt;&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%2Fjbpn2loge7l5iakt3ifg.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%2Fjbpn2loge7l5iakt3ifg.png" alt="Prom Console" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Import Nginx Controller Dashboard on Grafana and visualize the metrics (Dashboard ID: 9614) &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%2Faj4pif05kg1msiqtebab.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%2Faj4pif05kg1msiqtebab.png" alt="Grafana Dashboard" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading this, you can follow me for more such content, or reach out to me on &lt;a href="https://in.linkedin.com/in/rajitpaul" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>monitoring</category>
      <category>devops</category>
      <category>eks</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Deploy your application on Kubernetes (Amazon EKS) using AWS Serverless (Codebuild)</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Thu, 21 Jul 2022 14:52:32 +0000</pubDate>
      <link>https://dev.to/aws-builders/deploy-your-application-on-kubernetes-amazon-eks-using-aws-serverless-codebuild-594i</link>
      <guid>https://dev.to/aws-builders/deploy-your-application-on-kubernetes-amazon-eks-using-aws-serverless-codebuild-594i</guid>
      <description>&lt;p&gt;Hi folks, &lt;br&gt;
Recently I came across an use-case of deploying a microservice on EKS using CodeBuild with GitHub as source. Although I've used Jenkins numerous times to do the same thing but I haven't used AWS Serverless to deploy on EKS. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This blog is for you if you want to deploy your microservice to Kubernetes, or want to learn how to setup AWS CodePipeline with CodeBuild, or like to integrate CodeBuild with EKS or you are generally curious about Kubernetes and Serverless :)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  This is how I started the journey:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I enquired about the source code and got to know it was on GitHub. For this blogpost I am going to create my own GitHub Repo with a basic deployment manifest. You can create your own repo and have the full stack of manifests starting from Ingress, to the service, deployment etc required for your microservice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, I setup a CodePipeline. I'll show you how to do that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to Developer Tools in the console, and select Code Pipeline.
Provide your pipeline a name, select the default service role so CodePipeline can create a role on your behalf, let the advanced setting be as it is unless you have a custom location for your artifact and want to use a custom KMS Key.
&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%2Fat6l4zolgri82uz6bnyw.png" alt="Image description" width="800" height="418"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Moving on you need to specify where is your SourceCode that you want to build or deploy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a Source Provider: In our case that would be GitHub (Version2).
Connection: Select if you have an existing connection with your GitHub Account or Create a connection for GitHub, it's fairly simple.
Once you authenticate CodePipeline to connect to your GitHub Account you shall receive a CodeStar connection URL, use that.
Once you fill in all the details it should look something like this.
&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%2Fskg7zfrlsfxocqlodx63.png" alt="Image description" width="488" height="607"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/RajitPaul11/my_dummy_microservice_deploy_on_eks.git" rel="noopener noreferrer"&gt;My GitHub Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we shall add a build stage.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;As a build provider we will select AWS CodeBuild. Feel free to choose the region of your choice. If you have an existing project you can select the same or else create a new project. I am going to setup a project from scratch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To setup a CodeBuild Project you need to provide the Project Name &amp;amp; Description, you can also restrict concurrent builds and provide additional tags if you want.&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%2Fxial4mclsjhmwj58tzgr.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%2Fxial4mclsjhmwj58tzgr.png" alt="Image description" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Design the CodeBuild Environment, we shall go with the latest image of Amazon Linux 2 and ask CodeBuild to create a new service role on our behalf.&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%2Fq2u6xv7wr6ytvvxid706.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%2Fq2u6xv7wr6ytvvxid706.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Additional Environment Configuration&lt;br&gt;
Select your VPC, choose a private subnet and a SG with outbound allow and then validate your VPC setting. This is where your codebuild server will be provisioned ~ No, Serverless does not mean there are no servers, it's just that, you don't have to manage them ;)&lt;br&gt;
Provide appropriate compute resource to the server as per your code requirements and we are good to go. If you require you can add environment variables and filesystems for your server.&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%2Fg0w25wz2j3xtfk06th8j.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%2Fg0w25wz2j3xtfk06th8j.png" alt="Image description" width="728" height="779"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can leave the buildspec section empty if your buildspec file is buildspec.yml as codebuild will look for that file in your repo, if you have named your file otherwise you can mention that in the buildspec name section. Also if you have some additional requirements while building your code you can mention those in the additional build commands.&lt;br&gt;
Will ignore Batch configuration as we do not require that for this blogpost.&lt;br&gt;
It's best practise to export your build logs to Cloudwatch so that it's easier for you to troubleshoot. Additionally you can also export your CodeBuild logs to S3 for later analysis.&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%2Fvsizizg3z7y58qaotgbz.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%2Fvsizizg3z7y58qaotgbz.png" alt="Image description" width="704" height="730"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you click on continue to CodePipeline, the CodeBuild Project will be created and you can complete your CodePipeline setup.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In environment variables you can refer to environment values generated from CodePipeline or can add new env variables. On Build Type, we shall be executing a single build on execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Skip Deploy stage as codebuild will be taking care of the deployment and create your CodePipeline :)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;EKS Cluster: I shall consider you have a running EKS cluster where we shall be doing the deployment, if not, you can deploy a new EKS cluster. In case you need help, refer this previous blog of mine - &lt;a href="https://dev.to/aws-builders/creating-an-amazon-eks-cluster-from-scratch-using-eksctl-540i"&gt;Setup your EKS Cluster from scratch&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To allow CodeBuild to deploy on the EKS cluster we need to modify EKS RBAC by adding the CodeBuild Service Role with the required permission on the aws-auth configmap that is used to manage EKS RBAC.&lt;br&gt;
&lt;a href="https://dev.to/rajitpaul_savesoil/read-only-access-to-specific-resources-in-aws-eks-cluster-via-eks-authentication-authorization-2i13"&gt;To know more about EKS RBAC&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Locate your CodeBuild Service Role:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open your buildproject, that you shall be using.
In Build details tab, scroll down to Environment where you can see the Service Role hyperlink. 
&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%2Fo4f05qhyby9ouz5vs7ly.png" alt="Image description" width="800" height="126"&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Update the aws-auth configmap:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To edit the configmap run - &lt;b&gt;kubectl edit cm aws-auth -n kube-system&lt;/b&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Under mapRoles we shall add a new entry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- groups:
    - system:masters
  rolearn: arn:aws:iam::xxxaccidxxx:role/codebuild- microservice-deploy-to-eks-service-role 
  username: CodeBuild Role to Access EKS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; If you directly copy paste the CodeBuild Role ARN from the console to the configmap you will get a "error: You must be logged in to the server (Unauthorized)", make sure your remove the /servicerole path from the ARN.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Additionally to the CodeBuild Service Role attach a policy with eks:DescribeCluster action allowed. This will allow codebuild to download the kubeconfig file onto it's server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Deploy Your Application, Run the Pipeline:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once you have done all as I mentioned, you would have your application running on EKS with the help of CodeBuild :)&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%2Fkrwakndm5ktxwzzxuja2.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%2Fkrwakndm5ktxwzzxuja2.png" alt="Image description" width="800" height="393"&gt;&lt;/a&gt;&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%2Fl796hxy2afu5mpdq1ynh.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%2Fl796hxy2afu5mpdq1ynh.png" alt="Image description" width="734" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean UP
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Delete your CodeBuild Project&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%2Flfikg5ai5hlz0wag44vj.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%2Flfikg5ai5hlz0wag44vj.png" alt="Image description" width="800" height="150"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Delete your Pipeline&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%2F8x2mor3uspnv07gqmte4.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%2F8x2mor3uspnv07gqmte4.png" alt="Image description" width="800" height="146"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to know more about Kubernetes, DevOps, Serverless follow me, also I would love to have a chat with you on &lt;a href="https://www.linkedin.com/in/rajitpaul/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; :)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>kubernetes</category>
      <category>serverless</category>
    </item>
    <item>
      <title>ECS Networking - (awsvpc, bridge, host, none)</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Mon, 09 May 2022 14:47:06 +0000</pubDate>
      <link>https://dev.to/aws-builders/ecs-networking-awsvpc-bridge-host-none-4bg9</link>
      <guid>https://dev.to/aws-builders/ecs-networking-awsvpc-bridge-host-none-4bg9</guid>
      <description>&lt;p&gt;Hi folks, &lt;strong&gt;Elastic Container Service&lt;/strong&gt; is one of the container offerings from AWS. ECS helps us to run any number of docker containers across a managed cluster of EC2 instances. It helps to isolate our workloads and helps achieve faster time to market with efficient scaling in place. It is secure and you can easily migrate your on prem container workload to ECS and back.&lt;/p&gt;

&lt;p&gt;Let's deep dive and look into the different network types on ECS and see how they are different from one another.&lt;/p&gt;

&lt;h2&gt;
  
  
  We have Four Network modes in ECS:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;awsvpc&lt;/strong&gt;: It allocates a seperate Elastic Network Interface (ENI) to the task and also allocates a primary IPV4 address to it. The task networking behaves same as an EC2 instance networking. &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%2Fo6pmlul4iz6or8sdfpyt.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%2Fo6pmlul4iz6or8sdfpyt.png" alt="Image description" width="800" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this you can see a warning which says the containers in the task will share an ENI and port mappings can only specify container ports.&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%2F0qsbprq7z6lghe6tzotx.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%2F0qsbprq7z6lghe6tzotx.png" alt="Image description" width="800" height="167"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;We cannot set host port mappings as the network mode is &lt;strong&gt;awsvpc&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once you create the service we can check in the task, an ENI is assigned to the task and all the containers inside it.&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%2Fsmd605rcqz81ga91nkn6.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%2Fsmd605rcqz81ga91nkn6.png" alt="Image description" width="442" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we SSH into the instance and curl the private IP associated to the task ENI, we can access the website running on the container.&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%2F4fn1xqn5f1cjvp2bw9fb.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%2F4fn1xqn5f1cjvp2bw9fb.png" alt="Image description" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this network mode we cannot access the website using the Task Host (EC2) Public or Private IP.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;bridge&lt;/strong&gt;: In Bridge Network mode, the task makes use of the built-in Docker VNet (Virtual Network) which also allows the task to communicate with other tasks.&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%2Fla0xac2typv9lf1be3fp.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%2Fla0xac2typv9lf1be3fp.png" alt="Image description" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we select the bridged network mode for the task we can see an associated host port mapping available with the container port.&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%2F4f2b175cfoxv26ucbupm.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%2F4f2b175cfoxv26ucbupm.png" alt="Image description" width="800" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we check task networking the container does not have any additional network as it uses only the Docker Virtual Network.&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%2Fi9vxqoityeubjajqc2id.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%2Fi9vxqoityeubjajqc2id.png" alt="Image description" width="272" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We shall access the website running on the container using the DockerHost IP (Amazon EC2).&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%2Fbywnrqdt1n21rkg79stv.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%2Fbywnrqdt1n21rkg79stv.png" alt="Image description" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;host&lt;/strong&gt;: Host network mode facilitates the task to bypass the Docker built-in VNet (Virtual Network) and maps the container port directly to the task host (Amazon EC2) ENI. As a result, we cannot run multiple instances of the same task when Port Mappings are used and the network mode is host.&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%2Fpk4g4ekw3dafy8l31ys8.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%2Fpk4g4ekw3dafy8l31ys8.png" alt="Image description" width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The container shall be using in this case the instance network stack.&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%2F0kitmgviu4ti579b69ho.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%2F0kitmgviu4ti579b69ho.png" alt="Image description" width="626" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can access the website running on the container using the Docker Host Public IP (EC2 Instance Public IP).&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%2F047rqar83diepobq7hp4.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%2F047rqar83diepobq7hp4.png" alt="Image description" width="800" height="198"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;none&lt;/strong&gt;: Blackhole, the task does not have any external network connectivity. &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%2F4ho6fiuwmn7t0255hi75.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%2F4ho6fiuwmn7t0255hi75.png" alt="Image description" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You shall see a message stating that the container will not have any external connectivity in the network section of the task.&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%2Fhhszqw257h4wagq38g63.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%2Fhhszqw257h4wagq38g63.png" alt="Image description" width="800" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this has helped you get an idea of ECS networking. Follow me for more blogs on AWS &amp;amp; DevOps. &lt;br&gt;
Feel free to connect with me on &lt;a href="https://www.linkedin.com/in/rajitpaul/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ecs</category>
      <category>containers</category>
      <category>devops</category>
    </item>
    <item>
      <title>Dockerize an API based Flask app and deploy on Amazon ECS</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Sun, 17 Apr 2022 19:46:52 +0000</pubDate>
      <link>https://dev.to/aws-builders/dockerize-an-api-based-flask-app-and-deploy-on-amazon-ecs-2pk0</link>
      <guid>https://dev.to/aws-builders/dockerize-an-api-based-flask-app-and-deploy-on-amazon-ecs-2pk0</guid>
      <description>&lt;p&gt;Hi Folks!&lt;br&gt;
This is the first blog of the series Dockerize Your Application.&lt;/p&gt;

&lt;p&gt;In the age of microservices we want our application code and requirements to be packed in an image and use that in a suitable container orchestration tool for better scalability and availability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisites:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An EC2 Server with git and docker installed&lt;/li&gt;
&lt;li&gt;Amazon ECR Repository &lt;/li&gt;
&lt;li&gt;AWS CLI configured on your server with sufficient permissions (to push image to ecr) or you can attach a role to your server with sufficient permissions.&lt;/li&gt;
&lt;li&gt;Region: Mumbai(ap-south-1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  About the API
&lt;/h2&gt;

&lt;p&gt;It's a todo app with two API's one to get the list of to-do tasks and another to post your tasks.&lt;br&gt;
GET-POST api path - /todo/api/v1.0/tasks&lt;/p&gt;

&lt;h2&gt;
  
  
  Source: [Flask_API_App]
&lt;/h2&gt;

&lt;p&gt;(&lt;a href="https://github.com/RajitPaul11/AWS_workshop_2022_data/tree/collate/python_flask_code_in_aws_linux_restful_GET_POST" rel="noopener noreferrer"&gt;https://github.com/RajitPaul11/AWS_workshop_2022_data/tree/collate/python_flask_code_in_aws_linux_restful_GET_POST&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Dockerfile
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM alpine:latest

RUN apk add py3-pip
RUN pip3 install flask

WORKDIR /home

COPY app.py .

EXPOSE 80

ENTRYPOINT ["/usr/bin/flask","run"]

CMD ["--host=0.0.0.0", "--port=80"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Login to your EC2 Server and clone the repo
&lt;/h4&gt;

&lt;p&gt;git clone -b collate &lt;a href="https://github.com/RajitPaul11/AWS_workshop_2022_data.git" rel="noopener noreferrer"&gt;https://github.com/RajitPaul11/AWS_workshop_2022_data.git&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Change directory and build docker image
&lt;/h4&gt;

&lt;p&gt;cd AWS_workshop_2022_data/python_flask_code_in_aws_linux_restful_GET_POST&lt;br&gt;
docker build -t flask_api_app:v1 .&lt;/p&gt;

&lt;h4&gt;
  
  
  Tag your docker image
&lt;/h4&gt;

&lt;p&gt;docker tag flask_api_app:v1 youraccountID.dkr.ecr.ap-south-1.amazonaws.com/flask_api_app:v1&lt;/p&gt;

&lt;h4&gt;
  
  
  Login to your ECR Repo
&lt;/h4&gt;

&lt;p&gt;aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin youraccountID.dkr.ecr.ap-south-1.amazonaws.com&lt;/p&gt;

&lt;h4&gt;
  
  
  Push the docker image
&lt;/h4&gt;

&lt;p&gt;docker push youraccountID.dkr.ecr.ap-south-1.amazonaws.com/flask_api_app:v1&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy to ECS
&lt;/h2&gt;

&lt;p&gt;Select Services and then select ECS&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%2F0n253ojchn5r8o1rkax7.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%2F0n253ojchn5r8o1rkax7.png" alt="Image description" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Create an ECS Cluster
&lt;/h4&gt;

&lt;p&gt;We shall be creating an ECS Cluster with EC2&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%2F6esm057mii97vnrfk3d5.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%2F6esm057mii97vnrfk3d5.png" alt="Image description" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Cluster Config
&lt;/h4&gt;

&lt;p&gt;Choose a suitable name for your cluster, and select a provisioning model, in this case we shall go for Spot.&lt;br&gt;
Choose diversified spot instance allocation strategy so the instances are spread across az's.&lt;br&gt;
Select two instance types on a or basis.&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%2Fop9cquaf6rhkmwskqvij.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%2Fop9cquaf6rhkmwskqvij.png" alt="Image description" width="800" height="752"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Specify the Storage spec and select an existing key pair, so that you can ssh later to the EC2 instance and do some modification or troubleshoot from the terminal.&lt;br&gt;
Create a new VPC or you can select an existing VPC.&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%2Fa2oab7a93mhfcku7i1wi.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%2Fa2oab7a93mhfcku7i1wi.png" alt="Image description" width="800" height="743"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cluster created!&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%2Fmrhg8hu8q4bu0u1rc4wl.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%2Fmrhg8hu8q4bu0u1rc4wl.png" alt="Image description" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Task Definition
&lt;/h2&gt;

&lt;p&gt;Select the launch type as EC2&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%2Fi8mv0rck1s5j13ox1vzm.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%2Fi8mv0rck1s5j13ox1vzm.png" alt="Image description" width="800" height="467"&gt;&lt;/a&gt;&lt;br&gt;
Provide a suitable task def name, and select the Task Role and network mode (we shall be looking into the different network modes in an upcoming blog, for now let's go ahead with bridge), select a task execution role.&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%2Fuxnb7xvlie7ix9o9hcuq.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%2Fuxnb7xvlie7ix9o9hcuq.png" alt="Image description" width="800" height="639"&gt;&lt;/a&gt;&lt;br&gt;
Allocate sufficient task memory and cpu based on your application requirements.&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%2Foy0czikg1jtf4zoov74m.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%2Foy0czikg1jtf4zoov74m.png" alt="Image description" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Add a container
&lt;/h4&gt;

&lt;p&gt;Provide a container name and the ecr repo uri along with the version, you can set hard limit for the container in case you have set the task cpu and memory req this is not required, if you want dynamic port mapping, keep the host port as 0, in this case we have set it to 80 same as the container port&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%2F29oxkvhz3271nauybpmq.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%2F29oxkvhz3271nauybpmq.png" alt="Image description" width="800" height="544"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
As per requirement you can explore advanced details and set container healthcheck, container timeouts, storage, logging and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Service
&lt;/h2&gt;

&lt;p&gt;Select the launch type as EC2, select your task definition and it's version you can see the latest suffix to denote the latest version, select your cluster and provide a suitable service name, select a service type (in this case we shall go with replica), provide the number of tasks you want to run (keep in mind the instance type you chose and the resource allocated to each task while you designate the number of tasks)&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%2F23yjaoe3lhhkj18gjq9p.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%2F23yjaoe3lhhkj18gjq9p.png" alt="Image description" width="800" height="460"&gt;&lt;/a&gt;&lt;br&gt;
Select the deployment strategy (we shall go into depth on this in an upcoming blog, in this case we choose Rolling Update), select a Task Placement strategy (AZ Balanced spread will help to spread tasks across instances in different AZ's for high availability)&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%2Fvuujt19dg1dtf9xl5qej.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%2Fvuujt19dg1dtf9xl5qej.png" alt="Image description" width="800" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure a Load Balancer
&lt;/h2&gt;

&lt;p&gt;Select your load balancer type(in this case we choose application load balancer), Create a new service IAM role, and select your existing Load Balancer.&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%2Fpp4k7jczmtr3j47dkly0.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%2Fpp4k7jczmtr3j47dkly0.png" alt="Image description" width="800" height="462"&gt;&lt;/a&gt;&lt;br&gt;
In your target group you can register the existing ECS instance, and set the health check path as /todo/api/v1.0/tasks&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%2Fhbx1d04dk6l7wo85twdw.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%2Fhbx1d04dk6l7wo85twdw.png" alt="Image description" width="800" height="748"&gt;&lt;/a&gt;&lt;br&gt;
If you want to scale your tasks you can enable autoscaling, in this case we do not want to scale our tasks so we won't enable auto scaling.&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%2Fkrye8tqr1m5yl40suwpy.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%2Fkrye8tqr1m5yl40suwpy.png" alt="Image description" width="800" height="251"&gt;&lt;/a&gt;&lt;br&gt;
Select your listener, target group name for the Load Balancer and rest shall be populated&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%2F69hcx5r8vdx6ipcp1puo.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%2F69hcx5r8vdx6ipcp1puo.png" alt="Image description" width="800" height="454"&gt;&lt;/a&gt; &lt;br&gt;
Service Created and Task Running!&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%2Fs539oeb2xivvcbvnv5yu.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%2Fs539oeb2xivvcbvnv5yu.png" alt="Image description" width="800" height="330"&gt;&lt;/a&gt; &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%2Fqwvjxx2jix22xhhw109z.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%2Fqwvjxx2jix22xhhw109z.png" alt="Image description" width="800" height="296"&gt;&lt;/a&gt; &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%2F4jdjquwal08ha1e0rimf.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%2F4jdjquwal08ha1e0rimf.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Allow Port 80 in EC2 and ALB&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%2Fqf7u0qi476kzpjqnw6lb.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%2Fqf7u0qi476kzpjqnw6lb.png" alt="Image description" width="800" height="327"&gt;&lt;/a&gt;&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%2Fwkv0uzt1yh0xqc5dmlbb.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%2Fwkv0uzt1yh0xqc5dmlbb.png" alt="Image description" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Test API using ALB URL
&lt;/h2&gt;

&lt;h4&gt;
  
  
  GET Request
&lt;/h4&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%2Fkjdp3gdr5x7q735s5awp.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%2Fkjdp3gdr5x7q735s5awp.png" alt="Image description" width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  PUT Request
&lt;/h4&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%2Frjdw34sqmxon156gjt8q.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%2Frjdw34sqmxon156gjt8q.png" alt="Image description" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have any queries you can connect with me on &lt;a href="https://www.linkedin.com/in/rajitpaul/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>aws</category>
      <category>devops</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Creating an Amazon EKS Cluster from scratch using eksctl</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Wed, 30 Mar 2022 14:47:45 +0000</pubDate>
      <link>https://dev.to/aws-builders/creating-an-amazon-eks-cluster-from-scratch-using-eksctl-540i</link>
      <guid>https://dev.to/aws-builders/creating-an-amazon-eks-cluster-from-scratch-using-eksctl-540i</guid>
      <description>&lt;p&gt;Hi folks, to create an EKS cluster, you require a launch pad, for today we shall be using an Amazon Linux 2 EC2 server as our eks launchpad. There are few pre-requisites we require to take care of -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;kubectl: Kubernetes Client to communicate with the Kubernetes API Server.  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installing kubectl: [Source: &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html" rel="noopener noreferrer"&gt;Installing kubectl - AWS Docs&lt;/a&gt;]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin &amp;amp;&amp;amp; cp ./kubectl $HOME/bin/kubectl &amp;amp;&amp;amp; export PATH=$PATH:$HOME/bin
echo 'export PATH=$PATH:$HOME/bin' &amp;gt;&amp;gt; ~/.bashrc
kubectl version --client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;eksctl: The official Amazon EKS CLI, used to create and manage multiple EKS Clusters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installing eksctl: [Source: &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html" rel="noopener noreferrer"&gt;Installing eksctl - eksctl docs&lt;/a&gt;]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
export PATH=$PATH:/usr/local/bin
echo 'export PATH=$PATH:/usr/local/bin' &amp;gt;&amp;gt; ~/.bashrc
eksctl version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create an IAM Role for EC2 with following IAM policies: &lt;br&gt;
&lt;a href="https://eksctl.io/usage/minimum-iam-policies/" rel="noopener noreferrer"&gt;Source : eksctl doc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Role is created you can attach the role onto your EKS Launch Pad Server.&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%2Fde62mqi1wsldrrodxauw.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%2Fde62mqi1wsldrrodxauw.png" alt="Image description" width="582" height="337"&gt;&lt;/a&gt;&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%2Fwgke2pojrrnrr7xvuw8t.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%2Fwgke2pojrrnrr7xvuw8t.png" alt="Image description" width="800" height="269"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Once the pre-requisites has been taken care of we can go ahead with cluster creation.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a file named cluster.yaml with the following configuration: &lt;a href="https://github.com/RajitPaul11/AmazonEKS/blob/master/EKS-Managed-NodeGroups-Cluster/cluster.yaml" rel="noopener noreferrer"&gt;Source: My GitHub - cluster.yaml&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run eks create cluster with dry run&lt;br&gt;
&lt;code&gt;eksctl create cluster -f cluster.yaml --dry-run&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;[ This shall help you identify any errors on the config files or related to your permission, make sure you don't have additional aws user configured with less privileges than the privileges allowed in the EC2 attached role. ]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Launch your cluster with
&lt;code&gt;eksctl create cluster -f cluster.yaml&lt;/code&gt;
&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%2F9dff8alr69hvr7bq2q68.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%2F9dff8alr69hvr7bq2q68.png" alt="Image description" width="800" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to wait for a few minutes and you shall see on the screen the CFN Stack is being deployed
&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%2Fdpognx4qdzdzpng3rrpn.png" alt="Image description" width="800" height="141"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The CFN stack creates the  EKS Control Plane, SG's, Policies and Service Roles. It also creates a single nodegroup or more as mentioned in the cluster config.&lt;/p&gt;
&lt;/blockquote&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%2F647yycyxzytq7ao23ulv.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%2F647yycyxzytq7ao23ulv.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&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%2Ff9vy6ssfb5zm09q11ii1.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%2Ff9vy6ssfb5zm09q11ii1.png" alt="Image description" width="710" height="323"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you encounter any issues check the Cloudformation Console or try:&lt;br&gt;
&lt;code&gt;eksctl utils describe-stacks --region=Your-Region --cluster=Your-Cluster-Name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The EKS cluster has been successfully created 🎉&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%2F06ekxjqk0dh25mjg8808.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%2F06ekxjqk0dh25mjg8808.png" alt="Image description" width="800" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access the EKS cluster from your launch pad using kubectl!&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%2Fsdfy339tx52m1op5rehj.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%2Fsdfy339tx52m1op5rehj.png" alt="Image description" width="800" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Clean UP
&lt;/h3&gt;

&lt;p&gt;To delete the EKS Cluster run:&lt;br&gt;
&lt;code&gt;eksctl delete cluster your-cluster-name&lt;/code&gt;&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%2Ffso3t2rp8hwb63hrhb88.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%2Ffso3t2rp8hwb63hrhb88.png" alt="Image description" width="800" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you enjoyed the blog, if you face any issues please reach out to me on &lt;a href="https://www.linkedin.com/in/rajitpaul/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and we can discuss the same, thanks! &lt;/p&gt;

&lt;h3&gt;
  
  
  Wrap Up
&lt;/h3&gt;

&lt;p&gt;You can follow me to get updated on new AWS related blogs in the coming weeks, also I am an earth buddy, don't know what that is, check this out: &lt;a href="https://consciousplanet.org/action-now" rel="noopener noreferrer"&gt;Save our Soil&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adios!
&lt;/h3&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>cloud</category>
      <category>devops</category>
    </item>
    <item>
      <title>Restric Access to Cloudfront Distribution using Lambda@Edge</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Sat, 26 Mar 2022 06:36:51 +0000</pubDate>
      <link>https://dev.to/aws-builders/restric-access-to-cloudfront-distribution-using-lambdaedge-15ll</link>
      <guid>https://dev.to/aws-builders/restric-access-to-cloudfront-distribution-using-lambdaedge-15ll</guid>
      <description>&lt;p&gt;Hi folks!&lt;br&gt;
Recently I came across a usecase where I had to restrict access to a website in the UAT environment, so that the iterations and changes to the UAT env are not available for public view. The website was served with the CloudFront CDN, so one of the ways we could restrict access was enforcing authentication on the Cloudfront Distribution using Lambda@Edge.&lt;/p&gt;

&lt;h3&gt;How did I achive this?&lt;/h3&gt;

&lt;p&gt;Create a Lambda Function&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to us-east-1 region as that is the only region we can deploy Lambda@Edge functions.&lt;/li&gt;
&lt;li&gt;Go to the AWS Console and choose Lambda from services.&lt;/li&gt;
&lt;li&gt;Create function and author from scratch.&lt;/li&gt;
&lt;li&gt;Provide function name, and select Node JS 14.x as runtime.&lt;/li&gt;
&lt;li&gt;In Change Default Execution Role, create a new role with basic Lambda permissions.
&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%2Fw8flwn1xw7oufgkux5el.png" alt="Image description" width="582" height="691"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Boom! Your function is created.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the below code and replace the user and password with your required username and password.
&lt;a href="https://gist.githubusercontent.com/njofce/3382b0fe51c59ae9038046cd5087e42a/raw/1b6a1b7c477df4b49a2c2a633265d84b4a6ac846/basic-auth.js" rel="noopener noreferrer"&gt;code&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Source: &lt;a href="https://gist.github.com/njofce/3382b0fe51c59ae9038046cd5087e42a" rel="noopener noreferrer"&gt;https://gist.github.com/njofce/3382b0fe51c59ae9038046cd5087e42a&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy the code.&lt;/li&gt;
&lt;li&gt;Go to general configuration in Configuration and change the function timeout to 5sec, that's the max allowed timeout for CDN triggered Lambda Function.
&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%2Favnmq8n5icoc47784vrp.png" alt="Image description" width="800" height="189"&gt; &lt;/li&gt;
&lt;li&gt;Go to Permissions, and open the IAM role, and update the Trust Relationships with the below json snippet, which allows lambda and lambda@edge to assume the role.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
    "Version": "2012-10-17",&lt;br&gt;
    "Statement": [&lt;br&gt;
        {&lt;br&gt;
            "Effect": "Allow",&lt;br&gt;
            "Principal": {&lt;br&gt;
                "Service": [&lt;br&gt;
                    "lambda.amazonaws.com",&lt;br&gt;
                    "edgelambda.amazonaws.com"&lt;br&gt;
                ]&lt;br&gt;
            },&lt;br&gt;
            "Action": "sts:AssumeRole"&lt;br&gt;
        }&lt;br&gt;
    ]&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&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%2F1a4fu1uizkquz97wsyh8.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%2F1a4fu1uizkquz97wsyh8.png" alt="Image description" width="800" height="128"&gt;&lt;/a&gt;&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%2Fol8xtgj40xb5quwoa91i.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%2Fol8xtgj40xb5quwoa91i.png" alt="Image description" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to Actions, and under capabilities, select Deploy to &lt;a href="mailto:Lambda@Edge"&gt;Lambda@Edge&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Configure a new Cloudfront Trigger, select your distribution under Cloudfront event and select a Viewer request, then check include body, and confirm deploy to &lt;a href="mailto:Lambda@Edge"&gt;Lambda@Edge&lt;/a&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%2Fdeeo9q5hmiqw9kvdp1nk.png" alt="Image description" width="529" height="329"&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%2F56ids55084iewktigdxm.png" alt="Image description" width="800" height="469"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It shall take few minutes to enforce the authentication, once done we can see a sign in option as we try to access our UAT env website, provide the username and password you used in the code and access your website. (to not disclose our client, I have used a dummy CloudFront URL with my content)&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%2Fg3dskdvbb44seqms9zwc.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%2Fg3dskdvbb44seqms9zwc.png" alt="Image description" width="800" height="177"&gt;&lt;/a&gt;&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%2F0o2v2yyzpp8e9i4khf7i.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%2F0o2v2yyzpp8e9i4khf7i.png" alt="Image description" width="800" height="395"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;If you face any challenges please connect and discuss with me on &lt;a href="https://www.linkedin.com/in/rajitpaul/" rel="noopener noreferrer"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also I'm currently part of the Save Soil Movement initiated by the Isha Foundation, I know you are aware of the conditions of the soil and as a generation we have to turn this around, Become an &lt;a href="https://consciousplanet.org/action-now?utm_campaign=cp_vol_mob&amp;amp;utm_medium=social&amp;amp;utm_source=vanity" rel="noopener noreferrer"&gt;Earth Buddy&lt;/a&gt;&lt;br&gt;
Stay Joyful! :)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
      <category>security</category>
    </item>
    <item>
      <title>Bitbucket Branch Based Generic Webhook Trigger on Jenkins</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Wed, 02 Mar 2022 13:47:56 +0000</pubDate>
      <link>https://dev.to/rajitpaul/bit-bucket-branch-based-generic-webhook-trigger-on-jenkins-3p8</link>
      <guid>https://dev.to/rajitpaul/bit-bucket-branch-based-generic-webhook-trigger-on-jenkins-3p8</guid>
      <description>&lt;p&gt;Namaskaram!&lt;br&gt;
I faced a recent challenge when I used BitBucket Webhook to trigger a Jenkins build, the challenge was webhooks on bitbucket are based on the entire repository, which means a push to any of the BitBucket Branch will trigger a Jenkins build.&lt;br&gt;
What was I actually looking for was a branch based webhook to trigger Jenkins Build.&lt;/p&gt;

&lt;h3&gt;What you'll need&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Jenkins&lt;/li&gt;
&lt;li&gt;BitBucket&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Configuring BitBucket:&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to the Repository Settings of BitBucket and then to Webhooks.&lt;/li&gt;
&lt;li&gt;Add new webhook (Title, URL- &lt;b&gt;&lt;a href="http://JenkinsUsername:JenkinsPassword@Jenkins" rel="noopener noreferrer"&gt;http://JenkinsUsername:JenkinsPassword@Jenkins&lt;/a&gt; PublicIPorPublicDomain:8080/generic-webhook-trigger/invoke&lt;/b&gt;, Status is Active, Triggers on Repository Push).&lt;/li&gt;
&lt;li&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%2Fwpmp3r6111kddsr0iqbm.png" alt="Image description" width="785" height="658"&gt;&lt;/li&gt;
&lt;li&gt;Save it.&lt;/li&gt;
&lt;li&gt;Once saved go to view requests, and enable request history collection. &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Update code in the specific branch of BitBucket:&lt;/h3&gt;

&lt;p&gt;In this part you need to make some changes in the branch of BitBucket that you want to trigger the webhook from.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once the code is updated it will trigger a webhook request.&lt;/li&gt;
&lt;li&gt;Go to repository settings then to webhook, and then to view requests you should see something like this. (The status code may be different 404 is ok, but 301 means you are facing authentication issue)
&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%2Fh4uyy81cealn9q9g2hwq.png" alt="Image description" width="800" height="70"&gt;
&lt;/li&gt;
&lt;li&gt;Click on view details, and scroll down to the bottom, you can see the Request - headers and body, we need to expand the body.
&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%2Fscasar77c1m5a78vj64g.png" alt="Image description" width="330" height="670"&gt;
&lt;/li&gt;
&lt;li&gt;Once the body is expanded, copy the entire body from top to bottom.
&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%2Fq9etdauifb9cv3hfs3xb.png" alt="Image description" width="800" height="125"&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;a href="https://jsonpath.curiousconcept.com/" rel="noopener noreferrer"&gt;https://jsonpath.curiousconcept.com/&lt;/a&gt; and paste the JSON data you copied in your clipboard.&lt;/li&gt;
&lt;li&gt;Run this Json Path Expression - &lt;b&gt;push.changes[0].new.links.commits.href&lt;/b&gt;
&lt;/li&gt;
&lt;li&gt;In the result you should get the commit link with the repo and it's branch we are pushing to, keep this link saved.
Our job here is done, now we move to Jenkins.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Configuring Jenkins:&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;First we shall install the Generic WebHook Trigger Plugin for Jenkins.
Go to Manage Jenkins - Plugin Manager - and Install this plugin
&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%2Fmoaxfxvg077fpxwmwyrn.png" alt="Image description" width="800" height="152"&gt;
&lt;/li&gt;
&lt;li&gt;Go to the Configuration of the Jenkins Job you wish to trigger using BitBucket.
&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%2F9qkbkodgl30t07yowgsn.png" alt="Image description" width="800" height="210"&gt;
&lt;/li&gt;
&lt;li&gt;In Build Triggers you should see Generic Webhook Trigger
&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%2Fsuuoj9bnyi9r2zg99ee5.png" alt="Image description" width="800" height="240"&gt;
&lt;/li&gt;
&lt;li&gt;Click on add Post content Parameters - Add a variable named branch, in the expression put the JSON Path Expression we used earlier ( push.changes[0].new.links.commits.href ) and select JSONPath.
&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%2Fxlknkxx7os4qu3nejdwz.png" alt="Image description" width="800" height="280"&gt;
&lt;/li&gt;
&lt;li&gt;Scroll down and in Optional Filter, provide the RegEx &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;[.+?(?=repository/commits/branch)] - replace the repository and branch with your repo and branch name.&lt;/p&gt;

&lt;p&gt;You can refer the JSON Path Result that you saved earlier&lt;br&gt;
 &lt;a href="https://api.bitbucket.org/2.0/repositories/project/" rel="noopener noreferrer"&gt;https://api.bitbucket.org/2.0/repositories/project/&lt;/a&gt;&lt;b&gt;repository&lt;/b&gt;/commits/&lt;b&gt;branch&lt;/b&gt;, from this you shall get the repository and branch.&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%2F5y9y97k3a74km80xe41k.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%2F5y9y97k3a74km80xe41k.png" alt="Image description" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Considering you have your build setup, you can save the job.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make some changes in the code in the specific branch and see your Jenkins Job being triggered!&lt;/p&gt;

&lt;p&gt;If you wish to connect or face some issues while performing this demo, you can reach out @ &lt;a href="https://www.linkedin.com/in/rajitpaul/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/rajitpaul/&lt;/a&gt;&lt;br&gt;
See ya!&lt;/p&gt;

</description>
      <category>jenkins</category>
      <category>devops</category>
      <category>bitbucket</category>
    </item>
    <item>
      <title>Setup KinD (Kubernetes In Docker) on Amazon EC2</title>
      <dc:creator>Rajit Paul</dc:creator>
      <pubDate>Mon, 21 Feb 2022 08:06:26 +0000</pubDate>
      <link>https://dev.to/rajitpaul/setup-kind-kubernetes-in-docker-on-linux-3kbd</link>
      <guid>https://dev.to/rajitpaul/setup-kind-kubernetes-in-docker-on-linux-3kbd</guid>
      <description>&lt;h3&gt;Install Docker on Linux - &lt;/h3&gt;

&lt;p&gt;As I'm using an Amazon Linux I can install docker with a &lt;br&gt;
&lt;b&gt;yum install docker -y&lt;/b&gt;&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%2Ff6a3nhjz04egwr4umyf0.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%2Ff6a3nhjz04egwr4umyf0.png" alt="Image description" width="800" height="321"&gt;&lt;/a&gt;&lt;br&gt;
Start docker service - &lt;b&gt;systemctl start docker&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;For Docker Installations - &lt;a href="https://docs.docker.com/engine/install/" rel="noopener noreferrer"&gt;https://docs.docker.com/engine/install/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Install Go -&lt;/h3&gt;

&lt;p&gt;Go to &lt;a href="https://go.dev/dl/" rel="noopener noreferrer"&gt;https://go.dev/dl/&lt;/a&gt;&lt;br&gt;
Copy the link of go tarfile for linux platform&lt;br&gt;
Install using wget &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%2Fjj4ozt9d7th2fi78kvlx.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%2Fjj4ozt9d7th2fi78kvlx.png" alt="Image description" width="800" height="209"&gt;&lt;/a&gt;&lt;br&gt;
Extract it using &lt;b&gt;tar zxf go1.17.7.linux-amd64.tar.gz -C /usr/local&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;b&gt;/usr/local/go/bin&lt;/b&gt; to the PATH variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Install KinD&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;go install sigs.k8s.io/&lt;a href="mailto:kind@v0.11.1"&gt;kind@v0.11.1&lt;/a&gt;&lt;/b&gt;&lt;br&gt;
You can replace v0.11.1 with the latest stable kind version&lt;/p&gt;

&lt;h3&gt;Move the KinD Binary to /usr/local/bin -&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can find the kind binary inside the directory go/bin&lt;/li&gt;
&lt;li&gt;Move it to /usr/local/bin - &lt;b&gt;mv go/bin/kind /usr/local/bin&lt;/b&gt;
&lt;/li&gt;
&lt;li&gt;Make sure you have a path setup for /usr/local/bin&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Install Latest Version of Kubectl:&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;curl -LO "&lt;a href="https://dl.k8s.io/release/$(curl" rel="noopener noreferrer"&gt;https://dl.k8s.io/release/$(curl&lt;/a&gt; -L -s &lt;a href="https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" rel="noopener noreferrer"&gt;https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl&lt;/a&gt;"&lt;/b&gt;&lt;br&gt;
&lt;b&gt;chmod +x kubectl&lt;/b&gt;&lt;br&gt;
&lt;b&gt;mv kubectl /usr/local/bin&lt;/b&gt;&lt;/p&gt;

&lt;h3&gt;Create a cluster with kind&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;kind create cluster --name labcluster&lt;/b&gt;&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%2Fgxstcri6r7mts27q3c9b.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%2Fgxstcri6r7mts27q3c9b.png" alt="Image description" width="800" height="255"&gt;&lt;/a&gt;&lt;br&gt;
&lt;b&gt;kubectl get nodes -o wide&lt;/b&gt;&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%2Fa6ne23e3oyskueaw9utc.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%2Fa6ne23e3oyskueaw9utc.png" alt="Image description" width="800" height="32"&gt;&lt;/a&gt;&lt;br&gt;
&lt;b&gt;docker ps&lt;/b&gt;&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%2Fyoq41iocxe3fmra3fhob.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%2Fyoq41iocxe3fmra3fhob.png" alt="Image description" width="800" height="36"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
You are now running KinD successfully in Linux &lt;br&gt;
Once done you can delete the cluster using &lt;br&gt;
&lt;b&gt;kind delete cluster&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Multi-Node Cluster -&lt;/h2&gt;

&lt;p&gt;Create a config file kind-example-config.yaml&lt;br&gt;
kind: Cluster&lt;br&gt;
apiVersion: kind.x-k8s.io/v1alpha4&lt;br&gt;
nodes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;role: control-plane&lt;/li&gt;
&lt;li&gt;role: worker&lt;/li&gt;
&lt;li&gt;role: worker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;kind create cluster --config kind-cluster-config.yaml&lt;/b&gt;&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%2Feqfsmvt644z7o1ru2o9i.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%2Feqfsmvt644z7o1ru2o9i.png" alt="Image description" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You now have a running KinD Cluster with one master and two worker nodes.&lt;br&gt;
&lt;b&gt;kubectl get nodes -o wide&lt;/b&gt;&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%2Fnq8xuhea7u0x5ex30ki2.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%2Fnq8xuhea7u0x5ex30ki2.png" alt="Image description" width="800" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>docker</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
