<?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: anil augustine chalissery</title>
    <description>The latest articles on DEV Community by anil augustine chalissery (@anilchalissery).</description>
    <link>https://dev.to/anilchalissery</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%2F840543%2F420e908c-48a9-429c-83b7-614b0dabf830.jpeg</url>
      <title>DEV Community: anil augustine chalissery</title>
      <link>https://dev.to/anilchalissery</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anilchalissery"/>
    <language>en</language>
    <item>
      <title>Is Terraform better than AWS CloudFormation?</title>
      <dc:creator>anil augustine chalissery</dc:creator>
      <pubDate>Wed, 21 Sep 2022 07:23:41 +0000</pubDate>
      <link>https://dev.to/anilchalissery/is-terraform-better-than-aws-cloudformation-3g1f</link>
      <guid>https://dev.to/anilchalissery/is-terraform-better-than-aws-cloudformation-3g1f</guid>
      <description>&lt;h2&gt;
  
  
  Is Terraform better than AWS CloudFormation?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Let's outline some of the key differences between Terraform and AWS CloudFormation.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_HB_bvlX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2230/1%2AJD6Jo28EIZbZu4pqeYRp4Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_HB_bvlX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2230/1%2AJD6Jo28EIZbZu4pqeYRp4Q.png" alt="" width="880" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;When asked about the best tools to automate infrastructure provisioning, two prevalent names come to mind: Terraform and AWS CloudFormation. Infrastructure-as-Code (IaC) has become fundamental to businesses in their cloud journey. As the name implies, IaC provides the ability to define your infrastructure, typically cloud infrastructure, as code. In today’s world, where we are surrounded by companies heavily relying on cloud providers such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud, Building and managing cloud infrastructure manually can be quite the task and even more challenging when you’re operating as a distributed team.&lt;/p&gt;

&lt;p&gt;Cloud providers typically offer a native infrastructure as code language that exclusively supports the deployment of resources to their cloud platform. For AWS, that offering is a service called AWS CloudFormation. There are other tools on the market, some of which are sometimes described as “cloud agnostic” due to their ability to support the deployment to multiple cloud providers. Terraform by HashiCorp is one of the most common IaC tools which is “cloud agnostic”.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Terraform?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LiQX10hj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2AOIqXo-cfKyJQfbOdMt8mJw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LiQX10hj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2560/1%2AOIqXo-cfKyJQfbOdMt8mJw.png" alt="" width="880" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.terraform.io/"&gt;&lt;strong&gt;Terraform is an open-source&lt;/strong&gt;&lt;/a&gt;, cloud-agnostic infrastructure management tool developed by HashiCorp that enables modular configuration of infrastructure, thereby allowing you to use AWS modules and third-party modules in the same infrastructure. Terraform utilizes a syntax called the HashiCorp Configuration Language (HCL), which allows users to define their infrastructure programmatically.&lt;/p&gt;

&lt;p&gt;In addition to the “multi-provider” support that Terraform provides, there are other benefits to consider as well such as its ability to dynamically create resources using its for_each or count features and the ability to dynamically configure properties of a resource with the dynamic block functionality. Additionally, Terraform supports built-in functions that can be called and used within your code, which become very useful for everyday tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is AWS CloudFormation?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nxv0lDyU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2454/1%2AAe9Y_Sl28J7CHimk1L32oA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nxv0lDyU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2454/1%2AAe9Y_Sl28J7CHimk1L32oA.png" alt="" width="880" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/cloudformation/"&gt;&lt;strong&gt;Amazon CloudFormation&lt;/strong&gt;&lt;/a&gt; is a fantastic tool that gives the development and operations team the liberty to automate AWS’s infrastructure provision easily. It is a managed AWS service that allows you to design and provision AWS and third-party resources for your cloud environment. Cloudformation handles the configuration in a JSON or YAML format called templates. These templates enable the user to attain re-usability and scalability of infrastructure. In addition to this, AWS Support will probably be more capable of assisting you with issues when you need help. AWS Support is essential for large enterprises, particularly those new to the cloud or slow to adopt.&lt;/p&gt;

&lt;h2&gt;
  
  
  The comparison
&lt;/h2&gt;

&lt;p&gt;Now that we’ve defined these two IaC platforms, let’s review some of the key differences in more depth. When trying to determine the better of the two, you might be overwhelmed with the features they both offer. One of them could be better than the other depending on how they suit your infrastructure’s needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. State Management&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Both tools need to keep track of all the resources under management. CloudFormation is managing its state with so-called stacks. By default, Terraform is storing its state on disk. Terraform is offering remote state as well, for example, based on &lt;a href="https://www.terraform.io/docs/backends/types/s3.html"&gt;S3 and DynamoDB&lt;/a&gt; or &lt;a href="https://www.terraform.io/docs/cloud/index.html"&gt;Terraform Cloud&lt;/a&gt;. It is advisable to use a remote state when multiple users are working on the same infrastructure in parallel. CloudFormation manages state within the managed service out-of-the-box, which is a small plus compared to Terraform, where you need to configure remote state yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Cost and Support&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The best part about both these tools is that both are free of cost. Both of these tools have large communities with a lot of support and examples. Cloudformation is not billed. The only fee that users incur is the cost of AWS service provisioned by CloudFormation. Terraform is a free and open-source tool. Terraform however offers a paid enterprise version that has additional collaboration and governance options. The &lt;a href="https://aws.amazon.com/premiumsupport/plans/"&gt;AWS support plans&lt;/a&gt; include support for CloudFormation. Hashicorp, the company behind Terraform, is offering support plans as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Cloud Providers&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AWS CloudFormation, as the name suggests, is specific to Amazon Web Services. You can theoretically achieve deployment to third-party resources through the use of custom resources, but this is rather hacky, and at the end of the day those third-party resources are not truly supported by CloudFormation. On the other hand, Terraform allows you to deploy to other cloud providers as well. Granted, you won’t be able to re-use the same codebase from one cloud provider to another. At the very least, when using Terraform, you’ll have familiar syntax and methods for deploying to different cloud providers. For some companies this is a significant benefit, as being able to use the same syntax and deployment methods to deploy to multiple cloud providers is a clear plus.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Modularity&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;CloudFormation uses sets of “&lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html"&gt;nested stacks&lt;/a&gt;” or templates as modules. These nested stacks act as building blocks for your infrastructure and allow you to import and export standard configuration settings. For example, you might have multiple configurations of resources used for different applications or infrastructure. In these cases, you can create a dedicated template for such resources that you can then import into every stack that needs the resource.&lt;/p&gt;

&lt;p&gt;Terraform outstands when considering its modularity. HashiCorp built Terraform to be cloud-agnostic and be able to incorporate any resource. Terraform includes native support for many &lt;a href="https://registry.terraform.io/"&gt;third-party modules.&lt;/a&gt; It accomplishes this via “providers,” or plugins that implement resource types. You can add any resource, AWS or third-party, by adding a provider to your configuration.&lt;/p&gt;

&lt;p&gt;Terraform also uses &lt;a href="https://learn.hashicorp.com/collections/terraform/modules?utm_source=WEBSITE&amp;amp;utm_medium=WEB_IO&amp;amp;utm_offer=ARTICLE_PAGE&amp;amp;utm_content=DOCS"&gt;modules to organize&lt;/a&gt; configurations. Modules allow complex configurations to remain readable by managing related parts. You can also use modules to reuse and share common configurations. Reusing modules causes fewer errors and less time to rewrite your configurations. Terraform practitioners often publish modules online. The vast community that Terraform has built allows you to tap into community knowledge and experience and dramatically reduces the time you’d spend writing and debugging configuration files.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Rollback&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When CloudFormation fails to modify your infrastructure, it rolls back to the previous working state automatically. Terraform does not support rollbacks out of the box. Either you decide to fix the problem and deploy it again, or you have to apply the previous configuration yourself. You can also prevent a rollback by using the command &lt;a href="https://www.terraform.io/docs/cli/commands/plan.html"&gt;&lt;strong&gt;terraform plan&lt;/strong&gt;&lt;/a&gt; that outputs a list of all upcoming changes before actually executing them. You can also use &lt;strong&gt;terraform plan&lt;/strong&gt; to complete dry runs of an update, double-check the output to ensure all changes are as expected, and then commit your changes.&lt;/p&gt;

&lt;p&gt;Both CloudFormation and Terraform support a “prevent from deletion” feature. This safeguard ensures that you cannot delete resources in use as dependencies in other applications, thereby dramatically reducing your chances of accidentally breaking your infrastructure!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;6. Built-in Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The ability to use built-in functions within your code can have tremendous benefits. In Terraform, you have access to many different types of &lt;a href="https://www.terraform.io/language/functions#built-in-functions"&gt;functions&lt;/a&gt;. A few example categories of Terraform functions include numeric, string manipulation, encoding, date/time, and filesystem — and this is not the complete list! In comparison, CloudFormation is extremely limited, providing less than 15 intrinsic functions in total. The lack of helper functions can lead to annoying, complicated situations for basic tasks. For example, if you’re simply looking to obtain the date or time within your CloudFormation template, there’s no built-in function for this. Instead, you’ll need to create a custom resource within your template that calls a lambda function that returns the information you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  The final decision on Terraform vs CloudFormation
&lt;/h2&gt;

&lt;p&gt;Before determining between using CloudFormation or Terraform, consider your infrastructure’s needs and your organizational needs. Both CloudFormation and Terraform are flexible and powerful tools and offer comprehensive state management and automated logging. But they also provide different features that suit your infrastructure needs differently. If you’re mainly working with AWS resources, CloudFormation might work best for you. If your infrastructure relies on many third-party resources, Terraform might be a better fit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.terraform.io/intro/vs/cloudformation"&gt;https://www.terraform.io/intro/vs/cloudformation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.clickittech.com/devops/terraform-vs-cloudformation/#:~:text=While%20CloudFormation%20is%20confined%20to,most%20of%20the%20AWS%20resources"&gt;https://www.clickittech.com/devops/terraform-vs-cloudformation/#:~:text=While%20CloudFormation%20is%20confined%20to,most%20of%20the%20AWS%20resources&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://cloudonaut.io/cloudformation-vs-terraform/"&gt;https://cloudonaut.io/cloudformation-vs-terraform/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.missioncloud.com/blog/aws-cloudformation-vs-terraform-which-one-should-you-choose"&gt;https://www.missioncloud.com/blog/aws-cloudformation-vs-terraform-which-one-should-you-choose&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>terraform</category>
      <category>devops</category>
      <category>aws</category>
      <category>cloudskills</category>
    </item>
    <item>
      <title>Monitor Linux Memory Metrics in AWS CloudWatch</title>
      <dc:creator>anil augustine chalissery</dc:creator>
      <pubDate>Wed, 14 Sep 2022 12:50:13 +0000</pubDate>
      <link>https://dev.to/anilchalissery/monitor-linux-memory-metrics-in-aws-cloudwatch-1eoj</link>
      <guid>https://dev.to/anilchalissery/monitor-linux-memory-metrics-in-aws-cloudwatch-1eoj</guid>
      <description>&lt;h3&gt;
  
  
  How to install the CloudWatch agent in Ubuntu 20.04 and how to get memory metrics in the CloudWatch console
&lt;/h3&gt;

&lt;p&gt;In AWS, for the EC2 instance, we won't get memory metrics by default in CloudWatch. So one way to get this done is with the CloudWatch agent. By getting the memory metrics in AWS CloudWatch we can set up an Alarm to trigger notifications or any action. In this post, we see how the CloudWatch agent is installed in Ubuntu 20.04 and how to get memory metrics in the CloudWatch console.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create an IAM role
&lt;/h3&gt;

&lt;p&gt;As we use CloudWatch we need to authenticate to push metrics. If you are planning to implement this in an on-premise Ubuntu server, we can do this with IAM users, with programmatic access. As our instance is in EC2 we create an IAM role with the following steps.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note : if you already have an IAM role attached to instance then just attach &lt;strong&gt;CloudWatchAgentServerPolicy&lt;/strong&gt; policy to that role&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 1.1&lt;/strong&gt;: Sign in to the AWS Management Console and open the IAM console at &lt;a href="https://console.aws.amazon.com/iam/"&gt;https://console.aws.amazon.com/iam/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.2&lt;/strong&gt;: In the navigation pane of the IAM console, choose &lt;strong&gt;Roles&lt;/strong&gt;, and then choose to &lt;strong&gt;Create role&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.3&lt;/strong&gt;: &lt;strong&gt;For Select trusted entity&lt;/strong&gt;, choose AWS service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aeewQXuP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2222/1%2AIsBryefcekQqpSJHnh9pTA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aeewQXuP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2222/1%2AIsBryefcekQqpSJHnh9pTA.png" alt="Selecting trusted entity and use case" width="880" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.4&lt;/strong&gt;: Choose the use case as &lt;strong&gt;EC2&lt;/strong&gt;. Then, choose &lt;strong&gt;Next&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.5&lt;/strong&gt;: In &lt;strong&gt;Permission policies&lt;/strong&gt; search for &lt;strong&gt;CloudWatchAgentServerPolicy&lt;/strong&gt; and select that, then click &lt;strong&gt;Next&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cJlj-3c1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2510/1%2AaJVqADnZlB3io19mf1RGwA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cJlj-3c1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2510/1%2AaJVqADnZlB3io19mf1RGwA.png" alt="Attaching permission policies" width="880" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.6&lt;/strong&gt;: Give a name for the role created here we provide the name as EC2CloudWatchAgentRole. Below that we can review the things we created and, then click &lt;strong&gt;Create role&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RjjYUfO---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2040/1%2AQENg00hjL01mCwF0hI_R-A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RjjYUfO---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2040/1%2AQENg00hjL01mCwF0hI_R-A.png" alt="Providing a name for the role" width="880" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have created our IAM role.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Launch an EC2 with Ubuntu 20.04 ami
&lt;/h3&gt;

&lt;p&gt;If you already have an EC2 launched you can skip this step. If you are doing this on an on-premise instance you can skip this step(See &lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html"&gt;this&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.1:&lt;/strong&gt; Provide any name of the instance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.2:&lt;/strong&gt; Select Ubuntu Server 20.04 LTS AMI&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vWxSctdL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ACdpIJXcE_p71hp1P4SUwuA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vWxSctdL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ACdpIJXcE_p71hp1P4SUwuA.png" alt="Selecting Ubuntu 20.04 LTS AMI while creating an instance" width="779" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.3:&lt;/strong&gt; Choose t3a.micro or any instance type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.4:&lt;/strong&gt; Choose a key pair or create a new one if you don’t have access to existing key pairs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.5:&lt;/strong&gt; Keep Network settings default if you are new to VPC or customise as required&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.6:&lt;/strong&gt; Allocate more space if required. Suppose it's for testing purposes 8GB is enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.7:&lt;/strong&gt; Once reviewed you can click on &lt;strong&gt;launch instance.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we have created the instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Attach the IAM role to the instance
&lt;/h3&gt;

&lt;p&gt;Now we attach the IAM role created in Step 1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.1:&lt;/strong&gt; Select instance click &lt;strong&gt;Actions&lt;/strong&gt; then from &lt;strong&gt;Security&lt;/strong&gt; select &lt;strong&gt;Modify IAM role&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l0EDvobu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2228/1%2A8SxSJWaN_T5AD1CUv-jqag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l0EDvobu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2228/1%2A8SxSJWaN_T5AD1CUv-jqag.png" alt="Attaching role to instance" width="880" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.2:&lt;/strong&gt; Now from the drop-down you can select the role we created earlier&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9GINtXbs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AqDuFUeYZ_BFMajZjIsi-cw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9GINtXbs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AqDuFUeYZ_BFMajZjIsi-cw.png" alt="Selecting role" width="848" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the role and click &lt;strong&gt;Save&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Let's install and configure CloudWatch Agent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's run this as root so we could avoid sudo in every command.&lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rVPdC8sQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ALo7E2KNOA47Ey5p1ciqTcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rVPdC8sQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ALo7E2KNOA47Ey5p1ciqTcg.png" alt="Becoming root " width="774" height="41"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.1:&lt;/strong&gt; Download the CloudWatch agent:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget [https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb](https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jp_3_VTw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2728/1%2AeUcjI35fY2tzuRfKjvM7kw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jp_3_VTw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2728/1%2AeUcjI35fY2tzuRfKjvM7kw.png" alt="Downloading clouwatch agent" width="880" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.2:&lt;/strong&gt; Install the package:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dpkg -i -E ./amazon-cloudwatch-agent.deb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M3QmtIVA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2728/1%2AQ19hKkw1IDfKWasAs6yQQA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M3QmtIVA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2728/1%2AQ19hKkw1IDfKWasAs6yQQA.png" alt="Installing cloudwatch agent" width="880" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will create a user &lt;strong&gt;cwagent&lt;/strong&gt;, group with relevant permissions and installs the CloudWatch agent&lt;/p&gt;

&lt;p&gt;Now lets packages&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4.3:&lt;/strong&gt; Create the CloudWatch Agent Configuration File &lt;br&gt;
We could do this in two ways:&lt;br&gt;
1) Create this &lt;strong&gt;config.json&lt;/strong&gt; file directly&lt;br&gt;
2) Create the CloudWatch agent configuration file with the wizard&lt;/p&gt;

&lt;p&gt;For automating purposes I would suggest the First option. If you choose the second option, the wizard would create the &lt;strong&gt;config.json&lt;/strong&gt; for you, which also can be modified.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Creating config.json file directly&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a file named &lt;strong&gt;config.json&lt;/strong&gt; in this path &lt;strong&gt;/opt/aws/amazon-cloudwatch-agent/bin/config.json&lt;/strong&gt; and paste this JSON there&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "agent": {
  "metrics_collection_interval": 60,
  "run_as_user": "cwagent"
 },
 "metrics": {
  "aggregation_dimensions": [
   [
    "InstanceId"
   ]
  ],
  "metrics_collected": {
   "mem": {
    "measurement": [
     "mem_used_percent"
    ],
    "metrics_collection_interval": 60
   }
  }
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE : This policy is sending only memory metrics in every 60s. we have other intervals as 1s, 10s, 30s, and 60s. This metrics is fetched as cwagent&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create the CloudWatch agent configuration file with the wizard&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The questions and options are as follows&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On which OS are you planning to use the agent?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;Windows&lt;/li&gt;
&lt;li&gt;Darwin
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Trying to fetch the default region based on ec2 metadata…
Are you using EC2 or On-Premises hosts?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;EC2&lt;/li&gt;
&lt;li&gt;On-Premises
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Which user are you planning to run the agent?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;root&lt;/li&gt;
&lt;li&gt;cwagent&lt;/li&gt;
&lt;li&gt;others
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Do you want to turn on StatsD daemon?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;yes&lt;/li&gt;
&lt;li&gt;no
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Do you want to monitor metrics from CollectD? WARNING: CollectD must be installed or the Agent will fail to start&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;yes&lt;/li&gt;
&lt;li&gt;no
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Do you want to monitor any host metrics? e.g. CPU, memory, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;yes&lt;/li&gt;
&lt;li&gt;no
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Do you want to monitor CPU metrics per core?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;yes&lt;/li&gt;
&lt;li&gt;no
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName) into all of your metrics if the info is available?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;yes&lt;/li&gt;
&lt;li&gt;no
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Do you want to aggregate ec2 dimensions (InstanceId)?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;yes&lt;/li&gt;
&lt;li&gt;no
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Would you like to collect your metrics at high resolution (sub-minute resolution)? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output JSON file.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;1s&lt;/li&gt;
&lt;li&gt;10s&lt;/li&gt;
&lt;li&gt;30s&lt;/li&gt;
&lt;li&gt;60s
default choice: [4]:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Which default metrics config do you want?&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Basic&lt;/li&gt;
&lt;li&gt;Standard&lt;/li&gt;
&lt;li&gt;Advanced&lt;/li&gt;
&lt;li&gt;None
default choice: [1]:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After answering this series of questions it will create a &lt;strong&gt;config.json&lt;/strong&gt; at the same path as above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.4:&lt;/strong&gt; Check the status of the agent&lt;/p&gt;

&lt;p&gt;To check the status of the CloudWatch agent.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NAkUtgE_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2696/1%2AsN7I9cbPdlposEviRfs-Tg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NAkUtgE_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2696/1%2AsN7I9cbPdlposEviRfs-Tg.png" alt="Status before starting cwagent" width="880" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.5:&lt;/strong&gt; To start the CloudWatch agent&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GpTo0OG2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2716/1%2Aiy1S3uE5PiFph390wF17iA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GpTo0OG2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2716/1%2Aiy1S3uE5PiFph390wF17iA.png" alt="Response of starting cwagent" width="880" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check the status again to verify its running&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fAerg22B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2722/1%2AOwteAWF--l7MDaPoYIGl3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fAerg22B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2722/1%2AOwteAWF--l7MDaPoYIGl3g.png" alt="Response of status check after starting cwagent" width="880" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 5: Let's verify memory metrics are arriving in the CloudWatch console&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now to check in the AWS console, you can go to CloudWatch console, then metrics -&amp;gt; custom metrics -&amp;gt; host&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CYMI3kPb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2720/1%2AG9dZkNmC2sy2CULflse8NA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYMI3kPb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2720/1%2AG9dZkNmC2sy2CULflse8NA.png" alt="CloudWatch console" width="880" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s how we monitor Ubuntu memory utilisation with CloudWatch. Even though we used Ubuntu 20.04 this should also work in other Debian-based OS. In case you don’t find metrics in the CloudWatch console double-check the role and its access.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html"&gt;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent-commandline.html"&gt;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent-commandline.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html"&gt;https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>cloud</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>AWS VPC Traffic Mirroring</title>
      <dc:creator>anil augustine chalissery</dc:creator>
      <pubDate>Tue, 06 Sep 2022 16:46:55 +0000</pubDate>
      <link>https://dev.to/anilchalissery/aws-vpc-traffic-mirroring-41cg</link>
      <guid>https://dev.to/anilchalissery/aws-vpc-traffic-mirroring-41cg</guid>
      <description>&lt;p&gt;In this post, we will explore how to gain insight into your network traffic using Amazon VPC Traffic Mirroring. We will learn how to copy network traffic from an elastic network interface (ENI) from your EC2 instances into your VPCs and send it to the security and monitoring appliances.&lt;/p&gt;

&lt;p&gt;Before we begin we briefly go over what a network can look like and what are different native traffic monitoring capabilities available within AWS cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F8tMGs6G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AdO0-69T-wIcbuIj6HcktIw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F8tMGs6G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AdO0-69T-wIcbuIj6HcktIw.png" alt="[How traffic mirroring works](https://docs.aws.amazon.com/vpc/latest/mirroring/traffic-mirroring-how-it-works.html)" width="880" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Traffic Mirroring?
&lt;/h2&gt;

&lt;p&gt;Traffic Mirroring is an Amazon VPC feature that you can use to copy network traffic from an elastic network interface of Amazon EC2 instances. You can then send the traffic to out-of-band security and monitoring appliances for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Content inspection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Threat monitoring&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Troubleshooting&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Traffic Mirroring concepts
&lt;/h2&gt;

&lt;p&gt;The following are the key concepts for Traffic Mirroring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Source&lt;/strong&gt; — A network interface with the type instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Target&lt;/strong&gt; — The destination for mirrored traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Filter&lt;/strong&gt; — A set of rules that defines the traffic that is copied in a traffic mirror session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Session&lt;/strong&gt; — An entity that describes Traffic Mirroring from a source to a target using filters.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Get started with Traffic Mirroring
&lt;/h2&gt;

&lt;p&gt;Now we will setup traffic mirroring for a desired source and look at the captured packet on desired target. From this post you will learn how to successfully configure following components required for setting up Amazon VPC Traffic Mirroring:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Traffic mirror target&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Traffic mirror filter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Traffic mirror session&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 0: Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make sure that the traffic mirror source and traffic mirror target are in the same VPC, in different VPCs that are connected via VPC peering or a transit gateway.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure that the traffic mirror target instance allows traffic to UDP port 4789.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure that the traffic mirror source has a route table entry for the traffic mirror target.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure that there are no security group rules or network ACL rules on the traffic mirror target that drop the mirrored traffic from the traffic mirror source.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will need the following resource before proceeding&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;VPC&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IGW&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Public route table&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Public subnet&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Three EC2 instances&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Acting as client(optional we can use our local machine as client.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Acting as server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Acting as destination for mirrored traffic&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1: Create the traffic mirror target
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open the Amazon VPC console at &lt;a href="https://console.aws.amazon.com/vpc/"&gt;https://console.aws.amazon.com/vpc/&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Region&lt;/strong&gt; selector, choose the AWS Region that you used when you created the VPCs.&lt;/li&gt;
&lt;/ol&gt;


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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gWtE0g2b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2628/1%2AD-vmvsf_IOUh4vtVFpM8cg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gWtE0g2b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2628/1%2AD-vmvsf_IOUh4vtVFpM8cg.png" alt="choose **Traffic Mirroring**, **Mirror Targets**" width="880" height="1230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the navigation pane, choose &lt;strong&gt;Traffic Mirroring&lt;/strong&gt;, &lt;strong&gt;Mirror Targets&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose &lt;strong&gt;Create Traffic Mirror Target&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For &lt;strong&gt;Name tag&lt;/strong&gt;, enter a name for the traffic mirror target.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(Optional) For &lt;strong&gt;Description&lt;/strong&gt;, enter a description for the traffic mirror target.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For &lt;strong&gt;Target type&lt;/strong&gt;, choose the traffic mirror target type.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here we use &lt;strong&gt;Network Interface&lt;/strong&gt; as we are creating a target to an EC2 instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cZASdy0J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2436/1%2A0v3sePeLZJLzSEvtOpFjug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cZASdy0J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2436/1%2A0v3sePeLZJLzSEvtOpFjug.png" alt="" width="880" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For &lt;strong&gt;Target&lt;/strong&gt;, choose the traffic mirror target.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From the drop down select the ENI of our target instance(destination of mirrored traffic). We can see our ENI of instance in instance description in EC2 console. Click on &lt;strong&gt;Network Interface&lt;/strong&gt; eth0 and it will display the ENI.&lt;/p&gt;

&lt;p&gt;(Optional) Add or remove a tag.&lt;/p&gt;

&lt;p&gt;[Add a tag] Choose &lt;strong&gt;Add tag&lt;/strong&gt; and do the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For &lt;strong&gt;Key&lt;/strong&gt;, enter the key name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For &lt;strong&gt;Value&lt;/strong&gt;, enter the key value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;[Remove a tag] Next to the tag, choose &lt;strong&gt;Remove tag&lt;/strong&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B_2F8PjB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2410/1%2A75Z6n_f198FcvilUnAbtqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B_2F8PjB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2410/1%2A75Z6n_f198FcvilUnAbtqw.png" alt="Created the traffic mirror target" width="880" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create the traffic mirror filter
&lt;/h3&gt;

&lt;p&gt;A traffic mirror filter contains one or more traffic mirror rules, and a set of network services. The filters and rules that you add define the traffic that is mirrored. Now we will create traffic mirror filter&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the left navigation pane, scroll down and choose Traffic Mirroring, Mirror Filters:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose Create Traffic Mirror Target:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VhUV-76K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2044/1%2AqidzxXo8js_-bW7nolaZUQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VhUV-76K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2044/1%2AqidzxXo8js_-bW7nolaZUQ.png" alt="" width="880" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter value as show below and choose create traffic mirror filter:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ETH0OTHY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3716/1%2A26gQDufVPEc1kFeKcaoIKw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ETH0OTHY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3716/1%2A26gQDufVPEc1kFeKcaoIKw.png" alt="" width="880" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are going to mirror port 80 traffic ingressing on the server(source), hence we have created inbound rule for port 80. If you want to mirror traffic egressing from the server (source) outbound traffic, you need to create outbound rule as well.&lt;/p&gt;

&lt;p&gt;we can also get all traffic mirrored without providing port range also CIDR as 0.0.0.0/0&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--87WWMOkB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2628/1%2ApOddXonq7BiT1GUeWAi5yw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--87WWMOkB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2628/1%2ApOddXonq7BiT1GUeWAi5yw.png" alt="" width="880" height="912"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p4OUVnSz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2514/1%2ANtCzvKj1r5u_1EwbnFxTdQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p4OUVnSz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2514/1%2ANtCzvKj1r5u_1EwbnFxTdQ.png" alt="Created traffic mirror filter" width="880" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PWRtCLvL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2020/1%2AN7I6cJi3yCGgd-AB2IX37Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PWRtCLvL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2020/1%2AN7I6cJi3yCGgd-AB2IX37Q.png" alt="" width="880" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create the traffic mirror session
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the left navigation pane, scroll down and choose Traffic Mirroring, Mirror Session&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose Create Traffic Mirror session:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1iMQvkFg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2474/1%2AZ2TEB1LQ74kpfy5iCTbGmg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1iMQvkFg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2474/1%2AZ2TEB1LQ74kpfy5iCTbGmg.png" alt="" width="880" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For &lt;strong&gt;Name tag&lt;/strong&gt;, enter a name for the traffic mirror session.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For &lt;strong&gt;Description&lt;/strong&gt;, enter a description for the traffic mirror session.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;For mirror source, choose the network interface of the instance that you want to monitor. We will need the ENI of source instance so get the ENI as we did before&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For mirror target, choose the traffic mirror target. From the drop down we can select the target we created in step 1&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For &lt;strong&gt;Session number&lt;/strong&gt;, enter the session number.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use &lt;strong&gt;1&lt;/strong&gt; for the highest priority.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep all other values as default as its optional to know more about the other optional values &lt;a href="https://docs.aws.amazon.com/vpc/latest/mirroring/traffic-mirroring-getting-started.html#step-create-traffic-mirroring-sessions"&gt;refer this&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mT0idQnP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2628/1%2AOgyX1_VaiVrpo4z-XRlP3A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mT0idQnP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2628/1%2AOgyX1_VaiVrpo4z-XRlP3A.png" alt="" width="880" height="1039"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;At this point you should have your filter successfully created&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p32ag2lB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2538/1%2AoS4cgXlhjKlc8-2RIYu8AQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p32ag2lB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2538/1%2AoS4cgXlhjKlc8-2RIYu8AQ.png" alt="" width="880" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Mirror traffic
&lt;/h3&gt;

&lt;p&gt;As now our traffic mirroring target, session and filter is done now let check how to mirror traffic. In perquisite we creates three Amazon EC2 instances, they serve following purpose:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;as Client instance: (optional as we can curl from our local too. I would be good to know our public ip prior so we can verify from logs)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Using curl, we will send port 80 traffic from client to server&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Server instance:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is running web server and returns a basic hello html page. It will respond to client instances’s curl request. An Linux with Nginx or Apache would do this trick.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is also acting as a source. We are going to mirror port 80 traffic ingressing on the server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Destination instance:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Mirrored traffic is send to this instance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So lets Begin&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;From destination instance start capturing traffic with the following command
&amp;gt;  sudo tcpdump -nnni ens5 udp port 4789&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pxEIctys--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AeAXvDbeUKF3YCbkt2A6NBg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pxEIctys--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AeAXvDbeUKF3YCbkt2A6NBg.png" alt="Expected output" width="708" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Send port 80 traffic from client to server. You need to be on client instance terminal for this&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;curl &lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now in destination instance you will be getting the traffic mirrored&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J7DnidhT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AwurSBFD-g5dzOQJztBBKZA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J7DnidhT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AwurSBFD-g5dzOQJztBBKZA.png" alt="expected output" width="719" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it now traffic mirroring works fine.&lt;/p&gt;

&lt;p&gt;You can use open-source tools to monitor network traffic from Amazon EC2 instances. The following tools work with Traffic Mirroring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Zeek&lt;/strong&gt; — For more information, see the &lt;a href="https://www.zeek.org/"&gt;Zeek Network Monitor Security website&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Suricata&lt;/strong&gt; — For more information see the &lt;a href="https://suricata-ids.org/"&gt;Suricata website&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reference :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.awsnetworkshops.com/010_prerequisites/"&gt;https://www.awsnetworkshops.com/010_prerequisites/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/mirroring/what-is-traffic-mirroring.html"&gt;https://docs.aws.amazon.com/vpc/latest/mirroring/what-is-traffic-mirroring.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>tutorial</category>
      <category>awscommunity</category>
      <category>devops</category>
    </item>
    <item>
      <title>ECS Fargate with mounted EFS</title>
      <dc:creator>anil augustine chalissery</dc:creator>
      <pubDate>Wed, 31 Aug 2022 05:17:19 +0000</pubDate>
      <link>https://dev.to/anilchalissery/ecs-fargate-with-mounted-efs-4ekk</link>
      <guid>https://dev.to/anilchalissery/ecs-fargate-with-mounted-efs-4ekk</guid>
      <description>&lt;p&gt;Amazon Elastic File System (Amazon EFS) provides simple, scalable file storage for use with your Amazon ECS tasks. With Amazon EFS, storage capacity is elastic, growing and shrinking automatically as you add and remove files. Your applications can have the storage they need, when they need it.&lt;/p&gt;

&lt;p&gt;You can use Amazon EFS file systems with Amazon ECS to access file system data across your fleet of Amazon ECS tasks. That way, your tasks have access to the same persistent storage, no matter the infrastructure or container instance on which they land. When you reference your Amazon EFS file system and container mount point in your Amazon ECS task definition, Amazon ECS takes care of mounting the file system in your container. The following sections help you get started using Amazon EFS with Amazon ECS.&lt;/p&gt;

&lt;p&gt;This feature is supported by tasks that use both the EC2 and Fargate launch types, however this tutorial will use an Amazon ECS task that uses the Fargate launch type. This tutorial is also meant to be followed step by step, however if you already have some of these resources created on your account then you may be able to skip some steps.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The following resolution applies to the Fargate platform version 1.4.0 or later, which has persistent storage that you can define at the task and container level in Amazon ECS. Fargate platform versions 1.3.0 or earlier don’t support persistent storage using Amazon EFS.&lt;br&gt;
Amazon EFS may not be available in all Regions. For more information about which Regions support Amazon EFS, see Amazon Elastic File System Endpoints and Quotas in the AWS General Reference.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before you complete the steps , you must have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create_cluster.html"&gt;Amazon ECS cluster&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-getting-started.html"&gt;Amazon Virtual Private Cloud (Amazon VPC)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/tutorial-efs-volumes.html#efs-create-filesystem"&gt;Amazon EFS file system&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create and configure an Amazon EFS file system
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/efs/latest/ug/gs-step-two-create-efs-resources.html"&gt;Create an Amazon EFS file system&lt;/a&gt;, and then note the EFS ID and security group ID.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Your Amazon EFS file system, Amazon ECS cluster, and Fargate tasks must all be in the same VPC.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;To allow inbound connections on port 2049 (Network File System, or NFS) from the security group associated with your Fargate task or service, &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#AddRemoveRules"&gt;edit the security group rules of your EFS file system&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the security group of your Amazon ECS service to allow outbound connections on port 2049 to your Amazon EFS file system’s security group.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Create a task definition
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;a href="https://console.aws.amazon.com/ecs/"&gt;Amazon ECS console&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the navigation pane, choose Task Definitions, and then choose Create new Task Definition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Select launch type compatibility section, choose FARGATE, and choose Next Step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Configure task and container definitions section, for Task Definition Name, enter a name for your task definition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Volumes section, choose Add volume.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Name, enter a name for your volume.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Volume type, enter EFS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For File system ID, enter the ID for your Amazon EFS file system.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: You can specify custom options for Root directory, Encryption in transit, and EFS IAM authorization. Or, you can accept the default, where “/” is the root directory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Choose Add.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7tRNH4i6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/be8czqsxmcl8uufal8zj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7tRNH4i6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/be8czqsxmcl8uufal8zj.png" alt="volume section in task definition" width="880" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;In the Containers Definition section, choose Add container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the STORAGE AND LOGGING section, in the Mount points sub-section, select the volume that you created for Source volume in step 5.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Container path, choose your container path.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PRjCPpBJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7blnukzljmvx5jo7ku2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PRjCPpBJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7blnukzljmvx5jo7ku2.png" alt="Setting mount point in task definition" width="770" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;(Optional) In the ENVIRONMENT section, for Entry point, enter your entry point.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For Command, enter the [df ,-h] command to display the mounted file system.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: You can use the entry point and command to test if your Amazon EFS file system is mounted successfully. By default, the container exits after the df -h command executes successfully.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Choose Add.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fill out the remaining fields in the task definition wizard, and then choose Create.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Run a Fargate task and check your task logs
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Run a Fargate task using the task definition that you created earlier.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Important: Be sure to run your task on the &lt;a href="https://aws.amazon.com/blogs/containers/aws-fargate-launches-platform-version-1-4/"&gt;Fargate platform version 1.4.0&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To verify that your Amazon EFS file system is successfully mounted to your Fargate container, &lt;a href="https://docs.aws.amazon.com/AmazonECS/latest/userguide/using_awslogs.html#viewing_awslogs"&gt;check your task logs&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The output of df-h looks similar to the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DW6U1b4C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9qdm9gzexv1h1aclfl4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DW6U1b4C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9qdm9gzexv1h1aclfl4.png" alt="output screenshot from cloudwatch " width="880" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/ecs-fargate-mount-efs-containers-tasks/"&gt;How do I mount an Amazon EFS file system on an Amazon ECS container or task running on Fargate?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/efs/latest/ug/troubleshooting-efs-mounting.html"&gt;Troubleshooting Mount Issues&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>awscommunity</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
