<?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>Forem: Sivamuthu Kumar</title>
    <description>The latest articles on Forem by Sivamuthu Kumar (@ksivamuthu).</description>
    <link>https://forem.com/ksivamuthu</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%2F143603%2F4f502683-6bfc-4821-be5b-6dc4704ccf05.png</url>
      <title>Forem: Sivamuthu Kumar</title>
      <link>https://forem.com/ksivamuthu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ksivamuthu"/>
    <language>en</language>
    <item>
      <title>GitHub Actions Scheduled Workflows: Understanding the Limitations and Possible Solutions</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Sat, 21 Jan 2023 01:00:26 +0000</pubDate>
      <link>https://forem.com/ksivamuthu/github-actions-scheduled-workflows-understanding-the-limitations-and-possible-solutions-5hm5</link>
      <guid>https://forem.com/ksivamuthu/github-actions-scheduled-workflows-understanding-the-limitations-and-possible-solutions-5hm5</guid>
      <description>&lt;p&gt;GitHub Actions is a powerful tool that allows developers to automate their workflow, but when it comes to scheduling workflows, it may not always work as expected. Many users have reported that their scheduled workflows are not triggering at the scheduled time, and in some cases, the delay can be as long as an hour. In this blog post, we will explore the limitations of GitHub Actions scheduled workflows, the reasons for these delays, and what can be done to ensure that your workflows are executed on time. We will also discuss various alternative solutions that can be used to trigger the workflows manually, guaranteeing the execution of your production tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario: Actions not running at the scheduled time.
&lt;/h3&gt;

&lt;p&gt;I've recently written a GitHub action that generates reports by running scripts and sending an email of the report every Tuesday at 8 AM EST.&lt;/p&gt;

&lt;p&gt;E.g.,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Generate Report

on:
  schedule:
    - cron: "0 13 * * 2" # UTC

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
    # Reduced the code for brevity
    - name: Generate report and Send email
      run: |
        generate-report.sh 
        send-email.sh

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

&lt;/div&gt;



&lt;p&gt;It took less than a minute to generate a report. I was expecting the email to be received at least by 8.05 AM. But it's not started. It took 30min to 1 hour to get the new workflow run queued.&lt;/p&gt;

&lt;p&gt;One of the main reasons for delays in scheduled workflows is the fact that GitHub runs workflows on shared runners. There is no guarantee that the workflow will run at the exact scheduled time. When you set up a workflow schedule, you request GitHub to schedule it. However, many factors can affect the execution of the workflow, such as system load, queue size, and other workflows competing for resources.&lt;/p&gt;

&lt;p&gt;This means that the resources available to run workflows are not dedicated to a specific user or repository and are subject to the demands of other users and workflows. As a result, there may be delays in the execution of a scheduled workflow, as it may need to wait for resources to become available.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution: Use external schedulers &amp;amp; Workflow Dispatch
&lt;/h2&gt;

&lt;p&gt;One possible solution to overcome these limitations is manually triggering the workflow using an external scheduler. GitHub Actions supports the workflow_dispatch trigger, allowing you to trigger a workflow manually. This means you can use a third-party cron scheduling service, like &lt;a href="https://ifttt.com/" rel="noopener noreferrer"&gt;IFTTT&lt;/a&gt;, &lt;a href="https://cronhub.io/" rel="noopener noreferrer"&gt;Cronhub&lt;/a&gt;, &lt;a href="https://cronitor.io/" rel="noopener noreferrer"&gt;Cronitor&lt;/a&gt;, etc., to request the GitHub API to trigger the workflow. By doing so, you can ensure that the workflow is executed at the desired time, regardless of the state of the shared runners or the cron schedule.&lt;/p&gt;

&lt;p&gt;Add the workflow_dispatch to trigger the GitHub Actions manually.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Generate Report

on:
 workflow_dispatch:

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
    # Reduced the code for brevity
    - name: Generate report and Send email
      run: |
        generate-report.sh 
        send-email.sh

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

&lt;/div&gt;



&lt;p&gt;You could trigger the workflow using an HTTP call, for e.g,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token YOUR_ACCESS_TOKEN" https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches

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

&lt;/div&gt;



&lt;p&gt;This way, your workflow will be executed at the exact scheduled time, without any delays, regardless of the state of shared runners.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In summary, while GitHub Actions is a powerful tool for automating your workflow, its scheduled workflows may not always run at the exact scheduled time. This can be due to the shared runner's nature, where the system load, queue size and other workflows can affect the execution of your workflow. To ensure that your production tasks are executed on time, it is recommended to use an external scheduler to manually trigger the workflow. This way, you can guarantee the execution of your workflow and avoid delays.&lt;/p&gt;

&lt;p&gt;I'm Siva - Director, DevOps &amp;amp; Principal Architect at &lt;a href="https://www.ceiamerica.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Computer Enterprises Inc&lt;/strong&gt;&lt;/a&gt; from Orlando. I'm an AWS Community builder. I write blogs and tutorials about Cloud, Containers, IoT, and DevOps. If you are interested, please follow me &lt;a href="https://twitter.com/ksivamuthu" rel="noopener noreferrer"&gt;@ ksivamuthu&lt;/a&gt;on Twitter or check out my blogs at &lt;a href="http://sivamuthukumar.com" rel="noopener noreferrer"&gt;&lt;strong&gt;sivamuthukumar.com&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>devops</category>
    </item>
    <item>
      <title>Azure Terrafy: Import and Manage Existing Azure Resources with Terraform</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Fri, 30 Dec 2022 12:06:35 +0000</pubDate>
      <link>https://forem.com/ksivamuthu/azure-terrafy-import-and-manage-existing-azure-resources-with-terraform-23bj</link>
      <guid>https://forem.com/ksivamuthu/azure-terrafy-import-and-manage-existing-azure-resources-with-terraform-23bj</guid>
      <description>&lt;p&gt;As an Azure user, you may be looking for a way to manage your infrastructure with the power of Terraform. However, getting started with Terraform can be challenging, especially if you have existing resources that you want to include in your configuration. That's where Azure Terrafy comes in. Azure Terrafy is a tool that makes it easy to import your existing Azure resources into Terraform modules. In this blog post, I will introduce you to Azure Terrafy and show you how it can streamline your Azure resource management process. By the end, you will have a better understanding of how Terrafy can help you use Terraform to manage your infrastructure with ease.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Azure/aztfy" rel="noopener noreferrer"&gt;Azure Terrafy&lt;/a&gt; is a tool that makes it easy to import your existing Azure resources into Terraform modules. Suppose you're an Azure user looking to manage your infrastructure with the power of Terraform. In that case, Azure Terrafy can save you time and effort by automating the process of incorporating your existing resources into your Terraform configuration. This is especially useful for those who have a "brownfield" environment, where their infrastructure already has a number of existing resources that need to be brought under the management of Terraform. It can save you a lot of time and effort. Without Terrafy, you would need to manually create a Terraform configuration file for each resource you want to manage. This can be tedious and error-prone, especially if you have many resources.&lt;/p&gt;

&lt;p&gt;In addition to saving time and effort, using Azure Terrafy can also help you ensure that your Terraform configuration is accurate and up-to-date. By importing your existing resources into Terraform, you can ensure that your configuration reflects the current state of your resources rather than relying on potentially outdated documentation or manual configuration. This can help you avoid errors and ensure your infrastructure is managed effectively.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Features and benefits of using Terrafy:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Automates the process of importing existing Azure resources into Terraform modules&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Saves time and effort compared to manual resource management&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Helps ensure that your Terraform configuration is accurate and up-to-date&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Works with both Azure Resource Manager and Azure Classic resources&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can be easily integrated into existing Terraform workflows&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How Azure Terrafy fits into the overall Azure and Terraform landscape:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Azure Terrafy is a tool specifically designed to help manage Azure resources in Terraform&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It works alongside Azure Resource Manager to discover and import resources into Terraform modules&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Azure Terrafy is just one piece of the puzzle regarding managing Azure infrastructure with Terraform. Other tools and technologies, such as Azure DevOps and Azure Functions, can also be used in conjunction with Terrafy to create a comprehensive infrastructure management solution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An Azure account and subscription&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Terraform installed on your machine&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Azure CLI installed on your machine&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A configured Azure CLI profile with the necessary permissions to read resources in your Azure subscription&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;code&gt;aztfy&lt;/code&gt; from &lt;a href="https://github.com/Azure/aztfy/releases" rel="noopener noreferrer"&gt;GitHub Releases&lt;/a&gt; - pre-compiled binaries on macOS, Windows &amp;amp; Linux platforms&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Importing Existing Resources
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Run the &lt;code&gt;aztfy&lt;/code&gt; command to create a new Terraform configuration file on a single resource, resource group or query for the list of resources. You can pass the non-interactive option if you want to run in non-interactive mode. Here dapr-talk is the resource group name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Review the generated Terraform configuration file to ensure that it accurately reflects the state of your Azure resources&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the &lt;code&gt;terraform plan&lt;/code&gt; command to preview the changes that will be made to your resources when you apply the Terraform configuration&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the plan looks correct, run the &lt;code&gt;terraform apply&lt;/code&gt; the command to apply the Terraform configuration and bring your Azure resources under the management of Terraform.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are a few tips and best practices to keep in mind when using Terrafy to import your existing resources into Terraform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Be sure to review the generated Terraform configuration file carefully before applying it. This will help you ensure that the configuration accurately reflects the state of your resources and avoid any errors or unintended consequences.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have many resources, it may take some time for Azure Terrafy to scan and generate the configuration file. Be patient and allow the process to complete before applying the configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have resources that you don't want to include in your Terraform configuration, you can use the &lt;code&gt;aztfy res or aztfy query&lt;/code&gt; command to import specific resources individually. This can be helpful if you only want to manage a subset of your resources with Terraform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You must create terraform resources manually if there are not-supported / skipped resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don't forget to run the &lt;code&gt;terraform plan&lt;/code&gt; command before applying your configuration. This will help you identify potential issues or conflicts before they become a problem.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these steps and best practices, you can use Azure Terrafy to easily import your existing Azure resources into Terraform modules and start managing them with ease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limitations
&lt;/h3&gt;

&lt;p&gt;Here are some limitations of Azure Terrafy to consider:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Only works with Azure resources: Terrafy cannot import resources from other cloud providers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It may not be suitable for highly complex or customized infrastructure: Azure Terrafy does not support all resources. The resources which are not supported have to be done manually.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited context: The review is necessary to convert the sensitive configurations to terraform-managed variables.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In conclusion, I have found Azure Terrafy to be a valuable tool for managing Azure resources in Terraform. It has saved me time and effort compared to manual resource management, and its integration with Azure and Terraform has made it easy to use in various infrastructure management scenarios. However, like any tool, it has its limitations, such as only working with Azure resources and potentially complex for more customized infrastructure.&lt;/p&gt;

&lt;p&gt;Overall, I recommend giving Azure Terrafy a try if you are looking for a tool to help manage your Azure resources with Terraform. Just be sure to consider its limitations and whether it fits the needs of your specific infrastructure. By following the steps outlined in this blog post and keeping in mind best practices like reviewing the generated code before applying it, you can use Azure Terrafy to manage your Azure resources with Terraform effectively.&lt;/p&gt;

&lt;p&gt;I'm Siva - Director, DevOps &amp;amp; Principal Architect at &lt;a href="https://www.ceiamerica.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Computer Enterprises Inc&lt;/strong&gt;&lt;/a&gt; from Orlando. I'm an AWS Community builder. I write blogs and tutorials about Cloud, Containers, IoT, and DevOps. If you are interested, please follow me &lt;a href="https://hashnode.com/@ksivamuthu" rel="noopener noreferrer"&gt;@ksivamuthu&lt;/a&gt; on Twitter or check out my blogs at &lt;a href="http://sivamuthukumar.com" rel="noopener noreferrer"&gt;&lt;strong&gt;sivamuthukumar.com&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Boost Your Enterprise Security with GitHub Actions and the OSSF Score Card</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Fri, 30 Dec 2022 12:02:37 +0000</pubDate>
      <link>https://forem.com/ksivamuthu/boost-your-enterprise-security-with-github-actions-and-the-ossf-score-card-1d5p</link>
      <guid>https://forem.com/ksivamuthu/boost-your-enterprise-security-with-github-actions-and-the-ossf-score-card-1d5p</guid>
      <description>&lt;p&gt;In this blog post, we will cover how you can use the OSSF Scorecard to assess the security score of your repository and report the results in GitHub Advanced Security - Overview. This will allow you to assess the security scores of your repositories across your organization, providing a comprehensive view of your repositorys security posture.&lt;/p&gt;

&lt;p&gt;The Open Source Security Foundation (OSSF) Scorecard is a tool that helps assess the security measures taken in a repository. It does this by performing a series of checks, each of which is assigned a score of 0-10. By using the OSSF Scorecard, you can assess the risks that dependencies introduce, understand specific areas where you can improve the security posture of your project, and make informed decisions about accepting those risks or evaluating alternative solutions.&lt;/p&gt;

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

&lt;p&gt;Some of the checks included in the OSSF Scorecard are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Branch-Protection: This check assesses whether the project uses Branch Protection to ensure that code is reviewed before it is merged.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CI-Tests: This check looks for the presence of tests that are run in CI, such as GitHub Actions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Code-Review: This check assesses whether the project requires code review before code is merged.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dangerous-Workflow: This check looks for the use of dangerous coding patterns in GitHub Action workflows, which can pose a security risk.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dependency-Update-Tool: This check looks for the use of tools to help update dependencies, which can help keep the project up-to-date and secure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;License: This check assesses whether the project has a declared license, which is important for ensuring legal compliance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintained: This check looks for projects that are at least 90 days old and are actively maintained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pinned Dependencies: This check looks for the declaration and pinning of dependencies, which can help ensure that the project is using stable and secure versions of those dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Packaging: This check looks for the building and publishing of official packages from CI/CD, such as GitHub Publishing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SAST: This check looks for the use of static code analysis tools such as CodeQL or other SAST tools such as SonarCloud, which can help identify vulnerabilities in the code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security Policy: This check looks for the presence of a security policy, which can help outline the steps taken to ensure the security of the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Signed-Releases: This check looks for the use of cryptographic signing for releases, which can help ensure the authenticity and integrity of those releases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Token-Permissions: This check assesses whether the project declares GitHub workflow tokens as read-only, which can help prevent unauthorized access to sensitive information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Vulnerabilities: This check looks for unfixed vulnerabilities in the project and uses the OSV service to assess the risk level.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Webhooks: This check looks for the presence of tokens in webhooks that are used to authenticate the origins of requests. This can help prevent unauthorized access to the project.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can use GitHub Actions to automate the process of updating an OSSF scorecard for a project. To do this, you will need to set up a workflow that runs the OSSF Scorecard and then parses and displays the results.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will walk through the process of using GitHub Actions to automate the process of updating an OSSF scorecard for a project. We will cover the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Setting up a GitHub repository for your project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating a workflow file to automate OSSF scorecard updates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Running security scans and updating dependencies with GitHub Actions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Viewing and updating your OSSF scorecard&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Setting up a GitHub repository for your project
&lt;/h3&gt;

&lt;p&gt;If you don't already have a GitHub repository, the first step is to create one. To do this, log in to your GitHub account and click the "New repository" button. Give your repository a name and description, and choose whether you want it to be public or private.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a workflow file to automate OSSF Scorecard updates
&lt;/h3&gt;

&lt;p&gt;Next, we will create a workflow file to define the steps performed by our GitHub Action.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You can set up this directly or navigate to the Security tab Setup Code scanning (or Add more scanning tools).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the OSSF Scorecards supply-chain security analysis from the list and set up the workflow. It will create a workflow file like the one below.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Here is an example workflow file that runs a security scorecard scan and uploads the findings in Code scanning alerts whenever code is pushed to the &lt;code&gt;main&lt;/code&gt; branch:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this example, the &lt;code&gt;on&lt;/code&gt; block defines the trigger for the workflow, which is a push event to the &lt;code&gt;main&lt;/code&gt; branch. The &lt;code&gt;jobs&lt;/code&gt; block defines the steps that are performed by the workflow. In this case, the workflow has an &lt;code&gt;analysis&lt;/code&gt; job that runs on an Ubuntu virtual machine. The job has three steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;actions/checkout@&amp;lt;sha&amp;gt;&lt;/code&gt;: This action checks out the code from the repository to the virtual machine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ossf/scorecard-action@&amp;lt;sha&amp;gt;&lt;/code&gt;: This action runs an OSSF Scorecard section on the repo to identify any misconfigurations based on the OSSF rules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;actions/upload-artifact@&amp;lt;sha&amp;gt;:&lt;/code&gt;: This action runs an upload artifact - the sarif file result from the scorecard action&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;actions/upload-artifact@&amp;lt;sha&amp;gt;:&lt;/code&gt;: This action uploads OSSF Scorecard results to the code scanning alerts to the dashboard.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code scanning Alerts
&lt;/h3&gt;

&lt;p&gt;Using the OSSF Score card in conjunction with code scanning alerts can be a powerful way to ensure the security of your projects in the enterprise. By integrating the OSSF Scorecard with code scanning alerts, you can receive notifications whenever a check fails or a score falls below a certain threshold. This can help you stay informed about the security of your repository and take prompt action to fix any identified issues.&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%2Fr9oqfiewlc8kj0t2u7ex.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%2Fr9oqfiewlc8kj0t2u7ex.png" width="800" height="713"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the details of the check and the remediation steps to fix 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%2F8wbv9eizr7hv390rp64t.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%2F8wbv9eizr7hv390rp64t.png" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view code scanning alerts of all your repositories in the organization, you can go to the "Security" section. Monitoring code scanning alerts is an important part of maintaining the security of your repositories in the enterprise. Regularly reviewing and addressing any identified vulnerabilities can help ensure that your projects are secure and protect your organization against potential vulnerabilities. Here is the screenshot of the sample Security Risk of your organization.&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%2F5bkl1ytd74v413zsmci3.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%2F5bkl1ytd74v413zsmci3.png" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;p&gt;It is important to note that the OSSF Scorecard is just one tool that can help you assess the security of your repositories. It is recommended that you use a combination of tools and best practices to ensure the security of your projects in the enterprise. Some other best practices to consider include the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Regularly updating dependencies and keeping them up-to-date.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using secure coding practices and following best practices for secure development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Regularly scanning your code for vulnerabilities using tools such as CodeQL or other SAST tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Implementing branch protection and code review processes to ensure that code is reviewed before it is merged.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating and maintaining a security policy that outlines the steps taken to ensure the security of the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cryptographically signing releases to ensure the authenticity and integrity of those releases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these best practices and using tools like the OSSF Scorecard, you can help improve the security of your projects in the enterprise and protect your organization against potential vulnerabilities.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Using the OSSF Scorecard, you can get a comprehensive view of the security measures taken in your repository and identify areas for improvement. You can also use the scorecard in conjunction with code scanning alerts to receive notifications when potential vulnerabilities or security issues are discovered, allowing you to take prompt action to fix those issues.&lt;/p&gt;

&lt;p&gt;Overall, the OSSF Scorecard is a valuable tool for assessing and improving the security of your projects in the enterprise. By using it regularly, you can ensure that your projects are secure and well-maintained, and you can demonstrate to your customers and stakeholders that you are committed to maintaining a high level of security.&lt;/p&gt;

&lt;p&gt;I'm Siva - Director, DevOps &amp;amp; Principal Architect at &lt;a href="https://www.ceiamerica.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Computer Enterprises Inc&lt;/strong&gt;&lt;/a&gt; from Orlando. I'm an AWS Community builder. I write blogs and tutorials about Cloud, Containers, IoT, and DevOps. If you are interested, please follow me &lt;a href="https://hashnode.com/@ksivamuthu" rel="noopener noreferrer"&gt;@ksivamuthu&lt;/a&gt; on Twitter or check out my blogs at &lt;a href="http://sivamuthukumar.com" rel="noopener noreferrer"&gt;&lt;strong&gt;sivamuthukumar.com&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>github</category>
      <category>security</category>
      <category>enterprise</category>
    </item>
    <item>
      <title>EKS Observability Infrastructure as Code - AWS Observability Accelerator</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Mon, 26 Dec 2022 00:24:13 +0000</pubDate>
      <link>https://forem.com/aws-builders/eks-observability-infrastructure-as-code-aws-observability-accelerator-1m19</link>
      <guid>https://forem.com/aws-builders/eks-observability-infrastructure-as-code-aws-observability-accelerator-1m19</guid>
      <description>&lt;p&gt;Observability is an essential part of any cloud-&lt;strong&gt;native&lt;/strong&gt; environment. When it comes to Amazon EKS clusters, observability is an even more critical factor. This blog post will explore how you can provision an observability landscape to monitor and manage your EKS clusters using AWS Observability Accelerator for Terraform.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;AWS Observability accelerator for Terraform&lt;/strong&gt; is a powerful terraform module that enables developers to quickly and easily set up observability solutions for their Amazon Elastic Container Service for Kubernetes (EKS) clusters using Amazon Web Services (AWS) observability services. This tool includes a core module that helps you configure your cluster with the AWS Distro for OpenTelemetry (ADOT) Operator for EKS, Amazon Managed Service for Prometheus, and Amazon Managed Grafana.&lt;/p&gt;

&lt;p&gt;In addition to the core module, the AWS Observability accelerator also includes a set of workload modules that provide curated ADOT collector configurations, Grafana dashboards, Prometheus recording rules, and alerts. These modules allow you to leverage the power of these tools to monitor and troubleshoot your applications and infrastructure in real-time.&lt;/p&gt;

&lt;p&gt;%[&lt;a href="https://github.com/aws-observability/terraform-aws-observability-accelerator" rel="noopener noreferrer"&gt;https://github.com/aws-observability/terraform-aws-observability-accelerator&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013463968%2F0182baff-0966-4378-ac26-e6586684565c.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013463968%2F0182baff-0966-4378-ac26-e6586684565c.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post, we will set up the EKS cluster using terraform. Then we will provision AWS Managed service for Prometheus, AWS Managed service for Grafana, Install AWS Distro for Open Telemetry in Cluster to scrape the metrics and necessary recording rules, and dashboards for Prometheus and Grafana - all these in only a few lines of Infrastructure as Code.&lt;/p&gt;

&lt;p&gt;Let’s start with the setup of initializing the EKS cluster using the EKS Blueprints terraform module.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Initialize the EKS cluster using the EKS Blueprints terraform module. EKS blueprints are modular constructs available in CDK and as terraform modules that can provision fully functional production-ready kubernetes cluster and modular add-ons such as service mesh, autoscalers, networking, storage, gitops, etc.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="err"&gt;module&lt;/span&gt; &lt;span class="err"&gt;"eks_blueprints"&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;source&lt;/span&gt;          &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"github.com/aws-ia/terraform-aws-eks-blueprints?ref=v4.19.0"&lt;/span&gt;
  &lt;span class="py"&gt;cluster_name&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.cluster_name&lt;/span&gt;
  &lt;span class="py"&gt;cluster_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1.20"&lt;/span&gt;

  &lt;span class="py"&gt;vpc_id&lt;/span&gt;             &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.vpc_id&lt;/span&gt;
  &lt;span class="py"&gt;private_subnet_ids&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.private_subnet_ids&lt;/span&gt;
  &lt;span class="py"&gt;public_subnet_ids&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.public_subnet_ids&lt;/span&gt;

  &lt;span class="py"&gt;managed_node_groups&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;t3_small&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{&lt;/span&gt;
      &lt;span class="py"&gt;node_group_name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"node-group-t3-small"&lt;/span&gt;
      &lt;span class="py"&gt;instance_types&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;["t3.small"]&lt;/span&gt;
      &lt;span class="py"&gt;subnet_ids&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.private_subnet_ids&lt;/span&gt;
      &lt;span class="py"&gt;min_size&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;1&lt;/span&gt;
      &lt;span class="py"&gt;max_size&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;2&lt;/span&gt;
      &lt;span class="py"&gt;desired_size&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;1&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;

  &lt;span class="py"&gt;tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.tags&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can then specify which observability services you want to enable, such as the ADOT operator, Amazon Managed Prometheus, and Amazon Managed Grafana.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="err"&gt;module&lt;/span&gt; &lt;span class="err"&gt;"eks_observability_accelerator"&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;source&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"github.com/aws-observability/terraform-aws-observability-accelerator?ref=v1.5.0"&lt;/span&gt;

  &lt;span class="py"&gt;aws_region&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.aws_region&lt;/span&gt;
  &lt;span class="py"&gt;eks_cluster_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_blueprints.eks_cluster_id&lt;/span&gt;

    &lt;span class="py"&gt;enable_amazon_eks_adot&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
  &lt;span class="py"&gt;enable_managed_prometheus&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
  &lt;span class="py"&gt;enable_alertmanager&lt;/span&gt;       &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
    &lt;span class="py"&gt;enable_managed_grafana&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;

  &lt;span class="py"&gt;tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.tags&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You can also specify your own instance IDs if you want to reuse existing managed services or disable the creation of managed services altogether.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="err"&gt;module&lt;/span&gt; &lt;span class="err"&gt;"eks_observability_accelerator"&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;source&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"github.com/aws-observability/terraform-aws-observability-accelerator?ref=v1.5.0"&lt;/span&gt;

  &lt;span class="py"&gt;aws_region&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.aws_region&lt;/span&gt;
  &lt;span class="py"&gt;eks_cluster_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_blueprints.eks_cluster_id&lt;/span&gt;

    &lt;span class="py"&gt;enable_amazon_eks_adot&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
  &lt;span class="py"&gt;enable_managed_prometheus&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
  &lt;span class="py"&gt;enable_alertmanager&lt;/span&gt;       &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;

    &lt;span class="c"&gt;# Reuse existing setup by disabling the creation of managed grafana service
&lt;/span&gt;    &lt;span class="c"&gt;# and pass the existing service workspace id
&lt;/span&gt;  &lt;span class="py"&gt;enable_managed_grafana&lt;/span&gt;       &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;false&lt;/span&gt;
  &lt;span class="py"&gt;managed_grafana_workspace_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.managed_grafana_workspace_id&lt;/span&gt;
  &lt;span class="py"&gt;grafana_api_key&lt;/span&gt;              &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.grafana_api_key&lt;/span&gt;

  &lt;span class="py"&gt;tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;var.tags&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up the default Grafana dashboards, alerting rules, and metrics scraping configuration from AWS Observability Accelerator for Terraform modules. You can customize them as needed.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="err"&gt;module&lt;/span&gt; &lt;span class="err"&gt;"workloads_infra"&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;source&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"github.com/aws-observability/terraform-aws-observability-accelerator/modules/workloads/infra"&lt;/span&gt;

  &lt;span class="py"&gt;eks_cluster_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_observability_accelerator.eks_cluster_id&lt;/span&gt;

  &lt;span class="py"&gt;dashboards_folder_id&lt;/span&gt;            &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_observability_accelerator.grafana_dashboards_folder_id&lt;/span&gt;
  &lt;span class="py"&gt;managed_prometheus_workspace_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_observability_accelerator.managed_prometheus_workspace_id&lt;/span&gt;

  &lt;span class="py"&gt;managed_prometheus_workspace_endpoint&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_observability_accelerator.managed_prometheus_workspace_endpoint&lt;/span&gt;
  &lt;span class="py"&gt;managed_prometheus_workspace_region&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;module.eks_observability_accelerator.managed_prometheus_workspace_region&lt;/span&gt;

  &lt;span class="c"&gt;# optional, defaults to 60s interval and 15s timeout
&lt;/span&gt;  &lt;span class="py"&gt;prometheus_config&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;global_scrape_interval&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"60s"&lt;/span&gt;
    &lt;span class="py"&gt;global_scrape_timeout&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"15s"&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;

  &lt;span class="py"&gt;depends_on&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;[&lt;/span&gt;
    &lt;span class="err"&gt;module.eks_observability_accelerator&lt;/span&gt;
  &lt;span class="err"&gt;]&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you have included the AWS Observability Accelerator in your Terraform configuration and specified which services you want to enable, you can use Terraform to provision the observability landscape for your EKS cluster.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan &lt;span class="nt"&gt;-var-file&lt;/span&gt; &lt;span class="nb"&gt;env&lt;/span&gt;/dev.tfvars
terraform apply &lt;span class="nt"&gt;-var-file&lt;/span&gt; &lt;span class="nb"&gt;env&lt;/span&gt;/dev.tfvars
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The complete Observability Landscape has been set up for you - including ADOT (AWS Distro for Open Telemetry collectors), AWS Managed Services for Prometheus (Prometheus endpoints where ADOT writes the metrics), AWS Managed Services for Grafana (where it can query from Prometheus data sources to build dashboards and display alerts).&lt;/p&gt;

&lt;p&gt;You can view the Prometheus Endpoint URL, alerting, and recording rules in the AWS console.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013592543%2F6e8eccb4-8295-43f0-b26b-ff2cde669cee.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013592543%2F6e8eccb4-8295-43f0-b26b-ff2cde669cee.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigate the Grafana Dashboard in the AWS Managed Services for the Grafana workspace, and configure the user to view/edit the dashboards. The necessary dashboards are already created for the user to view.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Kubernetes - Cluster&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kubernetes - Namespace(Workloads)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kubernetes - Node (Pods)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kubernetes - Workload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kubernetes - Kubelet&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node Exporter - Nodes&lt;/p&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013616980%2F3663769c-079e-4f95-9d60-803f934f5b4d.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013616980%2F3663769c-079e-4f95-9d60-803f934f5b4d.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can navigate to the individual dashboard and view the charts based on the metrics scraped from the infrastructure and workloads.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013637285%2F101e3125-ce13-4bf1-b173-84ba8b0a925c.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013637285%2F101e3125-ce13-4bf1-b173-84ba8b0a925c.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013644230%2F0a006ea4-ecb7-44fd-955d-34a6b5a5187b.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1672013644230%2F0a006ea4-ecb7-44fd-955d-34a6b5a5187b.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;In conclusion, the AWS Observability Accelerator for Terraform is a powerful terraform module that allows you to quickly and easily set up observability solutions for your EKS clusters. It includes a core module and a set of workload modules that provide curated configurations, dashboards, recording rules, and alerts to help you monitor and troubleshoot your applications and infrastructure in real-time. Using the AWS Observability Accelerator, you can leverage the power of tools like Prometheus and Grafana to visualize and analyze your metrics and logs, enabling you to optimize and improve the performance and reliability of your cloud-native environments.&lt;/p&gt;

&lt;p&gt;I'm Siva - working as Director, DevOps &amp;amp; Principal Architect at &lt;a href="https://www.ceiamerica.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Computer Enterprises Inc&lt;/strong&gt;&lt;/a&gt; from Orlando. I'm an AWS Community builder. I will write a lot about Cloud, Containers, IoT, and DevOps. If you are interested, please follow me @&lt;a href="https://dev.to@ksivamuthu"&gt;@ksivamuthu&lt;/a&gt; on Twitter or check out my blogs at &lt;a href="https://sivamuthukumar.com" rel="noopener noreferrer"&gt;sivamuthukumar.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>motivation</category>
    </item>
    <item>
      <title>AWS re:Invent 2022 Announcements - Data, Infrastructure &amp; Security Highlights</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Wed, 30 Nov 2022 14:46:50 +0000</pubDate>
      <link>https://forem.com/aws-builders/aws-reinvent-2022-announcements-data-infrastructure-security-highlights-5dea</link>
      <guid>https://forem.com/aws-builders/aws-reinvent-2022-announcements-data-infrastructure-security-highlights-5dea</guid>
      <description>&lt;p&gt;Amazon made a couple of announcements today (November 29, 2022) at AWS re: Invent in Las Vegas, focusing on Data, Analytics, Infrastructure &amp;amp; Security. We will see the announcements that excite me in this blog post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data &amp;amp; Analytics:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Zero ETL future&lt;/p&gt;

&lt;p&gt;When you build a data platform - ETL takes primary effort. AWS committed to building the Zero ETL future and made two great announcements toward that.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- [Amazon Aurora zero-ETL integration with Amazon Redshift](https://aws.amazon.com/about-aws/whats-new/2022/11/amazon-aurora-zero-etl-integration-redshift/)
    - enables near-real-time analytics and ML on transaction data.
    - consolidate data from multiple Aurora database
    - continuous updates
    - serverless - no infrastructure to manage
- Amazon Redshift Integration for Apache Spark
    - Now, you can run Spark queries on REshift data from EMR, Glue, and Sagemaker within seconds. No need to move the data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/datazone/" rel="noopener noreferrer"&gt;Amazon Datazone&lt;/a&gt; - ML based Data management service

&lt;ul&gt;
&lt;li&gt;A data management service that helps orgs catalog, share and govern data.&lt;/li&gt;
&lt;li&gt;Integrates with Redshift, Athena and Quicksights and provides APIs to third party sources&lt;/li&gt;
&lt;li&gt;AWS Clean Room - Data sharing / masking services.

&lt;ol&gt;
&lt;li&gt;I think AWS is running out the names for the product. ;-) &lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;Amazon QuickSight - ML powered 

&lt;ul&gt;
&lt;li&gt;It includes AI-enhanced automated data preparation, making it fast &amp;amp; easy to enable data for natural language questions.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;a href="https://aws.amazon.com/blogs/aws/preview-amazon-opensearch-serverless-run-search-and-analytics-workloads-without-managing-clusters/" rel="noopener noreferrer"&gt;Amazon OpenSearch Serverless&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Run search and analytics workloads without managing clusters.&lt;/li&gt;
&lt;li&gt;It’s one of the features I expected - finally, it got announced.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;a href="https://aws.amazon.com/blogs/aws/new-fully-managed-blue-green-deployments-in-amazon-aurora-and-amazon-rds/" rel="noopener noreferrer"&gt;Amazon RDS Blue/Green Deployments&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;A new feature for Amazon Aurora with MySQL compatibility, Amazon RDS for MySQL, and Amazon RDS for MariaDB that enables you to make database updates safer, simpler, and faster.&lt;/li&gt;
&lt;li&gt;With just a few steps, you can use Blue/Green Deployments to create a separate, synchronized, fully managed staging environment that mirrors the production environment. The staging environment clones your production environment’s primary database and in-Region read replicas. Blue/Green Deployments keep these two environments in sync using logical replication&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h3&gt;
  
  
  Infrastructure
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Graviton: NEW 3rd generation processor. 25% faster &amp;amp; use 60% LESS energy.

&lt;ol&gt;
&lt;li&gt;Strong momentum for Graviton&lt;/li&gt;
&lt;li&gt;500x time increase: delivering highest performing #MachineLearning workloads. 70% lower cost per inference.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2022/11/aws-announces-amazon-ec2-inf2-instances-preview/" rel="noopener noreferrer"&gt;AWS announces EC2 Inf2 instances&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;

&lt;a href="https://aws.amazon.com/blogs/aws/new-aws-simspace-weaver-build-large-scale-spatial-simulations-in-the-cloud/" rel="noopener noreferrer"&gt;AWS Simspace Weave&lt;/a&gt;r - Run large-scale spatial simulations in the cloud&lt;/li&gt;

&lt;/ol&gt;

&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/blogs/aws/preview-amazon-security-lake-a-purpose-built-customer-owned-data-lake-service/" rel="noopener noreferrer"&gt;Amazon Security Lake&lt;/a&gt;: centralizes security data of your organization from AWS and third-party systems for quick risk response. Supports OCSF standard format. Amazon Security Lake is the first service/initiative to support OCSF open standard format - to normalize the structure for security findings across vendors and products.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1669784082331%2FWU48JVqnX.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1669784082331%2FWU48JVqnX.png%2520align%3D" alt="image.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AWS Guard Duty - Runtime vulnerability detection for containers., attempts to access host nodes, etc. This feature will be available soon and integrates with Amazon EKS&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Industries
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/blogs/aws/introducing-amazon-omics-a-purpose-built-service-to-store-query-and-analyze-genomic-and-biological-data-at-scale/" rel="noopener noreferrer"&gt;Amazon Omics&lt;/a&gt; - Genome large-scale multimodal analysis that integrates with Amazon Healthlake or Sagemaker&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/about-aws/whats-new/2022/11/aws-supply-chain-preview/#" rel="noopener noreferrer"&gt;AWS Supply Chain&lt;/a&gt;: improves visibility into systems to lower costs &amp;amp; improve #CX - supply chain resiliency.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;There were exciting announcements in today's keynote focused on Data, Analytics &amp;amp; Infrastructure mostly. I'm excited to about learning these new announcements and help enterprises on their successful journey - that innovates, analyzes, and scales their enterprise data analytics platform.&lt;/p&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at &lt;a href="https://www.ceiamerica.com" rel="noopener noreferrer"&gt;Computer Enterprises Inc&lt;/a&gt; from Orlando. I'm an AWS Community builder. I will write a lot about Cloud, Containers, IoT, and Devops. If you are interested, please follow me &lt;a class="mentioned-user" href="https://dev.to/ksivamuthu"&gt;@ksivamuthu&lt;/a&gt; on Twitter or check out my blogs at blog.sivamuthukumar.com!&lt;/p&gt;

</description>
      <category>github</category>
      <category>discuss</category>
    </item>
    <item>
      <title>EKS Blueprints - Modular Constructs for your Kubernetes cluster</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Sun, 08 May 2022 03:13:47 +0000</pubDate>
      <link>https://forem.com/aws-builders/eks-blueprints-modular-constructs-for-your-kubernetes-cluster-10ld</link>
      <guid>https://forem.com/aws-builders/eks-blueprints-modular-constructs-for-your-kubernetes-cluster-10ld</guid>
      <description>&lt;p&gt;Amazon Elastic Kubernetes Service (EKS) helps you manage, scale, and deploy your Kubernetes clusters. In the enterprise cluster setup, you need more than the cluster setup. To bootstrap, the kubernetes cluster requires significant features, including automated node management, ingress controller, monitoring, logging, security, networking tools, etc. &lt;/p&gt;

&lt;p&gt;With my experience with other cloud provider platform Kubernetes offerings such as GKE &amp;amp; AKS, EKS was behind in the management features - logging, ingress controllers, etc. We need to set it up manually to get the basic features. That was hard to get into the Kubernetes platform - especially if it’s the first time onboarding to Kubernetes experience and/or EKS cluster. Later the Kubernetes components from AWS speed up the operation’s onboarding process easier. &lt;/p&gt;

&lt;p&gt;AWS EKS Blueprints - AWS is making the operations and developer experience greater by providing modular Infrastructure as Code modules to expedite the process of onboarding the cluster and open source tools and security controls with production readiness.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are AWS EKS Blueprints?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/aws-quickstart/cdk-eks-blueprints/" rel="noopener noreferrer"&gt;EKS Blueprints&lt;/a&gt; is a collection of Infrastructure as Code (IaC) modules that will help you configure and deploy EKS clusters across accounts and regions. You can use EKS Blueprints to easily bootstrap an EKS cluster with Amazon EKS add-ons as well as a wide range of popular open-source add-ons, including Prometheus, Karpenter, Nginx, Traefik, AWS Load Balancer Controller, Fluent Bit, Keda, Argo CD, and more. EKS Blueprints also helps you implement relevant security controls needed to operate workloads from multiple teams in the same cluster.&lt;/p&gt;

&lt;p&gt;Highlights of the features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy Well-Architected EKS clusters across accounts and regions&lt;/li&gt;
&lt;li&gt;Manage cluster configuration, including add-ons from a single GIt repo.&lt;/li&gt;
&lt;li&gt;Teams and Access management&lt;/li&gt;
&lt;li&gt;Continuous Delivery pipelines for deploying infrastructure&lt;/li&gt;
&lt;li&gt;GitOps - based workflows for workloads&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Courtesy: Image from AWS Blog.&lt;/p&gt;

&lt;h3&gt;
  
  
  Imperative / Declarative
&lt;/h3&gt;

&lt;p&gt;When it comes to Infrastructure as Code, there are two options - Declarative (Terraform, yamls, etc.) and Imperative (CDK, etc.). AWS EKS Blueprints are available in both declarative and imperative options.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS EKS Blueprints for Terraform&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In AWS EKS Blueprints for Terraform - the tools are available as terraform modules to implement. You can bootstrap the kubernetes cluster and use the adds-on modules to install the open-source tools. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aws-ia" rel="noopener noreferrer"&gt;
        aws-ia
      &lt;/a&gt; / &lt;a href="https://github.com/aws-ia/terraform-aws-eks-blueprints" rel="noopener noreferrer"&gt;
        terraform-aws-eks-blueprints
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Configure and deploy complete EKS clusters.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;AWS EKS Blueprints for CDK&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In AWS EKS Blueprints for CDK - the tools are available as CDK constructs to implement. You can bootstrap the kubernetes cluster and use the adds-on modules to install the open-source tools. &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aws-quickstart" rel="noopener noreferrer"&gt;
        aws-quickstart
      &lt;/a&gt; / &lt;a href="https://github.com/aws-quickstart/cdk-eks-blueprints" rel="noopener noreferrer"&gt;
        cdk-eks-blueprints
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      AWS Quick Start Team
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Demo Walkthrough
&lt;/h2&gt;

&lt;p&gt;In today’s blog, we are going to set up the EKS Blueprint CDK and set up the necessary add-ons and the team structure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Install the AWS-CDK&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; aws-cdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Initialize the CDK application&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;eks-blueprint
cdk init app &lt;span class="nt"&gt;--language&lt;/span&gt; typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create the EKS Blueprint Construct and call it from bin/.ts&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;## ./bin/eks-blueprint.ts&lt;/span&gt;
&lt;span class="c"&gt;#!/usr/bin/env node&lt;/span&gt;
import &lt;span class="s1"&gt;'source-map-support/register'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
import &lt;span class="k"&gt;*&lt;/span&gt; as cdk from &lt;span class="s1"&gt;'aws-cdk-lib'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
import &lt;span class="o"&gt;{&lt;/span&gt; EKSBlueprintConstruct &lt;span class="o"&gt;}&lt;/span&gt; from &lt;span class="s1"&gt;'../lib/eks-blueprint-stack'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

const app &lt;span class="o"&gt;=&lt;/span&gt; new cdk.App&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
new EKSBlueprintConstruct&lt;span class="o"&gt;()&lt;/span&gt;.build&lt;span class="o"&gt;(&lt;/span&gt;app, &lt;span class="s1"&gt;'siva-dev'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The EKS Blueprint Construct has three parts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a generic EKS cluster with a node group configuration&lt;/li&gt;
&lt;li&gt;Add the addons&lt;/li&gt;
&lt;li&gt;Add the teams - dev team and platform team.
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EKSBlueprintConstruct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;devTeam&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ApplicationTeam&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dev&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserArns&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;devUsers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;platformTeam&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PlatformTeam&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;platform&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserArns&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;platformUsers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;teams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;devTeam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;platformTeam&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addOns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;VpcCniAddOn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CoreDnsAddOn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;KubeProxyAddOn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MetricsServerAddOn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AwsLoadBalancerControllerAddOn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ContainerInsightsAddOn&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;KarpenterAddOn&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clusterProvider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;GenericClusterProvider&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;KubernetesVersion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;V1_21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;managedNodeGroups&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-nodegroup`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;instanceTypes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InstanceType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;t3.small&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt;
        &lt;span class="na"&gt;minSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;maxSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
      &lt;span class="p"&gt;}],&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="nx"&gt;EksBlueprint&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addOns&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;addOns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clusterProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;clusterProvider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;teams&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;teams&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;region&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;us-east-1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;You can add the context properties that have &lt;code&gt;devUsers&lt;/code&gt; and &lt;code&gt;platformUsers&lt;/code&gt; that has a list of user/role ARN to create the team.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"context"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"devUsers"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
      &lt;span class="s2"&gt;"arn:aws:iam::xxxxxxxxxxx:user/user_name_1"&lt;/span&gt;,
      &lt;span class="s2"&gt;"arn:aws:iam::xxxxxxxxxxx:user/user_name_2"&lt;/span&gt;
    &lt;span class="o"&gt;]&lt;/span&gt;,
    &lt;span class="s2"&gt;"platformUsers"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
           &lt;span class="s2"&gt;"arn:aws:iam::xxxxxxxxxxx:user/admin_name"&lt;/span&gt;
        &lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```tsx
  private getUserArns(scope: Construct, key: string): ArnPrincipal[] {
    const context: string[] = scope.node.tryGetContext(key);
    if (context &amp;amp;&amp;amp; context.length &amp;gt; 0) {
      return context.map(e =&amp;gt; new ArnPrincipal(e));
    }
    return [];
  }
```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see the CDK output has kubernetes config commands, the role for the dev and platform team.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;creating&lt;/span&gt; &lt;span class="nx"&gt;CloudFormation&lt;/span&gt; &lt;span class="nx"&gt;changeset&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;

 &lt;span class="err"&gt;✅&lt;/span&gt;  &lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;

&lt;span class="err"&gt;✨&lt;/span&gt;  &lt;span class="nx"&gt;Deployment&lt;/span&gt; &lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1437.28&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;

&lt;span class="nx"&gt;Outputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;devsa&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;sa&lt;/span&gt;
&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;devteamrole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;aws&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;iam&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nx"&gt;xxxxxxxxxx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;
&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;platformteamadmin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;none&lt;/span&gt;
&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sivadevClusterName9C1D1E82&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;
&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sivadevConfigCommandF9D1C39C&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws&lt;/span&gt; &lt;span class="nx"&gt;eks&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;kubeconfig&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt; &lt;span class="nx"&gt;us&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;east&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;role_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sivadevGetTokenCommandA8918546&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;aws&lt;/span&gt; &lt;span class="nx"&gt;eks&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;cluster&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="nx"&gt;siva&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt; &lt;span class="nx"&gt;us&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;east&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;arn&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;role_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Caveats
&lt;/h3&gt;

&lt;p&gt;The latest kubernetes version is not supported yet. Having issues with k8s version 1.22. You may see issues. Please use v1.21 at this time. &lt;a href="https://github.com/aws-quickstart/cdk-eks-blueprints/issues/350" rel="noopener noreferrer"&gt;https://github.com/aws-quickstart/cdk-eks-blueprints/issues/350&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, you’ve to set the region - for the AWS Load balancer controller addon to work as the container images are derived from the region variable. &lt;/p&gt;

&lt;p&gt;Helm release - testing - It will be a great addition if the CDK is able to fail if the addons fail to install. For e.g., without setting the region, the AWS Load balancer controller was in a pending state.&lt;/p&gt;

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

&lt;p&gt;AWS EKS Blueprints is definitely a big step in making the dev and operation team's life easier. AWS is also working with Industrial partners and open source tools such as Datadog, Kasten.io, ArgoCD, Hashicorp, Snyk, etc. &lt;/p&gt;

&lt;p&gt;In the next post of this series,  we will see how to set up the CI/CD of the infrastructure and application workloads using EKS blueprints. And also how to extend the EKS blueprint to bring your own set of tools for your enterprise.&lt;/p&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at Computer Enterprises Inc from Orlando. I'm an AWS Community builder and Auth0 Ambassador. I am going to write a lot about Cloud, Containers, IoT, and Devops. If you are interested in any of that, make sure to follow me if you haven’t already. Please follow me &lt;strong&gt;&lt;a href="https://hashnode.com/@ksivamuthu" rel="noopener noreferrer"&gt;@ksivamuthu&lt;/a&gt;&lt;/strong&gt; on Twitter or check out my blogs at &lt;strong&gt;&lt;a href="https://blog.sivamuthukumar.com/" rel="noopener noreferrer"&gt;blog.sivamuthukumar.com&lt;/a&gt;&lt;/strong&gt;!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>AWS Copilot GitHub Actions</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Mon, 02 May 2022 18:39:14 +0000</pubDate>
      <link>https://forem.com/aws-builders/aws-copilot-github-actions-h83</link>
      <guid>https://forem.com/aws-builders/aws-copilot-github-actions-h83</guid>
      <description>&lt;p&gt;In this blog, I’m going to walk through how to set up AWS Copilot in GitHub actions. &lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Copilot
&lt;/h2&gt;

&lt;p&gt;AWS Copilot is an open-source command-line interface that makes it easy for developers to &lt;strong&gt;build&lt;/strong&gt;, &lt;strong&gt;release&lt;/strong&gt;, and &lt;strong&gt;operate&lt;/strong&gt; production-ready containerized applications on AWS App Runner, Amazon ECS, and AWS Fargate. &lt;/p&gt;

&lt;h3&gt;
  
  
  Initialize the Copilot Application
&lt;/h3&gt;

&lt;p&gt;Using copilot, you can initialize the entire infrastructure to run your containerized apps. Let’s take a look at an example. In this repository, we’ve demo &lt;strong&gt;nginx&lt;/strong&gt; container that serves the index.html file. You can check out this repo here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Initialize the application using the &lt;code&gt;copilot&lt;/code&gt; command-line tool.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; copilot init &lt;span class="nt"&gt;--app&lt;/span&gt; demo &lt;span class="se"&gt;\&lt;/span&gt;
        &lt;span class="nt"&gt;--name&lt;/span&gt; app &lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;--type&lt;/span&gt; &lt;span class="s1"&gt;'Load Balanced Web Service'&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
      &lt;span class="nt"&gt;--dockerfile&lt;/span&gt; &lt;span class="s1"&gt;'./Dockerfile
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copilot will create the necessary infrastructure needed for your app in the AWS account. It will create an app service in the demo app, exposed to the internet using a load balancer. The container for running services is mentioned using dockerfile. The CLI will build the container from the docker file, set up ECR, push the image to ECR and configure the ECS service to pull the image from ECR.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Ok great, we&lt;span class="s1"&gt;'ll set up a Load Balanced Web Service named app in application demo listening on port 80.

✔ Created the infrastructure to manage services and jobs under application demo.

✔ The directory copilot will hold service manifests for application demo.

✔ Wrote the manifest for service app at copilot/app/manifest.yml
Your manifest contains configurations like your container size and port (:80).

✔ Created ECR repositories for service app.

All right, you'&lt;/span&gt;re all &lt;span class="nb"&gt;set &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;local &lt;/span&gt;development.
Deploy: Yes

✔ Linked account 495775103319 and region us-east-1 to application demo.

✔ Proposing infrastructure changes &lt;span class="k"&gt;for &lt;/span&gt;the demo-test environment.
- Creating the infrastructure &lt;span class="k"&gt;for &lt;/span&gt;the demo-test environment.             &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;82.9s]
  - An IAM Role &lt;span class="k"&gt;for &lt;/span&gt;AWS CloudFormation to manage resources               &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;15.9s]
  - An ECS cluster to group your services                                &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;9.4s]
  - An IAM Role to describe resources &lt;span class="k"&gt;in &lt;/span&gt;your environment                &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;16.7s]
  - A security group to allow your containers to talk to each other      &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;5.7s]
  - An Internet Gateway to connect to the public internet                &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;21.7s]
  - Private subnet 1 &lt;span class="k"&gt;for &lt;/span&gt;resources with no internet access               &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;5.7s]
  - Private subnet 2 &lt;span class="k"&gt;for &lt;/span&gt;resources with no internet access               &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;5.7s]
  - Public subnet 1 &lt;span class="k"&gt;for &lt;/span&gt;resources that can access the internet           &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;12.6s]
  - Public subnet 2 &lt;span class="k"&gt;for &lt;/span&gt;resources that can access the internet           &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;9.3s]
  - A Virtual Private Cloud to control networking of your AWS resources  &lt;span class="o"&gt;[&lt;/span&gt;create &lt;span class="nb"&gt;complete&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="o"&gt;[&lt;/span&gt;18.2s]
✔ Created environment &lt;span class="nb"&gt;test &lt;/span&gt;&lt;span class="k"&gt;in &lt;/span&gt;region us-east-1 under application demo.
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Copilot Pipeline
&lt;/h3&gt;

&lt;p&gt;Copilot has a pipeline command to set up the Automated release pipeline using AWS CodePipeline for your application. You can learn more about it &lt;a href="https://aws.github.io/copilot-cli/docs/concepts/pipelines/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Copilot in GitHub Actions
&lt;/h2&gt;

&lt;p&gt;This article is going to focus on how to deploy the application using Copilot using GitHub Actions.  Let’s walk through the setup step by step and then I wrote a GitHub action to set up for you with easy configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Installing Copilot CLI&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The AWS copilot CLI has to be downloaded and installed to access. The AWS Copilot binaries are released on GitHub. We can download the platform-specific binaries for a specific version or the latest version from the GitHub releases pages here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/aws/copilot-cli/releases"&gt;Releases · aws/copilot-cli&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up OIDC provider
&lt;/h3&gt;

&lt;p&gt;OpenID Connect (OIDC) allows your GitHub Actions workflows to access resources in Amazon Web Services (AWS), without needing to store the AWS credentials as long-lived GitHub secrets.&lt;/p&gt;

&lt;p&gt;We can configure AWS to trust GitHub's OIDC as a federated identity and includes a workflow for the &lt;code&gt;[aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials)&lt;/code&gt; that use tokens to authenticate to AWS and access resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Copilot CLI Usage
&lt;/h3&gt;

&lt;p&gt;You can use the copilot after installing the tool in your PATH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;copilot &lt;span class="nt"&gt;--version&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can use the deploy command using copilot cli&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;copilot deploy &lt;span class="nt"&gt;--name&lt;/span&gt; demo &lt;span class="nt"&gt;--env&lt;/span&gt; &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I’ve written a GitHub Actions wrapping these functionalities&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installing Copilot CLI in Tool path&lt;/li&gt;
&lt;li&gt;Deploy the Copilot Application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/marketplace/actions/aws-copilot"&gt;AWS GitHub Copilot Actions&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ksivamuthu"&gt;
        ksivamuthu
      &lt;/a&gt; / &lt;a href="https://github.com/ksivamuthu/aws-copilot-github-action"&gt;
        aws-copilot-github-action
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
AWS Copilot GitHub Action&lt;/h1&gt;
&lt;p&gt;This repo contains the github actions for installing &lt;a href="https://github.com/aws/copilot-cli"&gt;AWS Copilot cli&lt;/a&gt; and deploying app. The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on AWS App Runner, Amazon ECS, and AWS Fargate.&lt;/p&gt;
&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;To install copilot-cli in your github actions.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code class="notranslate"&gt;  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::111111111111:role/my-github-actions-role-test
          aws-region: us-east-1
      - uses: ksivamuthu/aws-copilot-github-action@v0.0.1
        with:
          command: install
      - run: |
          copilot --version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;To deploy the app&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="snippet-clipboard-content position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code class="notranslate"&gt;  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::111111111111:role/my-github-actions-role-test
          aws-region: us-east-1
      - uses: ksivamuthu/aws-copilot-github-action@v0.0.1
        with:
          command: deploy
          app: your-awesome-app
          env: prod
          force: false # optional
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/ksivamuthu/aws-copilot-github-action"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;h2&gt;
  
  
  AWS Copilot GitHub Actions Usage
&lt;/h2&gt;

&lt;p&gt;To install the copilot cli in the path. You can add the &lt;code&gt;ksivamuth/aws-copilot-github-action@v0.0.1&lt;/code&gt; steps with commands install to add the copilot cli in tool path. You can access the copilot cli - for e.g we are checking the version here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Configure AWS credentials&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-actions/configure-aws-credentials@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;role-to-assume&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arn:aws:iam::111111111111:role/my-github-actions-role-test&lt;/span&gt;
          &lt;span class="na"&gt;aws-region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;us-east-1&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ksivamuthu/aws-copilot-github-action@v0.0.1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;install&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;copilot --version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To deploy the application using copilot. Pass the application name and environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Configure AWS credentials&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws-actions/configure-aws-credentials@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;role-to-assume&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;arn:aws:iam::111111111111:role/my-github-actions-role-test&lt;/span&gt;
          &lt;span class="na"&gt;aws-region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;us-east-1&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ksivamuthu/aws-copilot-github-action@v0.0.1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
          &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;your-awesome-app&lt;/span&gt;
          &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;prod&lt;/span&gt;
          &lt;span class="na"&gt;force&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;# optional&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;The above example is in the demo repository &lt;a href="https://github.com/ksivamuthu/demo-copilot-container-app"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When the changes are pushed into GitHub, the action build the docker image and push the image repository into ECR. Then the pushed docker image is deployed into configured environment for this ECS or AppRunner application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2GgFXRHy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3kgpv26a14q79m061g2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2GgFXRHy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3kgpv26a14q79m061g2.jpg" alt="Copilot" width="624" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the workflow is succeed, you can see the latest version of the application deployed. &lt;/p&gt;

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

&lt;p&gt;🚀 AWS Copilot supercharges your application - one cli tool to set up infrastructure, build your application with many services, setting up the pipeline to automate release, monitor the status of stack and application, and with add-ons. In this blog, we took a look how to integrate the Copilot app using GitHub Actions.&lt;/p&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at Computer Enterprises Inc from Orlando. I'm an AWS Community builder, Auth0 Ambassador and I am going to write a lot about Cloud, Containers, IoT, and Devops. If you are interested in any of that, make sure to follow me if you haven’t already. Please follow me &lt;strong&gt;&lt;a href="https://hashnode.com/@ksivamuthu"&gt;@ksivamuthu&lt;/a&gt;&lt;/strong&gt; Twitter or check out my blogs at &lt;strong&gt;&lt;a href="https://blog.sivamuthukumar.com/"&gt;blog.sivamuthukumar.com&lt;/a&gt;&lt;/strong&gt;!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>containers</category>
      <category>devops</category>
      <category>github</category>
    </item>
    <item>
      <title>Auth0 JWT Middleware in Go - Gin Web Framework</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Sat, 29 Jan 2022 06:59:17 +0000</pubDate>
      <link>https://forem.com/ksivamuthu/auth0-jwt-middleware-in-go-gin-web-framework-37mj</link>
      <guid>https://forem.com/ksivamuthu/auth0-jwt-middleware-in-go-gin-web-framework-37mj</guid>
      <description>&lt;p&gt;In today's blog post, we will see how to validate the JWTs using Auth0 Golang JWT middleware using Gin Web Framework. Gin is a web framework written in Go (Golang). In deep-dive, we will see how to integrate the Auth0 Golang JWT middleware to verify JWTs generated using both HS256 and RS256 using secret and JWKs.&lt;/p&gt;

&lt;p&gt;Auth0 Golang JWT middleware stable version v2.0.0 released on Jan 19, 2022&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/auth0/go-jwt-middleware/releases/tag/v2.0.0" rel="noopener noreferrer"&gt;Release v2.0.0 · auth0/go-jwt-middleware&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Gin Web Framework
&lt;/h2&gt;

&lt;p&gt;Gin is a high-performance micro-framework that can build web applications and microservices. It makes it simple to build a request handling pipeline from modular, reusable pieces. It does this by allowing you to write middleware that can be plugged into one or more request handlers or groups of request handlers.&lt;/p&gt;

&lt;p&gt;Let's create a simple API using Golang Gin Web Framework.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Gin package
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  go get &lt;span class="nt"&gt;-u&lt;/span&gt; github.com/gin-gonic/gin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Import it in your code and run simple api
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;  &lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"context"&lt;/span&gt;
    &lt;span class="s"&gt;"net/http"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ID&lt;/span&gt;    &lt;span class="kt"&gt;int&lt;/span&gt;     &lt;span class="s"&gt;`json:"id"`&lt;/span&gt;
    &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"title"`&lt;/span&gt;
    &lt;span class="n"&gt;Code&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"code"`&lt;/span&gt;
    &lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt; &lt;span class="s"&gt;`json:"price"`&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/products"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c"&gt;// Listen and Server in 0.0.0.0:5000&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":5000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add JWT Middleware
&lt;/h2&gt;

&lt;p&gt;Before configuring the Auth0 APIs, lets' integrate the Auth0 Golang JWT middleware.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/auth0/go-jwt-middleware" rel="noopener noreferrer"&gt;GitHub - auth0/go-jwt-middleware: A Middleware for Go Programming Language to check for JWTs on HTTP requests&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="n"&gt;github&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;auth0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;go&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;middleware&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Auth0 Golang JWT middleware is the HTTP middleware handler. To use it in the Gin Web framework, we need a wrapper to wrap the common HTTP middleware to the Gin middleware handler. For that purpose, I'm using Gin Adapter from Gareth Watts. &lt;a href="https://github.com/gwatts/gin-adapter" rel="noopener noreferrer"&gt;https://github.com/gwatts/gin-adapter&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"context"&lt;/span&gt;
    &lt;span class="s"&gt;"net/http"&lt;/span&gt;

    &lt;span class="n"&gt;jwtmiddleware&lt;/span&gt; &lt;span class="s"&gt;"github.com/auth0/go-jwt-middleware/v2"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/auth0/go-jwt-middleware/v2/validator"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/gwatts/gin-adapter"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ID&lt;/span&gt;    &lt;span class="kt"&gt;int&lt;/span&gt;     &lt;span class="s"&gt;`json:"id"`&lt;/span&gt;
    &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"title"`&lt;/span&gt;
    &lt;span class="n"&gt;Code&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"code"`&lt;/span&gt;
    &lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt; &lt;span class="s"&gt;`json:"price"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;keyFunc&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;interface&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"secret"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;jwtValidator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keyFunc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HS256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"http://localhost:5000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"api:read"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="n"&gt;jwtMiddleware&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;jwtmiddleware&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwtValidator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ValidateToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// Wrap the http handler with gin adapter&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwtMiddleware&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CheckJWT&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/products"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c"&gt;// Listen and Server in 0.0.0.0:5000&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":5000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's test this API with JWT URLs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;curl&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="c"&gt;//localhost:5000/products' \&lt;/span&gt;
&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;Authorization&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Bearer&lt;/span&gt; &lt;span class="n"&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjUwMDAiLCJhdWQiOiJhcGk6cmVhZCJ9&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hbgwKW_RILeXXDDUv5bVK3WgjtvqoK5IiuisgnFWefY&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can generate a new JWT with issuer &lt;code&gt;[http://localhost:5000](http://localhost:5000)&lt;/code&gt; and audience &lt;code&gt;api:read&lt;/code&gt; with the HS256 algorithm with a shared secret &lt;code&gt;secret&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜  ~  curl &lt;span class="nt"&gt;--location&lt;/span&gt; &lt;span class="nt"&gt;--request&lt;/span&gt; GET &lt;span class="s1"&gt;'http://localhost:5000/products'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--header&lt;/span&gt; &lt;span class="s1"&gt;'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjUwMDAiLCJhdWQiOiJhcGk6cmVhZCJ9.hbgwKW_RILeXXDDUv5bVK3WgjtvqoK5IiuisgnFWefY'&lt;/span&gt; | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   160  100   160    0     0   6011      0 &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- 20000
&lt;span class="o"&gt;[&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"id"&lt;/span&gt;: 1,
    &lt;span class="s2"&gt;"title"&lt;/span&gt;: &lt;span class="s2"&gt;"Product 1"&lt;/span&gt;,
    &lt;span class="s2"&gt;"code"&lt;/span&gt;: &lt;span class="s2"&gt;"p1"&lt;/span&gt;,
    &lt;span class="s2"&gt;"price"&lt;/span&gt;: 100
  &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"id"&lt;/span&gt;: 2,
    &lt;span class="s2"&gt;"title"&lt;/span&gt;: &lt;span class="s2"&gt;"Product 2"&lt;/span&gt;,
    &lt;span class="s2"&gt;"code"&lt;/span&gt;: &lt;span class="s2"&gt;"p2"&lt;/span&gt;,
    &lt;span class="s2"&gt;"price"&lt;/span&gt;: 200
  &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"id"&lt;/span&gt;: 3,
    &lt;span class="s2"&gt;"title"&lt;/span&gt;: &lt;span class="s2"&gt;"Product 3"&lt;/span&gt;,
    &lt;span class="s2"&gt;"code"&lt;/span&gt;: &lt;span class="s2"&gt;"p3"&lt;/span&gt;,
    &lt;span class="s2"&gt;"price"&lt;/span&gt;: 300
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configure Auth0 APIs
&lt;/h2&gt;

&lt;p&gt;Now it's time to add authorization to the API using Auth0. Let's configure Auth0 APIs with the signing algorithm RS256 and change the Auth0 Golang middleware code to support RS256.&lt;/p&gt;

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

&lt;p&gt;Add the permission &lt;code&gt;read:products&lt;/code&gt; in the API&lt;/p&gt;

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

&lt;p&gt;Change the Auth0 middleware to validate the RS256 signature JWT token.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;issuerURL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"AUTH0_ISSUER_URL"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;audience&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"AUTH0_AUDIENCE"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;jwks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewCachingProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;issuerURL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Minute&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;jwtValidator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;KeyFunc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RS256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;issuerURL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;audience&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;jwtMiddleware&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;jwtmiddleware&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwtValidator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ValidateToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwtMiddleware&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CheckJWT&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The complete code looks like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"log"&lt;/span&gt;
    &lt;span class="s"&gt;"net/http"&lt;/span&gt;
    &lt;span class="s"&gt;"net/url"&lt;/span&gt;
    &lt;span class="s"&gt;"os"&lt;/span&gt;
    &lt;span class="s"&gt;"time"&lt;/span&gt;

    &lt;span class="n"&gt;adapter&lt;/span&gt; &lt;span class="s"&gt;"github.com/gwatts/gin-adapter"&lt;/span&gt;

    &lt;span class="n"&gt;jwtmiddleware&lt;/span&gt; &lt;span class="s"&gt;"github.com/auth0/go-jwt-middleware/v2"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/auth0/go-jwt-middleware/v2/jwks"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/auth0/go-jwt-middleware/v2/validator"&lt;/span&gt;

    &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/joho/godotenv"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ID&lt;/span&gt;    &lt;span class="kt"&gt;int&lt;/span&gt;     &lt;span class="s"&gt;`json:"id"`&lt;/span&gt;
    &lt;span class="n"&gt;Title&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"title"`&lt;/span&gt;
    &lt;span class="n"&gt;Code&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="s"&gt;`json:"code"`&lt;/span&gt;
    &lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="kt"&gt;float32&lt;/span&gt; &lt;span class="s"&gt;`json:"price"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;godotenv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Load&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error loading .env file"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;issuerURL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"AUTH0_ISSUER_URL"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;audience&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"AUTH0_AUDIENCE"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;jwks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewCachingProvider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;issuerURL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Minute&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;jwtValidator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;KeyFunc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;validator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RS256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;issuerURL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;audience&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;jwtMiddleware&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;jwtmiddleware&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwtValidator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ValidateToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wrap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwtMiddleware&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CheckJWT&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/products"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Product 3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Code&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300.0&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusOK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c"&gt;// Listen and Server in 0.0.0.0:5000&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;":5000"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify Auth0 JWT
&lt;/h2&gt;

&lt;p&gt;Create a test JWT from the API Test page. Call the API with the test token.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜  auth0-go-gin-middleware  curl &lt;span class="nt"&gt;--location&lt;/span&gt; &lt;span class="nt"&gt;--request&lt;/span&gt; GET &lt;span class="s1"&gt;'http://localhost:5000/products'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--header&lt;/span&gt; &lt;span class="s1"&gt;'authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InVUT0ktNGhrSDBWNU9YUGxKV0xpXyJ9.eyJpc3MiOiJodHRwczovL3NpdmEtZGVtby1hcHAudXMuYXV0aDAuY29tLyIsInN1YiI6Inl2N1NDekVueUxTWGdMZ1d3b2pJODZvNk5ZMzh0cmNtQGNsaWVudHMiLCJhdWQiOiJodHRwczovL3Byb2R1Y3RzLWFwaS8iLCJpYXQiOjE2NDM0MzM4NTYsImV4cCI6MTY0MzUyMDI1NiwiYXpwIjoieXY3U0N6RW55TFNYZ0xnV3dvakk4Nm82TlkzOHRyY20iLCJndHkiOiJjbGllbnQtY3JlZGVudGlhbHMifQ.yH13H5XxLEABu3o8s2HZUs8Q9PXHeLGUcELQdlrYoClKP3k3B_WdUpaH2_c-UpA1ZjB_Is71-hSt3iqQN_OaMV_fFqpnt0qJQNXsoWSHBE5CzDDAclRlFf5XaWVbcA072rzUAtrJuPzHYf8kdR91243lJFA_13V5vlQuWxqFxas4FonVR5OLGcXYHqLfBI76DPfFaOBwOzefSYSI_jxKrrQtnux4Ktkqrgo7tpFckY6UfD6fXPeRvk4xLSb_SteAwcpCQrWJVyt7gTWv4_KkSNEyZduEbMTrnkU_jdQjHuKOLaTBc4t7t3MK_2_tmrda5xn0QXf-1y6P2M4zQu2mWA'&lt;/span&gt; | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   160  100   160    0     0   8045      0 &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- &lt;span class="nt"&gt;--&lt;/span&gt;:--:-- 40000
&lt;span class="o"&gt;[&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"id"&lt;/span&gt;: 1,
    &lt;span class="s2"&gt;"title"&lt;/span&gt;: &lt;span class="s2"&gt;"Product 1"&lt;/span&gt;,
    &lt;span class="s2"&gt;"code"&lt;/span&gt;: &lt;span class="s2"&gt;"p1"&lt;/span&gt;,
    &lt;span class="s2"&gt;"price"&lt;/span&gt;: 100
  &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"id"&lt;/span&gt;: 2,
    &lt;span class="s2"&gt;"title"&lt;/span&gt;: &lt;span class="s2"&gt;"Product 2"&lt;/span&gt;,
    &lt;span class="s2"&gt;"code"&lt;/span&gt;: &lt;span class="s2"&gt;"p2"&lt;/span&gt;,
    &lt;span class="s2"&gt;"price"&lt;/span&gt;: 200
  &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"id"&lt;/span&gt;: 3,
    &lt;span class="s2"&gt;"title"&lt;/span&gt;: &lt;span class="s2"&gt;"Product 3"&lt;/span&gt;,
    &lt;span class="s2"&gt;"code"&lt;/span&gt;: &lt;span class="s2"&gt;"p3"&lt;/span&gt;,
    &lt;span class="s2"&gt;"price"&lt;/span&gt;: 300
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In this blog post, we walked through how to use Auth0 Golang middleware v2.0.0 to verify the JWT on both HS256 and RS256 signatures. You can extend this demo project to verify the custom claims in JWT and more. We will see in more detail in upcoming blog posts.&lt;/p&gt;

</description>
      <category>auth0</category>
      <category>security</category>
      <category>go</category>
    </item>
    <item>
      <title>AWS EKS Connector - Manage all your Kubernetes Clusters in one place</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Tue, 04 Jan 2022 03:30:11 +0000</pubDate>
      <link>https://forem.com/aws-builders/aws-eks-connector-manage-all-your-kubernetes-clusters-in-one-place-56g8</link>
      <guid>https://forem.com/aws-builders/aws-eks-connector-manage-all-your-kubernetes-clusters-in-one-place-56g8</guid>
      <description>&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/eks-connector.html" rel="noopener noreferrer"&gt;Amazon EKS Connector&lt;/a&gt; is now generally available. With EKS Connector, you can now extend the EKS console to view your Kubernetes clusters outside AWS. What !?! Yes, now we can use the EKS console to visualize the Kubernetes clusters, both EKS and non-EKS clusters running in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On-premises Kubernetes Cluster&lt;/li&gt;
&lt;li&gt;Self-managed Clusters running on AWS EC2 instances&lt;/li&gt;
&lt;li&gt;Clusters from other cloud providers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In today's blog, we will see how to connect the kubernetes clusters from my home lab and Azure / GCP Cloud providers along with EKS using eksctl. Once connected, we can see the cluster details, configurations, and workloads in one place on the EKS console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kubernetes Clusters
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Home Lab&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have the home lab kubernetes cluster running on my mini pc that's running Linux. It was previously running on Raspberry Pi, and later I switched the lab to mini pc. I often flash Raspberry Pi for my IoT experiments; there are no apparent reasons. You can set up the kubernetes cluster on Raspberry Pi if you wish. I'm using K3s - lightweight kubernetes distribution designed for running production workloads in resource-constrained, IoT edge devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Azure Kubernetes Service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Amazon EKS connector can also connect the Kubernetes clusters running on other cloud providers. I've set up the AKS (Azure Kubernetes Service) for this blog in the Azure environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EKS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I've EKS cluster along with the other clusters too. Amazon Elastic Kubernetes Service (Amazon EKS) is a managed container service to run and scale Kubernetes applications in AWS infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Registering a Cluster
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;eksctl&lt;/code&gt; simplifies registering non-EKS clusters by creating the required AWS resources and generating Kubernetes manifests for EKS Connector to apply to the external cluster.&lt;/p&gt;

&lt;p&gt;To register or connect a non-EKS Kubernetes cluster, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ eksctl register cluster &lt;span class="nt"&gt;--name&lt;/span&gt; siva-home-lab &lt;span class="nt"&gt;--provider&lt;/span&gt; rancher
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The supported providers are : EKS_ANYWHERE, ANTHOS, GKE, AKS, OPENSHIFT, TANZU, RANCHER, EC2, OTHER&lt;/p&gt;

&lt;p&gt;When registering, eksctl creates three yaml files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;eks-connector.yaml - Deploys EKS connector agent&lt;/li&gt;
&lt;li&gt;eks-connector-clusterrole.yaml - Cluster Role of cluster&lt;/li&gt;
&lt;li&gt;eks-connector-console-dashboard-full-access-group.yaml - Console Dashboard Full Access
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ eksctl register cluster &lt;span class="nt"&gt;--name&lt;/span&gt; siva-home-lab &lt;span class="nt"&gt;--provider&lt;/span&gt; rancher
2022-01-03 21:30:07 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  creating IAM role &lt;span class="s2"&gt;"eksctl-20220103213007309381"&lt;/span&gt;
2022-01-03 21:30:17 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  registered cluster &lt;span class="s2"&gt;"siva-home-lab"&lt;/span&gt; successfully
2022-01-03 21:30:17 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  wrote file eks-connector.yaml to /Users/ksivamuthu/personal
2022-01-03 21:30:17 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  wrote file eks-connector-clusterrole.yaml to /Users/ksivamuthu/personal
2022-01-03 21:30:17 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  wrote file eks-connector-console-dashboard-full-access-group.yaml to /Users/ksivamuthu/personal
2022-01-03 21:30:17 &lt;span class="o"&gt;[!]&lt;/span&gt;  note: &lt;span class="s2"&gt;"eks-connector-clusterrole.yaml"&lt;/span&gt; and &lt;span class="s2"&gt;"eks-connector-console-dashboard-full-access-group.yaml"&lt;/span&gt; give full EKS Console access to IAM identity &lt;span class="s2"&gt;"arn:aws:iam::495775103319:user/siva"&lt;/span&gt;, edit &lt;span class="k"&gt;if &lt;/span&gt;required&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;read &lt;/span&gt;https://docs.aws.amazon.com/eks/latest/userguide/connector-grant-access.html &lt;span class="k"&gt;for &lt;/span&gt;more info
2022-01-03 21:30:17 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  run &lt;span class="sb"&gt;`&lt;/span&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; eks-connector.yaml,eks-connector-clusterrole.yaml,eks-connector-console-dashboard-full-access-group.yaml&lt;span class="sb"&gt;`&lt;/span&gt; before 07 Jan 22 02:30 UTC to connect the cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply the generated YAMLs in your cluster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; eks-connector.yaml, &lt;span class="se"&gt;\&lt;/span&gt;
            eks-connector-clusterrole.yaml, &lt;span class="se"&gt;\&lt;/span&gt;
            eks-connector-console-dashboard-full-access-group.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dashboard - Workloads, Configuration &amp;amp; Tags
&lt;/h2&gt;

&lt;p&gt;Once the cluster is registered and yamls are applied, you can view your non-EKS cluster in EKS Console.&lt;/p&gt;

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

&lt;p&gt;You can see the workloads, configuration and manage tags of the non-eks clusters.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Factwbvnep27bdu2n3rc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Factwbvnep27bdu2n3rc6.png" alt="cluster"&gt;&lt;/a&gt;&lt;br&gt;
Let’s register the AKS cluster by repeating the registration steps.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzp9kmy64lble2z44kuqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzp9kmy64lble2z44kuqa.png" alt="workloads"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Deregistering a cluster
&lt;/h2&gt;

&lt;p&gt;To deregister cluster, you can use eksctl command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ eksctl deregister cluster &lt;span class="nt"&gt;--name&lt;/span&gt; siva-home-lab &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It deregisters the cluster and we can delete the API server objects using kubectl&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ eksctl deregister cluster &lt;span class="nt"&gt;--name&lt;/span&gt; siva-home-lab &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
2022-01-03 21:56:39 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  deleting IAM role &lt;span class="s2"&gt;"eksctl-20220103213007309381"&lt;/span&gt;
2022-01-03 21:56:39 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  unregistered cluster &lt;span class="s2"&gt;"siva-home-lab"&lt;/span&gt; successfully
2022-01-03 21:56:39 &lt;span class="o"&gt;[&lt;/span&gt;ℹ]  run &lt;span class="sb"&gt;`&lt;/span&gt;kubectl delete &lt;span class="nt"&gt;-f&lt;/span&gt; eks-connector.yaml,eks-connector-clusterrole.yaml,eks-connector-console-dashboard-full-access-group.yaml&lt;span class="sb"&gt;`&lt;/span&gt; on your cluster to remove EKS Connector resources
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;EKS Anywhere and EKS Connector are part of a clear play for businesses embracing hybrid cloud and private infrastructure setups. EKS Connector supports self-managed clusters on EC2, EKS Anywhere clusters running on-premises, and other Kubernetes clusters running outside of AWS to the EKS console. It’s great tool providing single pane of dashboard managing all of your Kubernetes cluster including EKS &amp;amp; Non EKS.&lt;/p&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at &lt;a href="https://www.ceiamerica.com" rel="noopener noreferrer"&gt;Computer Enterprises Inc&lt;/a&gt; from Orlando. I'm an AWS Community builder, Auth0 Ambassador and I am going to write a lot about Cloud, Containers, IoT, and Devops. If you are interested in any of that, make sure to follow me if you haven’t already. Please follow me &lt;a href="https://www.twitter.com/ksivamuthu" rel="noopener noreferrer"&gt;@ksivamuthu&lt;/a&gt; Twitter or check out my blogs at &lt;a href="https://sivamuthukumar.com" rel="noopener noreferrer"&gt;https://sivamuthukumar.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>containers</category>
    </item>
    <item>
      <title>Deploy .NET 6 API to AWS App Runner using AWS Copilot CLI</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Sat, 30 Oct 2021 23:19:07 +0000</pubDate>
      <link>https://forem.com/aws-builders/deploy-net-6-api-to-aws-app-runner-using-aws-copilot-cli-4hnl</link>
      <guid>https://forem.com/aws-builders/deploy-net-6-api-to-aws-app-runner-using-aws-copilot-cli-4hnl</guid>
      <description>&lt;p&gt;In this tutorial blog post, we are going to see how to deploy .NET 6 API to AWS App Runner using AWS Copilot CLI. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is App Runner?
&lt;/h2&gt;

&lt;p&gt;AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs at scale and with no prior infrastructure experience required. Start with your source code or a container image. App Runner automatically builds and deploys the web application, and load balances traffic with encryption. App Runner also scales up or down automatically to meet your traffic needs. With App Runner, you have more time to focus on your applications rather than thinking about servers or scaling. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635622899259%2FlgLdZDVat.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635622899259%2FlgLdZDVat.png" alt="Untitled.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  App Runner Features
&lt;/h2&gt;

&lt;p&gt;The features of App Runner are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Autoscaling&lt;/strong&gt;: starting and stopping as demand changes, between configurable min and max limits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load balancing&lt;/strong&gt;: the service includes a transparent, non-configurable load balancer. The URL can be pointed to the &lt;strong&gt;custom domain.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSL &amp;amp; Certificates:&lt;/strong&gt; the deployed services will have HTTPS endpoints for applications with AWS-managed certificates. The certificates will be renewed when it's about to expire.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build service:&lt;/strong&gt; you can push your own images or let AWS build them for you from code.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  AWS Copilot CLI
&lt;/h2&gt;

&lt;p&gt;The AWS Copilot CLI is a tool for developers to build, release and operate production-ready containerized applications on AWS App Runner, Amazon ECS, and AWS Fargate. From getting started, pushing to staging, and releasing to production, Copilot can help manage the entire lifecycle of your application development.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aws" rel="noopener noreferrer"&gt;
        aws
      &lt;/a&gt; / &lt;a href="https://github.com/aws/copilot-cli" rel="noopener noreferrer"&gt;
        copilot-cli
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on AWS App Runner or Amazon ECS on AWS Fargate. 
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Setup a .NET 6 Minimal API
&lt;/h2&gt;

&lt;p&gt;Let's get started. This section will create minimal API services using .NET and dockerize the application to deploy in AWS AppRunner using Copilot CLI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create a new web API project using dotnet&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet new web &lt;span class="nt"&gt;-n&lt;/span&gt; CoffeeService
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The API code is like below that's by default generated by the template.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;"Hello World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's cool on seeing this minimal API (like how it's easy as developing Node.js code). Let's run locally and see whether we are getting this "Hello World" response.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Run the code&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="n"&gt;CoffeeService&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;dotnet&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Execute the URL and check the response&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="err"&gt;➜&lt;/span&gt;  &lt;span class="p"&gt;~&lt;/span&gt;  &lt;span class="n"&gt;curl&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//localhost:5023/&lt;/span&gt;
&lt;span class="n"&gt;Hello&lt;/span&gt; &lt;span class="n"&gt;World&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Create a file named &lt;em&gt;Dockerfile&lt;/em&gt; in the directory containing the &lt;em&gt;.csproj&lt;/em&gt; and open it in a text editor. Copy the contents below in the Dockerfile. In this Dockerfile, we are building the project and running it in the &lt;code&gt;aspnet:6.0&lt;/code&gt; runtime image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;mcr.microsoft.com/dotnet/sdk:6.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;build&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /src&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; ["CoffeeService.csproj", "./"]&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;dotnet restore &lt;span class="s2"&gt;"CoffeeService.csproj"&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; "/src/."&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;dotnet build &lt;span class="s2"&gt;"CoffeeService.csproj"&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; Release &lt;span class="nt"&gt;-o&lt;/span&gt; /app/build

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;build&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;publish&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;dotnet publish &lt;span class="s2"&gt;"CoffeeService.csproj"&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; Release &lt;span class="nt"&gt;-o&lt;/span&gt; /app/publish

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;mcr.microsoft.com/dotnet/aspnet:6.0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;base&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;
&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 5023&lt;/span&gt;
&lt;span class="k"&gt;ENV&lt;/span&gt;&lt;span class="s"&gt; ASPNETCORE_URLS=http://+:5023&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --from=publish /app/publish .&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["dotnet", "CoffeeService.dll"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Build the docker image&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; coffee-service:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the docker image&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 5023:5023 coffee-service:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Execute the URL and check the response&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="err"&gt;➜&lt;/span&gt;  &lt;span class="p"&gt;~&lt;/span&gt;  &lt;span class="n"&gt;curl&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//localhost:5023/&lt;/span&gt;
&lt;span class="n"&gt;Hello&lt;/span&gt; &lt;span class="n"&gt;World&lt;/span&gt;&lt;span class="p"&gt;!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Great. The .NET 6 minimal API is created and run from local and in the docker container. Now let's deploy into the AWS AppRunner using AWS Copilot CLI&lt;/p&gt;
&lt;h2&gt;
  
  
  Deploy into AWS AppRunner using AWS Copilot CLI
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;copilot init&lt;/code&gt; to set up the AWS AppRunner application for this service. The initialization tool is going to ask you the questions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use existing application or create a new application&lt;/li&gt;
&lt;li&gt;Application name&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Workload type&lt;/p&gt;

&lt;p&gt;You can choose one of the workload types. In this demo, we are setting up the AWS App Runner.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- **Request-Driven Web Service  - (App Runner)**
- Load Balanced Web Service  - (Internet to ECS on Fargate)
- Backend Service - (ECS on Fargate)
- Worker Service - (Events to SQS to ECS on Fargate)
- Scheduled Job - (Scheduled event to State Machine to Fargate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Service name and path of the Dockerfile to build&lt;/li&gt;
&lt;li&gt;Once the ECR is set up, you can set up the environment to deploy.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Welcome to the Copilot CLI! We&lt;span class="s1"&gt;'re going to walk you through some questions
to help you get set up with a containerized application on AWS. An application is a collection of
containerized services that operate together.

Use existing application: No
Application name: coffee-shop
Workload type: Request-Driven Web Service
Service name: coffee-service
Dockerfile: CoffeeService/Dockerfile
Ok great, we'&lt;/span&gt;ll &lt;span class="nb"&gt;set &lt;/span&gt;up a Request-Driven Web Service named coffee-service &lt;span class="k"&gt;in &lt;/span&gt;application coffee-shop listening on port 5023.

✔ Created the infrastructure to manage services and &lt;span class="nb"&gt;jobs &lt;/span&gt;under application coffee-shop..

✔ The directory copilot will hold service manifests &lt;span class="k"&gt;for &lt;/span&gt;application coffee-shop.

✔ Wrote the manifest &lt;span class="k"&gt;for &lt;/span&gt;service coffee-service at copilot/coffee-service/manifest.yml
Your manifest contains configurations like your container size and port &lt;span class="o"&gt;(&lt;/span&gt;:5023&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;

✔ Created ECR repositories &lt;span class="k"&gt;for &lt;/span&gt;service coffee-service..

All right, you&lt;span class="s1"&gt;'re all set for local development.
Deploy: Yes

✔ Linked account 495775103319 and region us-east-1 to application coffee-shop..

✔ Proposing infrastructure changes for the coffee-shop-test environment.
- Creating the infrastructure for the coffee-shop-test environment.      [create complete]  [79.6s]
  - An IAM Role for AWS CloudFormation to manage resources               [create complete]  [16.2s]
  - An ECS cluster to group your services                                [create complete]  [9.0s]
  - Enable long ARN formats for the authenticated AWS principal          [create complete]  [4.6s]
  - An IAM Role to describe resources in your environment                [create complete]  [13.9s]
  - A security group to allow your containers to talk to each other      [create complete]  [5.9s]
  - An Internet Gateway to connect to the public internet                [create complete]  [16.1s]
  - Private subnet 1 for resources with no internet access               [create complete]  [19.3s]
  - Private subnet 2 for resources with no internet access               [create complete]  [19.6s]
  - Public subnet 1 for resources that can access the internet           [create complete]  [19.6s]
  - Public subnet 2 for resources that can access the internet           [create complete]  [19.6s]
  - A Virtual Private Cloud to control networking of your AWS resources  [create complete]  [16.1s]
✔ Created environment test in region us-east-1 under application coffee-shop.
Environment test is already on the latest version v1.6.1, skip upgrade.
[+] Building 0.7s (18/18) FINISHED
 =&amp;gt; [internal] load build definition from Dockerfile                                                                                      0.0s
 =&amp;gt; =&amp;gt; transferring dockerfile: 588B                                                                                                      0.0s
 =&amp;gt; [internal] load .dockerignore                                                                                                         0.0s
 =&amp;gt; =&amp;gt; transferring context: 374B                                                                                                         0.0s
 =&amp;gt; [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0                                                                      0.5s
 =&amp;gt; [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0                                                                         0.5s
 =&amp;gt; [internal] load build context                                                                                                         0.0s
 =&amp;gt; =&amp;gt; transferring context: 1.63kB                                                                                                       0.0s
 =&amp;gt; [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:96ce062b7e664999048b86198385fea1ddaff31d8d2ab5f7c42c0077678afeac             0.0s
 =&amp;gt; [base 1/4] FROM mcr.microsoft.com/dotnet/aspnet:6.0@sha256:ed9b7dc3e8278a56be619b278762689565e1e21f61da51551fe028dc1d3a536f           0.0s
 =&amp;gt; CACHED [base 2/4] WORKDIR /app                                                                                                        0.0s
 =&amp;gt; CACHED [base 3/4] WORKDIR /app                                                                                                        0.0s
 =&amp;gt; CACHED [build 2/7] WORKDIR /src                                                                                                       0.0s
 =&amp;gt; CACHED [build 3/7] COPY [CoffeeService.csproj, ./]                                                                                    0.0s
 =&amp;gt; CACHED [build 4/7] RUN dotnet restore "CoffeeService.csproj"                                                                          0.0s
 =&amp;gt; CACHED [build 5/7] COPY . .                                                                                                           0.0s
 =&amp;gt; CACHED [build 6/7] WORKDIR /src/.                                                                                                     0.0s
 =&amp;gt; CACHED [build 7/7] RUN dotnet build "CoffeeService.csproj" -c Release -o /app/build                                                   0.0s
 =&amp;gt; CACHED [publish 1/1] RUN dotnet publish "CoffeeService.csproj" -c Release -o /app/publish                                             0.0s
 =&amp;gt; CACHED [base 4/4] COPY --from=publish /app/publish .                                                                                  0.0s
 =&amp;gt; exporting to image                                                                                                                    0.0s
 =&amp;gt; =&amp;gt; exporting layers                                                                                                                   0.0s
 =&amp;gt; =&amp;gt; writing image sha256:74811373b140080ac1cf2f55c1e15a8dcdd9059f9a82d98a97a4f94a4e40e559                                              0.0s
 =&amp;gt; =&amp;gt; naming to 495775103319.dkr.ecr.us-east-1.amazonaws.com/coffee-shop/coffee-service                                                  0.0s

Use '&lt;/span&gt;docker scan&lt;span class="s1"&gt;' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Login Succeeded
Using default tag: latest
The push refers to repository [495775103319.dkr.ecr.us-east-1.amazonaws.com/coffee-shop/coffee-service]
8cb51c566055: Pushed
...
e8b689711f21: Pushed
latest: digest: sha256:daeea40ed5b765e0ca27232964c529f3d6bb18eb8ccced8828a39c3153991c6a size: 1993
✔ Proposing infrastructure changes for stack coffee-shop-test-coffee-service
- Creating the infrastructure for stack coffee-shop-test-coffee-service           [create complete]    [246.5s]
  - An IAM Role for App Runner to use on your behalf to pull your image from ECR  [create complete]    [10.2s]
  - An IAM role to control permissions for the containers in your service         [create in progress]  [238.4s]
  - An App Runner service to run and manage your containers                       [create complete]    [225.4s]
✔ Deployed service coffee-service.
Recommended follow-up action:
    You can access your service at https://ptydisq8gp.us-east-1.awsapprunner.com over the internet.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Access the service at the URL.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ curl https://ptydisq8gp.us-east-1.awsapprunner.com
Hello World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Copilot is doing the heavy lifting for us - the developers. So we can focus on the application. Copilot will build, push, and launch your container on AWS to ECS, Fargate, and AppRunner.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up Automated Pipeline
&lt;/h2&gt;

&lt;p&gt;The key principle of the devops process is "Ship small, Ship often." The process of deploying small features on a regular cadence is crucial to DevOps. As the team becomes more agile, we need to automate application releases as multiple developers; multiple services teams push the code into the source code repository.&lt;/p&gt;

&lt;p&gt;AWS Copilot tool can help you in setting up the pipeline to automate application releases. You can run these commands to create an automated pipeline that builds and deploys the application on git push.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws-apprunner-dotnet6-demo git:&lt;span class="o"&gt;(&lt;/span&gt;main&lt;span class="o"&gt;)&lt;/span&gt;  copilot pipeline init
1st stage: &lt;span class="nb"&gt;test
&lt;/span&gt;Repository URL: git@github.com:ksivamuthu/aws-apprunner-coffee-shop
✔ Wrote the pipeline manifest &lt;span class="k"&gt;for &lt;/span&gt;aws-apprunner-coffee-shop at &lt;span class="s1"&gt;'copilot/pipeline.yml'&lt;/span&gt;
The manifest contains configurations &lt;span class="k"&gt;for &lt;/span&gt;your CodePipeline resources, such as your pipeline stages and build steps.
Update the file to add additional stages, change the branch to be tracked, or add &lt;span class="nb"&gt;test &lt;/span&gt;commands or manual approval actions.
✔ Wrote the buildspec &lt;span class="k"&gt;for &lt;/span&gt;the pipeline&lt;span class="s1"&gt;'s build stage at '&lt;/span&gt;copilot/buildspec.yml&lt;span class="s1"&gt;'
The buildspec contains the commands to build and push your container images to your ECR repositories.
Update the build phase to unit test your services before pushing the images.

Required follow-up actions:
- Commit and push the buildspec.yml, pipeline.yml, and .workspace files of your copilot directory to your repository.
- Run `copilot pipeline update` to create your pipeline.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The copilot buildspec, pipeline yaml files are committed and pushed. The code build pipelines are set up to deploy automatically in the test environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635622988061%2F2kjwADg2L.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635622988061%2F2kjwADg2L.png" alt="Untitled 1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, it's ready to bring more developers to start rocking. They don't need to install a copilot to deploy the machine's service as they are developing. The deployment steps are automated.&lt;/p&gt;

&lt;p&gt;Let's push more code to see changes that get automatically deployed.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;WebApplication&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s"&gt;"Hello AWS AppRunner !!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/api/coffee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;dynamic&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"cappucino"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Cappucino"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"latte"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Latte"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"mocha"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Mocha"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"americano"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Americano"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"macchiato"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Macchiato"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"frappe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Frappe"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"corretto"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Corretto"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"affogato"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Affogato"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;CoffeeId&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"filtercoffee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CoffeeName&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Filter Coffee"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜ aws-apprunner-dotnet6-demo git:&lt;span class="o"&gt;(&lt;/span&gt;main&lt;span class="o"&gt;)&lt;/span&gt; curl https://ptydisq8gp.us-east-1.awsapprunner.com
Hello AWS AppRunner &lt;span class="o"&gt;!!&lt;/span&gt;

➜ aws-apprunner-dotnet6-demo git:&lt;span class="o"&gt;(&lt;/span&gt;main&lt;span class="o"&gt;)&lt;/span&gt; curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://ptydisq8gp.us-east-1.awsapprunner.com/api/coffee | jq &lt;span class="s1"&gt;'.[0]'&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"coffeeId"&lt;/span&gt;: &lt;span class="s2"&gt;"cappucino"&lt;/span&gt;,
  &lt;span class="s2"&gt;"coffeeName"&lt;/span&gt;: &lt;span class="s2"&gt;"Cappucino"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Test the Autoscaling
&lt;/h2&gt;

&lt;p&gt;AWS App Runner automatically scales compute resources (instances) up or down for your App Runner application. Automatic scaling provides adequate request handling when incoming traffic is high and reduces your cost when traffic slows down. You can configure a few parameters to adjust autoscaling behavior for your service.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Settings&lt;/strong&gt; – Here's what you can configure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Max concurrency&lt;/em&gt; – The maximum number of concurrent requests that an instance processes. When the number of concurrent requests exceeds this quota, App Runner scales up the service.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Max size&lt;/em&gt; – The maximum number of instances that your service scales up to. At most this number of instances are actively serving traffic for your service.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Min size&lt;/em&gt; – The minimum number of instances that App Runner provisions for your service. The service always has at least this number of provisioned instances. Some of them actively serve traffic. The rest of them (provisioned and inactive instances) stand by as a cost-effective compute capacity reserve, which is ready to be quickly activated. You pay for the memory usage of all provisioned instances. You pay for the CPU usage of only the active subset.&lt;/p&gt;

&lt;p&gt;App Runner temporarily doubles the number of provisioned instances during deployments to maintain the same old and new code capacity.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635623015102%2Fk7i_euFLO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635623015102%2Fk7i_euFLO.png" alt="Untitled 2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's create load testing with 100 concurrent requests and check the number of instances.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hey &lt;span class="nt"&gt;-z&lt;/span&gt; 1m &lt;span class="nt"&gt;-c&lt;/span&gt; 100 https://ptydisq8gp.us-east-1.awsapprunner.com/api/coffee
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635623027989%2F3vFqcPU32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1635623027989%2F3vFqcPU32.png" alt="Untitled 3.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the "active instances" count get increased based on the concurrent requests for autoscaling. &lt;/p&gt;

&lt;p&gt;The source code repo of this demo&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ksivamuthu" rel="noopener noreferrer"&gt;
        ksivamuthu
      &lt;/a&gt; / &lt;a href="https://github.com/ksivamuthu/aws-apprunner-coffee-shop" rel="noopener noreferrer"&gt;
        aws-apprunner-coffee-shop
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;What is App Runner?&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs at scale and with no prior infrastructure experience required. Start with your source code or a container image. App Runner automatically builds and deploys the web application, and load balances traffic with encryption. App Runner also scales up or down automatically to meet your traffic needs. With App Runner, you have more time to focus on your applications rather than thinking about servers or scaling.&lt;/p&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/977b71de3f0a132f3499067b6486455577cfbd6acca51991b0d6ccf0b1db8f31/68747470733a2f2f63646e2e686173686e6f64652e636f6d2f7265732f686173686e6f64652f696d6167652f75706c6f61642f76313633353632323839393235392f6c674c645a445661742e706e67"&gt;&lt;img src="https://camo.githubusercontent.com/977b71de3f0a132f3499067b6486455577cfbd6acca51991b0d6ccf0b1db8f31/68747470733a2f2f63646e2e686173686e6f64652e636f6d2f7265732f686173686e6f64652f696d6167652f75706c6f61642f76313633353632323839393235392f6c674c645a445661742e706e67" alt="Untitled.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;App Runner Features&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;The features of App Runner are&lt;/p&gt;


&lt;ol&gt;

&lt;li&gt;

&lt;strong&gt;Autoscaling&lt;/strong&gt;: starting and stopping as demand changes, between configurable min and max limits.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Load balancing&lt;/strong&gt;: the service includes a transparent, non-configurable load balancer. The URL can be pointed to the &lt;strong&gt;custom domain.&lt;/strong&gt;
&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;SSL &amp;amp; Certificates:&lt;/strong&gt; the deployed services will have HTTPS endpoints for applications with AWS-managed certificates. The…&lt;/li&gt;

&lt;/ol&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/ksivamuthu/aws-apprunner-coffee-shop" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


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

&lt;p&gt;AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs at scale. It provides seamless "code-to-deploy" workflow for Node.js and Python runtime today and other runtimes using Dockerfile.Copilot also helps you to have your own customizable pipelines with just a few commands for your apps running AWS AppRunner.&lt;/p&gt;

&lt;p&gt;I presented a talk on AWS App Runners in &lt;a href="https://meetingplace.io/indyaws" rel="noopener noreferrer"&gt;IndyAWS&lt;/a&gt; meetup. This session covers &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS App Runner's features,&lt;/li&gt;
&lt;li&gt;The key challenges AWS App Runner solves,&lt;/li&gt;
&lt;li&gt;How to configure and integrate AWS App Runner with your source control to deploy your code in seconds&lt;/li&gt;
&lt;li&gt;Live demo using AWS Copilot CLI, a tool that supports AWS App Runner.&lt;/li&gt;
&lt;li&gt;Want a deeper dive? Download the &lt;a href="https://bit.ly/aws-apprunner" rel="noopener noreferrer"&gt;presentation slides&lt;/a&gt; and youtube video of the talk.
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/FfJVk2OS0jA"&gt;
&lt;/iframe&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at Computer Enterprises Inc from Orlando. I'm an AWS Community builder, Auth0 Ambassador and I am going to write a lot about Cloud, Containers, IoT, and Devops. If you are interested in any of that, make sure to follow me if you haven’t already. Please follow me &lt;strong&gt;&lt;a href="https://twitter.com/ksivamuthu" rel="noopener noreferrer"&gt;@ksivamuthu&lt;/a&gt;&lt;/strong&gt; Twitter or check out my blogs at &lt;strong&gt;&lt;a href="https://blog.sivamuthukumar.com/" rel="noopener noreferrer"&gt;blog.sivamuthukumar.com&lt;/a&gt;&lt;/strong&gt;!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>containers</category>
      <category>dotnet</category>
      <category>devops</category>
    </item>
    <item>
      <title>Enforcing Policy as Code using Kyverno in Kubernetes</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Wed, 06 Oct 2021 00:47:39 +0000</pubDate>
      <link>https://forem.com/aws-builders/enforcing-policy-as-code-using-kyverno-in-kubernetes-3epk</link>
      <guid>https://forem.com/aws-builders/enforcing-policy-as-code-using-kyverno-in-kubernetes-3epk</guid>
      <description>&lt;p&gt;Hello all, In today's blog, we are going to learn about policy as code in Kubernetes using Kyverno.  Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Policy as Code?
&lt;/h2&gt;

&lt;p&gt;Policy as Code (PaC) is the idea of writing code in a high-level language to manage and automate policies. The DevOps team can adopt the best practices by representing policies as code, such as version control, automated testing, and automated deployment. You can use these policies in audit or enforcement mode to monitor existing workloads, services for misconfiguration or prevent the misconfigurations applying in the cluster. &lt;/p&gt;

&lt;h2&gt;
  
  
  Policy as Code in Kubernetes
&lt;/h2&gt;

&lt;p&gt;Policies could be established for multiple areas of your operational environments. You want your Kubernetes clusters to be reliable and secure and you want to control who has access to what. You also want to enforce rules for your kubernetes resources. There are specific things you want to enforce Kubernetes workloads from security, configuration, deployment best practices, operational concerns, governance and compliance requirements.&lt;/p&gt;

&lt;p&gt;The three categories in the policy for kubernetes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard policies - Best practices across the cluster in the organizations

&lt;ul&gt;
&lt;li&gt;E.g: Requiring resources to specify the resource limits. Prevent workloads from running as root, etc&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Organization policies - Enforce the policies specific to your organization

&lt;ul&gt;
&lt;li&gt;E.g - Enforce the private image repository list to pull, Labels such as application name, environment to specify in workloads, policies with organization compliance and audit requirements.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Environment policies - Enforce the policies specific to environment

&lt;ul&gt;
&lt;li&gt;E.g - Stricter security enforcement in production cluster&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Kyverno - Policy Engine
&lt;/h2&gt;

&lt;p&gt;Kyverno (Greek for "govern") is a policy engine designed specifically for Kubernetes. The features are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;policies as Kubernetes resources in YAML (no new language to learn!)&lt;/li&gt;
&lt;li&gt;validate, mutate, or generate any resource using Kustomize overlays&lt;/li&gt;
&lt;li&gt;match resources using label selectors and wildcards&lt;/li&gt;
&lt;li&gt;block non-conformant resources using admission controls, or report policy violations&lt;/li&gt;
&lt;li&gt;test policies and validate resources using the Kyverno CLI, in your CI/CD pipeline, before applying them to your cluster&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kyverno" rel="noopener noreferrer"&gt;
        kyverno
      &lt;/a&gt; / &lt;a href="https://github.com/kyverno/kyverno" rel="noopener noreferrer"&gt;
        kyverno
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Cloud Native Policy Management
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;Kyverno runs as a dynamic admission controller in a Kubernetes cluster. Kyverno receives validating and mutating admission webhook HTTP callbacks from the kube-apiserver and applies matching policies to return results that enforce admission policies or reject requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkyverno.io%2Fimages%2Fkyverno-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fkyverno.io%2Fimages%2Fkyverno-architecture.png" alt="https://kyverno.io/images/kyverno-architecture.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;The prerequisite for this tutorial is a functional kubernetes cluster. You can create the EKS cluster using the &lt;code&gt;eksctl&lt;/code&gt; tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: eks-k8s-policy-demo
  region: us-east-1

availabilityZones: 
  - us-east-1a
  - us-east-1b

managedNodeGroups:
  - name: eks-k8s-policy-demo-ng
    instanceType: t3.medium
    minSize: 1
    maxSize: 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Policies and Usecases
&lt;/h2&gt;

&lt;p&gt;The Kyverno team created the best practices and most used policies in this website &lt;a href="https://kyverno.io/policies/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. There are three different policy types.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validate&lt;/li&gt;
&lt;li&gt;Mutate&lt;/li&gt;
&lt;li&gt;Generate&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will see the demo on the below use cases and policies we can enforce for kubernetes deployments.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enforce "application name" label in the pod&lt;/li&gt;
&lt;li&gt;Require Limits and Requests&lt;/li&gt;
&lt;li&gt;Add network policy&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Enforce "Application Name" label in the pod
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kyverno.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterPolicy&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;require-labels&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;validationFailureAction&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;enforce&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;check-for-labels&lt;/span&gt;
    &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;kinds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
    &lt;span class="na"&gt;validate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;label&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;`app.kubernetes.io/name`&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;is&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;required."&lt;/span&gt;
      &lt;span class="na"&gt;pattern&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;app.kubernetes.io/name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;?*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's see how this policy. works by creating the deployment in the pod. Apply the above policy in your cluster. Create a inflate deployment in the cluster without any labels.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;➜  kyverno-demo git:(main) ✗  kubectl create deployment inflate --image=public.ecr.aws/eks-distro/kubernetes/pause:3.2&lt;/span&gt;
&lt;span class="na"&gt;error: failed to create deployment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;admission webhook "validate.kyverno.svc" denied the request&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;

&lt;span class="s"&gt;resource Deployment/default/inflate was blocked due to the following policies&lt;/span&gt;

&lt;span class="na"&gt;require-labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;autogen-check-for-labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;validation&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;error:&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;The&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;label&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;`app.kubernetes.io/name`&lt;/span&gt;
    &lt;span class="s"&gt;is&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;required.&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Rule&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;autogen-check-for-labels&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;failed&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;at&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;path&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;/spec/template/metadata/labels/app.kubernetes.io/name/'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now, let's create the deployment with &lt;strong&gt;&lt;em&gt;app.kubernetes.io/name&lt;/em&gt;&lt;/strong&gt; label.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app.kubernetes.io/name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;inflate&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;inflate&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app.kubernetes.io/name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;inflate&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app.kubernetes.io/name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;inflate&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;public.ecr.aws/eks-distro/kubernetes/pause:3.2&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pause&lt;/span&gt;

&lt;span class="s"&gt;➜  kyverno-demo git:(main) ✗  kubectl apply -f deployment.yaml&lt;/span&gt;
&lt;span class="s"&gt;deployment.apps/inflate created&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Require Limits and Requests
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kyverno.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterPolicy&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;require-requests-limits&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;validationFailureAction&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;enforce&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;validate-resources&lt;/span&gt;
    &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;kinds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;
    &lt;span class="na"&gt;validate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CPU&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;memory&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;resource&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;requests&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;and&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;limits&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;are&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;required."&lt;/span&gt;
      &lt;span class="na"&gt;pattern&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;?*"&lt;/span&gt;
                &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;?*"&lt;/span&gt;
              &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;?*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;These policies are validation type policies. It validates the specific pattern in your kubernetes api objects.&lt;/p&gt;
&lt;h3&gt;
  
  
  Add network policy
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kyverno.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterPolicy&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;add-networkpolicy&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;validationFailureAction&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;enforce&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;default-deny&lt;/span&gt;
    &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
        &lt;span class="na"&gt;kinds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Namespace&lt;/span&gt;
    &lt;span class="na"&gt;generate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NetworkPolicy&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;default-deny&lt;/span&gt;
      &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{{request.object.metadata.name}}"&lt;/span&gt;
      &lt;span class="na"&gt;synchronize&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# select all pods in the namespace&lt;/span&gt;
          &lt;span class="na"&gt;podSelector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{}&lt;/span&gt;
          &lt;span class="c1"&gt;# deny all traffic&lt;/span&gt;
          &lt;span class="na"&gt;policyTypes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Ingress&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Egress&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Monitoring - Dashboard
&lt;/h2&gt;

&lt;p&gt;Kyverno has its metrics exposed through Prometheus metrics endpoint. You can scrape the kyverno metrics or display in grafana dashboard.  Kyverno has the policy reporter UI that can target different channels. Checkout here. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kyverno" rel="noopener noreferrer"&gt;
        kyverno
      &lt;/a&gt; / &lt;a href="https://github.com/kyverno/policy-reporter" rel="noopener noreferrer"&gt;
        policy-reporter
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Monitoring and Observability Tool for the PolicyReport CRD with an optional UI.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



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

&lt;h2&gt;
  
  
  Shift Left
&lt;/h2&gt;

&lt;p&gt;You can validate the policies before applying the cluster using cli. I've integrated kyverno cli action in github before deploying yaml files in kubernetes cluster.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ksivamuthu" rel="noopener noreferrer"&gt;
        ksivamuthu
      &lt;/a&gt; / &lt;a href="https://github.com/ksivamuthu/kyverno-policy-demo" rel="noopener noreferrer"&gt;
        kyverno-policy-demo
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Validate policy&lt;/span&gt;
        &lt;span class="s"&gt;uses&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gbaeke/kyverno-cli@v1&lt;/span&gt;
        &lt;span class="s"&gt;with&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
            &lt;span class="s"&gt;kyverno apply ./policies --resource=./k8s/2048.yaml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;After fixing the YAML files &lt;/p&gt;

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

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

&lt;p&gt;You can improve the security posture for your clusters with policies as code using Kyverno. No need to learn new language to create or manager policies. It works with your existing tools such as git, kustomize, kubectl etc.&lt;/p&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at Computer Enterprises Inc from Orlando. I'm an AWS Community builder, Auth0 Ambassador and I am going to write a lot about Cloud, Containers, IoT, and Devops. If you are interested in any of that, make sure to follow me if you haven’t already. Please follow me &lt;a class="mentioned-user" href="https://dev.to/ksivamuthu"&gt;@ksivamuthu&lt;/a&gt; Twitter or check out my blogs at &lt;a href="https://blog.sivamuthukumar.com" rel="noopener noreferrer"&gt;https://blog.sivamuthukumar.com&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Karpenter - Scaling Nodes Seamlessly in AWS EKS</title>
      <dc:creator>Sivamuthu Kumar</dc:creator>
      <pubDate>Fri, 24 Sep 2021 02:49:51 +0000</pubDate>
      <link>https://forem.com/aws-builders/karpenter-scaling-nodes-seamlessly-in-aws-eks-19f</link>
      <guid>https://forem.com/aws-builders/karpenter-scaling-nodes-seamlessly-in-aws-eks-19f</guid>
      <description>&lt;p&gt;Hello everyone !! If you are running your workloads on the AWS EKS cluster, you may explore the rules and limitations of node group scaling to provision the deployments dynamically.  This blog will explore the node lifecycle management solutions AWS Lab's Karpenter, an alternative approach to the frequently used Cluster Autoscaler solution. &lt;/p&gt;

&lt;h2&gt;
  
  
  Kubernetes Autoscaling
&lt;/h2&gt;

&lt;p&gt;Autoscaling allows you to dynamically adjust to demand without manual intervention through metrics or events. Without autoscaling, there will be considerable efforts to provision the (scaling up or down) resources. When the running conditions change, and optimal resource utilization and managing the cloud spending is challenging. The cluster is always running at peak capacity to ensure availability or not meeting peak demand as they don't have enough resources.&lt;/p&gt;

&lt;p&gt;When it comes to the Kubernetes Autoscaling, there are two different layers, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pod Level Autoscaling (Horizontal - HPA, and Vertical - HPA)&lt;/li&gt;
&lt;li&gt;Node Level Autoscaling&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Pod Level Autoscaling
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Horizontal Pod Autoscaling (Scaling out)&lt;/strong&gt; - dynamically increase or decrease the number of running pods per your application's usage changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vertical Pod Autoscaling (Scaling up)&lt;/strong&gt; - scale the given deployments vertically within a cluster by reconciling the pods' size ( CPU or memory targets) based on their current usage and the desired target.&lt;/p&gt;

&lt;p&gt;HPA and VPA essentially make sure that all of the services running in your cluster can dynamically handle the demand.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node Level Autoscaling
&lt;/h3&gt;

&lt;p&gt;Node Level autoscaling solves the issue - to scale the nodes in the cluster when the existing nodes are overloaded or pending to be scheduled with newly scaled pods or scale down when the nodes are underutilized.&lt;/p&gt;

&lt;p&gt;There is already an industry-adopted, open-source, and vendor-neutral tool - Cluster Autoscaler that automatically adjusts the cluster size (by adding or removing nodes) based on the presence of pending pods and node utilization metrics. It uses the existing cloud building blocks (Autoscaling Group on AWS) for scaling. The challenges in the cluster autoscaler are the limitations on node groups, and the scaling is tightly bound to the scheduler. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kubernetes" rel="noopener noreferrer"&gt;
        kubernetes
      &lt;/a&gt; / &lt;a href="https://github.com/kubernetes/autoscaler" rel="noopener noreferrer"&gt;
        autoscaler
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Autoscaling components for Kubernetes
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Karpenter
&lt;/h2&gt;

&lt;p&gt;Karpenter is a node lifecycle management solution - incubating in AWS Labs, OSS, and vendor-neutral. It observes incoming pods and launches the right instances for the situation. Instance selection decisions are intent-based and driven by the specification of incoming pods, including resource requests and scheduling constraints.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aws" rel="noopener noreferrer"&gt;
        aws
      &lt;/a&gt; / &lt;a href="https://github.com/aws/karpenter-provider-aws" rel="noopener noreferrer"&gt;
        karpenter-provider-aws
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Karpenter is a Kubernetes Node Autoscaler built for flexibility, performance, and simplicity.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a href="https://github.com/aws/karpenter/actions/workflows/ci.yaml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/aws/karpenter-provider-aws/actions/workflows/ci.yaml/badge.svg?branch=main" alt="CI"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/e6e748cab5d87e3a50f5e22b720da270394e0228454d4737071ba30d85d500d5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6177732f6b617270656e7465722d70726f76696465722d617773"&gt;&lt;img src="https://camo.githubusercontent.com/e6e748cab5d87e3a50f5e22b720da270394e0228454d4737071ba30d85d500d5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6177732f6b617270656e7465722d70726f76696465722d617773" alt="GitHub stars"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/7efb84c644c8c1162fd3f5b03b6a92c31686cc175b7e6d697d2dc60505d5e5af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6177732f6b617270656e7465722d70726f76696465722d617773"&gt;&lt;img src="https://camo.githubusercontent.com/7efb84c644c8c1162fd3f5b03b6a92c31686cc175b7e6d697d2dc60505d5e5af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6177732f6b617270656e7465722d70726f76696465722d617773" alt="GitHub forks"&gt;&lt;/a&gt;
&lt;a href="https://github.com/aws/karpenter-provider-aws/blob/main/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/72fc4f1ffb6696686d2e0f7333b82d9a9e7bafbc56edace2ec658070e1f99ae6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d6666363962342e737667" alt="GitHub License"&gt;&lt;/a&gt;
&lt;a href="https://goreportcard.com/report/github.com/aws/karpenter" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/7e7469e2b5ec4811b477eacb4073d974fbb998dfc6375bff47cc5d6c6586fa8e/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f6177732f6b617270656e7465722d70726f76696465722d617773" alt="Go Report Card"&gt;&lt;/a&gt;
&lt;a href="https://coveralls.io/github/aws/karpenter?branch=main" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c9858ff0215bf7b2d8624b24a30220627653ebbf48ce8b6f65dc6c032423141f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6177732f6b617270656e7465722d70726f76696465722d6177732f62616467652e7376673f6272616e63683d6d61696e" alt="Coverage Status"&gt;&lt;/a&gt;
&lt;a href="https://github.com/aws/karpenter-provider-aws/issues" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/a93286920599112849c7c2af9d239294be27738b440248e434813b1bd0ffb368/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e747269627574696f6e732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c6174" alt="contributions welcome"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/aws/karpenter-provider-awswebsite/static/banner.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Faws%2Fkarpenter-provider-awswebsite%2Fstatic%2Fbanner.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Karpenter is an open-source node provisioning project built for Kubernetes
Karpenter improves the efficiency and cost of running workloads on Kubernetes clusters by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Watching&lt;/strong&gt; for pods that the Kubernetes scheduler has marked as unschedulable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluating&lt;/strong&gt; scheduling constraints (resource requests, nodeselectors, affinities, tolerations, and topology spread constraints) requested by the pods&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provisioning&lt;/strong&gt; nodes that meet the requirements of the pods&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Removing&lt;/strong&gt; the nodes when the nodes are no longer needed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Come discuss Karpenter in the &lt;a href="https://kubernetes.slack.com/archives/C02SFFZSA2K" rel="nofollow noopener noreferrer"&gt;#karpenter&lt;/a&gt; channel, in the &lt;a href="https://slack.k8s.io/" rel="nofollow noopener noreferrer"&gt;Kubernetes slack&lt;/a&gt; or join the &lt;a href="https://karpenter.sh/docs/contributing/working-group/" rel="nofollow noopener noreferrer"&gt;Karpenter working group&lt;/a&gt; bi-weekly calls. If you want to contribute to the Karpenter project, please refer to the Karpenter docs.&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href="https://karpenter.sh/docs/" rel="nofollow noopener noreferrer"&gt;Docs&lt;/a&gt; to learn more.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Talks&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;03/19/2024 &lt;a href="https://www.youtube.com/watch?v=rq57liGu0H4" rel="nofollow noopener noreferrer"&gt;Harnessing Karpenter: Transforming Kubernetes Clusters with Argo Workflows&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;12/04/2023 &lt;a href="https://www.youtube.com/watch?v=lkg_9ETHeks" rel="nofollow noopener noreferrer"&gt;AWS re:Invent 2023 - Harness the power of Karpenter to scale, optimize &amp;amp; upgrade Kubernetes&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;09/08/2022 &lt;a href="https://youtu.be/BnksdJ3oOEs" rel="nofollow noopener noreferrer"&gt;Workload Consolidation with Karpenter&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;05/19/2022 &lt;a href="https://www.youtube.com/watch?v=UBb8wbfSc34" rel="nofollow noopener noreferrer"&gt;Scaling K8s Nodes Without Breaking the Bank or&lt;/a&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/aws/karpenter-provider-aws" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1632450827335%2Fnq0X2fa5G.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1632450827335%2Fnq0X2fa5G.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How does it work?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Observes the pod resource requests of unscheduled pods&lt;/li&gt;
&lt;li&gt;Direct provision of Just-in-time capacity of the node. (Groupless Node Autoscaling)&lt;/li&gt;
&lt;li&gt;Terminating nodes if outdated&lt;/li&gt;
&lt;li&gt;Reallocating the pods in nodes for better resource utilization&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Karpenter has two control loops that maximize the availability and efficiency of your cluster.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Allocator - Fast-acting controller ensuring that pods are scheduled as quickly as possible&lt;/li&gt;
&lt;li&gt;Reallocator - Slow-acting controller replaces nodes as pods capacity shifts over time.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Getting started
&lt;/h3&gt;

&lt;p&gt;In this section, we will quickly see the node lifecycle scenarios using Karpenter in an AWS EKS cluster.  Create necessary IAM roles for Karpenter autoscaler with the cloud formation template and  Create EKS cluster with the below config file using eksctl. Please refer to the documentation here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eksctl.io/v1alpha5&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterConfig&lt;/span&gt;

&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eks-karpenter-demo&lt;/span&gt;
  &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;us-east-1&lt;/span&gt;

&lt;span class="na"&gt;availabilityZones&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;us-east-1a&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;us-east-1b&lt;/span&gt;

&lt;span class="na"&gt;managedNodeGroups&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eks-karpenter-demo-ng&lt;/span&gt;
    &lt;span class="na"&gt;instanceType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;t3.medium&lt;/span&gt;
    &lt;span class="na"&gt;minSize&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="na"&gt;maxSize&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to enable the service account and auth-config map accounts to the Karpenter.  Please refer to the document &lt;a href="https://karpenter.sh/docs/getting-started/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Install the karpenter helm chart.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo add karpenter https://awslabs.github.io/karpenter/charts
helm repo update
helm upgrade &lt;span class="nt"&gt;--install&lt;/span&gt; karpenter karpenter/karpenter &lt;span class="nt"&gt;--namespace&lt;/span&gt; karpenter &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--create-namespace&lt;/span&gt; &lt;span class="nt"&gt;--set&lt;/span&gt; serviceAccount.create&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt; &lt;span class="nt"&gt;--version&lt;/span&gt; 0.3.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configure the Karpenter Provisioner
&lt;/h3&gt;

&lt;p&gt;Configure the Karpenter provisioner as below.  Please check the provider spec for more details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;karpenter.sh/v1alpha3&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Provisioner&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;default&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;cluster&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eks-karpenter-demo&lt;/span&gt;
    &lt;span class="na"&gt;endpoint&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;CLUSTER_ENDPOINT&amp;gt;&lt;/span&gt;
  &lt;span class="na"&gt;instanceTypes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;t3.medium&lt;/span&gt;    
  &lt;span class="na"&gt;ttlSecondsAfterEmpty&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deployment
&lt;/h3&gt;

&lt;p&gt;Let's do the deployment to check the launching capacity and terminating capacity features.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl create deployment inflate --image=public.ecr.aws/eks-distro/kubernetes/pause:3.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Provisioning Nodes
&lt;/h3&gt;

&lt;p&gt;Scale the deployment and check out the logs in the Karpenter controller.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;kubectl scale deployment inflate --replicas=10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the logs of the karpenter controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;➜  eks-karpenter-demo git:&lt;span class="o"&gt;(&lt;/span&gt;main&lt;span class="o"&gt;)&lt;/span&gt; kubectl logs &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; karpenter &lt;span class="si"&gt;$(&lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; karpenter &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nv"&gt;karpenter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;controller &lt;span class="nt"&gt;-o&lt;/span&gt; name&lt;span class="si"&gt;)&lt;/span&gt;
2021-09-23T04:46:11.280Z        INFO    controller.allocation.provisioner/default       Starting provisioning loop      &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:46:11.280Z        INFO    controller.allocation.provisioner/default       Waiting to batch additional pods        &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:46:12.452Z        INFO    controller.allocation.provisioner/default       Found 9 provisionable pods      &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:46:13.689Z        INFO    controller.allocation.provisioner/default       Computed packing &lt;span class="k"&gt;for &lt;/span&gt;9 pod&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt; with instance &lt;span class="nb"&gt;type &lt;/span&gt;option&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;t3.medium]  &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:46:16.228Z        INFO    controller.allocation.provisioner/default       Launched instance: i-0174aa47fe6d1f7b4, &lt;span class="nb"&gt;type&lt;/span&gt;: t3.medium, zone: us-east-1b, &lt;span class="nb"&gt;hostname&lt;/span&gt;: ip-192-168-116-109.ec2.internal    &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:46:16.265Z        INFO    controller.allocation.provisioner/default       Bound 9 pod&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt; to node ip-192-168-116-109.ec2.internal  &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:46:16.265Z        INFO    controller.allocation.provisioner/default       Watching &lt;span class="k"&gt;for &lt;/span&gt;pod events &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The allocation controller listens for pods changes. It launched a new instance and bound the provision-able pods into the new nodes by working with kube-scheduler.&lt;/p&gt;

&lt;p&gt;The provisioning time is fast compared to other node management solutions. The other node management solutions usually take 3 min to 6 min for the node to be available.  After deploying the pods, the instances are immediately created and binding. The provisioner decides to launch a new instance within a second, and the node joins the cluster for under 60 seconds. Within 60 seconds, the nodes are available to cluster for running pods.&lt;/p&gt;

&lt;p&gt;You can configure the instance types, capacity type, os, architecture, and other provisioner spec fields.&lt;/p&gt;

&lt;h3&gt;
  
  
  Terminating Nodes
&lt;/h3&gt;

&lt;p&gt;Now, delete the deployment &lt;code&gt;inflate&lt;/code&gt;. After 30 seconds (&lt;strong&gt;ttlSecondsAfterEmpty - Termination grace period&lt;/strong&gt;), Karpenter should terminate the empty nodes - cordon &amp;amp; drain by listening to the rebalance and termination events.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;2021-09-23T04:46:18.953Z        INFO    controller.allocation.provisioner/default       Watching &lt;span class="k"&gt;for &lt;/span&gt;pod events &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:49:05.805Z        INFO    controller.Node Added TTL to empty node ip-192-168-116-109.ec2.internal &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:49:35.823Z        INFO    controller.Node Triggering termination after 30s &lt;span class="k"&gt;for &lt;/span&gt;empty node ip-192-168-116-109.ec2.internal &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:49:35.849Z        INFO    controller.Termination  Cordoned node ip-192-168-116-109.ec2.internal   &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
2021-09-23T04:49:36.521Z        INFO    controller.Termination  Deleted node ip-192-168-116-109.ec2.internal    &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"commit"&lt;/span&gt;: &lt;span class="s2"&gt;"bc99951"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;Autoscaling nodes are always challenging. Karpenter addresses key areas of challenges by eliminating Node Group and directly provision nodes. Karpenter is easy to configure, high-performance portable solution, and vendor-agnostic. It scales seamlessly working alongside native kube-scheduler and efficiently responds to dynamic resource requests. &lt;/p&gt;

&lt;p&gt;Check out the &lt;a href="https://github.com/awslabs/karpenter/blob/main/ROADMAP.md" rel="noopener noreferrer"&gt;AWS Labs Karpenter Roadmap&lt;/a&gt;. It's still in beta. In the year 2021, Karpenter is going to focus on covering the majority of known use cases and plan to rigorously test it for scale and performance. &lt;/p&gt;

&lt;p&gt;I'm Siva - working as Sr. Software Architect at &lt;a href="https://www.ceiamerica.com" rel="noopener noreferrer"&gt;Computer Enterprises Inc&lt;/a&gt; from Orlando. I'm an AWS Community builder, Auth0 Ambassador and I am going to write a lot about Cloud, Containers, IoT, and Devops. If you are interested in any of that, make sure to follow me if you haven’t already. Please follow me &lt;a href="https://www.twitter.com/ksivamuthu" rel="noopener noreferrer"&gt;@ksivamuthu&lt;/a&gt; Twitter or check out my blogs at &lt;a href="https://blog.sivamuthukumar.com" rel="noopener noreferrer"&gt;https://blog.sivamuthukumar.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
      <category>containers</category>
      <category>community</category>
    </item>
  </channel>
</rss>
