<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chirag Modi</title>
    <description>The latest articles on DEV Community by Chirag Modi (@chiragdm).</description>
    <link>https://dev.to/chiragdm</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%2F461324%2F45994830-1181-4ca3-a8c3-696383b9e5bf.png</url>
      <title>DEV Community: Chirag Modi</title>
      <link>https://dev.to/chiragdm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chiragdm"/>
    <language>en</language>
    <item>
      <title>AWS RDS Blue/Green Deployment for Aurora using Terraform</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Thu, 27 Jun 2024 05:07:08 +0000</pubDate>
      <link>https://dev.to/chiragdm/aws-rds-bluegreen-deployment-for-aurora-using-terraform-3e77</link>
      <guid>https://dev.to/chiragdm/aws-rds-bluegreen-deployment-for-aurora-using-terraform-3e77</guid>
      <description>&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%2Fnztjg44fgjxtrbmnugfk.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%2Fnztjg44fgjxtrbmnugfk.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why ?&lt;br&gt;
If you are using AWS RDS and you have any of the following use cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upgrade DB Major/Minor version without impacting LIVE production cluster with zero downtime.&lt;/li&gt;
&lt;li&gt;Easily create a production-ready staging environment side by side to production to perform specific tests.&lt;/li&gt;
&lt;li&gt;Test database changes in a separate staging environment without affecting the production cluster.&lt;/li&gt;
&lt;li&gt;Implement and test new DB features on staging cluster before doing it on production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please take a look at this &lt;a href="https://faun.pub/aws-rds-blue-green-deployment-for-aurora-using-terraform-727a97f6d386?source=friends_link&amp;amp;sk=e9d74863dbd3764c1d00eb12142d9c11" rel="noopener noreferrer"&gt;article&lt;/a&gt; for detailed information.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>rds</category>
      <category>devops</category>
      <category>terraform</category>
    </item>
    <item>
      <title>How did I upgrade Aurora Postgres RDS clusters in Production using Terraform</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Mon, 20 Feb 2023 08:35:07 +0000</pubDate>
      <link>https://dev.to/chiragdm/how-did-i-upgrade-aurora-postgres-rds-clusters-in-production-using-terraform-2bf4</link>
      <guid>https://dev.to/chiragdm/how-did-i-upgrade-aurora-postgres-rds-clusters-in-production-using-terraform-2bf4</guid>
      <description>&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%2F6ivn3s92we3ztbey1xm1.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%2F6ivn3s92we3ztbey1xm1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step by Step Guide which includes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Planning required for the upgrade&lt;/li&gt;
&lt;li&gt;Usage of terraform module and version dependency&lt;/li&gt;
&lt;li&gt;Detailed steps for minor/major version upgrade&lt;/li&gt;
&lt;li&gt;Problems faced and their solutions as part of upgrade&lt;/li&gt;
&lt;li&gt;Best Practices for Database major version Upgrade&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take a look at detailed article - &lt;a href="https://faun.pub/how-did-i-upgrade-aurora-postgres-rds-clusters-in-production-using-terraform-ff57aeb16873?source=friends_link&amp;amp;sk=26630c75421b705ad15b36f622feaddb" rel="noopener noreferrer"&gt;https://faun.pub/how-did-i-upgrade-aurora-postgres-rds-clusters-in-production-using-terraform-ff57aeb16873?source=friends_link&amp;amp;sk=26630c75421b705ad15b36f622feaddb&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>rds</category>
      <category>devops</category>
      <category>terraform</category>
    </item>
    <item>
      <title>How to access AWS services from EKS</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Sun, 27 Nov 2022 15:37:20 +0000</pubDate>
      <link>https://dev.to/chiragdm/how-to-access-aws-services-from-eks-49j2</link>
      <guid>https://dev.to/chiragdm/how-to-access-aws-services-from-eks-49j2</guid>
      <description>&lt;p&gt;In-depth guide about different solutions to access AWS APIs from Kubernetes...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kube2IAM&lt;/li&gt;
&lt;li&gt;KIAM&lt;/li&gt;
&lt;li&gt;IRSA (IAM Role for Service Account)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://faun.pub/how-to-access-aws-services-from-eks-ab5fa003a1b6?source=friends_link&amp;amp;sk=ac00ca0fad44b7e7363d63c35dc4f0fc" rel="noopener noreferrer"&gt;https://faun.pub/how-to-access-aws-services-from-eks-ab5fa003a1b6?source=friends_link&amp;amp;sk=ac00ca0fad44b7e7363d63c35dc4f0fc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbvt6qc4of8uwdfvs7tmj.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%2Fbvt6qc4of8uwdfvs7tmj.png" alt="Image description" width="792" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Kubernetes Authentication in AWS EKS Using IAM Authenticator</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Thu, 21 Jul 2022 04:00:52 +0000</pubDate>
      <link>https://dev.to/chiragdm/kubernetes-authentication-in-aws-eks-using-iam-authenticator-5hc</link>
      <guid>https://dev.to/chiragdm/kubernetes-authentication-in-aws-eks-using-iam-authenticator-5hc</guid>
      <description>&lt;h2&gt;
  
  
  How Kubernetes integrates with AWS IAM authenticator
&lt;/h2&gt;

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

&lt;p&gt;There is a different way of authentication to Kubernetes based on different cloud provider implementations. I will specifically discuss authentication implemented by AWS EKS. This article should clarify the following questions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How authentication works in EKS?&lt;/li&gt;
&lt;li&gt;What is AWS IAM Authenticator for Kubernetes?&lt;/li&gt;
&lt;li&gt;What does “aws eks get-token” do in KubeConfig to access EKS cluster?&lt;/li&gt;
&lt;li&gt;What is “aws-auth” Configmap in EKS?&lt;/li&gt;
&lt;li&gt;How can I add AWS users/roles to access EKS cluster?&lt;/li&gt;
&lt;li&gt;How do AWS users/roles map to Kubernetes users and groups in EKS?&lt;/li&gt;
&lt;li&gt;How do I generate KubeConfig for EKS cluster?&lt;/li&gt;
&lt;li&gt;How do users get authorized to perform specific Kubernetes actions?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take a look at this article to find detailed explanation with hands-on use case - &lt;a href="https://betterprogramming.pub/kubernetes-authentication-in-aws-eks-using-iam-authenticator-de3a586e885c?source=friends_link&amp;amp;sk=fce36cdc7bbc7de2c9a39f73f013922b"&gt;https://betterprogramming.pub/kubernetes-authentication-in-aws-eks-using-iam-authenticator-de3a586e885c?source=friends_link&amp;amp;sk=fce36cdc7bbc7de2c9a39f73f013922b&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>aws</category>
      <category>cloud</category>
      <category>eks</category>
    </item>
    <item>
      <title>Docker, Containers &amp; Confusions</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Sat, 26 Feb 2022 08:44:57 +0000</pubDate>
      <link>https://dev.to/chiragdm/docker-containers-confusions-1l58</link>
      <guid>https://dev.to/chiragdm/docker-containers-confusions-1l58</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0y4gzhqb47um13t4oxo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0y4gzhqb47um13t4oxo.jpg" alt="Container Echo System" width="751" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is a lot of confusion about following common questions around Docker, Containers, Kubernetes and related technologies and tools.&lt;/p&gt;

&lt;p&gt;What is Dockershim ?&lt;br&gt;
What is a Container Runtime ?&lt;br&gt;
Why did Kubernetes use Docker ?&lt;br&gt;
What is the difference between Docker, Containerd, CRI-O ?&lt;br&gt;
What is RunC ?&lt;br&gt;
What are OCI and CRI specifications ?&lt;br&gt;
What are different Container Runtimes available ?&lt;br&gt;
Why did Kubernetes remove support for Docker ?&lt;br&gt;
What alternative Container tools are available ?&lt;br&gt;
What is the difference between Docker and Podman ?&lt;/p&gt;

&lt;p&gt;Take a look at this article for clarifying details from basics to today's container world - &lt;a href="https://faun.pub/docker-containers-confusions-2e2768530144?source=friends_link&amp;amp;sk=da2c8099b6db1bbe88e377da086ac111"&gt;https://faun.pub/docker-containers-confusions-2e2768530144?source=friends_link&amp;amp;sk=da2c8099b6db1bbe88e377da086ac111&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>cloud</category>
      <category>kubernetes</category>
      <category>aws</category>
    </item>
    <item>
      <title>A Cloud Migration Questionnaire</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Mon, 19 Jul 2021 16:53:13 +0000</pubDate>
      <link>https://dev.to/chiragdm/a-cloud-migration-questionnaire-17ng</link>
      <guid>https://dev.to/chiragdm/a-cloud-migration-questionnaire-17ng</guid>
      <description>&lt;p&gt;The questions you must ask your customers before migrating their on-premise workload to AWS Cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e?source=friends_link&amp;amp;sk=accffce9d79a29769a908036b90f9845" rel="noopener noreferrer"&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%2F5cxy6ft4fd59xlkg9e01.png" alt="Cloud Migration Questionnaire. Image by author"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#28dc" rel="noopener noreferrer"&gt;Why do you want to migrate to the cloud?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#06f8" rel="noopener noreferrer"&gt;How many code changes can you afford as part of migration?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#edbe" rel="noopener noreferrer"&gt;What type of database are you using?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#fe49" rel="noopener noreferrer"&gt;What type of load balancers are you using?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#69e0" rel="noopener noreferrer"&gt;What application servers and versions are you using?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#f325" rel="noopener noreferrer"&gt;What operating system are you using?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#f6b2" rel="noopener noreferrer"&gt;Is your application public facing?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#6e29" rel="noopener noreferrer"&gt;Is your application stateful or stateless?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#afeb" rel="noopener noreferrer"&gt;Is your application containerized?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#63e2" rel="noopener noreferrer"&gt;What are the current resource requirements of the servers?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#86c2" rel="noopener noreferrer"&gt;How is your workload variation?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#0b9e" rel="noopener noreferrer"&gt;What are your logging and monitoring requirements?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e#ecab" rel="noopener noreferrer"&gt;What is your current backup strategy?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Take a look at a detailed &lt;a href="https://betterprogramming.pub/a-cloud-migration-questionnaire-for-solution-architects-dec7ffcf063e?source=friends_link&amp;amp;sk=accffce9d79a29769a908036b90f9845" rel="noopener noreferrer"&gt;post&lt;/a&gt; to know why these questions are important and how it helps to lay the foundation for future design solutions and plan migrations better.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>microservices</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Kubernetes Helm Charts Testing</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Fri, 11 Jun 2021 15:04:33 +0000</pubDate>
      <link>https://dev.to/chiragdm/helm-charts-testing-4de2</link>
      <guid>https://dev.to/chiragdm/helm-charts-testing-4de2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Tools to use for Helm Chart Testing during Development to Release&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AvV-hnNm2VAEshpQ1bqS24g.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-images-1.medium.com%2Fmax%2F2000%2F1%2AvV-hnNm2VAEshpQ1bqS24g.png" alt="Helm Chart Testing during Development to Release"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://helm.sh/" rel="noopener noreferrer"&gt;Helm Chart&lt;/a&gt;&lt;/strong&gt; is a package management software to write Kubernetes templates and package it as a chart with all its dependencies. A single chart can be used to deploy nginx, memcache or any full stack web application. You can deploy any application chart just by running the following command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm install my-release bitnami/nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Scope
&lt;/h2&gt;

&lt;p&gt;This article does not cover detailed information about Helm Chart development instead Helm chart has very good documentation which you can go through to learn more about it.&lt;/p&gt;

&lt;p&gt;I am going to cover how to test helm charts as part of development and what different types of testing tools can be used to test charts from unit tests to integration tests.&lt;/p&gt;
&lt;h2&gt;
  
  
  Helm Chart Development — Not a pleasant Experience
&lt;/h2&gt;

&lt;p&gt;Helm Chart is written in go templates and writing those templates to render Kubernetes manifests is a painful experience. There is no good debugger support available and errors are clueless so sometimes you need to spend hours to fix minor indentation related issues. Helm provides a debug flag while rendering templates though it does not pinpoint the exact line where the error is in the code so it’s difficult to find issues. I hope to have better tools available in the future for helm chart development to make developers’ lives easy.&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-images-1.medium.com%2Fmax%2F3200%2F0%2At_56kOrA6PQmKdQD" 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-images-1.medium.com%2Fmax%2F3200%2F0%2At_56kOrA6PQmKdQD" alt="Photo by Ryan Snaadt on Unsplash"&gt;&lt;/a&gt;&lt;em&gt;Photo by Ryan Snaadt on Unsplash&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Are your chart templates correct ?
&lt;/h2&gt;

&lt;p&gt;As mentioned earlier, Helm Chart templates use go templates so as part of development you need to be sure of syntactical errors so you don’t get last minute surprises when you release your chart.&lt;/p&gt;

&lt;p&gt;Helm provides a lint command which finds and reports all these issues related to templates so you can execute this command frequently to find compile time errors as part of your development.&lt;/p&gt;

&lt;p&gt;Here is a helm chart deployment template with errors.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Helm lint&lt;/strong&gt; will report the following issues which were expected.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜ mychart helm lint .
==&amp;gt; Linting .
[INFO] Chart.yaml: icon is recommended

[ERROR] templates/: parse error at (mychart/templates/deployment.yaml:19): function “Values” not defined

[ERROR] templates/: template: mychart/templates/deployment.yaml:7:16: executing “mychart/templates/deployment.yaml” at &amp;lt;include “namespace” .&amp;gt;: error calling include: template: no template “namespace” associated with template “gotpl”

Error: 1 chart(s) linted, 1 chart(s) failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;I know this is a very simple example but good enough for understating how lint works.&lt;/p&gt;
&lt;h2&gt;
  
  
  Validate against Kubernetes Manifests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Helm template&lt;/strong&gt; is the command you can use to render/generate Kubernetes manifests/templates out of your helm chart templates.&lt;/p&gt;

&lt;p&gt;There is a command &lt;strong&gt;Helm install&lt;/strong&gt; to install/deploy charts to Kubernetes cluster. Internally, It  first executes helm template command and then deploys generated template output to the cluster.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm template . &amp;gt; deployment.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Are your  Kubernetes Manifests Valid ?
&lt;/h3&gt;

&lt;p&gt;If you make mistakes while developing a chart then it might be possible that the generated Kubernetes Manifests generate errors when applied to  the Kubernetes cluster but I want to know about those errors before deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.kubeval.com/" rel="noopener noreferrer"&gt;Kubeval&lt;/a&gt;&lt;/strong&gt; is the tool to rescue. It’s a tool to validate your generated manifests against official Kubernetes specification and reports issues if any.&lt;/p&gt;

&lt;p&gt;Can you spot any issue in this Deployment template ?&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Run kubeval against this deployment manifest and look at the issues.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜ mychart kubeval deployment.yaml

WARN — mychart/templates/deployment.yaml contains an invalid Deployment (myservice.nginx-deployment) — selector: selector is required

WARN — mychart/templates/deployment.yaml contains an invalid Deployment (myservice.nginx-deployment) — containerPort: containerPort is required

WARN — mychart/templates/deployment.yaml contains an invalid Deployment (myservice.nginx-deployment) — spec.replicas: Invalid type. Expected: [integer,null], given: string

##### This is the output if it was valid deployment #####
PASS — mychart/templates/deployment.yaml contains a valid Deployment (myservice.nginx-deployment)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Additionally you can specify Kubernetes version against which you want to validate generated templates using option* “ — kubernetes-version v1.20.4”*&lt;/p&gt;
&lt;h3&gt;
  
  
  Custom Validations against Kubernetes Manifests
&lt;/h3&gt;

&lt;p&gt;Let’s say I have the following simple requirements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Containers should not run as root.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker images should come from my org repository.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can address this by implementing an admission controller in Kubernetes when resources get deployed to the cluster but would it not be nice if we can apply this custom validation before deployment ?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.conftest.dev/" rel="noopener noreferrer"&gt;Conftest&lt;/a&gt;&lt;/strong&gt; is a framework which allows you to write rules using &lt;strong&gt;&lt;a href="https://www.openpolicyagent.org/docs/latest/policy-language/" rel="noopener noreferrer"&gt;OPA policies&lt;/a&gt;&lt;/strong&gt; and run it against the Kubernetes manifests.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Run these custom rules against deployment manifests using conftest which will report issues based on configured rules.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜ mychart conftest test — policy . deployment.yaml

FAIL — deployment.yaml — main — Containers must not run as root
FAIL — deployment.yaml — main — image ‘nginx’ doesn’t come from myorg.com repository

2 tests, 0 passed, 0 warnings, 2 failures, 0 exceptions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;You can write any custom policies for all your resources which you can execute against Kubernetes manifests before deployment. That’s Pretty Cool.&lt;/p&gt;
&lt;h2&gt;
  
  
  Schema Validations for Custom Values
&lt;/h2&gt;

&lt;p&gt;As I explained, you can verify Kubernetes manifests using Kubeval and Conftest tools but when you are creating a helm chart then you need to allow your users who are using the chart to add some custom values for any new feature. you need to validate that those custom values are in correct format to be consumed by the chart otherwise it will fail chart rendering which is a very difficult task to debug. how can we apply the first level of defense to make sure provided custom values are in correct format otherwise error it out with proper validation message.&lt;/p&gt;

&lt;p&gt;Helm Chart provides &lt;strong&gt;&lt;a href="https://helm.sh/docs/topics/charts/#schema-files" rel="noopener noreferrer"&gt;Schema Validation&lt;/a&gt;&lt;/strong&gt; feature for which you need to provide a schema file in a chart containing rules for all your custom values. It validates this schema validation first before executing any of these commands.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;helm lint&lt;/li&gt;
&lt;li&gt;helm template&lt;/li&gt;
&lt;li&gt;helm install&lt;/li&gt;
&lt;li&gt;helm upgrade&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are a few of the use cases using custom values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Users should be able to specify memory and cpu requirements.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Some users want to specify different log locations for application logs.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Users want to supply environment *variables&lt;/em&gt; for the application container.*&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s implement the first use case where if the user specifies custom values for memory and cpu then it will take it otherwise set default values.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Here is &lt;strong&gt;values.schema.json&lt;/strong&gt; file to validate against custom values.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This is custom-values.yaml which users can provide while consuming the chart.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;As the user has provided wrong custom values, it should fail.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜ mychart helm template . -f custom-values.yaml

Error: values don’t meet the specifications of the schema(s) in the following chart(s):
mychart:
- memory: Does not match pattern ‘^[0–9.]+[M|G]i$’
- cpu: Does not match pattern ‘^[0–9.]+m*$’
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can do any type of validation as long as it’s supported by json schema specifications though the only condition is you should have all json schema rules available in file named values.schema.json in your chart.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unit Testing
&lt;/h2&gt;

&lt;p&gt;Like any other programming language, Unit tests are the first which developers should consider in the early stage of development. I see a scarcity of good unit testing frameworks available for Helm Charts.&lt;/p&gt;

&lt;p&gt;There is a unit test framework &lt;strong&gt;&lt;a href="https://github.com/quintush/helm-unittest" rel="noopener noreferrer"&gt;helm-unittest&lt;/a&gt;&lt;/strong&gt;. It is a very nice framework for unit testing and lots of active deployment is going on so one should definitely go for it.&lt;/p&gt;

&lt;p&gt;There is another hacky way of testing Helm charts which is a mix of unit tests and regression tests.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Idea is very simple. you need to add a binding file containing custom values for each new feature you are implementing in helm chart and generate fixture file out of it using helm template command. You need to commit binding and it’s fixture file in the repository. Now create a simple shell script to be executed in CI which will create a fixture file out of a binding file on the fly against your changes in chart and compare it with existing fixture file. you just fail the test if there is difference in fixture files then you need to either fix your helm chart or update the existing fixture file if it’s expected behavior.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Testing using fixtures is very helpful in code refactoring and also can be considered for unit tests while writing new features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integration Tests using Kubetest
&lt;/h2&gt;

&lt;p&gt;Till now, we have tested helm chart templates and Kubernetes manifests using different tools but we did not verify anything by actually deploying Kubernetes manifests in the Kubernetes cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do we need integration tests ?
&lt;/h3&gt;

&lt;p&gt;I have mentioned a few of the use cases which can only be verified by deploying resources in a cluster.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;I have mounted the volume as writable which I want to verify by creating a file in volume.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;There are some custom resources which I want to verify.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;I want to verify the health-check of the internal load balancer created as part of Kubernetes service creation.&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are many tools available but I really liked &lt;strong&gt;&lt;a href="https://kubetest.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;Kubetest&lt;/a&gt;&lt;/strong&gt; which is a pytest plugin. Kubetest makes it easy to write integration tests by providing abstraction on top of Kubernetes client.&lt;/p&gt;

&lt;p&gt;It provides many helper functions so you don’t need to write complex code using Kubernetes client unless it’s absolutely necessary.&lt;/p&gt;

&lt;p&gt;It’s very intuitive and fun to write integration tests using Kubetest. I was tempted to skip not putting any example code here because it is  self explanatory once you look at this &lt;strong&gt;&lt;a href="https://kubetest.readthedocs.io/en/latest/examples.html" rel="noopener noreferrer"&gt;example&lt;/a&gt;&lt;/strong&gt; code.&lt;/p&gt;

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

&lt;p&gt;I have covered the basics about helm charts, various tools we can use for different types of testing including unit test and integration tests during the lifecycle from development to releasing the helm charts. &lt;/p&gt;

&lt;p&gt;Don’t miss out to look at my &lt;strong&gt;&lt;a href="https://github.com/chiragdm/helm-chart-testing" rel="noopener noreferrer"&gt;github&lt;/a&gt;&lt;/strong&gt; I have used as an example through out the article if anything is not clear.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed it. Cheers !&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://helm.sh/" rel="noopener noreferrer"&gt;https://helm.sh/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.kubeval.com/" rel="noopener noreferrer"&gt;https://www.kubeval.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.conftest.dev/" rel="noopener noreferrer"&gt;https://www.conftest.dev/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.openpolicyagent.org/docs/latest/policy-language/" rel="noopener noreferrer"&gt;https://www.openpolicyagent.org/docs/latest/policy-language/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://helm.sh/docs/topics/charts/#schema-files" rel="noopener noreferrer"&gt;https://helm.sh/docs/topics/charts/#schema-files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/quintush/helm-unittest" rel="noopener noreferrer"&gt;https://github.com/quintush/helm-unittest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubetest.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;https://kubetest.readthedocs.io/en/latest/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/chiragdm/helm-chart-testing" rel="noopener noreferrer"&gt;https://github.com/chiragdm/helm-chart-testing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>helm</category>
      <category>kubernetes</category>
      <category>unittesting</category>
      <category>integrationtesting</category>
    </item>
    <item>
      <title>Envelope Encryption using AWS CLI</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Thu, 10 Sep 2020 12:44:01 +0000</pubDate>
      <link>https://dev.to/chiragdm/envelope-encryption-using-aws-cli-3ejd</link>
      <guid>https://dev.to/chiragdm/envelope-encryption-using-aws-cli-3ejd</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;I have already posted article on Envelope Encryption and how it works. Please take a look at that &lt;a href="https://dev.to/chiragdm/aws-kms-envelope-encryption-3689"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This article covers how can we encrypt/decrypt large amount of data by Envelope Encryption using AWS CLI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;p&gt;This hands-on exercise requires AWS account and AWS CLI. You can get more information about installation and configuration of AWS CLI from &lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hands-on Exercise
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Generate Customer Master Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have AWS CLI setup by now so first step is to create AWS CMK (Customer Master key) using KMS. We have got our Customer Master Key which we will be using for encryption.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws kms create-key --description "This key is used for envelope encryption"
output:
{
"KeyMetadata": {
    "AWSAccountId": "************",
    "KeyId": "21763c54-353e-4099-8027-************",
    "Arn": "arn:aws:kms:us-east-1:************:key/21763c54-353e-4099-8027-************",
    "CreationDate": "2020-09-10T14:59:44.359000+05:30",
    "Enabled": true,
    "Description": "This key is used for envelope encryption",
    "KeyUsage": "ENCRYPT_DECRYPT",
    "KeyState": "Enabled",
    "Origin": "AWS_KMS",
    "KeyManager": "CUSTOMER",
    "CustomerMasterKeySpec": "SYMMETRIC_DEFAULT",
    "EncryptionAlgorithms": [
        "SYMMETRIC_DEFAULT"
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;1. Generate Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's generate Data key using CMK we generated earlier. It returns Data Key (Plaintext) and Encrypted Data key (CiphertextBlob).&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws kms generate-data-key --key-id 21763c54-353e-4099-8027-************ --key-spec AES_256
Output:
{
"CiphertextBlob": "************IPQE9CgC3MLxxTR8lu/AFcM2axxufFf5mB81aqlukaAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM5FCtUAUdCHJ72PYNAgEQgDs7EwfgzL4g4/E48AJTKVEKJq8EsuEM6hAlcZ6XWw0AlYpfLyXD910NSd/LasDtI2YkIp7wSitlpdkVuw==",
    "Plaintext": "XIJVOItN8cc40n/H8/Wzbs/u+57/H5ERL/gi/hArqZI=",
    "KeyId": "arn:aws:kms:us-east-1:************:key/21763c54-353e-4099-8027-************"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Decode Base64 encoded Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keep note that Data Key and Encrypted Data key generated in previous step are Base64 encoded so we need to decode it first.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'XIJVOItN8cc40n/H8/Wzbs/u+57/H5ERL/gi/hArqZI=' | base64 --decode &amp;gt; ~/plaintext_data_key.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. Encrypt Data using Plaintext Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We are encrypting actual data using Decoded plaintext data key using AES256 encryption.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "This is data I want to encrypt using plain data key"  | openssl enc -e -aes256 -k fileb:///Users/chirag/plaintext_data_key.txt &amp;gt; ~/encrypted_data.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;4. Package Encrypted Data and Data key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have now Encrypted Data and Encrypted Data Key which we can store together or separately on Data store. Make sure to store Encrypted Data key which will be required during decryption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Remove Plaintext Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can remove Data key from system after Data encryption as it's sensitive information and we don't require it as we have stored Encrypted Data key so in future whenever required we can get back plaintext data key.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm ~/plaintext_data_key.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;6. Extract Data for Decryption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's we want our encoded data back so first need to extract Encrypted Data key we stored earlier and then Decode it as it was also Base64 encoded.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo '************IPQE9CgC3MLxxTR8lu/AFcM2axxufFf5mB81aqlukaAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQM5FCtUAUdCHJ72PYNAgEQgDs7EwfgzL4g4/E48AJTKVEKJq8EsuEM6hAlcZ6XWw0AlYpfLyXD910NSd/LasDtI2YkIp7wSitlpdkVuw==' | base64 --decode &amp;gt; ~/encrypted_data_key.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;7. Decrypt Encrypted Plaintext Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once we get back Encrypted Data Key, we need to call Decrypt API to get Plaintext Data Key.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws kms decrypt --ciphertext-blob fileb:///Users/chirag/encrypted_data_key.txt
Output:
{
"KeyId": "arn:aws:kms:us-east-1:************:key/21763c54-353e-4099-8027-************",
"Plaintext": "XIJVOItN8cc40n/H8/Wzbs/u+57/H5ERL/gi/hArqZI=",
"EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;8. Decode Base64 encoded Plaintext Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Again Decrypted Data Key we got is Base64 encoded so we need to decode it first.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo 'XIJVOItN8cc40n/H8/Wzbs/u+57/H5ERL/gi/hArqZI=' | base64 --decode &amp;gt; ~/decrypted_plaintext_data_key.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;9. Decrypt actual data using Plaintext Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Take actual encrypted data and decrypt it using same AES256 algorithm and we got actual data back.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ~/encrypted_data.txt  | openssl enc -d -aes256 -k fileb:///Users/chirag/decrypted_plaintext_data_key.txt
Output:
This is data I want to encrypt using plain data key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;10. Remove Plaintext Data Key&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cleanup Plaintext Data Key.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm ~/decrypted_plaintext_data_key.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;I have masked all sensitive information here with "*"&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;So we have gone through full cycle of encryption (steps 1-5) and decryption (steps 6-10) making use of Envelope Encryption using AWS KMS. &lt;/p&gt;

&lt;p&gt;This is how AWS internally performs Data encryption for large datasets in S3, EBS, RDS, etc.. when data encryption is enabled.&lt;/p&gt;

&lt;p&gt;Thanks for joining me.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>microservices</category>
      <category>architecture</category>
      <category>encryption</category>
    </item>
    <item>
      <title>AWS KMS Envelope Encryption</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Tue, 08 Sep 2020 19:21:33 +0000</pubDate>
      <link>https://dev.to/chiragdm/aws-kms-envelope-encryption-3689</link>
      <guid>https://dev.to/chiragdm/aws-kms-envelope-encryption-3689</guid>
      <description>&lt;h2&gt;
  
  
  Background and Introduction
&lt;/h2&gt;

&lt;p&gt;Traditionally applications used to store security keys used for data encryption/decryption in application config files. Drawback of storing it in config files is risk involved if not stored and managed properly.&lt;/p&gt;

&lt;p&gt;AWS Key Management Service (KMS) is fully managed service offering which AWS itself is using to encrypt/decrypt data at rest for different AWS services like S3, EBS, RDS, etc..&lt;/p&gt;

&lt;p&gt;AWS KMS is highly available key management service to access, store, audit secret keys called CMKs (Customer Master Keys).&lt;/p&gt;

&lt;p&gt;There are two types of CMKs (Customer Master Keys).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS Managed CMKs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS creates keys for each of its services which provides data encryption. These keys are managed by AWS and it's default CMK used to encrypt/decrypt data for particular service.&lt;/li&gt;
&lt;li&gt;Customer does not have much control on it as it can only be viewed in KMS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Customer Managed CMKs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer creates keys in KMS and has full control over management of keys like Audit log, Key rotation, Key deletion, etc...&lt;/li&gt;
&lt;li&gt;Customer can also upload their own keys to KMS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Envelope Encryption works ?
&lt;/h2&gt;

&lt;p&gt;AWS KMS key called CMK (Customer Master Key) is used to encrypt/decrypt data but there is limitation of it as it can encrypt data up to 4KB only so the question pops up then how it's using it for encryption of big datasets in S3, EBS, etc...&lt;/p&gt;

&lt;p&gt;You got it right - Envelope Encryption.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Envelope encryption&lt;/strong&gt; is the practice of encrypting plaintext data with a data key, and then encrypting the data key under another key.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's see how envelope encryption works but before encrypting any data customer needs to create one or more CMKs (Customer Master Keys) in AWS KMS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QBj6EGIk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/1065/1%2AlVswCGRqvEKB4FYt3n_GWQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QBj6EGIk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/1065/1%2AlVswCGRqvEKB4FYt3n_GWQ.jpeg" alt="enter image description here" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encryption&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;API request is sent to KMS to generate Data key using CMK.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;KMS returns response with Plain Data key and Encrypted Data key (using CMK).&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Data is encrypted using Plain Data key.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Plain Data key is removed from memory.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Encrypted Data and Encrypted Data Key is packaged together as envelope and stored.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Decryption&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Encrypted Data key is extracted from envelope.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;API request is sent to KMS using Encrypted Data key which has information about CMK to be used in KMS for decryption&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;KMS returns response with Plain Data Key.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Encrypted Data is decrypted using Plain Data key.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Plain Data Key is removed from memory.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;I tried to explain here what is Envelope Encryption in AWS KMS and how can we encrypt/decrypt large amount of data using envelope encryption method.&lt;/p&gt;

&lt;p&gt;I am looking forward to put hands-on exercise on this in next &lt;a href="https://dev.to/chiragdm/envelope-encryption-using-aws-cli-3ejd"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for joining me.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping"&gt;https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>microservices</category>
      <category>architecture</category>
      <category>encryption</category>
    </item>
    <item>
      <title>Everything is Replaceable</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Sun, 06 Sep 2020 07:56:53 +0000</pubDate>
      <link>https://dev.to/chiragdm/everything-is-replaceable-2odd</link>
      <guid>https://dev.to/chiragdm/everything-is-replaceable-2odd</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0P1nT52M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://lh3.googleusercontent.com/proxy/U5kSAlJt5NGZ6JKf4vKxjPd6JH4zLHoKE2lmAfRqZ-DKa_ouZelXwQdJPKakPVqrxyKbywP-mKFwScTZqK13qXR8FqyrS1AaVuJN-BJL003HwEstDXI1wJW58CvwjEOfr3fmlEldLw" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0P1nT52M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://lh3.googleusercontent.com/proxy/U5kSAlJt5NGZ6JKf4vKxjPd6JH4zLHoKE2lmAfRqZ-DKa_ouZelXwQdJPKakPVqrxyKbywP-mKFwScTZqK13qXR8FqyrS1AaVuJN-BJL003HwEstDXI1wJW58CvwjEOfr3fmlEldLw" alt="Everything is replaceable" width="356" height="512"&gt;&lt;/a&gt;&lt;br&gt;
Many times we think that particular person is very important for organization or company and without him project can not go on as he has been working since long time and he knows everything.&lt;/p&gt;

&lt;p&gt;That's just belief everyone has in mind&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Everyone is important and same time truth is Everyone is replaceable&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We often heard founders are fired from the company which they had built from start so Better everyone should keep in mind that they are replaceable as doing that will not hurt you when you get replaced.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Everyone is important for certain period of time&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes person is very important for particular job, team or company till his work is over or when his replacement is found.&lt;/p&gt;

&lt;h2&gt;
  
  
  What people do to avoid they don't get replaced ?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Hide the information they know.&lt;/li&gt;
&lt;li&gt;Don't treat other people well being egoistic of knowing everything.&lt;/li&gt;
&lt;li&gt;Hinder the growth of company and other employees around.&lt;/li&gt;
&lt;li&gt;Don't grow themselves by keeping them to only what they know.&lt;/li&gt;
&lt;li&gt;They don't put important information on paper to avoid being used by others instead they are tried to remember everything.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to make ourselves aware about this Truth ?
&lt;/h2&gt;

&lt;p&gt;Just think that you won't be coming to office tomorrow due to you are sick or you left the job or whatsoever it may be.&lt;/p&gt;

&lt;p&gt;What would happen to company, team or project ? who would be able to take it over and help the company or project ?&lt;/p&gt;

&lt;p&gt;You should have proper plan put down from start and documented everything about tasks you are doing and decision you made like so that others can pick up where you left off. Information kept in your head will be forgotten one day and it does not benefit anyone.&lt;/p&gt;

&lt;p&gt;This little practice helps lot to you and the organization.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As everything is documented, you don't need to explain other team members repeatedly.&lt;/li&gt;
&lt;li&gt;Helps to grow yourselves so you can focus on other important things.&lt;/li&gt;
&lt;li&gt;Keeps yourselves free from remembering everything.&lt;/li&gt;
&lt;li&gt;Helps others to grow by delegating your duties to them.&lt;/li&gt;
&lt;li&gt;Frees yourselves to take time off as other team member can take up your tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have analogy to compare this with software architecture.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Don't be like tightly coupled monolithic architecture but instead&lt;br&gt;
loosely coupled microservice architecture&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rightly it has been said in &lt;a href="https://en.wikipedia.org/wiki/Karma_yoga"&gt;Karmyog&lt;/a&gt; of Bhagvad Gita..&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;"Do Karma but keep yourself free from Karma instead of tied to it"&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>microservices</category>
      <category>motivation</category>
    </item>
    <item>
      <title>Cloud Design Principals</title>
      <dc:creator>Chirag Modi</dc:creator>
      <pubDate>Tue, 01 Sep 2020 15:16:02 +0000</pubDate>
      <link>https://dev.to/chiragdm/cloud-design-principals-2k5g</link>
      <guid>https://dev.to/chiragdm/cloud-design-principals-2k5g</guid>
      <description>&lt;p&gt;It's all about how you develop and deploy application instead of where you are deploying application be it public cloud or private data center. Application designed in this way can best make use of offering provided by cloud. First step in that direction is building micro-service based applications and run them in containerized and orchestrated platform like Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7xepNkoH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/media/cloud-native-foundational-pillars.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7xepNkoH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/media/cloud-native-foundational-pillars.png" alt="Cloud Native Applications" width="642" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following are the design principals one should consider while creating Cloud applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Microservices
&lt;/h2&gt;

&lt;p&gt;Applications are created as micro-service so one can make use of best language, frameworks and tools suitable for different applications. Let's say we can build real-time applications using Nodejs, REST applications using Spring-Boot or Dropwizard and ML applications using python. &lt;/p&gt;

&lt;h2&gt;
  
  
  Containerization and Orchestration
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Containerized application requires less resources then VMs and starts up in fraction of seconds. Containers packages applications into small, lightweight execution environment which shares host operating system. Containers helps isolating different micro services running in same host operating system. Docker has been used heavily for containerization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Containerized application applications can be deployed using orchestration platform like Kubernetes which helps in container management, application deployment, scaling which has become standard for cloud application deployment.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Immutable and Disposable Resources
&lt;/h2&gt;

&lt;p&gt;Consider resources as disposable as opposed to traditional way of thinking of physical fixed servers in data center where application used to be running.&lt;/p&gt;

&lt;p&gt;Consider resources as immutable infrastructure where once application is deployed, it never gets updated instead new resources are provisioned for each deployment which can greatly improves consistency of application deployment/rollback.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Leverage Managed Services
&lt;/h2&gt;

&lt;p&gt;There are many service offered by cloud which can be used by applications so instead of investing resources in setting up that infrastructure in managing it, one can leverage managed services offered by different cloud providers.&lt;/p&gt;

&lt;p&gt;Scared of vendor lock in ?&lt;/p&gt;

&lt;p&gt;It's trade off operation cost of managing it or using managed services. You can always use many open source managed services offered by cloud and for others you have to decide based on operational costs. &lt;/p&gt;

&lt;h2&gt;
  
  
  Scalability and Elasticity
&lt;/h2&gt;

&lt;p&gt;Scalability is the ability to scale application without changing design and it achieved by scaling up and down whenever required. Scalability leads to other principals like Stateless applications and Disposable resources.&lt;/p&gt;

&lt;p&gt;Elasticity is the ability to use resource dynamically and all cloud providers offer it as pay as you go model. It solves problem of over-provisioning of resources for applications deployed in traditional data center.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stateless
&lt;/h2&gt;

&lt;p&gt;Stateless applications maintain states outside of application in database or other external entity so nodes can be added dynamically and removed and deployed applications without worrying about state. Application components also should be stateless as stateless components can be easily scaled, repaired, rolled-back and load balanced. Scalability can be achieved easily by designing stateless applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loose Coupling
&lt;/h2&gt;

&lt;p&gt;Loosely Coupled architecture reduces inter dependency between application  components so one failed component does not impact whole application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Discovery&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Services registers themselves and discovered automatically by other services&lt;/li&gt;
&lt;li&gt;Service endpoints does not need to be hard coded in applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous Communication&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decoupled components does not interact each other directly&lt;/li&gt;
&lt;li&gt;Communication between components happen using various message brokers like ActiveMq, SQS, etc..&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fault Tolerant and Resiliency
&lt;/h2&gt;

&lt;p&gt;Application is fault tolerant means it should continue functioning in-spite of fault detected in one of the application component. While Resiliency is about ability to recover from failures to the operation state when it was before failure so it's all about responding to failures without any downtime and data loss.&lt;/p&gt;

&lt;p&gt;Resiliency should be at core of any architecture and you should practice it from start when designing any application. &lt;/p&gt;

&lt;p&gt;Resilient applications offers High availability and Disaster recovery using load balanced clusters, multi-region deployments, replication, continuous monitoring.&lt;/p&gt;

&lt;p&gt;Different ways to make application resilient:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load balancing to avoid single point of failure&lt;/li&gt;
&lt;li&gt;Retry intermittent failures&lt;/li&gt;
&lt;li&gt;Circuit breaker to avoid cascading failures&lt;/li&gt;
&lt;li&gt;Request throttling to avoid unavailability and DDOS attacks&lt;/li&gt;
&lt;li&gt;Distributed transaction rollback using SAGA pattern&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Security
&lt;/h2&gt;

&lt;p&gt;Application component should communicate with each other using well defined authentication method without thinking whether it's internal service or external service to avoid any security vulnerability&lt;/p&gt;

&lt;h2&gt;
  
  
  Automation
&lt;/h2&gt;

&lt;p&gt;Last but very very important is we should strive for automation in every part of application development, build, deployment, monitoring, etc ...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Infrastructure Automation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Infrastructure automation can be achieved by provisioning infrastructure using tools like Terraform, Serverless, Cloudformation etc..&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CI/CD Automation&lt;/strong&gt;&lt;br&gt;
CI/CD pipeline greatly reduces manual efforts and help in automating everything from build, test, package and deployment. There are various tools like Jenkins, Spinnaker, Code pipeline, etc...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Auto Scaling&lt;/strong&gt;&lt;br&gt;
Automating scale up helps application availability during peak load and scale down reduces cost when application are not used heavily. Sometimes you can scale down to 0 for internal applications which are used rarely to further reduce costs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monitoring&lt;/strong&gt;&lt;br&gt;
Centralized logging and monitoring greatly helps in maintaining services in healthy condition and it should be automated using different tooling so if issue can be detected quickly and fixed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backup&lt;/strong&gt;&lt;br&gt;
Automated backup solution in place so data can be recovered quickly without much loss of data. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>distributedsystems</category>
      <category>architecture</category>
      <category>microservices</category>
    </item>
  </channel>
</rss>
