<?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: Animesh Bhadra 🎯</title>
    <description>The latest articles on DEV Community by Animesh Bhadra 🎯 (@animeshkbhadra).</description>
    <link>https://dev.to/animeshkbhadra</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%2F594553%2F9bbc0460-d488-417f-9701-f71e78917e70.png</url>
      <title>DEV Community: Animesh Bhadra 🎯</title>
      <link>https://dev.to/animeshkbhadra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/animeshkbhadra"/>
    <language>en</language>
    <item>
      <title>Doing Elastic Ips the Right Way</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Sun, 07 Nov 2021 16:30:06 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/doing-elastic-ips-the-right-way-3f3h</link>
      <guid>https://dev.to/animeshkbhadra/doing-elastic-ips-the-right-way-3f3h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c7OX0M8z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c7OX0M8z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP.png" alt="AWS Made Easy | AWS Elastic IP" title="AWS Made Easy | AWS Elastic IP" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;You are in the middle of understanding each of the &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html"&gt;steps in creating an EC2 instance&lt;/a&gt;. You have till now learned about Instance types, AMIs, CLIs and SDKs, and the pricing of AWS EC2 instance. One important step in this is to communicate with the AWS EC2 instance. Launching an AWS EC2 instance is of no use. There should be a medium to communicate with it. The communication may be external or internal.&lt;/p&gt;

&lt;p&gt;Whichever type of communication you try to make, IPs play an important role. IP is like a unique address for your AWS EC2 instance, which can help you to connect with the instance. We have 3 types of IPs associated with an AWS EC2 instance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Private IP&lt;/li&gt;
&lt;li&gt;Public IP&lt;/li&gt;
&lt;li&gt;Elastic IP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's jump right into learning what these different types of IPs are and what are its benefits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Private IP¶
&lt;/h2&gt;

&lt;p&gt;You might have already guessed by the name, this is a private IP. This is the default IP address associated with an AWS EC2 instance. This is an IP address which disassociated with an AWS EC2 instance based on these 2 parameters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VPC in which it is present.&lt;/li&gt;
&lt;li&gt;The Subnet in within the VPC it is present.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS EC2 instance within the VPC can communicate with each other based on the private IP.&lt;/p&gt;

&lt;p&gt;Each AWS EC2 instance, will have a private IP associate with it. This private IP is visible only within the VPC and not outside it.&lt;/p&gt;

&lt;p&gt;If you want to connect to this AWS EC2 instance from your Laptop, it will not be possible as for this communication we need a Public IP.&lt;/p&gt;

&lt;p&gt;Your laptop should have a Public IP for connecting to the AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--joIl3Vz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Public-Private-IP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--joIl3Vz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Public-Private-IP.png" alt="AWS Made Easy | AWS IP | Private IP" title="AWS Made Easy | AWS IP | Private IP" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should keep these things in mind while using private IP.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Private IP on an AWS EC2 instance does not change on reboot.&lt;/li&gt;
&lt;li&gt;It also does not change when the AWS EC2 instance is in stopping state.&lt;/li&gt;
&lt;li&gt;No two AWS EC2 instance, can have the same private IP in the same VPC.&lt;/li&gt;
&lt;li&gt;You will need an AWS EC2 with private IP to launch a database system.

&lt;ul&gt;
&lt;li&gt;This provides inherit protection from attach outside the AWS environment.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h2&gt;
  
  
  Public IP¶
&lt;/h2&gt;

&lt;p&gt;AWS EC2 instance cannot function in isolation. There are certain use case which needs only private IPs, like for database machine.&lt;/p&gt;

&lt;p&gt;A web server should be open to all. If you launch a web server in an AWS EC2 instance it should be accessible from outside. You will need a public IP on this AWS EC2 instance to achieve this.&lt;/p&gt;

&lt;p&gt;Your AWS EC2 instance communicates over open Internet using a public IP. An AWS EC2 instance, can have both private and public IP associated with it.&lt;/p&gt;

&lt;p&gt;When you stop an AWS EC2 instance, it releases the public IP associated with it. Public IP are a scarce resource in AWS, it's use should demand justification.&lt;/p&gt;

&lt;p&gt;You can still keep the public IP address on the AWS EC2 instance if it reboots.&lt;/p&gt;

&lt;p&gt;All AWS EC2 instance having a public IP does not connect to the Internet. You should enable the relevant security groups.&lt;/p&gt;

&lt;p&gt;When you launch an AWS EC2 instance, in the default VPC, it has a Public IP. This is not the case of non default VPC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--joIl3Vz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Public-Private-IP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--joIl3Vz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Public-Private-IP.png" alt="AWS Made Easy | AWS IP | Public IP" title="AWS Made Easy | AWS IP | Public IP" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Elastic IP¶
&lt;/h2&gt;

&lt;p&gt;You might be wondering, Private IP and Public IP both solve a specific problem.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is the need of Elastic IP?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you want to access your AWS EC2 instance with a fixed IP every time, How do you do it? The AWS EC2 instance releases the public IP when it is in stopped state.&lt;/p&gt;

&lt;p&gt;How do you assign a Static Public IP to your AWS EC2 Instance.&lt;/p&gt;

&lt;p&gt;AWS Elastic IP belongs to an account and not to an Instance. Once you create an Elastic IP, you can assign it to any AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;The Elastic IP and the AWS EC2 has a symbiotic relationship. Once the AWS EC2 instance terminates, it frees the Elastic IP.&lt;/p&gt;

&lt;p&gt;You can remove the Elastic IP attached to current AWS EC2 instance once the purpose finishes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost of AWS Elastic IP¶
&lt;/h3&gt;

&lt;p&gt;AWS Elastic IP has a weird pricing policy. It is free to use, till it's used.&lt;/p&gt;

&lt;p&gt;If the elastic IP is not used, then it is chargeable.&lt;/p&gt;

&lt;p&gt;These conditions will determine if your Elastic IP is in use.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS EC2 instance has an Elastic IP associated with itself.&lt;/li&gt;
&lt;li&gt;The AWS EC2 instance is in running state.&lt;/li&gt;
&lt;li&gt;Only one Elastic IP attached with this AWS EC2 instance.&lt;/li&gt;
&lt;li&gt;The Elastic IP associated with an attached network interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AWS Elastic IP limits¶
&lt;/h3&gt;

&lt;p&gt;AWS limits only 5 Elastic IP address per region. You can alter the limit from the console.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Is AWS Elastic IP free?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;AWS elastic IP is free if it is in use. It's charged when not in use.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is an Elastic IP in AWS?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It is a Static public IP associated with an instance.&lt;/p&gt;

&lt;p&gt;In case of an instance failure, Elastic IP added to a new instance, without any impact on incoming traffic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Public IP Vs Elastic IP¶
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Public IP&lt;/th&gt;
&lt;th&gt;Elastic IP&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;It is associated with the AWS EC2 Instance&lt;/td&gt;
&lt;td&gt;It is associated with the AWS Account, and not the instance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public IP cannot be manually attached from one instance to another.&lt;/td&gt;
&lt;td&gt;It can be removed from one instance and attached to another.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public IP is released when the instance is stopped.&lt;/td&gt;
&lt;td&gt;Elastic IP is not released, when the instance is stopped.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public IP is free by default.&lt;/td&gt;
&lt;td&gt;Elastic IP is charged if it is Idle.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An instance, launched in default VPC will have a public IP associated with it.&lt;/td&gt;
&lt;td&gt;Elastic IP is manually assigned, it is not attached by default.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IPv4 and IPv6 support.&lt;/td&gt;
&lt;td&gt;Only IPv6 support.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vzd5YCRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Elastic-IP-Vs-Public-IP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vzd5YCRi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Elastic-IP-Vs-Public-IP.png" alt="AWS Made Easy | AWS IP | Elastic IP Vs Public IP" title="AWS Made Easy | AWS IP | Elastic IP Vs Public IP" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Static IP Vs Elastic IP¶
&lt;/h2&gt;

&lt;p&gt;AWS Elastic IP is a static public IP for an AWS account.&lt;/p&gt;

&lt;p&gt;There is a benefit in using Elastic IP&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can associate a new EC2 instance when old EC2 instance fails. &lt;/li&gt;
&lt;li&gt;This happens through code, and no manual attention required. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Assign Public IP to an AWS EC2 Instance after launch¶
&lt;/h2&gt;

&lt;p&gt;If you have an AWS EC2 instance, in running state having a private IP. How do you attach a public IP to this running instance. This is a million dollar question for you.&lt;/p&gt;

&lt;p&gt;The only option to attach a public IP to an already running AWS EC2 instance is AWS Elastic IP. You can create a new Elastic IP. Once created you can associate this Elastic IP with the running instance. The running instance picks the new Elastic Public IP.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fj7Iv2jX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Attach-Public-IP-To-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fj7Iv2jX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/06-AWS-Elastic-IP-Attach-Public-IP-To-Instance.png" alt="AWS Made Easy | AWS IP | Attach Public IP to a running AWS Instance" title="AWS Made Easy | AWS IP | Attach Public IP to a running AWS Instance" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;You have got a significant insight into the 3 different IP provided by AWS.&lt;/p&gt;

&lt;p&gt;Private IP secures the AWS EC2 instance from outside traffic. Like, in database system, you do not need any outside traffic reaching it. AWS EC2 always have a private IP.&lt;/p&gt;

&lt;p&gt;No communication inside a VPC is possible without these private IP. It's attached to the AWS EC2 instance throughout the life cycle of the instance. It's released only when the instance terminated.&lt;/p&gt;

&lt;p&gt;When the AWS EC2 instance need communication with outside world, Public IP is the medium. Web Server needs public communication. When AWS EC2 instance launched in default VPC, its comes with Public IP.&lt;/p&gt;

&lt;p&gt;It's assigned before creation or restart of the instance. The public IP is only associated with the AWS EC2 instance till instance is in running or reboot state. In any other state it release the Public IP.&lt;/p&gt;

&lt;p&gt;Elastic IP associated with an AWS account and not AWS EC2 instance. The Elastic IP switched between instances. This only supports IPv4 unlike others which supports IPv6.&lt;/p&gt;

&lt;p&gt;Elastic IP comes in helpful, when the EC2 instance fails. You can use Elastic IP reassigned to another AWS EC2. This is not a good architecture, but you should remember this is an option though not used.&lt;/p&gt;

&lt;p&gt;Now the idea of AWS elastic IP, public IP, private IP might be clear. If you want to launch an EC2 instance. Checkout, the free tier EC2 instance launch article. See &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html"&gt;Step by Step guide to create an EC2 instance&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=mgfpduy5ZAo"&gt;YouTube | Alan Rodrigues | AWS Elastic IP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=MTBR9jyD5RM"&gt;YouTube | KnowledgeIndia | AWS - Difference between Elastic, Public &amp;amp; Private IP | DEMO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=PIMls6oGc0U"&gt;YouTube | KnowledgeIndia | AWS ENI - Elastic Netwok Interface - Mutiple IPs on an EC2 (DEMO)&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html"&gt;Amazon EC2 instance IP addressing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/54128771/does-private-ip-of-an-aws-instance-change-while-instance-is-running"&gt;Does private IP of an AWS instance change while instance is running?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/55414302/an-ip-address-of-ec2-instance-gets-changed-after-the-restart"&gt;An IP address of EC2 instance gets changed after the restart&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/elastic-ip-charges/"&gt;Why am I being billed for Elastic IP addresses when all my Amazon EC2 instances are terminated?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://serverfault.com/questions/390841/difference-between-static-ip-and-elastic-ip-address"&gt;Difference between static IP and elastic IP address?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@datapath_io/elastic-ip-static-ip-public-ip-whats-the-difference-8e36ac92b8e7"&gt;Elastic IP, Static IP, Public IP. What’s the Difference?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.quora.com/Whats-the-difference-between-a-public-IP-and-an-elastic-IP-in-AWS-EC2"&gt;What's the difference between a public IP and an elastic IP in AWS EC2?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://serverfault.com/questions/706560/assign-public-ip-not-elastic-ip-after-instance-launched"&gt;Assign Public IP (not Elastic IP) after instance launched.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>ec2</category>
    </item>
    <item>
      <title>Save 72% of AWS EC2 cost with these pricing and tenancy options.</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Sun, 06 Jun 2021 05:35:22 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/save-72-of-aws-ec2-cost-with-these-pricing-and-tenancy-options-37e5</link>
      <guid>https://dev.to/animeshkbhadra/save-72-of-aws-ec2-cost-with-these-pricing-and-tenancy-options-37e5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sltrhQ2---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sltrhQ2---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy.png" alt="AWS Made Easy | AWS EC2 | Pricing and Tenancy" title="AWS Made Easy | AWS EC2 | Pricing and Tenancy" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;AWS as we know is pay as you go model. We pay for the amount of computing services we use. It is very good when we have limited requirement to compute. In a production environment, we need ways to reduce this cost. Pay as you go model does not always work in a production system. AWS provides 5 different pricing options for AWS EC2.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On-Demand&lt;/li&gt;
&lt;li&gt;Savings Plans&lt;/li&gt;
&lt;li&gt;Reserved Instance&lt;/li&gt;
&lt;li&gt;Spot Instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might be thinking where is the 5th? The 5th is called a &lt;strong&gt;Dedicated Host&lt;/strong&gt;. You can run your above instance except Spot instance on these dedicated host. Dedicated Host is not actually a pricing model, but more of a Tenancy option.&lt;/p&gt;

&lt;p&gt;You might already be getting confused. You had come to read this blog for saving some cost on your EC2 bills, but the different pricing and tenancy option is making it more confusing.&lt;/p&gt;

&lt;p&gt;Do not worry, we will peel each layer of this pricing onion and figure out the best pricing solution for your requirement. Just to know a rough hierarchy if you are not interested in reading the whole blog.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;On Demand pricing is the default and the costliest option.&lt;/li&gt;
&lt;li&gt;Spot Instance is the cheapest option, almost 90% cheaper, but not suitable for production, dedicated instance requirement.&lt;/li&gt;
&lt;li&gt;Reserved Instance and Savings Plans provide the maximum costing benefits if you commit to a certain period of usage.&lt;/li&gt;
&lt;li&gt;Dedicated host is mostly used when you have existing licenses which you want to use on the cloud.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you the above 4 lines have solved your initial pricing problem than thanks for reading. If you still have the patience to read more about the different pricing options and how it can save your cost by 72% compared to an on demand pricing read along.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS EC2 Pricing¶
&lt;/h2&gt;

&lt;p&gt;You are already aware of the 5 different pricing options of AWS. There is also a free tier, which gives 750 hours of t2.micro on Linux or windows. This is a great way to test the water in the cloud world.&lt;/p&gt;

&lt;p&gt;AWS EC2 pricing is also impacted by the amount of use an individual has on the cloud. There is no meaning of 72% reduced cost if you are learning AWS, and free tier will full fill your requirement. Let us first divide the type of user who will need these different options to save cost.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hobby User.

&lt;ul&gt;
&lt;li&gt;These users are like us, learning or trying AWS to see the services. These users should be happy with the free tier.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Amateur User

&lt;ul&gt;
&lt;li&gt;These users are the intermediate user, who have graduated from the free tier. These users can use a lot of the services on AWS and can also have little complicated requirements.&lt;/li&gt;
&lt;li&gt;These users can mostly run On Demand EC2 instance.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Professional 

&lt;ul&gt;
&lt;li&gt;The professional is the real users of AWS, which includes companies, small start-up etc.&lt;/li&gt;
&lt;li&gt;These are people whose business rely on AWS. &lt;/li&gt;
&lt;li&gt;These people often need 2-3 types of AWS environment.&lt;/li&gt;
&lt;li&gt;Development - This is the AWS account which developer uses to develop the application.&lt;/li&gt;
&lt;li&gt;Staging - This is the AWS account which is almost similar to production environment, but lower scale.&lt;/li&gt;
&lt;li&gt;Production - The real user facing application runs on Production system.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;You can understand with the above classification that AWS EC2 pricing impacts the 3rd type of user. If you fall into the first two categories the choice is pretty simple.&lt;/p&gt;

&lt;p&gt;Now let's solve the pricing problem of the Professionals and also give insight to the Amateur User on On Demand pricing.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 On Demand Pricing¶
&lt;/h3&gt;

&lt;p&gt;On-demand pricing is the default pricing model in AWS. This is the most easiest pricing model. You pay for the duration you use the EC2 instance. This is just like paying our electricity bills every month. The usage is broken into seconds.&lt;/p&gt;

&lt;p&gt;On Demand pricing includes the cost of running AMIs on the EC2 instance. The lowest priced EC2 instance is t4g.nano with 1 vCPU, with On-Demand hourly rate at $0.0042. The max priced Ec2 instance is u-6tb1.112xlarge with 448 vCPUs, and On-Demand hourly rate of $54.60.&lt;/p&gt;

&lt;p&gt;The usage duration is calculated between the time of termination or Stopping the instance. The partial hours are charged on per second basis, else charge on the full hourly basis.&lt;/p&gt;

&lt;p&gt;Kindly remember the data transfer in and out of the AWS EC2 instance is also charged.&lt;/p&gt;

&lt;p&gt;You might be thinking that there is no choice in AWS On-Demand pricing. There is no way to reduce the cost. There is one way. Generally the AWS Graviton is cheaper than the Intel Based EC2 and even the AMD based EC2 is cheaper than them. Pair a Linux AMI on these AWS Graviton or AMD based EC2 instance and you get you a significant cost savings.&lt;/p&gt;

&lt;p&gt;If you use a m6g.large, which is an AWS Graviton based EC2 instance, you are charged $0.077. If you use a m6i.large in its place which is charged $0.096 per hour. This is 24% more.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is an advantage of using the aws on-demand pricing model?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The major advantage of using AWS On-Demand pricing are these.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Off the shelf pricing, you do not have to use a lot of brain to figure out which is best for you.&lt;/li&gt;
&lt;li&gt;Highly flexible, it ranges from $0.0042 to $54.60 hourly. &lt;/li&gt;
&lt;li&gt;On-Demand pricing is the reason we have cloud computing today.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AWS EC2 Spot instance Pricing¶
&lt;/h3&gt;

&lt;p&gt;You have seen the default pricing option on AWS. The AWS EC2 spot instance is another pricing model which will suit an individual developer the most. These Instances are available at 90% discount to On Demand pricing.&lt;/p&gt;

&lt;p&gt;You might be already thinking, what is the gotcha for this drastically reduced pricing. There is no gotcha for this pricing. AWS has already dedicated data centers with huge computing power siting idle if not used. It is using EC2 Spot pricing to get some revenue of from idle instance.&lt;/p&gt;

&lt;p&gt;Think of AWS EC2 Spot instance, as an End of Season Sale. You can use all the instances, with all the configurations of On demand, but at a 90 % lower price.&lt;/p&gt;

&lt;p&gt;Little things might be bothering you right now, let's try to answer those questions.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is the disadvantage of using an EC2 Spot instance?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is no disadvantage, just remember that when AWS needs this capacity back, it will give a 2 minutes notice to wind up the current work being performed on the instances.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When would you use Spot Instances?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you have a highly containerized application which can handle the 2 minutes notice for taking away the compute capacity, then you can use AWS EC2 Spot instance for production grade application.&lt;/p&gt;

&lt;p&gt;Generally AWS EC2 Spot instance is used when you need more compute capacity, but at a lower price. These instances are very good for non mission critical application.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How can we save data for use once we lose the current pool of AWS EC2 spot instance?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can just hibernate the AWS EC2 Spot instance and it will save the local data on the EC2 instance. Once the pricing or the capacity for AWS EC2 Spot instance is available, we can reactivate these hibernated instances.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How do you tell if an instance is a spot instance?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can find the type of instance by selecting the Show/Hide Column on the AWS EC2 instance dashboard. Then we need to select the &lt;strong&gt;lifestyle&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sFNTe9_D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Enable-Spot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sFNTe9_D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Enable-Spot.png" alt="AWS Made Easy | AWS EC2 | Enable EC2 Spot instance" title="AWS Made Easy | AWS EC2 | Enable EC2 Spot instance" width="478" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should note that, once an AWS EC2 spot instance is available, there is not difference between it and an On demand instance. We can have all the ASG (Auto Scaling Groups) for these instances.&lt;/p&gt;

&lt;p&gt;We can create an AWS EC2 instance, in two ways, the first is by selecting the below step AWS EC2 instance creation process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the check box for requesting Spot instance.&lt;/li&gt;
&lt;li&gt;Provide the maximum price you are willing to pay for a Spot Instance.&lt;/li&gt;
&lt;li&gt;Lastly, mention if the request is persistent or not, if it is a persistent request, it will keep on trying to create the spot instance even after the request is full filled.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vFFwA4Ru--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Spot-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vFFwA4Ru--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Spot-Instance.png" alt="AWS Made Easy | AWS EC2 | Pricing and Tenancy" title="AWS Made Easy | AWS EC2 | Pricing and Tenancy" width="880" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also check the current pricing of the AWS EC2 Spot instance &lt;a href="https://aws.amazon.com/ec2/spot/pricing/"&gt;here&lt;/a&gt;. As shown in the screen shot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vGMbp5hn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Spot-Pricing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vGMbp5hn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Spot-Pricing.png" alt="AWS Made Easy | AWS EC2 | Spot Pricing" title="AWS Made Easy | AWS EC2 | Spot Pricing" width="880" height="213"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have now understood of two pricing mode, OnDemand and Spot instance, the issue is OnDemand is the instance you can rely on but Spot instance is something where you can run your non mission critical workloads. These workloads can survive a termination of the instance.&lt;/p&gt;

&lt;p&gt;Though you can save 90% of the cost by using AWS EC2 Spot Instance, it may not be a perfect solution for mission critical jobs. Lets show you other pricing option which will save you cost for mission critical application.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Savings Plans Pricing¶
&lt;/h3&gt;

&lt;p&gt;You have learned about 2 flexible AWS pricing option, On demand and Spot. AWS provides deep discounts if you commit to a regular usage of compute power for a predefined usage period. There are two pricing options in this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Savings Plans&lt;/li&gt;
&lt;li&gt;Reserved Instance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Savings Plans is a newer edition of Reserved Instance so first learn this. We won't have any additional baggage of learning reserved instance. We can just learn what is the use of Reserved Instance. Saving Plans provide almost the same savings as reserved instance with an additional benefit of flexibility.&lt;/p&gt;

&lt;p&gt;The flexibility offered by Savings plans is based on&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instance Family&lt;/li&gt;
&lt;li&gt;Instance Size&lt;/li&gt;
&lt;li&gt;Tenancy&lt;/li&gt;
&lt;li&gt;or Region.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In savings plans you have to commit to a usage of predefined compute power, calculated on $/per hour basis for a fixed duration of 1 or 3 years.&lt;/p&gt;

&lt;p&gt;Savings plans also offer you the option of paying in 3 modes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All Upfront&lt;/li&gt;
&lt;li&gt;Partial Upfront&lt;/li&gt;
&lt;li&gt;No Upfront.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are three AWS Savings Plan type.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compute pricing plans

&lt;ul&gt;
&lt;li&gt;This plan provides the best flexibility in terms of the variation of instance, size, tenancy and movement of the region.&lt;/li&gt;
&lt;li&gt;As it provides such flexibility the saving on this pricing plan is less, just 66% in place of the 72% promised.&lt;/li&gt;
&lt;li&gt;You can also migrate between fargate and lambda.&lt;/li&gt;
&lt;li&gt;This the best plan if you need all the flexibility. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;EC2 Instance saving Plans

&lt;ul&gt;
&lt;li&gt;If you are sure to restrict yourself to a type of instance, say &lt;code&gt;M5&lt;/code&gt; or &lt;code&gt;C4&lt;/code&gt; in a particular region.&lt;/li&gt;
&lt;li&gt;These provide the best savings of 72% in the savings plans.&lt;/li&gt;
&lt;li&gt;We can change the size of the instance from &lt;code&gt;.xlarge&lt;/code&gt; to &lt;code&gt;.2xlarge&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;We can even choose the different OS on these EC2 instance.&lt;/li&gt;
&lt;li&gt;We can change the tenancy from Host to, dedicated to, default.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;SageMaker saving plans

&lt;ul&gt;
&lt;li&gt;This plan offers 64% savings. &lt;/li&gt;
&lt;li&gt;This plan is applicable to all SageMaker Instance and provide all the flexibility of the &lt;strong&gt;Compute Pricing Plans&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Irrespective of which savings plans, you take, a few things you should always keep in mind.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Saving Plans do not provide capacity reservation.&lt;/li&gt;
&lt;li&gt;Saving Plans provide discounted pricing based on the On Demand pricing, so we cannot cancel the request.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can choose a savings plan by searching for "Saving Plans" in AWS console, and you will get a screen like below. Choose the type of plan you want as described earlier. You also need to select the term of 1 year or 3 years.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ASzlckB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Saving-Plan-01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ASzlckB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Saving-Plan-01.png" alt="AWS Made Easy | AWS EC2 | Saving Plan 01" title="AWS Made Easy | AWS EC2 | Saving Plan 01" width="880" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you select the Type of plan and the term, next is to choose the hourly pricing. You can take help of the AWS Cost Explorer. The AWS Cost Explorer will check for your existing usage and suggest an appropriate plan to purchase.&lt;/p&gt;

&lt;p&gt;Next just select the payment option mentioned earlier. Choose a start date and done.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0pYJVeoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Saving-Plan-02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0pYJVeoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Saving-Plan-02.png" alt="AWS Made Easy | AWS EC2 | Saving Plan 01" title="AWS Made Easy | AWS EC2 | Saving Plan 01" width="880" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Can you sell AWS savings plans?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You cannot resell the AWS Savings plans like the Reserved Instance had a marketplace.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Can you cancel AWS savings plan?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once purchased, you cannot cancel the AWS Savings plans.&lt;/p&gt;

&lt;p&gt;You are now aware of AWS Savings Plans, which is also called Reserved Instance 2.0 or (RI 2.0). Now let take a step back and learn about the Reserved Instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Reserved Instance Pricing¶
&lt;/h3&gt;

&lt;p&gt;You have already learned about Savings Plans which is an improvement over Reserved Instances. You might be wondering what was in reserve instance, that led to creating savings plans. Reserved Instance and Savings plans looks almost the same.&lt;/p&gt;

&lt;p&gt;You might still be wondering, will reserved instance exists down the like as savings plans are flexible. Let's try to find some of those answers and in the process learn about reserving instance.&lt;/p&gt;

&lt;p&gt;The first thing to note is when you say reserved instance, it does not mean a physical instance reserved for you in AWS. It's just a terminology for a billing discount. This discount is applied to the On Demand prices.&lt;/p&gt;

&lt;p&gt;The reserved pricing also based on 3 factors.&lt;/p&gt;

&lt;p&gt;The first one and the very obvious one being instance type. You have to choose the same 4 attributes for an instance you chose in the savings plan.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instance Type - &lt;code&gt;m4.large&lt;/code&gt;, You have to select both instance family type and the size of the instance.&lt;/li&gt;
&lt;li&gt;Region - Obviously, you have to tell the region where the instance would be needed, as EC2 is a regional service.&lt;/li&gt;
&lt;li&gt;Tenancy - If you want to run it on the shared tenancy model or already have any dedicated instance.&lt;/li&gt;
&lt;li&gt;Platform - Unix or Window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above choice is almost similar to the EC2 Instance saving Plans, the difference being, we selected the family of instance there, and the size of instances could be changed.&lt;/p&gt;

&lt;p&gt;Once you are ready with your instance type, the next selection you have to do is for the Term commitment. There are same 2 choice like EC2 Instance saving Plans. The bigger the commitment you give, the bigger is the savings.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One - year &lt;/li&gt;
&lt;li&gt;Three - year&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The thing to note here is, the term does not get renewed automatically, we have to renew it else it will be charged on the on-demand rates once the term ends.&lt;/p&gt;

&lt;p&gt;There are similar payment option like EC2 Instance saving Plans, and the names are self explanatory, The more you pay upfront the more you save.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All Upfront&lt;/li&gt;
&lt;li&gt;Partial Upfront &lt;/li&gt;
&lt;li&gt;No Upfront - You are required to have a billing history before you opt for this option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The reserved instance also provides some flexibility depending on something called an offering class.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard 

&lt;ul&gt;
&lt;li&gt;It allows some attributes of the instance to be modified.&lt;/li&gt;
&lt;li&gt;These instances can't be exchanged.&lt;/li&gt;
&lt;li&gt;It can be bought and sold in a Reserved instance marketplace.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Convertible

&lt;ul&gt;
&lt;li&gt;It also allows some instance attributes to be modified.&lt;/li&gt;
&lt;li&gt;These instances can be exchanged.&lt;/li&gt;
&lt;li&gt;It cannot be bought and sold in the marketplace.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;You cannot cancel your purchase of Reserved Instances. Though depending on the type of offering class you have chosen, you can modify, exchange or sell the reserved instance.&lt;/p&gt;

&lt;p&gt;There are also two different types of Reserved instance, you can purchase.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regional Reserved Instance

&lt;ul&gt;
&lt;li&gt;This does not provide capacity reservation.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Zonal Reserved Instance

&lt;ul&gt;
&lt;li&gt;These provide capacity reservation on an Availability Zone.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Here is a snapshot to depict the type of savings you can get based on the reserved instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pht1GSJA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Reserved-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pht1GSJA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Reserved-Instance.png" alt="AWS Made Easy | AWS EC2 | Reserved Instance" title="AWS Made Easy | AWS EC2 | Reserved Instance" width="880" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Can I cancel AWS Reserved Instance?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You cannot cancel your AWS Reserved Instance once you have purchased it. You can modify the instance, or trade them in the reserved instance market place.&lt;/p&gt;

&lt;p&gt;You have learned about the Reserved Instance, and also learned that there is a capacity reservation in case of Zonal Reserved Instances, let us see how this capacity reservation helps us.&lt;/p&gt;

&lt;p&gt;Can we reserve capacity when using Regional reserved instance, or AWS EC2 Savings Plans. These 2 does not offer any capacity reservation.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Capacity Reservation¶
&lt;/h3&gt;

&lt;p&gt;You have Zonal Capacity Reservation, which reserves capacity in a particular Availability Zone. This reservation provides a type of peace of mind, knowing that you can launch an EC2 instance at any given moment during high traffic as there is reservation.&lt;/p&gt;

&lt;p&gt;AWS EC2 Savings plans and Regional Reserved Instance do not have this option, we can enable this by creating an independent capacity reservation. When you create a capacity reservation, you have to specify,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Availability Zone (AZs) in which the capacity will be reserved.&lt;/li&gt;
&lt;li&gt;The Number of instance &lt;/li&gt;
&lt;li&gt;Instance attributes, like tenancy, instance type etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please note that the capacity reservation will only be applicable only when you have the above matching instance running. If there is a mismatch the above capacity reservation will not be applied.&lt;/p&gt;

&lt;p&gt;You have learned about all the pricing options available for an AWS instance, be it the default On Demand pricing, or highly discounted Spot instance used for non productive work, and immensely save cost using reserved instance or savings plans (RI 2.0).&lt;/p&gt;

&lt;p&gt;There is also another factor for AWS instance, i.e. the tenancy, the physical host on which you run the AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;You cannot run an AWS EC2 instance, in a shared mode, which is the default because of compliance with laws in any case and in some case because of efficiency. Let's dive into the world of AWS EC2 tenancy.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS EC2 Tenancy¶
&lt;/h2&gt;

&lt;p&gt;You can see in the below snapshot, that there are 3 types of tenancy available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---dAfMaHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Options.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---dAfMaHe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Options.png" alt="AWS Made Easy | AWS EC2 | Pricing and Tenancy" title="AWS Made Easy | AWS EC2 | Pricing and Tenancy" width="880" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shared Tenancy&lt;/li&gt;
&lt;li&gt;Dedicated Instance&lt;/li&gt;
&lt;li&gt;Dedicated Host&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tenancy is just like we rent a house when we move to a new city. How we move between houses is what is called tenancy.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Shared Host¶
&lt;/h3&gt;

&lt;p&gt;Share Host or Tenancy, it is more like few friend rents 2 or more houses in the city. The rent of the house is being paid, but which individual stays in which house is not predictable.&lt;/p&gt;

&lt;p&gt;You can live in one house, but for a party, you can to the other house, if you sleep there, you will wake up in the same house, but if you leave the house there is an option you can land it either of the two houses.&lt;/p&gt;

&lt;p&gt;The same is the case with AWS EC2 instance, when in the shared tenancy mode, the AWS EC2 instance can be launched on any physical machine. In case of reboot only the host will remain same else when you start or stop the instance can switch to a new host or physical machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Dedicated Instance¶
&lt;/h3&gt;

&lt;p&gt;The next one is a dedicated instance, it is more like a township of a big factory in a remote place. The township is created by the factory as people who work in the factory has to live.&lt;/p&gt;

&lt;p&gt;You can live in one house in the township created by the factory and then in few years move to a bigger or a better house in the same township as you may seem suitable.&lt;/p&gt;

&lt;p&gt;AWS EC2 dedicated instance is also a lot similar, when an instance is launched in this mode, AWS makes sure that it launches this instance, in the same physical host which has another instance of the same AWS Account.&lt;/p&gt;

&lt;p&gt;When you stop and restart the instance it may not start the instance on the same instance, but it will make sure it starts the instance on a physical host where only your account instance are running.&lt;/p&gt;

&lt;p&gt;_When would you use a dedicated instance?_Compliance is a big reason why you would want to launch a dedicated instance.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Dedicated Host¶
&lt;/h3&gt;

&lt;p&gt;When you are more stable in your life, with family, you need a house which you do not have to change. This is where you buy your own house.&lt;/p&gt;

&lt;p&gt;The AWS EC2 dedicated host is also similar. A lot of time, especially in Banks and other financial organization they need surety that the application is running on a server which is physically separated from the other.&lt;/p&gt;

&lt;p&gt;In addition to the compliance issue, there is also the case of software licenses, some costly licenses are per machine basis, if you have a physical server with AWS running only your instance, then you can move your licenses to these servers.&lt;/p&gt;

&lt;p&gt;You can create your own dedicated host by selecting the proper option in the below snapshot. This we will discuss in details later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F_KtpYqj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Dedicated-Host-01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F_KtpYqj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Dedicated-Host-01.png" alt="AWS Made Easy | AWS EC2 | Dedicated Host" title="AWS Made Easy | AWS EC2 | Dedicated Host" width="880" height="375"&gt;&lt;/a&gt; &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uIiR0I0K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Dedicated-Host-02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uIiR0I0K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Dedicated-Host-02.png" alt="AWS Made Easy | AWS EC2 | Dedicated Host" title="AWS Made Easy | AWS EC2 | Dedicated Host" width="880" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the three main reasons for using a dedicated host?* The main reason for using dedicated host is compliance. Software licenses bought per machine basis is also a reason for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;_What happens if the physical host we are using goes down?_If failure is detected on the physical host then AWS runs something called a Host recovery, which will basically recreate the same host instance setting. You can also use the AWS licenses Manager to migrate the licenses to this new machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison¶
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Regional Vs Zonal Reserved Instance¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Regional Reserved Instance&lt;/th&gt;
&lt;th&gt;Zonal Reserved Instance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Does not provide any capacity reservation.&lt;/td&gt;
&lt;td&gt;Provides capacity reservation in a specific Availability Zone.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reserved instance discount applies to any instance running in the region.&lt;/td&gt;
&lt;td&gt;The discount is only specific to a Availability Zone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It provides flexibility in the same instance class, you can change the size of the instance.&lt;/td&gt;
&lt;td&gt;It is very specific to the instance type and its corresponding size.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The purchase can be queued.&lt;/td&gt;
&lt;td&gt;The purchase cannot be queued.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The limit of regional reserved instance to be launched is equal to the limit of the EC2 instance that can be launched in the region.&lt;/td&gt;
&lt;td&gt;This provides addition limit from the regional limits.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;This is just a billing discount.&lt;/td&gt;
&lt;td&gt;Capacity reservation comes paired withe the discount.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Additional capacity reservation can be taken to make it more flexible.&lt;/td&gt;
&lt;td&gt;No additional flexibility can be taken.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rFNj3O5W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Reserved-Instance-Regional-Vs-Zonal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rFNj3O5W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Reserved-Instance-Regional-Vs-Zonal.png" alt="AWS Made Easy | AWS EC2 | Regional Vs Zonal RIs" title="AWS Made Easy | AWS EC2 | Regional Vs Zonal RIs" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Standard Vs Convertible Reserved Instance¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Standard Reserved Instance&lt;/th&gt;
&lt;th&gt;Convertible Reserved Instance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;You can modify only the Availability Zone, Scope, Networking Type and instance Size.&lt;/td&gt;
&lt;td&gt;You can modify the instance family, OS, and tenancy in addition.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It cannot be exchanged.&lt;/td&gt;
&lt;td&gt;It can be exchanged as long as the new instance is also convertible of higher or same pricing.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It can be bought and sold in the reserved instance marketplace.&lt;/td&gt;
&lt;td&gt;It cannot be bought and sold in the reserved instance marketplace.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It provides the limited flexibility in configuration changes.&lt;/td&gt;
&lt;td&gt;It provides the maximum flexibility in configuration changes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Limited flexibility, hence highest discount.&lt;/td&gt;
&lt;td&gt;Maximum Flexibility, hence limited discount&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7s2CPopr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Reserved-Instance-Standard-Vs-Convertible.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7s2CPopr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Reserved-Instance-Standard-Vs-Convertible.png" alt="AWS Made Easy | AWS EC2 | Standard Vs Convertible" title="AWS Made Easy | AWS EC2 | Standard Vs Convertible" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Compute Vs EC2 Savings Plans¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compute Savings Plans&lt;/th&gt;
&lt;th&gt;EC2 Savings Plans&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Provides the maximum flexibility.&lt;/td&gt;
&lt;td&gt;Provides the minimum flexibility.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Provides the minimum discount.&lt;/td&gt;
&lt;td&gt;Provides the maximum discount.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Discount can go up to 66%.&lt;/td&gt;
&lt;td&gt;Discount can go up to 72%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flexible across Instance family, AWS ECS, EKS using Fargate and even Lambda.&lt;/td&gt;
&lt;td&gt;Flexible only across the instance size.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can be compared to Convertible Reserved Instance.&lt;/td&gt;
&lt;td&gt;Can be compared to Standard Reserved Instance.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8JkhaYcY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Savings-Plans-Compute-Vs-EC2-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8JkhaYcY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Savings-Plans-Compute-Vs-EC2-Instance.png" alt="AWS Made Easy | AWS EC2 | Compute Vs EC2 Savings Plans" title="AWS Made Easy | AWS EC2 | Compute Vs EC2 Savings Plans" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Compute Savings Plans Vs Convertible Reserved Instance¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Compute Savings Plans&lt;/th&gt;
&lt;th&gt;Convertible Savings Plans&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;66% discount&lt;/td&gt;
&lt;td&gt;66% discount&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does not provide capacity reservation.&lt;/td&gt;
&lt;td&gt;Does not provide capacity reservation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same term or 1 or 3 years.&lt;/td&gt;
&lt;td&gt;Same term or 1 or 3 years.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Applies the pricing discount automatically across instance family, tenancy or OS.&lt;/td&gt;
&lt;td&gt;The benefits needs to be manually applied. across instance family, tenancy or OS.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flexible across region.&lt;/td&gt;
&lt;td&gt;Not flexible across region.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V3FjIimO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Compute-Savings-Plans-Vs-Convertible-RI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V3FjIimO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Compute-Savings-Plans-Vs-Convertible-RI.png" alt="AWS Made Easy | AWS EC2 | Compute Savings Vs Convertible RIs" title="AWS Made Easy | AWS EC2 | Compute Savings Vs Convertible RIs" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  EC2 Savings Plans Vs Standard Reserved Instance¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;EC2 Savings Plans&lt;/th&gt;
&lt;th&gt;Standard Savings Plans&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;72% discount&lt;/td&gt;
&lt;td&gt;72% discount&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does not provide capacity reservation.&lt;/td&gt;
&lt;td&gt;Does not provide capacity reservation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Same term or 1 or 3 years.&lt;/td&gt;
&lt;td&gt;Same term or 1 or 3 years.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Applies the pricing discount automatically across instance size, tenancy or OS.&lt;/td&gt;
&lt;td&gt;The benefits needs to be manually applied. across instance size, tenancy or OS.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2HMguHmt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-EC2-Savings-Plans-Vs-Standard-RI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2HMguHmt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-EC2-Savings-Plans-Vs-Standard-RI.png" alt="AWS Made Easy | AWS EC2 | EC2 Savings Vs Standard RIs" title="AWS Made Easy | AWS EC2 | EC2 Savings Vs Standard RIs" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Reserved Instances vs Savings Plan¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Savings Plans&lt;/th&gt;
&lt;th&gt;Reserved Instances&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;66% to 72% discount&lt;/td&gt;
&lt;td&gt;66% to 72% discount&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Discount is provided on On-Demand price based on the spending commitment.&lt;/td&gt;
&lt;td&gt;Discount is provided on On-Demand price based on the utilisation commitment.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ECS, Fargate &amp;amp; Lambda are also covered in this discount.&lt;/td&gt;
&lt;td&gt;None of these services are covered in RIs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RDS instance are not covered under the Savings plans&lt;/td&gt;
&lt;td&gt;RDS instance are covered under RIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;There is no marketplace for Savings Plans&lt;/td&gt;
&lt;td&gt;There is a marketplace for Reserved Instance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;There is no capacity reservation.&lt;/td&gt;
&lt;td&gt;There is a capacity reservation in Zonal RIs.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b_JQnksA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Savings-Plans-Vs-Reserved-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b_JQnksA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Savings-Plans-Vs-Reserved-Instance.png" alt="AWS Made Easy | AWS EC2 | Savings Plans Vs Reserved Instance" title="AWS Made Easy | AWS EC2 | Savings Plans Vs Reserved Instance" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Dedicated Instances vs Dedicated Host¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dedicated Instances&lt;/th&gt;
&lt;th&gt;Dedicated Host&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The Instance is not guaranteed to launch on same host.&lt;/td&gt;
&lt;td&gt;The complete Host is dedicated.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The instance is always launched on host where same account instance are running.&lt;/td&gt;
&lt;td&gt;The instance is always running on the same host.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You cannot use license which is per machine basis.&lt;/td&gt;
&lt;td&gt;You can use license which are per machine basis.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It can be of any instance type.&lt;/td&gt;
&lt;td&gt;The machine is based on instance type, so different size of same instance type can be launched.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;There is no compute power wastage.&lt;/td&gt;
&lt;td&gt;If the completed compute power of the host is not used, then the wastage is your responsibility.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vVmKKf9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Dedicated-host-Vs-dedicated-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vVmKKf9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/05-AWS-EC2-Tenancy-Dedicated-host-Vs-dedicated-Instance.png" alt="AWS Made Easy | AWS EC2 | Dedicated Instance Vs Dedicated Host" title="AWS Made Easy | AWS EC2 | Dedicated Instance Vs Dedicated Host" width="880" height="2000"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;AWS Pricing and tenancy is little confusing. There are just too many terms to go over. Let's keep it simple, Tenancy mean who owns the actual resources. Pricing means the discount provided for better commitment.&lt;/p&gt;

&lt;p&gt;You should understand that in AWS Pricing options, except EC2 on-demand pricing and spot instance, the other two are just discount on the bill over the on-demand price.&lt;/p&gt;

&lt;p&gt;On-demand is the default pricing options, and it is the costliest option. This can be used for production environment.&lt;/p&gt;

&lt;p&gt;AWS Spot instance, are the unused instance, which AWS sells at a cheap discount. These are good for non productive work. AWS gives a 2 minute window to wind up the current activity on the instance before reclaiming.&lt;/p&gt;

&lt;p&gt;Now coming to the discount schemes, both Reserved Instance and Savings Plans provide somewhere up to 66% to 72% discount over on-demand prices. This discount is based on commitment from us, to make use of the compute power for certain predefined duration, or agreeing to pay a certain amount per hour for using the same instance.&lt;/p&gt;

&lt;p&gt;Savings plans are the newer version of discount pricing. It gives a better discount when you commit to a pay per hour a certain amount for compute usage. It also extends beyond just EC2 instance to AWS Fargate, ECS and AWS Lambda.&lt;/p&gt;

&lt;p&gt;There is a one plan which is very flexible, Compute Savings Plans, this provide lots of choice in instance family, size, tenancy, etc.As this is a flexible option it provides limited savings.&lt;/p&gt;

&lt;p&gt;If you are okay with a particular type of EC2 instance in a particular region, then EC2 Savings plans are a great plan, which can save you up to 72% from on-demand prices.&lt;/p&gt;

&lt;p&gt;Savings plans are still not applicable to AWS RDS.&lt;/p&gt;

&lt;p&gt;The last pricing option to discuss is the AWS Reserved Instances. This pricing option lowers the bill if we commit to a certain type or EC2 instance for a certain duration of time. The Reserved instance comes in 2 form like Savings Plans, Standard and convertible.&lt;/p&gt;

&lt;p&gt;The difference between these 2 is that, the provide what degree of flexibility. More flexibility means less discount.&lt;/p&gt;

&lt;p&gt;AWS has there type of tenancy. Shared, Dedicated Instance, and dedicated host.&lt;/p&gt;

&lt;p&gt;Shared is the default tenancy mode, where an instance can come up on any number of physical hosts, with instance from other account also present on the same server.&lt;/p&gt;

&lt;p&gt;Dedicated Instance means that the instance will only be launched in a physical server where it is already running the instance from the same account.&lt;/p&gt;

&lt;p&gt;Dedicated hosting, means that the completed physical server is owned by you. You have to just books an instance type. Per software licenses loves such server.&lt;/p&gt;

&lt;p&gt;Now the idea of AWS EC2 tenancy and pricing might be clear. If you want to launch an EC2 instance. Checkout, the free tier EC2 instance launch article. see &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html"&gt;Step by Step guide to create an EC2 instance&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reinvent Videos

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=uQ9ry-9uUvo"&gt;AWS re:Invent 2019: [REPEAT 1] Dive deep on how to save with AWS Savings Plans (CMP210-R1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=7q5AeoKsGJw"&gt;AWS re:Invent 2019: Save up to 90% and run production workloads on Spot Instances (CMP331-R1)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;YouTube Videos

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=sOsALtwltLQ"&gt;AWS - Shared, Dedicated Instances &amp;amp; Dedicated Host Differences - EC2 Tenancy Models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=YvZ4seVgyYY&amp;amp;list=PLTyrc6mz8dg9AIAuZocHAqekMgA0eDfQb"&gt;Pricing PlayList&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=cbV8bnbMe9w"&gt;Introducing Savings Plans for Amazon EC2, AWS Fargate, and AWS Lambda - AWS Online Tech Talks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=c_zlPQimrvY"&gt;AWS Savings Plan - Nov 2019&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;AWS Tenancy

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://theithollow.com/2017/10/16/understanding-aws-tenancy/"&gt;Understanding AWS Tenancy.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-dedicated-instances.html"&gt;Configuring instance tenancy with a launch configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.trek10.com/blog/dedicated-hosts-and-dedicated-instances"&gt;What is the Difference Between Dedicated Hosts and Dedicated Instances on AWS?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;AWS EC2 Pricing

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/ec2/pricing/"&gt;Amazon EC2 pricing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Savings Plans

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/aws/new-savings-plans-for-aws-compute-services/"&gt;New – Savings Plans for AWS Compute Services&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/savingsplans/"&gt;AWS Savings Plans&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Spot Instance

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/61906684/how-to-identify-if-a-ec2-instance-is-a-spot-instance-or-a-on-demand-instance"&gt;How to Identify if a ec2 instance is a spot instance or a on demand instance?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=H24h3DoOZtE"&gt;Launch an AWS Spot Instance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html"&gt;Using AWS EC2 Spot Instance.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;AWS Reserved Instances

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-reserved-instances.html"&gt;Reserved Instances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/whitepapers/latest/cost-optimization-reservation-models/cost-optimization-reservation-models.pdf"&gt;Amazon EC2 Reserved Instances and Other AWS Reservation Models AWS Whitepaper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Capacity Reservation.

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-capacity-reservations.html"&gt;On-Demand Capacity Reservations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


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

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awsec2</category>
    </item>
    <item>
      <title>The unconventional guide to AWS EC2 instance types.</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Mon, 10 May 2021 11:46:09 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/the-unconventional-guide-to-aws-ec2-instance-types-2kkk</link>
      <guid>https://dev.to/animeshkbhadra/the-unconventional-guide-to-aws-ec2-instance-types-2kkk</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Y5vbrop--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Y5vbrop--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type.png" alt="AWS Made Easy | AWS EC2 Instance Type" title="AWS Made Easy | AWS EC2 Instance Type"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;AWS EC2 instance is the heart of AWS. They are the real server.&lt;/p&gt;

&lt;p&gt;An AWS EC2 instance, has to support workload all across the boards, right from a web server, to FPGA and even HPC.&lt;/p&gt;

&lt;p&gt;AWS EC2 instance supports all forms of computing needs. The hardware choice is diverse for such needs.&lt;/p&gt;

&lt;p&gt;You have 350 types of different AWS EC2 instance, in the year 2021. Selecting the right AWS EC2 instance from these big piles will be difficult.&lt;/p&gt;

&lt;p&gt;In this article you will learn how can you choose the correct AWS EC2 instance without breaking the bank. You will also learn about the various types of the AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;If you are studying for AWS Certification. You will also learn about the AWS EC2 instance naming convention. What does the AWS decides on the instance sizing. It will also help you with understanding the various instance type, and make its home in your memory. This is by far the best technique to remember the various names of the AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;Let's jump right in.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS EC2 Naming Convention.¶
&lt;/h2&gt;

&lt;p&gt;The first thing you should learn is&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How is the AWS EC2 instance, getting their name?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What does a name like &lt;code&gt;M5d.xlarge&lt;/code&gt; means?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The below image may help you understand that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CBtelxr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Naming-Convention.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CBtelxr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Naming-Convention.png" alt="AWS Made Easy | AWS EC2 | Instance Naming Convention" title="AWS Made Easy | AWS EC2 | Instance Naming Convention"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you look, these four component form the Instance Type.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instance Size&lt;/li&gt;
&lt;li&gt;Instance Family&lt;/li&gt;
&lt;li&gt;Instance Generation&lt;/li&gt;
&lt;li&gt;Additional Capability&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AWS EC2 Instance Size¶
&lt;/h3&gt;

&lt;p&gt;First, you should know the easy stuff, what does the &lt;code&gt;xlarge&lt;/code&gt; means in the AWS EC2 naming convention?&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;xlarge&lt;/code&gt; denotes the T-shirt size representation of the AWS EC2 instance. It defines the amount of&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;li&gt;Network Performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An AWS EC2 instance possesses.&lt;/p&gt;

&lt;p&gt;Now lets explore the &lt;code&gt;M5d&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Instance Family¶
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;M&lt;/code&gt; means that AWS EC2 instance belongs to General purpose computing instance type. This is the &lt;code&gt;M&lt;/code&gt;ain Computing AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;You have five main categories of instance types.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;General Purpose&lt;/li&gt;
&lt;li&gt;Compute Optimized&lt;/li&gt;
&lt;li&gt;Memory Optimized&lt;/li&gt;
&lt;li&gt;Storage Optimized&lt;/li&gt;
&lt;li&gt;Accelerated Computing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You also have sub classification with-in the five classifications.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Instance Generation¶
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;5&lt;/code&gt; in &lt;code&gt;M5d&lt;/code&gt; represents the generation of the AWS EC2 instance. &lt;code&gt;5&lt;/code&gt; is the current generation. The latest (current) generation of AWS EC2 instance is always better than a previous generation.&lt;/p&gt;

&lt;p&gt;If you use the &lt;a href="https://calculator.aws/#/createCalculator/EC2"&gt;EC2 pricing calculator,&lt;/a&gt; you will find the pricing between an &lt;code&gt;m4.large&lt;/code&gt; and &lt;code&gt;m5.large&lt;/code&gt; is as below.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for m5.large in the US East (Ohio) for 1 Year term and No Upfront is 0.06 USD&lt;/p&gt;

&lt;p&gt;EC2 Instance Savings Plans rate for m4.large in the US East (Ohio) for 1 Year term and No Upfront is 0.062 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you take the percentage, you have to pay &lt;code&gt;3.33%&lt;/code&gt; more for using an older generation AWS EC2. With this in mind, always choose the latest generation of hardware.&lt;/p&gt;

&lt;p&gt;If the need is for a specific hardware, then choose the previous generation hardware.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS EC2 Additional capability¶
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;d&lt;/code&gt; in &lt;code&gt;M5d&lt;/code&gt; represents an additional capability.&lt;/p&gt;

&lt;p&gt;Here is a table of additional capabilities.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;Representation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AMD&lt;/td&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Graviton2&lt;/td&gt;
&lt;td&gt;g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local NVMe SSD&lt;/td&gt;
&lt;td&gt;d&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;High networking(100Gbps)&lt;/td&gt;
&lt;td&gt;n&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extra capacity&lt;/td&gt;
&lt;td&gt;e&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now you are aware of the different component of the AWS EC2 name.&lt;/p&gt;

&lt;p&gt;Every Instance size(xLarge) will have twice the number or CPU and Memory and storage resource from the previous size(large). How does this happen, jump forward to find it out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Instance Sizing¶
&lt;/h2&gt;

&lt;p&gt;The below image, helps you understand this concept. Each instance size (xlarge) will have twice the number of CPU and memory than previous size (large).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CH9-vMt9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Sizing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CH9-vMt9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Sizing.png" alt="AWS Made Easy | AWS EC2 | Instance Type Sizing" title="AWS Made Easy | AWS EC2 | Instance Type Sizing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should not believe the above image, lets talk data, use the &lt;a href="(https://calculator.aws/#/createCalculator/EC2)"&gt;AWS EC2 pricing calculator.&lt;/a&gt; It helped in creating the below table.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Instance Size&lt;/th&gt;
&lt;th&gt;vCPUs&lt;/th&gt;
&lt;th&gt;Memory (GiB)&lt;/th&gt;
&lt;th&gt;Network Performance&lt;/th&gt;
&lt;th&gt;1yr Std reserved hourly cost&lt;/th&gt;
&lt;th&gt;Price increase&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;.large&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;upto 10 Gbps&lt;/td&gt;
&lt;td&gt;0.06&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.xlarge&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;upto 10 Gbps&lt;/td&gt;
&lt;td&gt;0.121&lt;/td&gt;
&lt;td&gt;101.67 %&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.2xlarge&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;upto 10 Gbps&lt;/td&gt;
&lt;td&gt;0.242&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.4xlarge&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;64&lt;/td&gt;
&lt;td&gt;upto 10 Gbps&lt;/td&gt;
&lt;td&gt;0.484&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.8xlarge&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;128&lt;/td&gt;
&lt;td&gt;10 Gbps&lt;/td&gt;
&lt;td&gt;0.968&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The table and the image representation completely match. &lt;code&gt;xlarge&lt;/code&gt; has twice the number of vCPU and the memory compared to &lt;code&gt;large&lt;/code&gt;. The pricing for 1 yr reserved hourly cost, is twice.&lt;/p&gt;

&lt;p&gt;This poses an important question, while choosing the size. Will one go for 1 &lt;code&gt;8xlarge&lt;/code&gt; instance or 8 &lt;code&gt;xlarge&lt;/code&gt; instance.&lt;/p&gt;

&lt;p&gt;Multiplying &lt;code&gt;0.121 * 8 = 0.968&lt;/code&gt; tells that there is no difference between the two. You can pick any of the combinations.&lt;/p&gt;

&lt;p&gt;The load on the service is not linear, it is a curve. This is not considered in the above multiplication.&lt;/p&gt;

&lt;p&gt;If you remember the &lt;a href="https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm"&gt;Bresenham's line drawing algorithm.&lt;/a&gt;It tells us, how to draw a line using square pixels.&lt;/p&gt;

&lt;p&gt;The line can only be smooth if you have many dense pixels. The AWS EC2 instance, can match the uneven load if you have much granular AWS EC2 instance size.&lt;/p&gt;

&lt;p&gt;It is always better to use a lower instance size. Use a Higher instance size if you have a specific need for it.&lt;/p&gt;

&lt;p&gt;There are far to many instance classifications of AWS EC2, lets learn about them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Instance Classification¶
&lt;/h2&gt;

&lt;p&gt;The below image represent the relations of different AWS Instance Type. It has an alphabet written on a Green background. It will tell you the value of Instance Familyin AWS EC2 Naming Convention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NcdLQJ3x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Instance-Classification.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NcdLQJ3x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Instance-Classification.png" alt="AWS Made Easy | AWS EC2 | Instance Classification" title="AWS Made Easy | AWS EC2 | Instance Classification"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will only focus on the naming of the classification and sub classification. The details of these classifications will come later.&lt;/p&gt;

&lt;p&gt;There are five main categories of the AWS EC2 instance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;General Purpose

&lt;ul&gt;
&lt;li&gt;General Purpose - T3/T4g Instance&lt;/li&gt;
&lt;li&gt;Development environment for application can use the T3/T4g instance. &lt;/li&gt;
&lt;li&gt;Transient or Temporary are a nice way to remember this sub classification. &lt;/li&gt;
&lt;li&gt;The short burst of CPU power which it will need is available. &lt;/li&gt;
&lt;li&gt;General Purpose - M5 Instance&lt;/li&gt;
&lt;li&gt;This is the main general purpose compute choice in AWS EC2. &lt;/li&gt;
&lt;li&gt;It is better to use this instance in place of the Brustable instance. &lt;/li&gt;
&lt;li&gt;These instances have predictable performance.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Compute Optimized - Optimized CPU

&lt;ul&gt;
&lt;li&gt;The C Instance&lt;/li&gt;
&lt;li&gt;These instances are good for high compute power.&lt;/li&gt;
&lt;li&gt;These instances can serve high traffic web servers.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Memory Optimized - Optimized RAM

&lt;ul&gt;
&lt;li&gt;Memory Optimized - R Instance&lt;/li&gt;
&lt;li&gt;They have higher capacity RAM, Like in case of &lt;code&gt;r5.large&lt;/code&gt;, the base memory is 16 GiB, but in &lt;code&gt;c4.large&lt;/code&gt; it is only 4 GiB.&lt;/li&gt;
&lt;li&gt;Memory Optimized - X Instance &lt;/li&gt;
&lt;li&gt;These are &lt;strong&gt;X&lt;/strong&gt; tream RAM instance, the base &lt;code&gt;x1.16xlarge&lt;/code&gt; is an instance with 976 GiB RAM.&lt;/li&gt;
&lt;li&gt;Memory Optimized - Z Instance &lt;/li&gt;
&lt;li&gt;The best CPU, with more memory. &lt;/li&gt;
&lt;li&gt;The &lt;code&gt;z1d.large&lt;/code&gt; has a 4.0 GHz processor, with a memory starting at 16 GiB and going till 384 GiB. &lt;/li&gt;
&lt;li&gt;It even has a NVMe SSD attached, that is the reason of the &lt;code&gt;d&lt;/code&gt; in the name. &lt;/li&gt;
&lt;li&gt;This is a complete instance for high performance&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Storage Optimized - Optimized HDD/SSD

&lt;ul&gt;
&lt;li&gt;Storage Optimized - D Instance&lt;/li&gt;
&lt;li&gt;The application with use high I/O performance.&lt;/li&gt;
&lt;li&gt;Storage Optimized - I Instance&lt;/li&gt;
&lt;li&gt;The instance has NVMe SSD with low latency.&lt;/li&gt;
&lt;li&gt;Storage Optimized - H Instance &lt;/li&gt;
&lt;li&gt;These are HDD based local storage, so higher throughput for operation. &lt;/li&gt;
&lt;li&gt;These are good for Big data operation. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Accelerated Computing - These are GPU and FPGA related

&lt;ul&gt;
&lt;li&gt;Accelerated Computing - P Instance&lt;/li&gt;
&lt;li&gt;Parallel processing using the GPUs. &lt;/li&gt;
&lt;li&gt;Accelerated Computing - G Instance&lt;/li&gt;
&lt;li&gt;Graphics Rendering using the GPUs&lt;/li&gt;
&lt;li&gt;Accelerated Computing - F Instance&lt;/li&gt;
&lt;li&gt;The instance for programmable gate arrays.&lt;/li&gt;
&lt;li&gt;Accelerated Computing - Inf1 Instance&lt;/li&gt;
&lt;li&gt;The instance for AI/ML work load.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;The instance body of work provides the root of above classification. Web Server can use the General Purpose instance. These instance are good for day to day computing.&lt;/p&gt;

&lt;h2&gt;
  
  
  General Purpose Instance¶
&lt;/h2&gt;

&lt;p&gt;The most basic and all rounder AWS EC2 instances are the General Purpose Instances. They provide a perfect balance of computing, memory and networking resource. The below image shows the important points of both the sub class of the General Purpose Instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--57aPtUO3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-General-Purpose.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--57aPtUO3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-General-Purpose.png" alt="AWS Made Easy | AWS EC2 | General Purpose Instance Property" title="AWS Made Easy | AWS EC2 | General Purpose Instance Property"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The four sub classification of the General Purpose Instance are.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;General purpose - T3/T4g Instance&lt;/li&gt;
&lt;li&gt;General purpose - M5 Instance&lt;/li&gt;
&lt;li&gt;General Purpose - Mac&lt;/li&gt;
&lt;li&gt;General purpose - Arm Instance&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  General Purpose - T3/T4g Instance¶
&lt;/h3&gt;

&lt;p&gt;The T3/T4g have a baseline CPU performance of 2.5 GHz. These instance can burst to higher performance for shorter duration. The T3/T4g are burstable instance for this reason.&lt;/p&gt;

&lt;p&gt;This burst is paid with CPU credits. When the instance is idle it leads to accumulation of CPU Credits.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for t3.large in the US East (Ohio) for 1 Year term and No Upfront is 0.0522 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The T4g is the AWS Graviton2 Processor.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for t4g.large in the US East (Ohio) for 1 Year term and No Upfront is 0.0421 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The ideal use case for these instances are micro-service, low-latency application, development environment.&lt;/p&gt;

&lt;p&gt;You should be safe to not rely on the burstable CPU performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  General Purpose - M5 Instance¶
&lt;/h3&gt;

&lt;p&gt;These are, the more stable instance, in comparison to the T2/T4a Instance. They use a 3.1 GHz Intel Processor. These should be the first choice for anyone starting out on AWS. These instances provide a better baseline performance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for m5.large in the US East (Ohio) for 1 Year term and No Upfront is 0.06 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The best use case for M5 Instance are small and midsize databases, data processing tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  General Purpose - Mac Instance¶
&lt;/h3&gt;

&lt;p&gt;AWS EC2 now provides macOS as an option for development. These are based on the Apple Mac Mini computer. It uses the Intel core I7 processor with 3.2 GHz (4.6 GHz Turbo) performance. There is only the &lt;code&gt;mac1.metal&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;macOS products can use these instance for development, testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  General Purpose - Arm Instance (A1)¶
&lt;/h3&gt;

&lt;p&gt;The ARM based processor for AWS EC2 instance. It fully supports the ARM based development environment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for a1.large in the US East (Ohio) for 1 Year term and No Upfront is 0.0321 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Web server, micro-services, are some of the workload example for these instance.&lt;/p&gt;

&lt;p&gt;If you have to pick one instance, then pick the &lt;code&gt;M5&lt;/code&gt; instance in this general category.&lt;/p&gt;

&lt;p&gt;Use a &lt;code&gt;T3/T4g&lt;/code&gt; only if you want to use the free tier service.&lt;/p&gt;

&lt;p&gt;The other ARM and Mac instance, are very specific. You should use them till you do not have a specific need for these instance.&lt;/p&gt;

&lt;p&gt;Lets move on the some very specific AWS EC2 computes instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compute Optimized Instance¶
&lt;/h2&gt;

&lt;p&gt;The server you need to use for higher compute power. They support 3.6 GHz to 3.9 GHz compute power.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RvD1cieZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Compute-Optimized.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RvD1cieZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Compute-Optimized.png" alt="AWS Made Easy | AWS EC2 | Compute Optimized Instance Property" title="AWS Made Easy | AWS EC2 | Compute Optimized Instance Property"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for c5.large in the US East (Ohio) for 1 Year term and No Upfront is 0.054 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The cost of a &lt;code&gt;C5.large&lt;/code&gt; is cheaper than then General Purpose M instance. You need little higher compute power than use the &lt;code&gt;C5&lt;/code&gt; instance.&lt;/p&gt;

&lt;p&gt;The general use case for Compute Optimized Instance are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;high performance web servers&lt;/li&gt;
&lt;li&gt;scientific modeling &lt;/li&gt;
&lt;li&gt;gaming server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Memory Optimized Instance¶
&lt;/h2&gt;

&lt;p&gt;RAM has a direct impact on any compute operation. If you need higher RAM, then these are the instance you should use. They support 4.0 GHz compute frequency. The baseline instance, has 16 GiB RAM in them. This is more than the Compute Optimized and General Purpose Instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IIumwcUg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Memory-Optimized.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IIumwcUg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Memory-Optimized.png" alt="AWS Made Easy | AWS EC2 | Memory Optimized Instance Property" title="AWS Made Easy | AWS EC2 | Memory Optimized Instance Property"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are 3 types of sub classification in these memory optimized instances.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory Optimized - R instance&lt;/li&gt;
&lt;li&gt;Memory Optimized - X instance&lt;/li&gt;
&lt;li&gt;Memory Optimized - Z instance&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Memory Optimized - R Instance¶
&lt;/h3&gt;

&lt;p&gt;These are the generic higher RAM instance. They give more RAM per vCPU. 768 GiB being the highest RAM available.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for r5.large in the US East (Ohio) for 1 Year term and No Upfront is 0.079 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Memory intensive applications can use the R instance to perfection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Memory Optimized - X Instance¶
&lt;/h3&gt;

&lt;p&gt;These instances support the large scale, enterprise class, in-memory application.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for x1.16xlarge in the US East (Ohio) for 1 Year term and No Upfront is 4.11 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;SAP HANA application can use the X Instance to perfection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Memory Optimized - Z Instance¶
&lt;/h3&gt;

&lt;p&gt;These are the instance which supports high compute capacity and high memory. The compute power is 4.0 GHz. They also support the NVMe SSD for low latency IO and higher RAM starting from 16 GiB to 384 GiB&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for z1d.large in the US East (Ohio) for 1 Year term and No Upfront is 0.117 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Relational databases can use the Z instance to perfection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Storage Optimized Instance¶
&lt;/h2&gt;

&lt;p&gt;These instance provides the variety in the Hard Disk or local storage option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rCu8NEv_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Storage-Optimized.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rCu8NEv_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Storage-Optimized.png" alt="AWS Made Easy | AWS EC2 | Storage Optimized Instance Property" title="AWS Made Easy | AWS EC2 | Storage Optimized Instance Property"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are 3 sub classification of these instances.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Storage Optimized - D Instance&lt;/li&gt;
&lt;li&gt;Storage Optimized - I Instance&lt;/li&gt;
&lt;li&gt;Storage Optimized - H Instance&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Storage Optimized - D Instance¶
&lt;/h3&gt;

&lt;p&gt;These are the D or Dense instance. They provide 48 TB HDD instance storage.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for d3.xlarge in the US East (Ohio) for 1 Year term and No Upfront is 0.315 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These instances are good for &lt;strong&gt;D&lt;/strong&gt; istributed file systems like HDFS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage Optimized - I Instance¶
&lt;/h3&gt;

&lt;p&gt;High IO need the power of NVMe SSD. Since these instances are supporting NVMe SSD. You can get very low latency performance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for i3.large in the US East (Ohio) for 1 Year term and No Upfront is 0.107 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These instances are ideal for NoSQL databases like Cassandra, MongoDB, Redis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage Optimized - H Instance¶
&lt;/h3&gt;

&lt;p&gt;These instance support 16 TB of HDD based local storage. Since the storage is local, the latency is very low in these.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for h1.2xlarge in the US East (Ohio) for 1 Year term and No Upfront is 0.318 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These instances are ideal for MapReduce work loads.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accelerated Computing Instance¶
&lt;/h2&gt;

&lt;p&gt;Till now all the instance type was using similar hardware. There was no special hardware used to improve performance. The Accelerated Computing instance changes that. It uses specific hardware for specific tasks. Like a GPU for both GPU intensive work or parallel processing.&lt;/p&gt;

&lt;p&gt;It even uses hardware accelerators for FPGA and AWS Inferentia for AWS AI/ML work load.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iHbZfW-Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Accelerated-Computing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iHbZfW-Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Accelerated-Computing.png" alt="AWS Made Easy | AWS EC2 | Accelerated Computing Instance Property" title="AWS Made Easy | AWS EC2 | Accelerated Computing Instance Property"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is four sub classification of the Accelerated Computing Instance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accelerated Computing - P Instance&lt;/li&gt;
&lt;li&gt;Accelerated Computing - G Instance&lt;/li&gt;
&lt;li&gt;Accelerated Computing - F Instance&lt;/li&gt;
&lt;li&gt;Accelerated Computing - Inf1 Instance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lets dig deeper into these.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accelerated Computing - P Instance¶
&lt;/h3&gt;

&lt;p&gt;The P instances are also referred to as Parallel Instance. These instances are best for Machine Learning and HPC. These instances have many network cards.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for p4d.24xlarge in the US East (Ohio) for 1 Year term and No Upfront is 20.1754983 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The use case of these P Instances are Machine Learning, HPC, Computational Finance etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accelerated Computing - G Instance¶
&lt;/h3&gt;

&lt;p&gt;These instances are best used for Graphics Intensive workloads.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for g3s.xlarge in the US East (Ohio) for 1 Year term and No Upfront is 0.551 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The use case of these instances are 3D Visualization, graphics-intensive remote workstation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accelerated Computing - F Instance¶
&lt;/h3&gt;

&lt;p&gt;These instances are the equipped with field programmable gate arrays (FPGAs).&lt;/p&gt;

&lt;p&gt;These instances are best for genomics research, financial analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accelerated Computing - Inf1 Instance¶
&lt;/h3&gt;

&lt;p&gt;The Inf1 instance are best used for Machine learning inference application.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EC2 Instance Savings Plans rate for inf1.xlarge in the US East (Ohio) for 1 Year term and No Upfront is 0.232 USD&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These instances are useful for Recommendation engine, forecasting etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to choose an instance type¶
&lt;/h2&gt;

&lt;p&gt;AWS provides a very good tool called &lt;a href="https://aws.amazon.com/ec2/instance-explorer"&gt;AWS Instance Type Explorer&lt;/a&gt;. It helps to choose your required instance type.&lt;/p&gt;

&lt;p&gt;You can select one of these four options.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instance category&lt;/li&gt;
&lt;li&gt;Hardware configuration&lt;/li&gt;
&lt;li&gt;Accelerators&lt;/li&gt;
&lt;li&gt;Additional Capabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--69IHQz6c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Category.png" alt="AWS Made Easy - AWS EC2 - Instance Category Selection" title="AWS Made Easy - AWS EC2 - Instance Category Selection"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--46nbKLsw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Hardware-Configuration.png" alt="AWS Made Easy - AWS EC2 - Hardware configuration" title="AWS Made Easy - AWS EC2 - Hardware configuration"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QA16Aipc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Accelerators.png" alt="AWS Made Easy - AWS EC2 - Accelerators" title="AWS Made Easy - AWS EC2 - Accelerators"&gt;&lt;/td&gt;
&lt;td&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S0mHkr5b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Addtional-Capability.png" alt="AWS Made Easy - AWS EC2 - Additional Capabilities" title="AWS Made Easy - AWS EC2 - Additional Capabilities"&gt; .&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When you provide the requirement through these four options. This tool will suggest you some of the instance type which you can use. Like for the above combination the suggestion came as.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qoWaQq7b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Instance%2520Explorer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qoWaQq7b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/04-EC2-Instance-Type-Instance%2520Explorer.png" alt="AWS Made Easy | AWS EC2 | Instance Explorer Results" title="AWS Made Easy | AWS EC2 | Instance Explorer Results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, it suggests &lt;code&gt;M5d&lt;/code&gt; and &lt;code&gt;M5dn&lt;/code&gt; but it did not suggest a size. If you get the category of the instance type like you have now. It is always better to start with the lowest size. Perform some testing with the on-demand instance and then decide on the size.&lt;/p&gt;

&lt;p&gt;To reduce cost always go with the lower sized instance.&lt;/p&gt;

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

&lt;p&gt;AWS EC2 has a great naming convention. Though this is not well document. The above naming convention comes from a few of the re-invent video and common sense. The more you look at the naming, the more confusing it looks at first. If you can separate the noise then you can observe the hidden pattern in the name of an AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;Once you have the grasp of the name.&lt;/p&gt;

&lt;p&gt;The most important thing is to understand the four main classifications. Like, the various use of a server are.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do memory heavy work&lt;/li&gt;
&lt;li&gt;Do Compute heavy work&lt;/li&gt;
&lt;li&gt;Do high IO work&lt;/li&gt;
&lt;li&gt;Do GPU related work&lt;/li&gt;
&lt;li&gt;Do generic work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above five reasons, are the classification of the instance type. Be it Memory Optimized or Compute Optimized. Like I said you have to remove the noise to find the pattern.&lt;/p&gt;

&lt;p&gt;Once you have the understanding of the main classification. The sub classification can come naturally. Like in Memory optimized instance, you may need&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;higher ram&lt;/li&gt;
&lt;li&gt;higher optimized memory&lt;/li&gt;
&lt;li&gt;finally a better CPU and memory work synchronization. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AWS instance classification and sub classification are for a reason. Try your own understanding in finding the pattern. This will help you in remembering the details.&lt;/p&gt;

&lt;p&gt;Finally, once you have decided on the instance. You should always choose the lower size instance to run experimentation. Based on the experimentation, decide on the actual instance size. As a rule of thumb always chose a lower instance size, it saves money.&lt;/p&gt;

&lt;p&gt;Hope you are clear with the concept of AMI. If you want to launch an EC2 instance. Checkout, the free tier EC2 instance launch article. see &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html"&gt;Step by Step guide to create an EC2 instance&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.logicata.com/blog/aws-ec2-everything-you-need-to-know-about-ec2-instances/"&gt;AWS EC2 – Everything You Need to Know About EC2 Instances&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.parkmycloud.com/blog/ec2-instance-types/"&gt;EC2 Instance Types Comparison (and how to remember them)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloudacademy.com/blog/aws-ec2-instance-types-explained/"&gt;AWS EC2 Instance Types Explained.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html"&gt;Instance types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/48235393/meaning-of-the-number-in-aws-instance-type-name"&gt;Meaning of the number in AWS instance type name.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.qa.com/about-qa/our-thinking/aws-virtual-machine-sizes-what-does-m5d2xlarge-mean/"&gt;AWS virtual machine sizes: What does m5d.2xlarge mean?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=W0PKclqP3U0"&gt;AWS re:Invent 2018: Amazon EC2 Instances &amp;amp; Performance Optimization Best Practices (CMP307-R1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=q5Dn9gcmpJg"&gt;AWS re:Invent 2020: Selecting the right Amazon EC2 instance for your workloads&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-recommendations.html"&gt;Get recommendations for an instance type | AWS Compute Optimizer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.apptio.com/blog/aws-ec2-c4-vs-c5/"&gt;Amazon EC2 Comparisons: C4 vs. C5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=29QZPttiKJA"&gt;Deep Dive on Amazon EC2 Instances - January 2017 Online Tech Talks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/ec2/instance-explorer"&gt;Instance Type Explorer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://calculator.aws/#/createCalculator/EC2"&gt;AWS EC2 Calculator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awsec2</category>
    </item>
    <item>
      <title>How not knowing AWS CLI and SDKs makes you a Rookie.</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Sat, 01 May 2021 11:39:47 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/how-not-knowing-aws-cli-and-sdks-makes-you-a-rookie-1mo8</link>
      <guid>https://dev.to/animeshkbhadra/how-not-knowing-aws-cli-and-sdks-makes-you-a-rookie-1mo8</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ouc3UIdL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-SDK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ouc3UIdL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-SDK.png" alt="AWS Made Easy | AWS CLI &amp;amp; SDKs" title="AWS Made Easy | AWS CLI &amp;amp; SDKs"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;AWS provides many ways to control its resources. One of the fastest and the most effective way is the AWS CLIs and SDKs. The best benefit of using CLI or SDKs it that you can automate complex workflow.&lt;/p&gt;

&lt;p&gt;Depending on your expertise, you can use a bash script to control the AWS resources. You can use many programming languages, like .NET, Python, Go, etc. to control the AWS resources. You can use the Postman client to make HTTP API calls.&lt;/p&gt;

&lt;p&gt;This article will provide an introduction to use the AWS CLI, SDKs and the HTTP APIs provided by AWS. Using these techniques, to control the AWS resources can save a lot of time.&lt;/p&gt;

&lt;p&gt;Come and explore the work of AWS CLIs, SDKs and Postman Client.&lt;/p&gt;

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

&lt;p&gt;You can use &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;venv&lt;/code&gt; modules of Python for installing CLI and SDKs. &lt;code&gt;pip&lt;/code&gt; is the Python package manager. &lt;code&gt;venv&lt;/code&gt; is the virtual environment.&lt;/p&gt;

&lt;p&gt;Python is cross platform. If you use Python, then the process becomes easier for Windows, Linux and MacOS.&lt;/p&gt;

&lt;p&gt;There is a new version of AWS CLI V 2.x which do not support installation via pip. You will install only AWS CLI V 2.x via the package installer method mentioned below by AWS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Python on Windows, Linux or macOS¶
&lt;/h3&gt;

&lt;p&gt;There are many resources out there to install Python on these platforms. I cannot make any improvement over these installation instructions.&lt;/p&gt;

&lt;p&gt;Please follow this &lt;a href="https://realpython.com/installing-python/"&gt;RealPython&lt;/a&gt; article, to install Python on your respective operating system.&lt;/p&gt;

&lt;p&gt;Execute the below command to confirm the installation is complete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python --version

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

&lt;/div&gt;



&lt;p&gt;If you get any version information in return, you have installed Python.&lt;/p&gt;

&lt;p&gt;You should now proceed to install the next important package called &lt;code&gt;pip&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install PiP on Window, Linux or macOS¶
&lt;/h3&gt;

&lt;p&gt;Once you have Python installed, the next step would be to install the package manager called &lt;code&gt;pip&lt;/code&gt;. It is the default installation on Python 2 version &amp;gt;= 2.7.9 and Python 3 version &amp;gt;= 3.4. You can check the installation by executing this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip --version

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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;pip&lt;/code&gt; is already present, if you get the version information in response to the command. If not present you can use this documentation to install &lt;code&gt;pip&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pip.pypa.io/en/stable/installing/"&gt;Installing PiP for Windows, Linux and macOS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you have &lt;code&gt;pip&lt;/code&gt; installed, the next step is to create a virtual environment using the package &lt;code&gt;venv&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Virtual Environment¶
&lt;/h3&gt;

&lt;p&gt;You can have separate environments for your Python installation. This helps in not polluting the global package installation.&lt;/p&gt;

&lt;p&gt;Create a directory name &lt;code&gt;aws-cli&lt;/code&gt; in your local machine and follow along. Change to this &lt;code&gt;aws-cli&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Create a virtual environment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv .env

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

&lt;/div&gt;



&lt;p&gt;If no error comes then there will be a &lt;code&gt;.env&lt;/code&gt; inside &lt;code&gt;aws-cli&lt;/code&gt;. If we get an error of package not found, please install the virtual environment package, using &lt;code&gt;pip&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;.env&lt;/code&gt; is generally used to identify an environment folder, but you are free to use any name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip install --user virtualenv

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

&lt;/div&gt;



&lt;p&gt;Once you have your &lt;code&gt;.env&lt;/code&gt; folder created now we can proceed with the AWS CLI and SDK installation.&lt;/p&gt;

&lt;p&gt;You are all set to install AWS CLI and SDK.&lt;/p&gt;

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

&lt;p&gt;AWS CLI is a tool to manage many services. If you choose the Amazon Linux AMI, the AWS CLI is pre-installed.&lt;/p&gt;

&lt;p&gt;AWS CLI is an open source tool. AWS Management console provides the same functionality as AWS CLI. AWS CLI should have the new AWS IaaS administration features available. &lt;em&gt;180 days&lt;/em&gt; is the time limit for AWS CLI to have these new AWS IaaS features.&lt;/p&gt;

&lt;p&gt;You get access to only the public APIs. While using AWS CLI, you do not have any special APIs to use, all the APIs are available in public.&lt;/p&gt;

&lt;p&gt;AWS CLI comes in two versions, the most recent version is 2.x, it can be used in a production environment. 2.x version is not available as a Python package for installation through &lt;code&gt;pip&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You have to use a separate installer to install the version 2.x. The support for AWS ClI v1 is still available.&lt;/p&gt;

&lt;p&gt;There is an unofficial port of AWS ClI v2 on pypi &lt;a href="https://pypi.org/project/awscliv2/"&gt;called awscliv2.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to install v2, jump to Install AWS CLI v2.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install AWS CLI v1¶
&lt;/h3&gt;

&lt;p&gt;Activate the virtual environment inside &lt;code&gt;aws-cli&lt;/code&gt; folder. The below command works on Linux/macOS. It may be little different on Windows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source .env/bin/activate

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

&lt;/div&gt;



&lt;p&gt;After activating the virtual environment, execute this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip install awscli

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

&lt;/div&gt;



&lt;p&gt;Once you have installed, it will show this at the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Successfully installed PyYAML-5.4.1 awscli-1.19.62 botocore-1.20.62 colorama-0.4.3 docutils-0.15.2 jmespath-0.10.0 pyasn1-0.4.8 python-dateutil-2.8.1 rsa-4.7.2 s3transfer-0.4.2 six-1.15.0 urllib3-1.26.4

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

&lt;/div&gt;



&lt;p&gt;If you see, while installing &lt;code&gt;awscli&lt;/code&gt; it installs the above dependencies, one of that dependency is &lt;code&gt;botocore&lt;/code&gt;. &lt;code&gt;botocore&lt;/code&gt; is the base for even &lt;code&gt;boto3&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can verify the installation by running the command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws --version

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

&lt;/div&gt;



&lt;p&gt;If the version is successfully installed, you will get an output as &lt;code&gt;aws-cli/1.19.62 Python/3.7.5 Darwin/18.6.0 botocore/1.20.62&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You have &lt;code&gt;awscli&lt;/code&gt; v1 installed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install AWS CLI v2¶
&lt;/h3&gt;

&lt;p&gt;For macOS:-&lt;/p&gt;

&lt;p&gt;Download the latest AWS CLI v2 packages from &lt;a href="https://awscli.amazonaws.com/AWSCLIV2.pkg"&gt;AWS CLI pkg Download.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install the package, by following the instructions. At the end, &lt;code&gt;aws&lt;/code&gt; would be installed.&lt;/p&gt;

&lt;p&gt;If you have both AWS CLI v1 and v2 installed, then it will pick the executable which is first in the &lt;code&gt;PATH&lt;/code&gt; variable. Confirm the installation by opening a new terminal and executing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws --version

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

&lt;/div&gt;



&lt;p&gt;You should get an output as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws-cli/2.2.1 Python/3.8.8 Darwin/18.6.0 exe/x86_64 prompt/off

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

&lt;/div&gt;



&lt;p&gt;The above output proves that we have the AWS CLI v2 installed. Now you should execute a sample command to see &lt;code&gt;aws&lt;/code&gt; cli in action.&lt;/p&gt;

&lt;h3&gt;
  
  
  describeimages api using cli¶
&lt;/h3&gt;

&lt;p&gt;Before you execute any &lt;code&gt;aws&lt;/code&gt; command we should configure the aws environment. Please follow the instruction already mentioned. See &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-api-keys.html#using-iam-api-keys-with-aws-cli"&gt;AWS CLI configure AWS environment.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have your AWS environment configured. Try running some operation on the AWS CLI.&lt;/p&gt;

&lt;p&gt;Try the command mentioned in &lt;a href="https://www.archerimagine.com/articles/aws/aws-ami-tutorial.html#what-is-ami"&gt;What is AMI?&lt;/a&gt; We will execute the &lt;code&gt;describe-images&lt;/code&gt; command on an &lt;code&gt;ec2&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 describe-images --image-ids ami-0d758c1134823146a

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

&lt;/div&gt;



&lt;p&gt;If executed successfully we will get an output as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Images": [
        {
            "Architecture": "x86_64",
            "CreationDate": "2021-02-24T18:24:50.000Z",
            "ImageId": "ami-0d758c1134823146a",
            "ImageLocation": "099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223",
            "ImageType": "machine",
            "Public": true,
            "OwnerId": "099720109477",
            "PlatformDetails": "Linux/UNIX",
            "UsageOperation": "RunInstances",
            "State": "available",
            "BlockDeviceMappings": [
                {
                    "DeviceName": "/dev/sda1",
                    "Ebs": {
                        "DeleteOnTermination": true,
                        "SnapshotId": "snap-072d11ffd95664698",
                        "VolumeSize": 8,
                        "VolumeType": "gp2",
                        "Encrypted": false
                    }
                },
                {
                    "DeviceName": "/dev/sdb",
                    "VirtualName": "ephemeral0"
                },
                {
                    "DeviceName": "/dev/sdc",
                    "VirtualName": "ephemeral1"
                }
            ],
            "Description": "Canonical, Ubuntu, 20.04 LTS, amd64 focal image build on 2021-02-23",
            "EnaSupport": true,
            "Hypervisor": "xen",
            "Name": "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223",
            "RootDeviceName": "/dev/sda1",
            "RootDeviceType": "ebs",
            "SriovNetSupport": "simple",
            "VirtualizationType": "hvm"
        }
    ]
}

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

&lt;/div&gt;



&lt;p&gt;The above command and output is same in v1 and v2. Congratulations on executing your first AWS CLI command successfully.&lt;/p&gt;

&lt;p&gt;You should continue your command line journey with a little knowledge on AWS SDKs.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS SDK | Python | Boto3¶
&lt;/h2&gt;

&lt;p&gt;SDKs take the complexity out of coding. They provide language specific APIs for AWS service. AWS SDK is available in these various languages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;PHP&lt;/li&gt;
&lt;li&gt;.NET&lt;/li&gt;
&lt;li&gt;Ruby&lt;/li&gt;
&lt;li&gt;Java&lt;/li&gt;
&lt;li&gt;Go&lt;/li&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;C++&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can use any of the SDK for controlling the AWS resources. You will learn to use the Python SDK called &lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html"&gt;Boto3.&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The Python Boto3 provides two key Python packages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Botocore - Library providing low-level functionality shared with Python SDK and the AWS CLI&lt;/li&gt;
&lt;li&gt;Boto3 - The Python SDK.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Installation of Boto3 is very easy. Activate the Python virtual environment, which we already did Install AWS CLI v1&lt;/p&gt;

&lt;p&gt;Once you have activated the virtual environment, just execute this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m pip install boto3

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

&lt;/div&gt;



&lt;p&gt;Once the installation is done, it will give this message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Successfully installed boto3-1.17.62

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

&lt;/div&gt;



&lt;p&gt;You can again execute the configure option, if not done as explained in &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-api-keys.html#using-iam-api-keys-with-aws-cli"&gt;AWS CLI configure AWS environment.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  describe_images API using Python Boto3¶
&lt;/h3&gt;

&lt;p&gt;Once installation is complete, we can execute the same &lt;code&gt;describe_images&lt;/code&gt; to get the details of the AMI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
import pprint

ec2 = boto3.client("ec2")

ImageIds = ["ami-0d758c1134823146a"]

response = ec2.describe_images(ImageIds=ImageIds)
pprint.pprint(response[""])

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

&lt;/div&gt;



&lt;p&gt;Once you execute the output would be.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "Images":[
      {
         "Architecture":"x86_64",
         "BlockDeviceMappings":[
            {
               "DeviceName":"/dev/sda1",
               "Ebs":{
                  "DeleteOnTermination":true,
                  "Encrypted":false,
                  "SnapshotId":"snap-072d11ffd95664698",
                  "VolumeSize":8,
                  "VolumeType":"gp2"
               }
            },
            {
               "DeviceName":"/dev/sdb",
               "VirtualName":"ephemeral0"
            },
            {
               "DeviceName":"/dev/sdc",
               "VirtualName":"ephemeral1"
            }
         ],
         "CreationDate":"2021-02-24T18:24:50.000Z",
         "Description":"Canonical, Ubuntu, 20.04 LTS, amd64 focal image ""build on 2021-02-23",
         "EnaSupport":true,
         "Hypervisor":"xen",
         "ImageId":"ami-0d758c1134823146a",
         "ImageLocation":"099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223",
         "ImageType":"machine",
         "Name":"ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223",
         "OwnerId":"099720109477",
         "PlatformDetails":"Linux/UNIX",
         "Public":true,
         "RootDeviceName":"/dev/sda1",
         "RootDeviceType":"ebs",
         "SriovNetSupport":"simple",
         "State":"available",
         "UsageOperation":"RunInstances",
         "VirtualizationType":"hvm"
      }
   ],
   "ResponseMetadata":{
      "HTTPHeaders":{
         "cache-control":"no-cache, no-store",
         "content-length":"2184",
         "content-type":"text/xml;charset=UTF-8",
         "date":"Sun, 02 May 2021 13:42:28 GMT",
         "server":"AmazonEC2",
         "strict-transport-security":"max-age=31536000; ""includeSubDomains",
         "vary":"accept-encoding",
         "x-amzn-requestid":"bd357758-f81e-450d-bc7f-5764944d5186"
      },
      "HTTPStatusCode":200,
      "RequestId":"bd357758-f81e-450d-bc7f-5764944d5186",
      "RetryAttempts":0
   }
}

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

&lt;/div&gt;



&lt;p&gt;If you see the output, it is almost similar to the output when we executed the AWS CLI command for the same describe_images. see describeimages api using cli&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Postman to execute AWS REST API¶
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;What is Postman?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As described by the company &lt;a href="https://www.postman.com/"&gt;itself.&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Postman is a collaboration platform for API development.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This tells us that we can use &lt;a href="https://www.postman.com/"&gt;Postman,&lt;/a&gt; to test the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;Automated testing on the APIs etc. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you do not want to write code for getting some tasks done, we can use &lt;a href="https://www.postman.com/"&gt;Postman,&lt;/a&gt; for that. Configuring Postman to achieve it is little complicated so please keep the focus.&lt;/p&gt;

&lt;p&gt;You have understood about these 2 concepts in Postman to use it with AWS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Environment&lt;/li&gt;
&lt;li&gt;Collections&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configure Postman environment for AWS¶
&lt;/h3&gt;

&lt;p&gt;As mentioned in Postman documentation, &lt;a href="https://learning.postman.com/docs/sending-requests/managing-environments/"&gt;an environment is&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Postman environment is a set of variables, which you can use in Postman request.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can use Postman environment to create a production or a staging environment. In our case we will create these 4 variables in the environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;region - providing the AWS region, where to execute the Action&lt;/li&gt;
&lt;li&gt;accountId - the 12 digit account ID&lt;/li&gt;
&lt;li&gt;accessKey - The accessKey which is present when IAM console&lt;/li&gt;
&lt;li&gt;secretAccessKey - The secret Access Key which we get once creating a new user, see &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-api-keys.html#using-iam-api-keys-with-aws-cli"&gt;AWS CLI configure AWS environment.&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create Postman environment for AWS¶
&lt;/h3&gt;

&lt;p&gt;Let first create a Postman environment for AWS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K5KKfuTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-environment.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K5KKfuTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-environment.png" alt="AWS Made Easy | AWS CLI | Postman Environment" title="AWS Made Easy | AWS CLI | Postman Environment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see above you have to provide these 4 information in the environment, you can name your environment anything, I have named it &lt;code&gt;aws-environment&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once you have the environment, it's time for collection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Postman collection for AWS¶
&lt;/h3&gt;

&lt;p&gt;As mentioned in Postman documentation, &lt;a href="https://learning.postman.com/docs/getting-started/creating-the-first-collection/"&gt;a collection is&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Group of saved request which is organized into folders.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create a new collection as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8MjoXYcq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-collection.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8MjoXYcq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-collection.png" alt="AWS Made Easy | AWS CLI | Postman Collection" title="AWS Made Easy | AWS CLI | Postman Collection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you create a new collection, you should provide the Authorization details. Select AWS Signature as shown above.&lt;/p&gt;

&lt;p&gt;You should provide all the AWS environment variable, we created in this collection.&lt;/p&gt;

&lt;p&gt;You can reference all the AWS environment variables inside the Authorization panel of Postman collection by using &lt;code&gt;{{accessKey}}&lt;/code&gt;, i.e. surrounding it inside &lt;code&gt;{{ }}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To verify if your variable are set properly, hover over the &lt;code&gt;{{accessKey}}&lt;/code&gt;, if you get an &lt;code&gt;Unresolved variable&lt;/code&gt; error like this,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--przFkc_W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-unresolved-variables.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--przFkc_W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-unresolved-variables.png" alt="AWS Made Easy | AWS CLI | Postman Collection Unresolved Variables" title="AWS Made Easy | AWS CLI | Postman Collection Unresolved Variables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This can happen, because the environment, we set is not accessible to this collection. Please check this drop down and choose the appropriate environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ayIw_13S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-collection-select-environment.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ayIw_13S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-collection-select-environment.png" alt="AWS Made Easy | AWS CLI | Postman Collection set environment" title="AWS Made Easy | AWS CLI | Postman Collection set environment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the environment is properly set, we can use the PostMan Collection to fire our request.&lt;/p&gt;

&lt;h3&gt;
  
  
  describeimages api using Postman¶
&lt;/h3&gt;

&lt;p&gt;Once your Postman environment and collection is set, you can fire the same &lt;code&gt;DescribeImages&lt;/code&gt; API to if the Postman is working.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tHodS237--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-AWS-request.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tHodS237--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/03-AWS-CLI-Postman-AWS-request.png" alt="AWS Made Easy | AWS CLI | Postman Send Request" title="AWS Made Easy | AWS CLI | Postman Send Request"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown above, create a new request inside your existing collection which we create in the previous step.&lt;/p&gt;

&lt;p&gt;You have to provide these Query Params.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Action - The &lt;code&gt;DescribeImages&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Version - This version should be &lt;code&gt;2016-11-15&lt;/code&gt;, which is the last document version, do not change it.&lt;/li&gt;
&lt;li&gt;ImageId.1 - The AMI id you want to search.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If everything goes right, you should get a response in XML like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"&amp;gt;
    &amp;lt;requestId&amp;gt;961658cb-8af7-4d49-85d6-9012ac662616&amp;lt;/requestId&amp;gt;
    &amp;lt;imagesSet&amp;gt;
        &amp;lt;item&amp;gt;
            &amp;lt;imageId&amp;gt;ami-0d758c1134823146a&amp;lt;/imageId&amp;gt;
            &amp;lt;imageLocation&amp;gt;099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223&amp;lt;/imageLocation&amp;gt;
            &amp;lt;imageState&amp;gt;available&amp;lt;/imageState&amp;gt;
            &amp;lt;imageOwnerId&amp;gt;099720109477&amp;lt;/imageOwnerId&amp;gt;
            &amp;lt;creationDate&amp;gt;2021-02-24T18:24:50.000Z&amp;lt;/creationDate&amp;gt;
            &amp;lt;isPublic&amp;gt;true&amp;lt;/isPublic&amp;gt;
            &amp;lt;architecture&amp;gt;x86_64&amp;lt;/architecture&amp;gt;
            &amp;lt;imageType&amp;gt;machine&amp;lt;/imageType&amp;gt;
            &amp;lt;sriovNetSupport&amp;gt;simple&amp;lt;/sriovNetSupport&amp;gt;
            &amp;lt;name&amp;gt;ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223&amp;lt;/name&amp;gt;
            &amp;lt;description&amp;gt;Canonical, Ubuntu, 20.04 LTS, amd64 focal image build on 2021-02-23&amp;lt;/description&amp;gt;
            &amp;lt;rootDeviceType&amp;gt;ebs&amp;lt;/rootDeviceType&amp;gt;
            &amp;lt;rootDeviceName&amp;gt;/dev/sda1&amp;lt;/rootDeviceName&amp;gt;
            &amp;lt;blockDeviceMapping&amp;gt;
                &amp;lt;item&amp;gt;
                    &amp;lt;deviceName&amp;gt;/dev/sda1&amp;lt;/deviceName&amp;gt;
                    &amp;lt;ebs&amp;gt;
                        &amp;lt;snapshotId&amp;gt;snap-072d11ffd95664698&amp;lt;/snapshotId&amp;gt;
                        &amp;lt;volumeSize&amp;gt;8&amp;lt;/volumeSize&amp;gt;
                        &amp;lt;deleteOnTermination&amp;gt;true&amp;lt;/deleteOnTermination&amp;gt;
                        &amp;lt;volumeType&amp;gt;gp2&amp;lt;/volumeType&amp;gt;
                        &amp;lt;encrypted&amp;gt;false&amp;lt;/encrypted&amp;gt;
                    &amp;lt;/ebs&amp;gt;
                &amp;lt;/item&amp;gt;
                &amp;lt;item&amp;gt;
                    &amp;lt;deviceName&amp;gt;/dev/sdb&amp;lt;/deviceName&amp;gt;
                    &amp;lt;virtualName&amp;gt;ephemeral0&amp;lt;/virtualName&amp;gt;
                &amp;lt;/item&amp;gt;
                &amp;lt;item&amp;gt;
                    &amp;lt;deviceName&amp;gt;/dev/sdc&amp;lt;/deviceName&amp;gt;
                    &amp;lt;virtualName&amp;gt;ephemeral1&amp;lt;/virtualName&amp;gt;
                &amp;lt;/item&amp;gt;
            &amp;lt;/blockDeviceMapping&amp;gt;
            &amp;lt;virtualizationType&amp;gt;hvm&amp;lt;/virtualizationType&amp;gt;
            &amp;lt;hypervisor&amp;gt;xen&amp;lt;/hypervisor&amp;gt;
            &amp;lt;enaSupport&amp;gt;true&amp;lt;/enaSupport&amp;gt;
            &amp;lt;platformDetails&amp;gt;Linux/UNIX&amp;lt;/platformDetails&amp;gt;
            &amp;lt;usageOperation&amp;gt;RunInstances&amp;lt;/usageOperation&amp;gt;
        &amp;lt;/item&amp;gt;
    &amp;lt;/imagesSet&amp;gt;
&amp;lt;/DescribeImagesResponse&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;You can now experiment with the different HTTP APIs provided by AWS. Create an instance, destroy instance, everything which is possible using the public API.&lt;/p&gt;

&lt;p&gt;From here on, the more you practice the more you can enhance the APIs. AWS provides multiple ways to control its resources. One of the fastest and the most effective way is the AWS CLIs and SDKs. The best benefit of using CLI or SDKs it that you can automate complex work flow.&lt;/p&gt;

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

&lt;p&gt;AWS CLI, SDKs and HTTP APIs are three alternate ways to access and configure the AWS resources. AWS CLIs and SDKs requires a little bit of programming knowledge. It can be shell scripting or any programming language. HTTP Clients like Postman can use the HTTP APIs to provide the same result.&lt;/p&gt;

&lt;p&gt;Python is a preferred choice when it comes to choosing the the AWS SDKs. The AWS CLIs core is also made with a Python Package. AWS has changed the way of installing AWS CLIs from &lt;code&gt;pip&lt;/code&gt; to independent packages in Version 2.x.&lt;/p&gt;

&lt;p&gt;In this article we have used the &lt;code&gt;describeimage&lt;/code&gt; API to execute AWS CLIs, SDKs and HTTP CLient and get the same result in all the three possible ways.&lt;/p&gt;

&lt;p&gt;You can proceed with any one of the technique from here on. It may depend on your previous experience. If you are knowledgeable in Shell scripting choose AWS CLI. If you are good in programming, choose the AWS SDKs. You can use the HTTP Client called Postman to fire the HTTP APIs if you have no programming experience.&lt;/p&gt;

&lt;p&gt;Knowing AWS CLI, SDKs or HTTP API is one important step in the AWS Configuration. Checkout, the free tier EC2 instance launch article. see &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html"&gt;Step by Step guide to create an EC2 instance&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.scottlowe.org/2020/04/10/using-postman-to-launch-ec2-instance-via-api-calls/"&gt;Using Postman to Launch an EC2 Instance via API Calls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.scottlowe.org/2020/02/27/region-endpoint-match-in-aws-api-requests/"&gt;Region and Endpoint Match in AWS API Requests&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://virtualhobbit.com/2020/02/26/wednesday-tidbit-using-postman-to-authenticate-to-aws/"&gt;Wednesday Tidbit: Using Postman to authenticate to AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html"&gt;DescribeImages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.postman.com/audit-your-aws-infrastructure-with-postman/"&gt;Audit your AWS infrastructure with Postman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.postman.com/postman-extension-available-for-aws-gateway-apis-now/"&gt;Postman extension available for AWS Gateway APIs now&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kevinhakanson.com/2019-07-07-aws-signature-authorization-using-postman"&gt;AWS Signature Authorization using Postman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/pinpoint/latest/developerguide/tutorials-using-postman-configuration.html"&gt;Step 2: Set up Postman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=soHdD87LNl4"&gt;Postman Environment Variables: API Testing using Postman - (Part 4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloudacademy.com/blog/aws-cli-10-useful-commands/"&gt;AWS CLI: 10 Useful Commands You May Not Know&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/26326408/difference-between-s3cmd-boto-and-aws-cli"&gt;Difference between s3cmd, boto and AWS CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/aws/aws-cli/issues/4947"&gt;publish v2 to PyPI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/U5y7JI_mHk8?t=701"&gt;Introduction to AWS CLI V2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/developer/aws-cli-v2-is-now-generally-available/"&gt;AWS CLI v2 is now generally available&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learning.postman.com/docs/sending-requests/managing-environments/"&gt;Managing Postman environment.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cli</category>
      <category>sdk</category>
      <category>ec2</category>
    </item>
    <item>
      <title>The complete beginner's guide to AWS AMIs</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Fri, 23 Apr 2021 07:16:43 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/the-complete-beginner-s-guide-to-aws-amis-3d4j</link>
      <guid>https://dev.to/animeshkbhadra/the-complete-beginner-s-guide-to-aws-amis-3d4j</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2jFD5sGE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2jFD5sGE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI.png" alt="AWS Made Easy | AWS AMI" title="AWS Made Easy | AWS AMI"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Have you ever pondered on the question&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why AMI (Amazon Machine Image) is not called Operating System?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you revisit our previous article, where the first AWS EC2 instance in free tier was created, see &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html#step-1-choose-an-amazon-machine-image-ami"&gt;Step by Step guide to create an EC2 instance,&lt;/a&gt;. The first selection was for AMI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iSL6v8W3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Ubuntu-AMI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iSL6v8W3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Ubuntu-AMI.png" alt="AWS Made Easy | AWS EC2 | Ubuntu AMI" title="AWS Made Easy | AWS EC2 | Ubuntu AMI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article you will find out, &lt;em&gt;Why Amazon Machine Image (AMI) is not called operating system?&lt;/em&gt; This article is everything, you need to understand AWS AMIs.&lt;/p&gt;

&lt;p&gt;You will also get answer's to these questions&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why are they referred to as AMI?&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;What does the AMI cost?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This article will enlighten you with the AWS AMIs inner working. It also explains that you pay for the AMI, when you get bill for your EC2 instance.&lt;/p&gt;

&lt;p&gt;This will be a beginner friendly resource. For an experienced person, it will provide some details which you might have ignored.&lt;/p&gt;

&lt;p&gt;Let's say &lt;strong&gt;Hello World&lt;/strong&gt; to the Amazon AMIs.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is AMI?¶
&lt;/h2&gt;

&lt;p&gt;You should understand by now, AMI stands for Amazon Machine Image.&lt;/p&gt;

&lt;p&gt;What is an Amazon Machine Image, the answer depends on the Storage supported.&lt;/p&gt;

&lt;p&gt;An AMI includes these things depending on the Storage supported&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amazon Elastic Block Storage

&lt;ul&gt;
&lt;li&gt;It provides the snapshot. This snapshot will include the operating system, or any other application required.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Instance Store Backed

&lt;ul&gt;
&lt;li&gt;It is a template, providing&lt;/li&gt;
&lt;li&gt;Operating system&lt;/li&gt;
&lt;li&gt;Application server&lt;/li&gt;
&lt;li&gt;Application.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Amazon Elastic Block Storage and Instance Store, they both provide the same details.&lt;/p&gt;

&lt;p&gt;You can extract the details of an AWS AMI, by the use of an API &lt;code&gt;describe-images&lt;/code&gt;. To use this API, you might need the AMI Id.&lt;/p&gt;

&lt;p&gt;In the previous post to create Free Tier AWS EC2 instance, see &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html#step-1-choose-an-amazon-machine-image-ami"&gt;Step by Step guide to create an EC2 instance,&lt;/a&gt; you used the Ubuntu AMI.&lt;/p&gt;

&lt;p&gt;It has a unique identifier call AMI ID, as highlighted in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MWf-tSeu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Ubuntu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MWf-tSeu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Ubuntu.png" alt="AWS Made Easy | AWS EC2 | Ubuntu AMI ID" title="AWS Made Easy | AWS EC2 | Ubuntu AMI ID"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will use the AWS CLI, to execute this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 describe-images --image-ids ami-0d758c1134823146a

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

&lt;/div&gt;



&lt;p&gt;The output is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Images": [
        {
            "Architecture": "x86_64",
            "CreationDate": "2021-02-24T18:24:50.000Z",
            "ImageId": "ami-0d758c1134823146a",
            "ImageLocation": "099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223",
            "ImageType": "machine",
            "Public": true,
            "OwnerId": "099720109477",
            "PlatformDetails": "Linux/UNIX",
            "UsageOperation": "RunInstances",
            "State": "available",
            "BlockDeviceMappings": [
                {
                    "DeviceName": "/dev/sda1",
                    "Ebs": {
                        "DeleteOnTermination": true,
                        "SnapshotId": "snap-072d11ffd95664698",
                        "VolumeSize": 8,
                        "VolumeType": "gp2",
                        "Encrypted": false
                    }
                },
                {
                    "DeviceName": "/dev/sdb",
                    "VirtualName": "ephemeral0"
                },
                {
                    "DeviceName": "/dev/sdc",
                    "VirtualName": "ephemeral1"
                }
            ],
            "Description": "Canonical, Ubuntu, 20.04 LTS, amd64 focal image build on 2021-02-23",
            "EnaSupport": true,
            "Hypervisor": "xen",
            "Name": "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20210223",
            "RootDeviceName": "/dev/sda1",
            "RootDeviceType": "ebs",
            "SriovNetSupport": "simple",
            "VirtualizationType": "hvm"
        }
    ]
}

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

&lt;/div&gt;



&lt;p&gt;This tells me all about the AMI, which family the AMI belongs, What is the Virtualization type. It also tells what is the root device type.&lt;/p&gt;

&lt;p&gt;The above information is also present in the below screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UCavUNJ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Ubuntu-AMI-Id.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UCavUNJ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Ubuntu-AMI-Id.png" alt="AWS Made Easy | AWS EC2 | Ubuntu AMI ID details" title="AWS Made Easy | AWS EC2 | Ubuntu AMI ID details"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned above, each AMIs has 3 information in itself, you will try to find these 3 information first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the above AMI an EBS backed or Instance Store.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;"RootDeviceType": "ebs",&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What is the operating system?&lt;/em&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;"PlatformDetails": "Linux/UNIX",&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;"Description": "Canonical, Ubuntu, 20.04 LTS, amd64 focal image build on 2021-02-23",&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;It will be created from this snapshot id &lt;code&gt;"SnapshotId": "snap-072d11ffd95664698",&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;There is no additional application server or any other application installed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above AMI is a bare bone Ubuntu Image.&lt;/p&gt;

&lt;p&gt;If you want, you can install your own Web Server Apache2, or any other application and then create an AMI from it.&lt;/p&gt;

&lt;p&gt;The next natural progression should be to explore &lt;em&gt;what is the use of AWS AMIs?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the use of AMIs?¶
&lt;/h2&gt;

&lt;p&gt;If you observe the image below, you can understand 2 basic uses of the AMIs, &lt;em&gt;Can you please guess the 2 use you can think of?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oIIbAhnh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Use.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oIIbAhnh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Use.png" alt="AWS Made Easy | AWS EC2 | Use of AWS AMIs" title="AWS Made Easy | AWS EC2 | Use of AWS AMIs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before I can give you the answer to the above question, you should comprehend the above Image.&lt;/p&gt;

&lt;p&gt;The first step is to create an EBS Snapshot, Once you have the EBS Snapshot, you should register the AMI.&lt;/p&gt;

&lt;p&gt;These two steps are not required if you are choosing an existing AMI.&lt;/p&gt;

&lt;p&gt;In Addition, the above image shows us the 3 use or life cycle of the AMI&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch

&lt;ul&gt;
&lt;li&gt;launches an AWS EC2 instance from AMI&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Copy

&lt;ul&gt;
&lt;li&gt;You can copy an existing AMI, for future use.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;De-register 

&lt;ul&gt;
&lt;li&gt;You can de-register the AMI if not used.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;If you have guessed any two use from the above image, please pat your back.&lt;/p&gt;

&lt;p&gt;Once you are clear with the life cycle / use of an AWS AMIs, you should proceed towards seeing the types of AMIs.&lt;/p&gt;

&lt;p&gt;Region, Operating System, Architecture, and Storage can define the AMI's classification. Let's us discuss them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of AMI¶
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Region (see Regions and Zones)¶
&lt;/h3&gt;

&lt;p&gt;The region restricts the availability of a particular AMI.&lt;/p&gt;

&lt;p&gt;If you check Ohio (us-east-2), the number of public AMIs are 69,431.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ibAbi7GF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Region-us-east-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ibAbi7GF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Region-us-east-2.png" alt="AWS Made Easy | AWS EC2 | AWS AMI in us-east-2" title="AWS Made Easy | AWS EC2 | AWS AMI in us-east-2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you check for N.Virginia (us-east-1), the number of public AMIs are 140,650.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pTxtgM6M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Region-us-east-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTxtgM6M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Region-us-east-1.png" alt="AWS Made Easy | AWS EC2 | AWS AMI in us-east-1" title="AWS Made Easy | AWS EC2 | AWS AMI in us-east-1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above numbers can change in the future. The disparity between region for AMIs will still be present.&lt;/p&gt;

&lt;p&gt;The AMI are region specific. You can create EC2 instance with the AMI present in that region.&lt;/p&gt;

&lt;p&gt;If you want any other AMI from a different region you may have to copy those AMIs to your region.&lt;/p&gt;

&lt;h3&gt;
  
  
  Operating System &amp;amp; Architecture¶
&lt;/h3&gt;

&lt;p&gt;You have already seen, AMIs are available for both Linux and Windows. There are different variants for both the operating system.&lt;/p&gt;

&lt;p&gt;You also have both 32-bit and 64-bit architecture support in these.&lt;/p&gt;

&lt;h3&gt;
  
  
  Launch permissions¶
&lt;/h3&gt;

&lt;p&gt;The AMI owner can specify the availability, by providing the launch permission. There are three types of launch permissions&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;public - Anyone on AWS can launch using this AMI&lt;/li&gt;
&lt;li&gt;explicit - One account can grant explicit permission to another account.&lt;/li&gt;
&lt;li&gt;implicit - Owner of the AMI has implicit permission to launch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will learn about public, explicit and implicit AMIs once you reach a state of creating AMIs. Till that time being, you can read this article on the same, see &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sharingamis-explicit.html"&gt;Share an AMI with specific AWS accounts.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage for the root device¶
&lt;/h3&gt;

&lt;p&gt;The storage of the root device, creates two distinct classifications of AMI Types.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backed by AWS EBS

&lt;ul&gt;
&lt;li&gt;The root device would be an AWS Elastic Block Store&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Backed by AWS Instance Store.

&lt;ul&gt;
&lt;li&gt;The root device would be an instance store volume, created from a template.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;AWS EBS&lt;/th&gt;
&lt;th&gt;AWS Instance Store&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Boot time&lt;/td&gt;
&lt;td&gt;less than 1 minute&lt;/td&gt;
&lt;td&gt;less than 5 min&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Size Limit&lt;/td&gt;
&lt;td&gt;16 TiB&lt;/td&gt;
&lt;td&gt;10 GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Root device volume&lt;/td&gt;
&lt;td&gt;EBS&lt;/td&gt;
&lt;td&gt;Instance Store&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data Persistence&lt;/td&gt;
&lt;td&gt;Root Volume data is deleted, Non root EBS is persisted&lt;/td&gt;
&lt;td&gt;Data is persists only till life of the instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modification&lt;/td&gt;
&lt;td&gt;Instance type, Kernel, Ram Disk, User data can be changed in stopped state&lt;/td&gt;
&lt;td&gt;It is fixed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Charges&lt;/td&gt;
&lt;td&gt;Charged for instance use, EBS volume usage and Storing of AMI as EBS Snapshot&lt;/td&gt;
&lt;td&gt;Instance usage and AMI storage on S3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AMI Creation&lt;/td&gt;
&lt;td&gt;Single command&lt;/td&gt;
&lt;td&gt;requires installation and use of AMI tool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stopped State&lt;/td&gt;
&lt;td&gt;Can be in stopped state&lt;/td&gt;
&lt;td&gt;Cannot be in stopped state.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yIeTF7I---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-InfoG-EBS-Vs-Instance-Store.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yIeTF7I---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-InfoG-EBS-Vs-Instance-Store.png" alt="AWS Made Easy | AWS EC2 | AWS EBS Vs Instance Store" title="AWS Made Easy | AWS EC2 | AWS EBS Vs Instance Store"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might have this question in mind, &lt;em&gt;Why should you use Instance Store, when EBS is better in all aspects?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Instance Store is the option when you need low latency. Read and write are faster because host has the volume mounted. Check out the result published &lt;a href="https://gist.github.com/ktheory/3c3616fca42a3716346b"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Instance store is ephemeral. This makes them a perfect candidate for temporary data which changes very often.&lt;/p&gt;

&lt;h2&gt;
  
  
  Linux AMI virtualization types¶
&lt;/h2&gt;

&lt;p&gt;You might be thinking, &lt;em&gt;What is Virtualization after all?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Virtualization is a type of abstraction. It allows many machines created from a single computer. It translates the virtual machine into the underlying hardware.&lt;/p&gt;

&lt;p&gt;You might have used a Virtual Box to run Linux on your Windows PC, that is also a type of Virtualization.&lt;/p&gt;

&lt;p&gt;Virtualization is at the heart for all AWS or any Cloud Provider. You will be running many different operating system on the same piece of hardware.&lt;/p&gt;

&lt;p&gt;You might be thinking, &lt;em&gt;How can you run different operating system on the same piece of hardware?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The answer is a technology called HyperVisor or Virtual Machine Monitor (VMM). It allows to host different virtual machine.&lt;/p&gt;

&lt;p&gt;The different virtualization techniques used are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full Software Virtualization&lt;/li&gt;
&lt;li&gt;Hardware-assisted software virtualization or Hardware Virtual Machine (HVM)&lt;/li&gt;
&lt;li&gt;Paravirtualization or paravitualized Machine (PV)&lt;/li&gt;
&lt;li&gt;Hardware assisted software virtualization with Paravirtual drivers (PVHVM)&lt;/li&gt;
&lt;li&gt;Component or resource virtualization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BENQty4l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-InfoG-Linux-Virtualization-Types.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BENQty4l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-InfoG-Linux-Virtualization-Types.png" alt="AWS Made Easy | AWS EC2 | Linux Virtualization Types" title="AWS Made Easy | AWS EC2 | Linux Virtualization Types"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS supports two types of AMIs based on the virtualization techniques.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paravirtual (PV)&lt;/li&gt;
&lt;li&gt;Hardware virtual machine (HVM)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What are these Paravirtualization or Hardware Virtual Machine (HVM)? Come further the rabbit hole.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hardware virtual machine (HVM)¶
&lt;/h3&gt;

&lt;p&gt;CPU Chips with built in virtualization can support Hardware virtual machine (HVM).&lt;/p&gt;

&lt;p&gt;The Hardware virtual machine is a type of full software virtualization. It is dependent on the hardware capability. Hardware Virtual Machine (HVM) is the future.&lt;/p&gt;

&lt;h3&gt;
  
  
  Paravirtualization¶
&lt;/h3&gt;

&lt;p&gt;In this virtualization techniques, the guest OS uses the facilities provided by the host OS.&lt;/p&gt;

&lt;h3&gt;
  
  
  PV and HVM AMIs¶
&lt;/h3&gt;

&lt;p&gt;Have you seen any Paravirtual (PV) or Hardware Virtual Machine (HVM) AMIs in AWS. Check the images below&lt;/p&gt;

&lt;p&gt;HVM:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IS8Kcr8H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Virtualization-HVM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IS8Kcr8H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Virtualization-HVM.png" alt="AWS Made Easy | AWS EC2 | Virtualization HVM" title="AWS Made Easy | AWS EC2 | Virtualization HVM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Paravirtual&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0ZbPrcR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Virtualization-PV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0ZbPrcR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-Virtualization-PV.png" alt="AWS Made Easy | AWS EC2 | Virtualization PV" title="AWS Made Easy | AWS EC2 | Virtualization PV"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that Paravirtual is a thing of the past. It is only available in community AMIs and not present in the Quick Start AMIs.&lt;/p&gt;

&lt;p&gt;You have only HVM's as an option in Quick Start AMIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  HVM Vs PV¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;HVM&lt;/th&gt;
&lt;th&gt;PV&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Description&lt;/td&gt;
&lt;td&gt;HVM AMIs are presented with a fully Virtualized set of hardware and boot by executing the master boot record of the root block device of the image.&lt;/td&gt;
&lt;td&gt;PV AMIs boot with a special boot loader called PV-GRUB, which starts the boot cycle and then chain loads the kernel specified in the menu.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hardware extension&lt;/td&gt;
&lt;td&gt;Yes, can take advantage&lt;/td&gt;
&lt;td&gt;No, cannot take any advantage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Instance Type&lt;/td&gt;
&lt;td&gt;All current generation&lt;/td&gt;
&lt;td&gt;Only certain generation, like C1, C3, HS1, M1, M3, M2 and T1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Region&lt;/td&gt;
&lt;td&gt;All Region&lt;/td&gt;
&lt;td&gt;Asia Pacific (Tokyo), Asia Pacific (Singapore), Asia Pacific (Sydney), Europe (Frankfurt), Europe (Ireland), South America (São Paulo), US East (N. Virginia), US West (N. California), and US West (Oregon)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How to find&lt;/td&gt;
&lt;td&gt;Virtualization type of the AMI is set to hvm&lt;/td&gt;
&lt;td&gt;virtualization type of the AMI is set to paravirtual,&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fgn0Ky7W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-InfoG-HVM-VS-PV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fgn0Ky7W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/02-AWS-AMI-InfoG-HVM-VS-PV.png" alt="AWS Made Easy | AWS EC2 | Difference between HVM and PV" title="AWS Made Easy | AWS EC2 | Difference between HVM and PV"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have understood the difference between the virtualization techniques. Its time to move to understand &lt;em&gt;why would you pay for an AMI?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Shared and Paid AMIs¶
&lt;/h2&gt;

&lt;p&gt;You can separate the AMIs based on the payment option.&lt;/p&gt;

&lt;p&gt;As a Developers, you can share AMIs to the community, which you have created. Other developer's can pick these AMIs for modification. The Community AMIs are falling in this category.&lt;/p&gt;

&lt;p&gt;Use of these shared AMIs in production environment without audit is a security risk.&lt;/p&gt;

&lt;p&gt;The Paid AMIs are available from AWS Marketplace. It provides high quality licensed software configured in the AMIs. These are generally charged based on the hourly rate given by the owner.&lt;/p&gt;

&lt;p&gt;You might be thinking, normal EC2 billing I can understand.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How does a component of that EC2 charges money?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Come with me to find..&lt;/p&gt;

&lt;h2&gt;
  
  
  Billing¶
&lt;/h2&gt;

&lt;p&gt;You have executed the &lt;code&gt;describe-images&lt;/code&gt; command in What is AMI? section. In the JSON output you got this two details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "PlatformDetails": "Linux/UNIX",
    "UsageOperation": "RunInstances",
}

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

&lt;/div&gt;



&lt;p&gt;These two parameters define the billing of the AMI, and also compatibility.&lt;/p&gt;

&lt;p&gt;When launching a spot instance, always check if the spot instance supports the particular &lt;code&gt;PlatformDetails&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In case of Reserved Instance, you should check if the operating system platform lits the AMI &lt;code&gt;PlatformDetails&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;UsageOperation&lt;/code&gt; tells the &lt;a href="https://docs.aws.amazon.com/cur/latest/userguide/Lineitem-columns.html#Lineitem-details-O-Operation"&gt;lineitem/Operation&lt;/a&gt; in the actual billing of the AWS EC2 instance.&lt;/p&gt;

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

&lt;p&gt;Cloud Computing is possible today because of advancement in virtualization techniques. Hardware virtual machine (HVM) has a special role in this.&lt;/p&gt;

&lt;p&gt;AMI (Amazon machine image) has further enhanced the options.. Many instances can use these AMIs to launch identical copies. AMIs are the blueprint. AMIs have a definite life cycle of creating, register, copy, launch and de-register. If you are not creating your own AMI, then you have only last three life cycle states.&lt;/p&gt;

&lt;p&gt;AMIs are different based on the region, you are launching. It is different based on the architecture and operating system. It differs in the way different people have access to launch. It is differentiated based on the root device type.&lt;/p&gt;

&lt;p&gt;AWS supports only HVM and PV virtualization techniques. Between these, AWS is recommending the HVM and in future you may not even have a PV AMI.&lt;/p&gt;

&lt;p&gt;The billing of an EC2 instance includes AMI cost. &lt;code&gt;PlatformDetails&lt;/code&gt; &amp;amp; &lt;code&gt;UsageOperation&lt;/code&gt; field of the AMI contributes toward this cost.&lt;/p&gt;

&lt;p&gt;Hope you are clear with the concept of AMI. If you want to launch an EC2 instance. Checkout, the free tier EC2 instance launch article. see &lt;a href="https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html"&gt;Step by Step guide to create an EC2 instance&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cloudacademy.com/blog/aws-ami-hvm-vs-pv-paravirtual-amazon/"&gt;AWS AMI Virtualization Types: HVM vs PV (Paravirtual VS Hardware VM)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@kumargaurav1247/aws-ami-amazon-machine-image-3e0d53ae003b"&gt;AWS AMI- Amazon Machine Image.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linkeit.com/blog/what-are-amazon-machine-images-ami"&gt;What are Amazon Machine Images (AMI)?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/18650697/cost-of-storing-ami"&gt;Cost of storing AMI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/ktheory/3c3616fca42a3716346b"&gt;EC2 EBS-SSD vs instance-store performance on an EBS-optimized m3.2xlarge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=R-n4dDGfQd4"&gt;Deep Dive on New Amazon EC2 Instances and Virtualization Technologies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://logicalread.com/virtualization-for-oracle-mc11/#.YImYz-vhVTY"&gt;Overview of Virtualization Technologies&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awsec2</category>
    </item>
    <item>
      <title>The Insider's Guide to AWS EC2</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Wed, 21 Apr 2021 05:18:54 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/the-insider-s-guide-to-aws-ec2-1d46</link>
      <guid>https://dev.to/animeshkbhadra/the-insider-s-guide-to-aws-ec2-1d46</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--krZOiy2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--krZOiy2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2.png" alt="AWS Made Easy | AWS EC2 | Launching Instance" title="AWS Made Easy | AWS EC2 | Launching Instance"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;This is the shortest, easiest, and a beginner friendly step by step guide to launch and run a free tier AWS EC2 instance.&lt;/p&gt;

&lt;p&gt;I am going to teach you everything, launch a free tier EC2 instance, connect to the EC2 instance using SSH or RDP. This post will teach you just enough to be dangerous.&lt;/p&gt;

&lt;p&gt;If you ever wanted, just be able to launch a server (EC2) in the cloud and use that server, without worrying about the inner details. Even worried that it may cost you a fortune. This is the post you were waiting for.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In seven days, God Created the world.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You need only seven steps to create an AWS EC2 instance in cloud.&lt;/p&gt;

&lt;p&gt;Let's say &lt;strong&gt;Hello World&lt;/strong&gt; to the cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is AWS EC2 ?¶
&lt;/h2&gt;

&lt;p&gt;EC2 stands for Elastic Compute Cloud, AWS's virtual server in the cloud.&lt;/p&gt;

&lt;p&gt;In order to create an AWS EC2 instance, you should understand&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is AWS EC2?&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;Why to use EC2?&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;What is the benefit over your existing on premise server?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Cloud computing is all about collection of servers running on someone else premise. In case of AWS it is Amazon's premise.&lt;/p&gt;

&lt;p&gt;AWS EC2 is that single server in the school of servers on the cloud. AWS EC2 is one of the ingredients in the cloud recipe.&lt;/p&gt;

&lt;p&gt;AWS EC2 is that virtual server running in the cloud. It is also referred to as an &lt;strong&gt;instance&lt;/strong&gt; sometimes. You can select the amount of memory, storage and compute power each of your AWS EC2 should have.&lt;/p&gt;

&lt;p&gt;You can even commission and decommission AWS EC2 on demand. This is was makes it a preferred choice compared to the on premise server. Due to this facility, cloud can always manage the traffic coming to them. When the load is high you can have more EC2 instance, and less instance when the load is low.&lt;/p&gt;

&lt;p&gt;Cloud computing is all about paying what you use. You never pay for anything which you are not using.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How do you create this AWS EC2 instance?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lets jump right into it.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to create EC2 instance in AWS ?¶
&lt;/h2&gt;

&lt;p&gt;You have learned about &lt;a href="https://www.archerimagine.com/pages/aws-certification.html#aws-iam"&gt;AWS IAM&lt;/a&gt; before this, if not please read it. You have become comfortable with AWS Management console. You have still not seen anything happening in the cloud.&lt;/p&gt;

&lt;p&gt;The purpose of this Blog, is to get your own private server running in the cloud. You will learn about all the inner details of the AWS EC2 instance, in future series of Blog.&lt;/p&gt;

&lt;p&gt;In short you have still not said &lt;em&gt;Hello, World!&lt;/em&gt; to cloud. You will learn it today. Login into AWS Management console and follow along. You are entering The Matrix.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CUm_wRgh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Matrix.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CUm_wRgh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Matrix.jpg" alt="AWS Made Easy | Matrix" title="AWS Made Easy | Matrix"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  EC2 DashBoard¶
&lt;/h2&gt;

&lt;p&gt;In the AWS Management console, search for the service called EC2. It should launch an EC2 Dashboard just like this one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JRajT-fc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Dashboard.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JRajT-fc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Dashboard.png" alt="AWS Made Easy | AWS EC2 | DashBoard" title="AWS Made Easy | AWS EC2 | DashBoard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have to select the &lt;strong&gt;Launch Instance&lt;/strong&gt;. There are two ways to launch instances,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch Instance&lt;/li&gt;
&lt;li&gt;Launch Instance with a template.

&lt;ul&gt;
&lt;li&gt;This is a basic configuration which can be saved as a template and be used to launch multiple instance with the same configuration.&lt;/li&gt;
&lt;li&gt;You will learn more about this in future, when you learn Auto Scaling Group.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will have this screen next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kmIxyFA1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Choose%2520AMI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kmIxyFA1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Choose%2520AMI.png" alt="AWS Made Easy | AWS EC2 | Choose AMI" title="AWS Made Easy | AWS EC2 | Choose AMI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can clearly see that creating an EC2 instance is a 7 step process. These steps are.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Choose AMI&lt;/li&gt;
&lt;li&gt;Choose Instance Type&lt;/li&gt;
&lt;li&gt;Configure Instance&lt;/li&gt;
&lt;li&gt;Add Storage&lt;/li&gt;
&lt;li&gt;Add Tags&lt;/li&gt;
&lt;li&gt;Confirm Security Group.&lt;/li&gt;
&lt;li&gt;Review&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You will have to proceed with these 7 steps to create your AWS EC2 Instance.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Choose an Amazon Machine Image (AMI)¶
&lt;/h2&gt;

&lt;p&gt;An AMI or Amazon Machine Image, is a template which provide these information&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating System&lt;/li&gt;
&lt;li&gt;Application Server&lt;/li&gt;
&lt;li&gt;Application&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An AMI is just like kids Stencil, which they use draw same diagram multiple times. Hope you remember these...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Fa6Dt-M3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Stencil.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Fa6Dt-M3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Stencil.jpg" alt="AWS Made Easy | Stencil" title="AWS Made Easy | Stencil"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are multiple vendor for AMIs, but you will not focus on them here. This is a battle for another day.&lt;/p&gt;

&lt;p&gt;Please note, all the AMI listed at Quick Start are not free, please select the check box &lt;strong&gt;Free tier only&lt;/strong&gt; , to list only 16 AMIs out of 40 AMIs. See the below image for reference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXK_lSG8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Free-tier.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXK_lSG8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Free-tier.png" alt="AWS Made Easy | AWS EC2 | Free Tier AMI" title="AWS Made Easy | AWS EC2 | Free Tier AMI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Broadly the AMI's are divided based on Operating System, Linux and Windows, and Linux is subdivided primarily based on its flavor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iSL6v8W3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Ubuntu-AMI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iSL6v8W3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Ubuntu-AMI.png" alt="AWS Made Easy | AWS EC2 | Ubuntu AMI" title="AWS Made Easy | AWS EC2 | Ubuntu AMI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should go with &lt;strong&gt;Ubuntu Server 20.04 LTS (HVM), SSD Volume Type&lt;/strong&gt;, Select 64-bit (x86) version and move to the next step to Choose the instance type.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Choose an Instance Type¶
&lt;/h2&gt;

&lt;p&gt;This step is analogous to choosing the hardware for your server. You have hardware which is optimized for database operation, some are optimized for Machine learning and AI application, some web application. You will understand the details on this in the very short future.&lt;/p&gt;

&lt;p&gt;This screen looks like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0rWyLlnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Instance-Type.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0rWyLlnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Instance-Type.png" alt="AWS Made Easy | AWS EC2 | Instance Type" title="AWS Made Easy | AWS EC2 | Instance Type"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The instance type tells us in detail about the family of hardware, the number of CPU cores it has, what type of instance storage it supports, Network performance, etc.You will learn about this, but as of now focus on the free tier instance type.&lt;/p&gt;

&lt;p&gt;You have a &lt;code&gt;t2.micro&lt;/code&gt;, which is eligible for free tier. You get 750 hrs of usage each month for the first year of joining. Please select this instance and proceed to the next step of, Configure Instance.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3: Configure Instance Details¶
&lt;/h2&gt;

&lt;p&gt;This is the step which will require an article on its own. Just look at the configuration you can do on this screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mHfxm1Sz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Configure-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mHfxm1Sz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Configure-Instance.png" alt="AWS Made Easy | AWS EC2 | Configure Instance Type" title="AWS Made Easy | AWS EC2 | Configure Instance Type"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can configure all the below option.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of instances you want to launch&lt;/li&gt;
&lt;li&gt;Do you need spot instance, a type of instance which is very cheap and can be used for non production work&lt;/li&gt;
&lt;li&gt;Do you want to use the default VPC, which will have an Internet gateway, making it easier for the instance to connect to the Internet.&lt;/li&gt;
&lt;li&gt;Do you want it to launch in the default subnet of into your own subnet, also do you want to Auto assign public IP.

&lt;ul&gt;
&lt;li&gt;Do not worry if you do not understand anything above 2 points, will make all of this information very easy to digest in a future Blog.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;What placement group, capacity reservation to do, any join directory, or any specific IAM role to use.&lt;/li&gt;
&lt;li&gt;How does the machine shutdown, hibernation needs to be enabled, any detailed Cloud watch monitoring to be done, please note this is a paid option so do not enable details cloud watch monitoring.&lt;/li&gt;
&lt;li&gt;What type of tenancy will you choose, dedicated instance, dedicated host or shared instance.&lt;/li&gt;
&lt;li&gt;Do you want your instance to burst from baseline performance in case of high load.&lt;/li&gt;
&lt;li&gt;Do you want to mount an EFS file system on the creation time?&lt;/li&gt;
&lt;li&gt;In certain advanced details, you can select to enable the Metadata information access, version, response hop limit etc.,&lt;/li&gt;
&lt;li&gt;There is also an option to create a bootstrapping script.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the matter of simplicity, do not change any option in this screen and just proceed to the next step to Add Storage.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4: Add Storage¶
&lt;/h2&gt;

&lt;p&gt;Every computer, be it server or desktop needs a hard disk. The hard disk can be magnetic or SSD. AWS provides all the options for hard drive. Depending on the type of instance chosen in the step two the option of Hard drive may change.&lt;/p&gt;

&lt;p&gt;The screen will look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OmNdM_9G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Add-Storage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OmNdM_9G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Add-Storage.png" alt="AWS Made Easy | AWS EC2 | Add Storage" title="AWS Made Easy | AWS EC2 | Add Storage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see the option carefully, you can observe that there is also option to encrypt the data. Even you can attach additional storage (EBS) later. Select the default option and move to the next step, Add Tags.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 5: Add Tags¶
&lt;/h2&gt;

&lt;p&gt;AWS gives you an option to add tags for everything. This will help in finding a particular instance and execute some script on those instances. The tags are case-sensitive.&lt;/p&gt;

&lt;p&gt;The Add Tags screen looks like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0DiUE8L6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Add-Tags.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DiUE8L6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Add-Tags.png" alt="AWS Made Easy | AWS EC2 | Add Tags" title="AWS Made Easy | AWS EC2 | Add Tags"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add a &lt;code&gt;Name&lt;/code&gt; and value as &lt;code&gt;Webserver&lt;/code&gt; tag. Proceed to next step a very important step to Configure the security group.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 6: Configure Security Group¶
&lt;/h2&gt;

&lt;p&gt;Security is important in AWS, and as you learned in the &lt;a href="https://www.archerimagine.com/articles/aws/general-aws.html#aws-shared-responsibility-model"&gt;Shared Responsibility model&lt;/a&gt;. The security of the instance is the user's responsibility.&lt;/p&gt;

&lt;p&gt;The screen looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--koVacrAH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Configure-Security-Group.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--koVacrAH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Configure-Security-Group.png" alt="AWS Made Easy | AWS EC2 | Configure Security Groups" title="AWS Made Easy | AWS EC2 | Configure Security Groups"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have to understand few things about security group. Security group is basically a firewall to the instance. The default is to deny all traffic. The port which you open is the only traffic allowed.&lt;/p&gt;

&lt;p&gt;You may be aware, there are two needs to communicate with your AWS EC2 instance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH to the AWS EC2 instance 

&lt;ul&gt;
&lt;li&gt;You should open port 22 for this.&lt;/li&gt;
&lt;li&gt;You can open it from anywhere in the world, denoted by &lt;code&gt;0.0.0.0/0&lt;/code&gt; Source, in the above screen shot.&lt;/li&gt;
&lt;li&gt;You can even restrict the Source to be from just our public IP.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The AWS EC2 instance, should behave as a Web Server

&lt;ul&gt;
&lt;li&gt;You can just open port 80 for this.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The default set in the above screen is allowing SSH to this particular AWS EC2 instance from anywhere in the world. This is good for our first AWS EC2 instance launch.&lt;/p&gt;

&lt;p&gt;Select next and go to the last and final step of every AWS operation - &lt;strong&gt;Review&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 7: Review Instance Launch¶
&lt;/h2&gt;

&lt;p&gt;Here you are in the EndGame. This screen looks like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G2wsx_wx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Review.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G2wsx_wx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Review.png" alt="AWS Made Easy | AWS EC2 | Review and Launch" title="AWS Made Easy | AWS EC2 | Review and Launch"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This gives all the six steps you have done till now. This is the place you can review it. If you still want to change anything you can change it now. Press &lt;strong&gt;Launch&lt;/strong&gt; if you have no changes to be done. It provides with a pop-up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXveIB8z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Key-Pair.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXveIB8z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Key-Pair.png" alt="AWS Made Easy | AWS EC2 | Key Pair" title="AWS Made Easy | AWS EC2 | Key Pair"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This Key Pair is necessary for SSH-ing to the Linux AWS EC2, and you can use this Key-Pair to generate RDP (Remote desktop) credentials in case of Windows AWS EC2. Save the eye pair (PEM file) in your local machine.&lt;/p&gt;

&lt;p&gt;You are now ready to launch into Cloud, click &lt;strong&gt;Launch instance&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kRWrwqt---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Start.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kRWrwqt---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Start.jpg" alt="AWS Made Easy | AWS EC2 | Start" title="AWS Made Easy | AWS EC2 | Start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the AWS EC2 is created, you will be presented with this screen. This means the AWS EC2 is launching&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UoRBHd2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Launch-Status.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UoRBHd2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Launch-Status.png" alt="AWS Made Easy | AWS EC2 | Launch Status" title="AWS Made Easy | AWS EC2 | Launch Status"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulation on launching your first AWS EC2 instance. Welcome to the Cloud.&lt;/p&gt;
&lt;h2&gt;
  
  
  What next? Login to AWS EC2 using ssh¶
&lt;/h2&gt;

&lt;p&gt;You have launched your first AWS EC2 instance. What Next....&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What do you do with it?&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;How do you run the application on this server?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You have to SSH to the AWS EC2 instance. To SSH into the AWS you need some information.&lt;/p&gt;

&lt;p&gt;You should go to EC2 Dashboard &amp;gt; Instance, the screen will look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_3-eLdNB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-DashBoard-Instances.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_3-eLdNB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-DashBoard-Instances.png" alt="AWS Made Easy | AWS EC2 | Post Launch EC2 dashboard" title="AWS Made Easy | AWS EC2 | Post Launch EC2 dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see in the above screen, the AWS EC2 is still in &lt;em&gt;Initializing&lt;/em&gt; phase. Please click the Connect button to get the connect information, which would look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a-mkCH9h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Connect.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a-mkCH9h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Connect.png" alt="AWS Made Easy | AWS EC2 | EC2 Connect" title="AWS Made Easy | AWS EC2 | EC2 Connect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above screen tells you all the information you need to connect.&lt;/p&gt;

&lt;p&gt;To elaborate on the step, it is a two step process&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reduce the permission on the PEM key.&lt;/li&gt;
&lt;li&gt;Connect to the AWS EC2 using the SSH command.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Reduce permission of PEM File¶
&lt;/h3&gt;

&lt;p&gt;You should have the PEM file downloaded before, saved locally. Navigate to the directory where the PEM file is present. Execute this command to reduce the permission&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 400 &amp;lt;key_file&amp;gt;.pem

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;chmod&lt;/code&gt; command above will only provide the read permission to only owner. Groups and Others have no permission on the files. Once you have reduced the permission move to the next step.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSH connect to AWS EC2¶
&lt;/h3&gt;

&lt;p&gt;This is the big step, where you actually connect to AWS EC2. The general structure of the command is,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i "key_file_name.pem" ubuntu@ec2-12-66-176-143.&amp;lt;region&amp;gt;.compute.amazonaws.com

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

&lt;/div&gt;



&lt;p&gt;Once you have the SSH executed your terminal should look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e0NsrYKl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-SSH-connect.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e0NsrYKl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-SSH-connect.png" alt="AWS Made Easy | AWS EC2 | SSH Connect" title="AWS Made Easy | AWS EC2 | SSH Connect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can execute some command on the SSH terminal, like for Ubuntu the most popular commands to execute is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y

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

&lt;/div&gt;



&lt;p&gt;This is will update the software on the server.&lt;/p&gt;

&lt;p&gt;Please think how you can launch an Apache2 Web Server in this AWS EC2 instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Terminate of launched AWS EC2¶
&lt;/h2&gt;

&lt;p&gt;You have launched the AWS EC2 instance, in the free tier, it does not mean that you have infinite free usage. You should terminate the launched AWS EC2 instance. This will prevent you from unwanted cost.&lt;/p&gt;

&lt;p&gt;Go to EC2 Dashboard &amp;gt; Instance, and click on Action, it will look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iYKAVvQp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iYKAVvQp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminate.png" alt="AWS Made Easy | AWS EC2 | Terminate EC2" title="AWS Made Easy | AWS EC2 | Terminate EC2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the Instance State &amp;gt; Terminate. This will ask for confirmation like this,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lvyfcScB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminate-Instance.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lvyfcScB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminate-Instance.png" alt="AWS Made Easy | AWS EC2 | Termination Confirmation" title="AWS Made Easy | AWS EC2 | Termination Confirmation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once selecting Yes, Terminate, it will start the termination process, and once done you should a screen like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aNL6e_CD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminated.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aNL6e_CD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminated.png" alt="AWS Made Easy | AWS EC2 | EC2 Terminated" title="AWS Made Easy | AWS EC2 | EC2 Terminated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, you have safely launched, executed and terminated an AWS EC2 instance. Congratulation on the big step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tcvaIz8w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Congrats.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tcvaIz8w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/ec2/01-Generic-Congrats.png" alt="AWS Made Easy | AWS EC2 | Congratulations" title="AWS Made Easy | AWS EC2 | Congratulations"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;When this article started, you may not have known what is an AWS EC2 instance, How to make it work. You may have never thought it could be so easy to create one.&lt;/p&gt;

&lt;p&gt;You may still do not understand a lot of options which were selected in the above process, but you will understand each and every detail in the coming series of article.&lt;/p&gt;

&lt;p&gt;Launching a new free-tier EC2 instance is a 7 Step process, and you can login to the instance by SSH in case of Linux OS and RDP for Windows.&lt;/p&gt;

&lt;p&gt;Now you have your own piece in the cloud, do not forget to terminate the instance else, this piece of cloud will put a hole in your pocket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Image by &lt;a href="https://pixabay.com/users/comfreak-51581/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=356024"&gt;Comfreak&lt;/a&gt; from &lt;a href="https://pixabay.com/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=356024"&gt;Pixabay&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Photo by &lt;a href="https://www.pexels.com/@shvetsa?utm_content=attributionCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=pexels"&gt;Anna Shvets&lt;/a&gt; from &lt;a href="https://www.pexels.com/photo/crop-man-transferring-sketch-on-bag-5642045/?utm_content=attributionCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=pexels"&gt;Pexels&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freepik.com/photos/technology"&gt;Technology photo created by onlyyouqj - www.freepik.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@wilstewart3?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Wil Stewart&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/congratulations?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awsec2</category>
    </item>
    <item>
      <title>How to start using AWS Cognito</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Sat, 17 Apr 2021 08:46:23 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/how-to-start-using-aws-cognito-4b91</link>
      <guid>https://dev.to/animeshkbhadra/how-to-start-using-aws-cognito-4b91</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SJPCMYVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/09-AWS-Cognito.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SJPCMYVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/09-AWS-Cognito.png" alt="AWS Made Easy | AWS Cognito" title="AWS Made Easy | AWS Cognito"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Does AWS provide any service which will offload my sign-up, login, user management responsibility?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What if I told you, AWS has a service which does all of the above, and also provide a hosted web UI which can used by you. It even provides data sync across devices. Everything is perfectly secure. I will help you understand everything you need to know about this service.&lt;/p&gt;

&lt;p&gt;As a developer if you ever wished to focus only on the functionality or business logic of the application you are developing, and leaving the worries or sign-up, login, user management, data sync across devices in a safe and secure manner. Paying only based on the number of users per month. The AWS has answered your wish, and I will guide you through this.&lt;/p&gt;

&lt;p&gt;As per AWS&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can focus on creating great app experiences instead of worrying about building, securing, and scaling a solution to handle user management, authentication, and sync across platforms and devices.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's jump right into the enticing world of AWS Cognito.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Amazon Cognito?¶
&lt;/h2&gt;

&lt;p&gt;The official definition from AWS:-&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Amazon Cognito provides authentication, authorization, and user management for your web and mobile apps.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The most important concept in the above definition is &lt;strong&gt;authentication&lt;/strong&gt; &amp;amp; &lt;strong&gt;authorization&lt;/strong&gt;. This is provided using two components in AWS Cognito.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Cognito User Pool&lt;/li&gt;
&lt;li&gt;AWS Cognito Identity Pool&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Originally AWS Cognito was used for mobile developers, who could use AWS Cognito for its authentication &amp;amp; authorization capabilities along with the user management.&lt;/p&gt;

&lt;p&gt;AWS Lambda and ServerLess architecture have given a new dimension to use AWS Cognito. These developers can now offload user management of their application to an AWS Managed service.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AWS Cognito provides such developer with fully managed, scalable an cost-effective sign-up/sign-in service.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before you jump into learning about &lt;strong&gt;User Pool&lt;/strong&gt; and &lt;strong&gt;Identity Pool&lt;/strong&gt; , you should have a fair understanding of the terms &lt;strong&gt;authentication&lt;/strong&gt; &amp;amp; &lt;strong&gt;authorization&lt;/strong&gt;. You may also need to understand &lt;strong&gt;federation&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basics of Identity and Access Management (IAM)¶
&lt;/h2&gt;

&lt;p&gt;There is a great article by &lt;a href="https://www.okta.com/identity-101/authentication-vs-authorization/"&gt;Okta&lt;/a&gt;, which explains about IAM. Since you are here, I will summarize it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Authentication¶
&lt;/h3&gt;

&lt;p&gt;This is the first step in the security process of identity and access management.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Authentication is the act of validating that users are whom they claim to be.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The most common ways to authenticate user are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User Name and password combination&lt;/li&gt;
&lt;li&gt;OTPs&lt;/li&gt;
&lt;li&gt;Biometrics&lt;/li&gt;
&lt;li&gt;SSO (Social Sign On)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Authentication tells the application &lt;em&gt;Who am I?&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Authorization¶
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Authorization in a system security is the process of giving the user permission to access a specific resource or function.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once a person is Authenticated, you have to provide him with relevant access. Even a &lt;strong&gt;Guest&lt;/strong&gt; user, can be provided with minimum access.&lt;/p&gt;

&lt;p&gt;You can divide your users, into these four categories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Admin of the application&lt;/li&gt;
&lt;li&gt;Authenticated User&lt;/li&gt;
&lt;li&gt;Premium user (Paid)&lt;/li&gt;
&lt;li&gt;Guest user&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An Administrator can have a different view of the application than a normal authenticated user.&lt;/p&gt;

&lt;p&gt;Even an authenticated user can be free user or a premium user, depending on the type, the view of your application may be different.&lt;/p&gt;

&lt;p&gt;What type of experience you want to provide your user, decides the level of access.&lt;/p&gt;

&lt;p&gt;Lets understand this concept used by an analogy in most of the company.&lt;/p&gt;

&lt;p&gt;Most companies in pre-covid times used to give the RFID access card to its employee. Authentication means the process by which someone receives the RFID Access card. Once you receive your RFID access card, depending on the authorization of the employee, he may or may not have access to different parts of the office buildings.&lt;/p&gt;

&lt;p&gt;Hope you are clear on these questions now&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;What is Authentication?&lt;/em&gt; --&amp;gt; This answers the question "Who am I?"&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What is Authorization?&lt;/em&gt; --&amp;gt; This answers the question "What I can use?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a third variable in this equation, which is called Federation. Lets understand &lt;em&gt;What is federation?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Federation¶
&lt;/h3&gt;

&lt;p&gt;The word &lt;em&gt;federation&lt;/em&gt;, means a united, trusted relationship between two or more entities. To understand federation properly, you have to understand few other concepts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Identity Federation&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;It is a system of trust between two parties, to authenticate users and also convey the information required for giving authorization.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identity provider&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The party in identity federation, which stores the user information, responsible for user authentication.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service Provider&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The party in identity federation, which provides the service based on authentication and authorization provided by Identity provider.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open Standards&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Identity federation is possible because of these open standards&lt;/li&gt;
&lt;li&gt;OIDC (OpenID Connect)&lt;/li&gt;
&lt;li&gt;SAML (Security assertion markup language) 2.0&lt;/li&gt;
&lt;li&gt;OAuth 2.0&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;When you book movie ticket online, you are authenticated by an online entity, who takes your money and gives you the ticket, when you go to the actual theater you are granted entry based on the ticket, you purchased online. In this case the online ticket vendor is the &lt;strong&gt;Identity provider&lt;/strong&gt; , the theater is the &lt;strong&gt;service provider&lt;/strong&gt; , and the bi-party arrangement is the &lt;strong&gt;Identity Federation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1j6JljXl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Federation.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1j6JljXl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Federation.png" alt="AWS Made Easy | Federation" title="AWS Made Easy | Federation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the basic identity and access management is clear to you, let's move on to understand &lt;strong&gt;User Pool&lt;/strong&gt; and &lt;strong&gt;identity pool&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  User Pool¶
&lt;/h2&gt;

&lt;p&gt;AWS Cognito &lt;strong&gt;User Pool&lt;/strong&gt; , is a way to provide &lt;strong&gt;Authentication&lt;/strong&gt; to user of an Application. It is represented as a user directory in Amazon Cognito.&lt;/p&gt;

&lt;p&gt;The authentication mechanism provided by AWS Cognito User Pools is:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Social Identity Providers&lt;/li&gt;
&lt;li&gt;SAML Identity Providers&lt;/li&gt;
&lt;li&gt;AWS Cognito User Pools, also provide authentication, or act as an identity provider.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Federation, as explained, the Identity provider, stores the user information. When AWS Cognito User Pools are used as the identity provider, the user directory of AWS Cognito stores the user login details, else its store in the identity providers storage.&lt;/p&gt;

&lt;p&gt;The user directory is accessible by an SDK. This can be used by applications to access user profile.&lt;/p&gt;

&lt;p&gt;AWS Cognito User pool provide:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign up and sign in service&lt;/li&gt;
&lt;li&gt;A built-in customizable web-ui for user to register.&lt;/li&gt;
&lt;li&gt;Social sign-in with social identity provider.&lt;/li&gt;
&lt;li&gt;User directory management and user profile.&lt;/li&gt;
&lt;li&gt;MFA.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once a user is authenticated, the application receives a JWT (JavaScript Web token). The next step of &lt;strong&gt;authorizing&lt;/strong&gt; uses this JWT.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure User Pool¶
&lt;/h3&gt;

&lt;p&gt;When you select AWS Cognito in AWS console you get this screen, asking to choose .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AYPLsofU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-choose-02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AYPLsofU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-choose-02.png" alt="AWS Made Easy | AWS Cognito Choose" title="AWS Made Easy | AWS Cognito Choose"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since you will configure the User Pool, lets choose the User Pool Option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LI8fIhLm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LI8fIhLm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-01.png" alt="AWS Made Easy | AWS Cognito User Pool" title="AWS Made Easy | AWS Cognito User Pool"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To Make life easier you can select the &lt;strong&gt;Review Defaults&lt;/strong&gt; , and it could provide you with a good basic user pool.&lt;/p&gt;

&lt;p&gt;You can also choose to configure each of these ten settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BH_6YnI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-steps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BH_6YnI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-steps.png" alt="AWS Made Easy | AWS Cognito User Pool steps" title="AWS Made Easy | AWS Cognito User Pool step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Customizing all the settings for user pool creation, would be beyond the scope of this Blog. Let's take these two approaches.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a user pool with the default option.&lt;/li&gt;
&lt;li&gt;Add an App to enable the hosted WebUI.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create a User Pool (Default)¶
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Step 1 : Select the " &lt;strong&gt;Create a user pool&lt;/strong&gt;".&lt;/li&gt;
&lt;li&gt;Step 2 : It provides us with this screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LI8fIhLm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-01.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LI8fIhLm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-01.png" alt="AWS Made Easy | AWS Cognito User Pool" title="AWS Made Easy | AWS Cognito User Pool"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 3 : Provide a name for Pool, and press the &lt;strong&gt;Review Defaults&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Step 4 : On pressing the &lt;strong&gt;Review Defaults&lt;/strong&gt; , you get this &lt;strong&gt;Review&lt;/strong&gt; screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C323H0j0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-Review.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C323H0j0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-Review.png" alt="AWS Made Easy | AWS Cognito User Pool Review" title="AWS Made Easy | AWS Cognito User Pool Review"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The review pages, tells us these important information.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pool Name&lt;/li&gt;
&lt;li&gt;Email is a required attributes.&lt;/li&gt;
&lt;li&gt;There is a password policies.&lt;/li&gt;
&lt;li&gt;How the message's for AWS Cognito needs to be communicated.&lt;/li&gt;
&lt;li&gt;MFA is enabled or not.&lt;/li&gt;
&lt;li&gt;Tags are created or not&lt;/li&gt;
&lt;li&gt;App Clients are registered or not.&lt;/li&gt;
&lt;li&gt;Which are Triggers to configure. like pre sign-up, pre-authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you carefully watch the Review page and the steps to create a user pool, they match.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 5 : Press the &lt;strong&gt;Create Pool&lt;/strong&gt; , button and your User Pool is created.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vTZv7nT6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-Created.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vTZv7nT6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-Created.png" alt="AWS Made Easy | AWS Cognito User Pool Created" title="AWS Made Easy | AWS Cognito User Pool Created"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congrats on creating the default user pool. Now you should check out the Hosted UI provided by the AWS Cognito for sign-up and login.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add an App to Enable the Hosted Web UI¶
&lt;/h3&gt;

&lt;p&gt;AWS Cognito even goes a step ahead into offloading your user management work. It provides a user sign-in, login page as a hosted web. Let's see, how can you configure this.&lt;/p&gt;

&lt;p&gt;You will use the default user pool created before. Once you have created a User Pool, you can edit a lot of attributes provided here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KFemSbVE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-attributes.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KFemSbVE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-attributes.png" alt="AWS Made Easy AWS Cognito User Pool Attributes" title="AWS Made Easy AWS Cognito User Pool Attributes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To Use the hosted WebUi, you will focus on the &lt;strong&gt;App Integration&lt;/strong&gt; property of the user pool.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Select &lt;strong&gt;App Integration&lt;/strong&gt; from Setting of User Pool.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HY9Iiddz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-AppIntegration.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HY9Iiddz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-AppIntegration.png" alt="AWS Made Easy AWS Cognito User Pool App Integration" title="AWS Made Easy AWS Cognito User Pool App Integration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get the Web Hosted UI, you have to use this configuration, if you have your own domain, provide your custom domain, else use the AWS domain.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 2: Add Domain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On choosing the Add Domain option, you get this screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--31kHPTXb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-AddDomain.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--31kHPTXb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-AddDomain.png" alt="AWS Made Easy AWS Cognito User Pool Add Domain" title="AWS Made Easy AWS Cognito User Pool Add Domain"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the domain, you wish, and keep a note of this, you will require it later.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 3 : Add &lt;strong&gt;App Client&lt;/strong&gt; under &lt;strong&gt;General settings&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Select the App Client under General Setting, so you can enter the app client attributes. The screen will look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--07V_Cfzm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-ChooseClient.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--07V_Cfzm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-ChooseClient.png" alt="AWS Made Easy AWS Cognito User Pool Add App Client" title="AWS Made Easy AWS Cognito User Pool Add App Client"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should select the &lt;strong&gt;Add an app client&lt;/strong&gt; option. The screen will look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_nV2Pi6y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-ChooseClient-02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_nV2Pi6y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-ChooseClient-02.png" alt="AWS Made Easy AWS Cognito User Pool Add App Client" title="AWS Made Easy AWS Cognito User Pool Add App Client"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should provide the name of the client, and de-select the option &lt;strong&gt;Generate client secret&lt;/strong&gt;. This option can be used when you have a server side component to generate the client secret. Once the app client is created. We move to the Step 4.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 4 App Client Settings:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Select the App Client Setting, under App Integration. You will get a screen like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N4fOIcZo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-App-Client-Settings.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N4fOIcZo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-App-Client-Settings.png" alt="AWS Made Easy AWS Cognito User Pool App Client Settings" title="AWS Made Easy AWS Cognito User Pool App Client Settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you check the App Client details are already present, In the above screen, you have to select&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cognito User Pool as the enabled identity providers.&lt;/li&gt;
&lt;li&gt;Since you are testing, provide " &lt;strong&gt;&lt;a href="http://localhost"&gt;http://localhost&lt;/a&gt;&lt;/strong&gt;" as the callback URLs, this is for validation.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Implicit Grant&lt;/strong&gt; , in Allowed OAuth Flows.&lt;/li&gt;
&lt;li&gt;Select All the allowed OAuth Scope, you want.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Save the option.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 5 : Launch the WebHosted UI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the bottom of the previous screen, there is an option for &lt;strong&gt;Launch Hosted UI&lt;/strong&gt;. Use this option. You should get a sign-up page like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g9fTKm5u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-WebHostedUI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g9fTKm5u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-WebHostedUI.png" alt="AWS Made Easy AWS Cognito User Pool WebHosted UI" title="AWS Made Easy AWS Cognito User Pool WebHosted UI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is your simple web hosted a for Login and sign up. Though everything may not work. Just refer this as a guideline.&lt;/p&gt;

&lt;p&gt;At this point you can use IAM roles for your application and this authentication to make your application function. But providing different level of authorization will still be the application's responsibility. If you want to hand over this part also then move to Identity Pool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Identity Pool¶
&lt;/h2&gt;

&lt;p&gt;AWS Cognito Identity pool does both Authentication and authorization, but in a different way.&lt;/p&gt;

&lt;p&gt;The AWS Cognito Identity pool uses Federated identity for authenticating users. Different identity federation can be provided by&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Social Identity Provider&lt;/li&gt;
&lt;li&gt;SAML Identity Provider&lt;/li&gt;
&lt;li&gt;OpenID Connect Provider&lt;/li&gt;
&lt;li&gt;Amazon Cognito User Pool.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kindly note, the AWS Identity pool is the service provider in the identity federation paradigm. It uses the identity providers to authenticate the user.&lt;/p&gt;

&lt;p&gt;Once these identity providers do their magic (authentication), they inform the Identity pool by issuing a type of token. On receiving the token, identity pool will authorize users to a different level of access.&lt;/p&gt;

&lt;p&gt;Identity pool will provide the user with different level of access by using IAM Roles.&lt;/p&gt;

&lt;p&gt;Identity pool uses &lt;a href="https://www.archerimagine.com/articles/aws/aws-sts.html"&gt;AWS STS&lt;/a&gt;, service to grant the users credentials to access AWS resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure Identity Pool¶
&lt;/h3&gt;

&lt;p&gt;Configuring Identity Pool is a 2 Step Process.&lt;/p&gt;

&lt;p&gt;Select Manage identity Pool from the screen when you created the user pool. You will be greeted with this screen.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1 : Create Identity Pool&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l4yPKMXn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-IdentityPool-Configure.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l4yPKMXn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-IdentityPool-Configure.png" alt="AWS Made Easy AWS Cognito Identity pool configure" title="AWS Made Easy AWS Cognito Identity pool configure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this step you have to configure 3 things apart from providing a name to the identity pool.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unauthenticated Identities

&lt;ul&gt;
&lt;li&gt;AWS Cognitio provides support for Guest user. It generates a unique ID for each guest.&lt;/li&gt;
&lt;li&gt;In the future if they register, the complete session is saved into the user directory.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Authentication flow settings

&lt;ul&gt;
&lt;li&gt;We can select a basic or an enhanced authentication flow.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Authentication providers

&lt;ul&gt;
&lt;li&gt;We have All the Social Identity providers along with OpenID and SAML.&lt;/li&gt;
&lt;li&gt;We will use Cognito, which needs us to provide &lt;strong&gt;user pool id&lt;/strong&gt; and &lt;strong&gt;App Client ID&lt;/strong&gt; , which was created during the user pool.
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Once you fill the required details, let's proceed to the most important step in AWS Cognito, providing Permissions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 2 : Set Permissions &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the screen, as you can guess, can provide two types of IAM Role to both Authenticated and Unauthenticated user. The IAM Role will be created here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ElUA8cL8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-IdentityPool-IAMRole.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ElUA8cL8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-IdentityPool-IAMRole.png" alt="AWS Made Easy AWS Cognito Identity pool IAM Role" title="AWS Made Easy AWS Cognito Identity pool IAM Role"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the IAM policy statement for Authenticated Users in AWS Cognito Identity pool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "mobileanalytics:PutEvents",
        "cognito-sync:*",
        "cognito-identity:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

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

&lt;/div&gt;



&lt;p&gt;Here is the IAM policy statement for UnAuthenticated Users in AWS Cognito Identity pool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "mobileanalytics:PutEvents",
        "cognito-sync:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

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

&lt;/div&gt;



&lt;p&gt;Once you are ready, just select &lt;strong&gt;Allow&lt;/strong&gt;. You will have your AWS Cognito Identity Pool created, just use this option for integrating with the SDK you want to use.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Getting Started with Amazon Cognito&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ze3B650c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-IdentityPool-Configured.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ze3B650c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-IdentityPool-Configured.png" alt="AWS Made Easy AWS Cognito Identity pool configured" title="AWS Made Easy AWS Cognito Identity pool configured"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Code for AWS Cognito¶
&lt;/h2&gt;

&lt;p&gt;You might be thinking, how does it all come together. You have a user pool and an identity pool. You also created the Web Hosted UI. You might be thinking how do I use it together.&lt;/p&gt;

&lt;p&gt;If you like video, to learn, visit the &lt;a href="https://www.youtube.com/playlist?list=PLLhEJK7fQIxDSD-5FgBuegurOjzGwjtzw"&gt;AWS Cognito Python tutorials&lt;/a&gt; by &lt;strong&gt;Paris Nakita Kejser&lt;/strong&gt;. This is the only AWS Cognito's in Python video tutorial.&lt;/p&gt;

&lt;p&gt;We will just pick two important flow from the above tutorials, as some changes need to be done in the code mentioned in the video.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sign-Up using AWS Cognito, Python SDK Boto3¶
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import boto3
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

# read the .env-sample, to load the environment variable.
dotenv_path = os.path.join(os.path.dirname( __file__ ), ".env-sample")
load_dotenv(dotenv_path)

username = "abc.xyz@gmail.com"
password = "#Abc1234"

client = boto3.client("cognito-idp", region_name="&amp;lt;region-name&amp;gt;")

print(os.getenv("COGNITO_USER_CLIENT_ID"))

# The below code, will do the sign-up
response = client.sign_up(
    ClientId=os.getenv("COGNITO_USER_CLIENT_ID"),
    Username=username,
    Password=password,
    UserAttributes=[{"Name": "email", "Value": username}],
)

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

&lt;/div&gt;



&lt;p&gt;There are certain prerequisites for this code to work.&lt;/p&gt;

&lt;p&gt;Create a file called &lt;code&gt;.env-sample&lt;/code&gt;, in the current directory where you have the above code. In this file you should provide the macro &lt;code&gt;COGNITO_USER_CLIENT_ID&lt;/code&gt;, with the client ID from &lt;strong&gt;General Settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;App Client&lt;/strong&gt; &amp;gt; &lt;strong&gt;App client id&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The above will be picked using the &lt;code&gt;dotenv&lt;/code&gt; module.&lt;/p&gt;

&lt;p&gt;When you execute the above code, you will get this back as a response,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "UserConfirmed":false,
   "CodeDeliveryDetails":{
      "Destination":"a ***@g***.com",
      "DeliveryMedium":"EMAIL",
      "AttributeName":"email"
   },
   "UserSub":"123456-d094-44e0-942d-789012134",
   "ResponseMetadata":{
      "RequestId":"123-1842-4027-345-789abc09234",
      "HTTPStatusCode":200,
      "HTTPHeaders":{
         "date":"Mon, 19 Apr 2021 05:11:44 GMT",
         "content-type":"application/x-amz-json-1.1",
         "content-length":"175",
         "connection":"keep-alive",
         "x-amzn-requestid":"123-1842-4027-345-789abc09234"
      },
      "RetryAttempts":0
   }
}

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

&lt;/div&gt;



&lt;p&gt;If you check the &lt;strong&gt;General Setting&lt;/strong&gt; &amp;gt; &lt;strong&gt;User and groups&lt;/strong&gt; , the user will be unconfirmed, you will see this, and get a verification code in your email.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9JPD1NJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-newUser.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9JPD1NJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-newUser.png" alt="AWS Made Easy AWS Cognito User Pool Unconfirmed user" title="AWS Made Easy AWS Cognito User Pool Unconfirmed user"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Confirmation Code using AWS Cognito, Python SDK Boto3¶
&lt;/h3&gt;

&lt;p&gt;Now you are an unconfirmed user, you have got the confirmation code in the mail. Let's find a way to make you a confirm user. Here is the code to do that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import boto3
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

dotenv_path = os.path.join(os.path.dirname( __file__ ), ".env-sample")
load_dotenv(dotenv_path)

username = "abc.xyz@gmail.com"

client = boto3.client("cognito-idp", region_name="&amp;lt;region-id&amp;gt;")

print(os.getenv("COGNITO_USER_CLIENT_ID"))
confirm_code = "112418"

# Below API sends the confirmation code.
response = client.confirm_sign_up(
    ClientId=os.getenv("COGNITO_USER_CLIENT_ID"),
    Username=username,
    ConfirmationCode=confirm_code,
)

print(response)

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

&lt;/div&gt;



&lt;p&gt;Post this the response is this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "ResponseMetadata":{
      "RequestId":"3412d123-c175-4571-91a5-12349c14a9bd",
      "HTTPStatusCode":200,
      "HTTPHeaders":{
         "date":"Mon, 19 Apr 2021 05:22:10 GMT",
         "content-type":"application/x-amz-json-1.1",
         "content-length":"2",
         "connection":"keep-alive",
         "x-amzn-requestid":"3412d123-c175-4571-91a5-12349c14a9bd"
      },
      "RetryAttempts":0
   }
}

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

&lt;/div&gt;



&lt;p&gt;If you again go and check in &lt;strong&gt;General Setting&lt;/strong&gt; &amp;gt; &lt;strong&gt;User and groups&lt;/strong&gt; , the user should be confirmed now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T04nadPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-confirm-user.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T04nadPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-confirm-user.png" alt="AWS Made Easy AWS Cognito User Pool confirmed user" title="AWS Made Easy AWS Cognito User Pool confirmed user"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have successfully created your first app user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Login and Getting User details using AWS Cognito¶
&lt;/h3&gt;

&lt;p&gt;You have now successfully created a new user, and also confirmed the user. The next logical step will be to Login and get some user details from AWS Cognito.&lt;/p&gt;

&lt;p&gt;This you can achieve in this manner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import boto3
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

dotenv_path = os.path.join(os.path.dirname( __file__ ), ".env-sample")
load_dotenv(dotenv_path)

username = "abc.xyz@gmail.com"
password = "#Abc1234"

client = boto3.client("cognito-idp", region_name="ap-south-1")

print(os.getenv("COGNITO_USER_CLIENT_ID"))

# Initiating the Authentication, 
response = client.initiate_auth(
    ClientId=os.getenv("COGNITO_USER_CLIENT_ID"),
    AuthFlow="USER_PASSWORD_AUTH",
    AuthParameters={"USERNAME": username, "PASSWORD": password},
)

# From the JSON response you are accessing the AccessToken
print(response)
# Getting the user details.
access_token = response["AuthenticationResult"]["AccessToken"]

response = client.get_user(AccessToken=access_token)
print(response)

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

&lt;/div&gt;



&lt;p&gt;Please note sometime you may get this error&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;botocore.errorfactory.InvalidParameterException: An error occurred (InvalidParameterException) when calling the InitiateAuth operation: USER_PASSWORD_AUTH flow not enabled for this client

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

&lt;/div&gt;



&lt;p&gt;If you get this error, please check in &lt;strong&gt;General Settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;App Client&lt;/strong&gt; &amp;gt; &lt;strong&gt;Auth Flow Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should have this option selected &lt;code&gt;ALLOW_USER_PASSWORD_AUTH&lt;/code&gt; selected, or just for testing enable all the option like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hv03-VBN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-auth-flow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hv03-VBN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-UserPool-auth-flow.png" alt="AWS Made Easy AWS Cognito User Pool Authenticate user" title="AWS Made Easy AWS Cognito User Pool Authenticate user"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will get a JSON as a response of &lt;code&gt;initiate_auth&lt;/code&gt;, you have to just pick the &lt;code&gt;AccessToken&lt;/code&gt; from it and pass it to &lt;code&gt;get_user&lt;/code&gt;. Once that is done, you will get this as a response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "Username":"abc.xyz@gmail.com",
   "UserAttributes":[
      {
         "Name":"sub",
         "Value":"1234eb31-d094-44e0-942d-50a1234a66b"
      },
      {
         "Name":"email_verified",
         "Value":"true"
      },
      {
         "Name":"email",
         "Value":"abc.xyz@gmail.com"
      }
   ],
   "ResponseMetadata":{
      "RequestId":"xxxxxxx-1231-4f1c-b881-dcf10c54e576",
      "HTTPStatusCode":200,
      "HTTPHeaders":{
         "date":"Mon, 19 Apr 2021 08:26:10 GMT",
         "content-type":"application/x-amz-json-1.1",
         "content-length":"213",
         "connection":"keep-alive",
         "x-amzn-requestid":"xxxxxxx-1231-4f1c-b881-dcf10c54e576"
      },
      "RetryAttempts":0
   }
}

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

&lt;/div&gt;



&lt;p&gt;This is enough to understand how AWS Cognito works, you can even follow the video for Forgot Password flow also.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Cognito Sync¶
&lt;/h2&gt;

&lt;p&gt;The official documentation of AWS Cognito Sync is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Amazon Cognito Sync is an AWS service and client library that enables cross-device syncing of application-related user data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Few use cases of the AWS Cognito Syncs are.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Synchronize the user profile data across the mobile devices and the web, without a back-end.&lt;/li&gt;
&lt;li&gt;The application can cache data locally if there is no connectivity, and once you get connected the data are synced.&lt;/li&gt;
&lt;li&gt;The AWS Identity pool is required to use the AWS Cognito Sync.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;AWS Cognito is a service to use if you want to offload complete user management tasks to AWS. This will cost a little, but you can continue to focus on the good things of your application and ignore the mundane activity of user management.&lt;/p&gt;

&lt;p&gt;You can rest assured that AWS will take responsibility of upgrading the service for latest security patches, and you are not exposed to such security flaws.&lt;/p&gt;

&lt;p&gt;AWS Cognito User pools and Identity pools are the two brothers of AWS Cognito, shouldering the responsibility of authentication and authorization. Using IAM roles, you can provide very fine grained access to users.&lt;/p&gt;

&lt;p&gt;Integration using SAML, OIDC also help in using 3rd party vendors as your Identity Providers. Even the Guest users can be assigned a unique ID which can later be saved to a user profile, if he registers.&lt;/p&gt;

&lt;p&gt;Though you may never use the AWS Cognito provided Web Hosted UI, but it makes a great point in AWS service, how thought out their services are.&lt;/p&gt;

&lt;p&gt;The AWS Boto3 SDK can use the AWS Cognito APIs to provide the complete functionality of User Management in your application with the most minimal amount of code.&lt;/p&gt;

&lt;p&gt;This would have given you a fair understanding of AWS Cognito Service. Let me know if you tried the Python Code to login the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=abTy-Yyo6lI"&gt;Introduction to Amazon Cognito - User Authentication and Mobile Data Service on AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=OAR4ZHP8DEg"&gt;Authentication for Your Applications: Getting Started with Amazon Cognito - AWS Online Tech Talks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=jTu--LpjA18"&gt;AWS Cognito | Amazon Cognito | AWS Tutorial for Beginners | AWS Training | Edureka&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=tAUmz94O2Qo"&gt;Fine-grained Access Control with Amazon Cognito Identity Pools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.smashingmagazine.com/2017/08/user-authentication-web-ios-apps-aws-cognito-part-1/"&gt;User Authentication For Web And iOS Apps With AWS Cognito (Part 1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/"&gt;What's the difference between Amazon Cognito user pools and identity pools?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thenewstack.io/understanding-aws-cognito-user-and-identity-pools-for-serverless-apps/"&gt;Understanding AWS Cognito User and Identity Pools for Serverless Apps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://securityboulevard.com/2020/05/iam-101-series-federation-and-federated-sso/"&gt;IAM 101 Series: Federation and Federated SSO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://security.stackexchange.com/questions/13803/what-is-the-difference-between-federated-login-and-single-sign-on"&gt;What is the difference between Federated Login and Single Sign On?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/what-is-amazon-cognito.html"&gt;What Is Amazon Cognito?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/identity/federation/"&gt;Identity federation in AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=KWjgiNgDfwI"&gt;Deep Dive on User Sign-up and Sign-in with Amazon Cognito&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/playlist?list=PLLhEJK7fQIxDSD-5FgBuegurOjzGwjtzw"&gt;Learning AWS Cognito with Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/49000676/aws-cognito-authentication-user-password-auth-flow-not-enabled-for-this-client"&gt;AWS Cognito Authentication USER_PASSWORD_AUTH flow not enabled for this client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cognito-idp.html#CognitoIdentityProvider.Client.admin_confirm_sign_up"&gt;Python Boto3 for AWS Cognito&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/41546883/what-is-the-use-of-python-dotenv"&gt;What is the use of python-dotenv?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://auth0.com/docs/flows"&gt;Authentication and Authorization Flows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Info graphics¶
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Authentication Vs Authorization¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Authentication&lt;/th&gt;
&lt;th&gt;Authorization&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Validate the user&lt;/td&gt;
&lt;td&gt;provide access to resources&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Passwords, biometrics, OTP used for authentication.&lt;/td&gt;
&lt;td&gt;Policy and rules are used to grant access.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First Step in IAM&lt;/td&gt;
&lt;td&gt;Follows authentication, (exception - Guest user)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OIDC 2.0&lt;/td&gt;
&lt;td&gt;OAuth 2.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ID Token are used&lt;/td&gt;
&lt;td&gt;Access tokens are used&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User has some control&lt;/td&gt;
&lt;td&gt;User have no control&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xjnLE2wL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Authentication-Vs-Authorization.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xjnLE2wL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Authentication-Vs-Authorization.png" alt="AWS Made Easy | Authentication Vs Authorization" title="AWS Made Easy | Authentication Vs Authorization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Cognito User Pool Vs Identity Pool¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;User Pool&lt;/th&gt;
&lt;th&gt;Identity Pool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Authentication&lt;/td&gt;
&lt;td&gt;Authorization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User Management&lt;/td&gt;
&lt;td&gt;IAM Roles for Access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sign-Up &amp;amp; Login&lt;/td&gt;
&lt;td&gt;Fine Grain Access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Provide WebHosted UI&lt;/td&gt;
&lt;td&gt;Complete back end access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User Pool is charged&lt;/td&gt;
&lt;td&gt;Identity pool is free&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No Guest user&lt;/td&gt;
&lt;td&gt;Guest User&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aLoobQNz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-User-Pool-Vs-Identity-Pool.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aLoobQNz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Cognito-User-Pool-Vs-Identity-Pool.png" alt="AWS Made Easy | AWS Cognito User Pool vs Identity Pool" title="AWS Made Easy | AWS Cognito User Pool vs Identity Pool"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using AWS Cognito User Pool With Identity Pool¶
&lt;/h3&gt;

&lt;p&gt;When you have both AWS Cognito user pool and identity pool, they can function together with each other to provide access to user for AWS resources. These can be done in three steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Application uses the AWS Cognito User Pool, to authenticate, and gets tokens in return.&lt;/li&gt;
&lt;li&gt;The application exchanges this tokes with the AWS Cognito Identity Pool and received AWS credentials in returns.&lt;/li&gt;
&lt;li&gt;Use the AWS Credentials, and use to access the AWS resources. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v_QUycaF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/UserPoolWith-Identity.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v_QUycaF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/UserPoolWith-Identity.png" alt="AWS Made Easy | AWS Cognito User Pool with Identity Pool" title="AWS Made Easy | AWS Cognito User Pool with Identity Pool"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;When you are using AWS Cognito User Pool With Identity Pool, the flow is explained above.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The application authenticates and get token from AWS Cognito User Pool as a JWT Token.&lt;/li&gt;
&lt;li&gt;This JWT Token is then passed on to AWS Cognito Identity Pool, which returns an IAM Roles for the user.&lt;/li&gt;
&lt;li&gt;Once the IAM role is assigned, the user can access any resources on AWS.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awscognito</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The AWS Inspector Blog of your dreams</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Sun, 11 Apr 2021 06:47:36 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/the-aws-inspector-blog-of-your-dreams-dbc</link>
      <guid>https://dev.to/animeshkbhadra/the-aws-inspector-blog-of-your-dreams-dbc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--44RhnTD6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/08-AWS-Inspector.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--44RhnTD6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/08-AWS-Inspector.png" alt="AWS Made Easy | AWS Inspector" title="AWS Made Easy | AWS Inspector"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;You have learned about the &lt;a href="https://www.archerimagine.com/articles/aws/general-aws.html#aws-shared-responsibility-model"&gt;AWS Shared responsibility model,&lt;/a&gt; Have you stopped and thought, how do you check if your VPC is accessible from outside network? Does my application compromises the EC2 in any regards?&lt;/p&gt;

&lt;p&gt;You should remember that &lt;strong&gt;network accessibility&lt;/strong&gt; and &lt;strong&gt;software security&lt;/strong&gt; is the &lt;strong&gt;user's responsibility&lt;/strong&gt; in &lt;a href="https://www.archerimagine.com/articles/aws/general-aws.html#aws-shared-responsibility-model"&gt;AWS Shared responsibility model.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a beginner using the AWS, this responsibility may seem daunting. No worries, when AWS gives you a challenge, it also shows you the path.&lt;/p&gt;

&lt;p&gt;You will learn how can we use an AWS Service to check the security vulnerability of your software. You will also learn how this service helps in checking the network accessibility of the VPC.&lt;/p&gt;

&lt;p&gt;Let's dive into the inspected world of AWS Inspector.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is AWS Inspector?¶
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AWS inspector&lt;/strong&gt; is a service provided by AWS, which helps you in two ways&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding security vulnerabilities in your software.&lt;/li&gt;
&lt;li&gt;Checking the network accessibility of the VPCs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS inspector gives findings for the checks done, on which you can act on. You can use the findings and corrects the weakness in your application or the network.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Inspector Agent¶
&lt;/h3&gt;

&lt;p&gt;You should be thinking by now, okay, network assessment can be done via some external tools or service given sufficient permission via the IAM Roles.&lt;/p&gt;

&lt;p&gt;How does AWS inspector do a security vulnerability test on an EC2 instance? Is some application is running beyond your knowledge in your own EC2 instance.&lt;/p&gt;

&lt;p&gt;The answer to this is, When you enable the AWS Inspector to do a security vulnerability test on your application running on the EC2 instance, it asks permission to install an &lt;strong&gt;AWS inspector agent&lt;/strong&gt; on the EC2 instance.&lt;/p&gt;

&lt;p&gt;The AWS inspector agent does &lt;strong&gt;software telemetry&lt;/strong&gt; for application and the OS running on the EC2 instance.&lt;/p&gt;

&lt;p&gt;It provides various information about EC2 instance and the application running on it. Installation of this AWS inspector agent is &lt;strong&gt;optional&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If installed, AWS inspector agent monitors&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Behavior of the EC2 instance.&lt;/li&gt;
&lt;li&gt;checks the network file system&lt;/li&gt;
&lt;li&gt;process activity &lt;/li&gt;
&lt;li&gt;collects a lot of behavior and configuration data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Benefits of AWS Inspector¶
&lt;/h2&gt;

&lt;p&gt;You have learned that AWS inspector does network assessments and security vulnerability checks on the EC2 instance, is this the only use of the AWS inspector?&lt;/p&gt;

&lt;p&gt;No, you do get the other benefits of using the AWS inspector including&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automation&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;You can integrate the security vulnerability, and network assessments automatically in your &lt;strong&gt;CI/CD pipeline&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This gives your findings if any security or network related check are broken in the upgrade and could be corrected.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application security&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The application security checks also can be automated, providing you with valuable information.&lt;/li&gt;
&lt;li&gt;AWS inspector vulnerability scanning when automated, helps in finding issues which can lead to hacking of your application.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h2&gt;
  
  
  Caution while using AWS Inspector.¶
&lt;/h2&gt;

&lt;p&gt;You shouldn't relax knowing that AWS inspector does both network assessments and security vulnerability test. This should not give you a false sense of security that you will find all types of vulnerability by just running the AWS inspector.&lt;/p&gt;

&lt;p&gt;AWS inspector helps in finding some of the security issues with your EC2 instance and application running on it.&lt;/p&gt;

&lt;p&gt;AWS Inspector &lt;strong&gt;does not&lt;/strong&gt; find issues in real time by log analysis like an AWS GuardDuty, or AWS Trusted Advisor, which even provides optimization techniques for your architecture.&lt;/p&gt;

&lt;p&gt;The application running on the EC2 instance, and it's instance configuration itself poses complexity, which AWS inspector may not be configured for.&lt;/p&gt;

&lt;p&gt;We as a user have a responsibility, which we should fulfill by running some complementary test like the AWS GuardDuty or AWS Trusted Advisor.&lt;/p&gt;

&lt;p&gt;AWS inspector is part of the security and network monitoring not the heart of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Inspector Pricing¶
&lt;/h2&gt;

&lt;p&gt;Pricing is an important parameters while choosing a particular AWS Service, especially when we have &lt;strong&gt;3rd party&lt;/strong&gt; tools also competing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.tenable.com/products/nessus"&gt;Tenable Nessus.&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.qualys.com/cloud-platform/"&gt;Qualys Cloud Platform&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AWS inspector pricing is based on these two dimensions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Number of EC2 instance&lt;/strong&gt; included in each assessment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Number of rules&lt;/strong&gt; invoked in each run.

&lt;ul&gt;
&lt;li&gt;Host assessment&lt;/li&gt;
&lt;li&gt;Common vulnerability and exposures ( &lt;strong&gt;CVE&lt;/strong&gt; )

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cve.mitre.org/"&gt;CVE&lt;/a&gt; is a mission which identify, define and catalogs publicly disclosed CyberSecurity vulnerabilities.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Center for Internet security ( &lt;strong&gt;CIS&lt;/strong&gt; ) benchmarks

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.cisecurity.org/cis-benchmarks/"&gt;CIS&lt;/a&gt; provides more than 100 configuration guidelines across 25+ vendor product families to safeguard systems against today’s evolving cyber threats.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Security best practices&lt;/li&gt;
&lt;li&gt;Runtime behavior analysis.&lt;/li&gt;
&lt;li&gt;Network assessment&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more detailed pricing report, visit the &lt;a href="https://aws.amazon.com/inspector/pricing/"&gt;AWS official pricing page.&lt;/a&gt; The pricing on Free Tier is very easy, read along to find out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Free tier¶
&lt;/h3&gt;

&lt;p&gt;You do not have to bother about all the above complexities, accounts which have never run AWS inspector once, are eligible for&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;250 agent assessments&lt;/strong&gt; with host rules package&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;250 instance assessments&lt;/strong&gt; with the network reachability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the first &lt;strong&gt;90 days.&lt;/strong&gt; Other assessments will be billed at the normal price.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Inspector service limits¶
&lt;/h2&gt;

&lt;p&gt;AWS Inspector has a predefined service limits for different resource you can use. AWS inspector provides these four major categories for resources.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of instance running assessment.&lt;/li&gt;
&lt;li&gt;Number of assessment running.&lt;/li&gt;
&lt;li&gt;Number of various assessment template in every assessment.&lt;/li&gt;
&lt;li&gt;Number of assessment targets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2YLJWChZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-inspector-service-limits.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2YLJWChZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-inspector-service-limits.png" alt="AWS Made Easy | AWS Inspector service limits.." title="AWS Made Easy | AWS Inspector service limits."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started with Amazon Inspector¶
&lt;/h2&gt;

&lt;p&gt;Let's dive into configuring AWS inspector, and how it can be used.&lt;/p&gt;

&lt;p&gt;There are certain prerequisite for starting AWS inspector configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisite for AWS Inspector¶
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You much have at least &lt;strong&gt;one EC2 instance running&lt;/strong&gt;. &lt;em&gt;What will AWS inspector check if there is no EC2 instance running?&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;For Host assessment, you may need to &lt;strong&gt;install&lt;/strong&gt; the &lt;strong&gt;AWS inspector agent&lt;/strong&gt; on the EC2 instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lets first see how to configure AWS Inspector.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xpYXtea_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/welcome-aws-inspector.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xpYXtea_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/welcome-aws-inspector.png" alt="AWS Made Easy | AWS Inspector welcome page." title="AWS Made Easy | AWS Inspector welcome page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that AWS inspector uses a &lt;strong&gt;service-linked role&lt;/strong&gt; , to describe the EC2 instance and network configuration.&lt;/p&gt;

&lt;p&gt;You can see there are two types of AWS inspector setup we can do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network Assessment (Inspector Agent is not required.)&lt;/li&gt;
&lt;li&gt;Host Assessment (Inspector Agent is required.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The default option is the most easiest configuration to trigger AWS Inspector. Let us understand &lt;strong&gt;Network Assessment&lt;/strong&gt; and &lt;strong&gt;Host Assessment&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Network Assessment¶
&lt;/h3&gt;

&lt;p&gt;The checks performed by AWS inspector &lt;strong&gt;without&lt;/strong&gt; the installation of an agents are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network configuration analysis to checks which ports are reachable from outside of the VPC.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have the AWS inspector agents &lt;strong&gt;installed&lt;/strong&gt; , it can provide you with additional information like,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The process whose ports are reachable from outside of the VPC.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Host Assessment¶
&lt;/h3&gt;

&lt;p&gt;Host assessment requires the installation of the AWS inspector agent, so once it is installed we get this information&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Common vulnerability and exposures (CVE)

&lt;ul&gt;
&lt;li&gt;The host is checked towards the know CyberSecurity vulnerabilities.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Center for Internet security (CIS) benchmarks&lt;/li&gt;
&lt;li&gt;Security best practices&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you click on &lt;strong&gt;Run Once&lt;/strong&gt; , the confirmation screen is displayed like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rSZf-By3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-confirmation.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rSZf-By3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-confirmation.png" alt="AWS Made Easy | AWS Inspector confirmation page." title="AWS Made Easy | AWS Inspector confirmation page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we complete the test, we will receive a &lt;strong&gt;findings&lt;/strong&gt; from the test. Before looking into findings, lets see there is an &lt;strong&gt;Advanced setup.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Inspector | Advanced Setup¶
&lt;/h2&gt;

&lt;p&gt;As shown in this screen, advance setup is a &lt;strong&gt;three&lt;/strong&gt; step process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2vv0cIpM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2vv0cIpM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment.png" alt="AWS Made Easy | AWS Inspector assessment page." title="AWS Made Easy | AWS Inspector assessment page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define an assessment target&lt;/li&gt;
&lt;li&gt;Define an assessment template&lt;/li&gt;
&lt;li&gt;Review.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advance Setup | Define an assessment target¶
&lt;/h3&gt;

&lt;p&gt;You might have guessed by now, an assessment, target is the &lt;strong&gt;AWS resources&lt;/strong&gt; on which you can run the AWS inspector. As of now it is restricted by the operating system and region.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Network reachability test&lt;/strong&gt; can be run on any EC2 instance without using the AWS inspector agent.&lt;/p&gt;

&lt;p&gt;For running the assessment with an AWS inspector agent let us first check the &lt;strong&gt;supported Linux based operating systems&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;64-bit x86 instance

&lt;ul&gt;
&lt;li&gt;Amazon Linux 2&lt;/li&gt;
&lt;li&gt;Ubuntu&lt;/li&gt;
&lt;li&gt;Debian&lt;/li&gt;
&lt;li&gt;Red Hat Enterprise Linux&lt;/li&gt;
&lt;li&gt;CentOs&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;ARM instance

&lt;ul&gt;
&lt;li&gt;Amazon Linux 2&lt;/li&gt;
&lt;li&gt;Red Hat Enterprise Linux&lt;/li&gt;
&lt;li&gt;Ubuntu&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;The supported &lt;strong&gt;Windows operating systems&lt;/strong&gt; are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows Server 2019 Base&lt;/li&gt;
&lt;li&gt;Windows Server 2016 Base&lt;/li&gt;
&lt;li&gt;Windows Server 2012 R2&lt;/li&gt;
&lt;li&gt;Windows Server 2012&lt;/li&gt;
&lt;li&gt;Windows Server 2008 R2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The supported &lt;strong&gt;AWS regions&lt;/strong&gt; are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;US East (Ohio) us-east-2&lt;/li&gt;
&lt;li&gt;US East (N. Virginia) us-east-1&lt;/li&gt;
&lt;li&gt;US West (N. California) us-west-1&lt;/li&gt;
&lt;li&gt;US West (Oregon) us-west-2&lt;/li&gt;
&lt;li&gt;Asia Pacific (Mumbai) ap-south-1&lt;/li&gt;
&lt;li&gt;Asia Pacific (Seoul) ap-northeast-2&lt;/li&gt;
&lt;li&gt;Asia Pacific (Sydney) ap-southeast-2&lt;/li&gt;
&lt;li&gt;Asia Pacific (Tokyo) ap-northeast-1&lt;/li&gt;
&lt;li&gt;Europe (Frankfurt) eu-central-1&lt;/li&gt;
&lt;li&gt;Europe (Ireland) eu-west-1&lt;/li&gt;
&lt;li&gt;Europe (London) eu-west-2&lt;/li&gt;
&lt;li&gt;Europe (Stockholm) eu-north-1&lt;/li&gt;
&lt;li&gt;AWS GovCloud (US-East) gov-us-east-1&lt;/li&gt;
&lt;li&gt;AWS GovCloud (US-West) gov-us-east-2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first task of defining the assessment, target is to give it a &lt;strong&gt;name&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Then you have an option to run it on all EC2 instances in your account, or you can run it based on certain tags on the EC2 instance. Generally, we can run these assessments only on the production tagged system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OQPPojRf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment-tag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OQPPojRf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment-tag.png" alt="AWS Made Easy | AWS Inspector assessment tag option." title="AWS Made Easy | AWS Inspector assessment tag option"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The AWS inspector agent is pre-installed on Amazon Linux AMIs. If you want to install on other AMIs manually you may have to uses AWS System Manager service. Best option is to use the install the agent automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Setup | Define an assessment template¶
&lt;/h3&gt;

&lt;p&gt;As shown below,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YDF6p9vv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment-template.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YDF6p9vv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment-template.png" alt="AWS Made Easy | AWS Inspector assessment template." title="AWS Made Easy | AWS Inspector assessment template"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first task is to Name the assessment templates. Once done, we have to define the rules packages to use. By default, there are 4 rules packages to select.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Common Vulnerabilities and Exposures-1.1&lt;/li&gt;
&lt;li&gt;CIS Operating System Security Configuration Benchmarks-1.0&lt;/li&gt;
&lt;li&gt;Network Reachability-1.1&lt;/li&gt;
&lt;li&gt;Security Best Practices-1.0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you select which of these 4 rules you want to run, next selection to be done is the &lt;strong&gt;duration&lt;/strong&gt; of the test.&lt;/p&gt;

&lt;p&gt;In addition, you also also schedule the assessment to be recurring.&lt;/p&gt;

&lt;p&gt;The findings of these assessments can also be fed to an SNS topic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Setup | Review¶
&lt;/h3&gt;

&lt;p&gt;As you might have seen many a times, the final step is the Review step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C8R9pv6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment-review.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C8R9pv6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/aws-inspector-assessment-review.png" alt="AWS Made Easy | AWS Inspector assessment review." title="AWS Made Easy | AWS Inspector assessment review"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Post all this you can just run the inspector assessment.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Inspector Findings¶
&lt;/h2&gt;

&lt;p&gt;Once you run any AWS inspector assessment, the result is called &lt;strong&gt;Findings&lt;/strong&gt;. These are the potential security issues that AWS inspector has found during its assessment. Findings is not generated while the assessment is on going, it is only generated after the assessment is completed.&lt;/p&gt;

&lt;p&gt;Individual findings from AWS Inspector cannot be deleted. You have to delete the completed assessment run.&lt;/p&gt;

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

&lt;p&gt;AWS works in &lt;a href="https://www.archerimagine.com/articles/aws/general-aws.html#aws-shared-responsibility-model"&gt;Shared responsibility model.&lt;/a&gt; In this model, as a user of AWS services you have certain responsibility. Two of them primarily are.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check the network reachability of the VPCs.&lt;/li&gt;
&lt;li&gt;Check the application's security running on the VPCs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It would have been very difficult for you to accomplish this on your own. Just like for many other services, AWS has provided a managed service for this called the &lt;strong&gt;AWS Inspector&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;AWS Inspector is a managed service which helps in finding security vulnerabilities in the application running on your EC2 instance and also checks if the instance's VPC is reachable from outside.&lt;/p&gt;

&lt;p&gt;If we install an AWS inspector agent using the AWS system manager service, then we get additional telemetry about the application running on the EC2 instance.&lt;/p&gt;

&lt;p&gt;You should not get a false sense of security thinking that AWS inspector will find all types of security vulnerabilities, It finds some, but it still does not find all the different possible vulnerabilities, it will be in your best interest to find some other alternatives to test complete security vulnerabilities.&lt;/p&gt;

&lt;p&gt;AWS inspector has a limitation today on the type of resources it can evaluate, like it can evaluate the security vulnerabilities of an application on an EC2 instance running selective Linux and windows operating system. Though you can use its network reachability test for any type of hardware.&lt;/p&gt;

&lt;p&gt;AWS inspector provides 250 agent and instance, assessment for the free tier, and then normal pricing.&lt;/p&gt;

&lt;p&gt;Before running AWS inspector you should at least have 1 instance running and the agent should be installed.&lt;/p&gt;

&lt;p&gt;You can use the most basic configuration to trigger the assessment which does both types of checks. The report or findings of the test, inform you about the vulnerabilities in different form.&lt;/p&gt;

&lt;p&gt;AWS inspector is a great tool for doing the self evaluation of the application running on the EC2 instance, and also check the network reachability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Info graphics¶
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AWS Inspector Vs AWS GuardDuty¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS Inspector&lt;/th&gt;
&lt;th&gt;AWS GuardDuty&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Finds if known threat exists.&lt;/td&gt;
&lt;td&gt;Finds threat from different log source.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Static analysis from configuration and settings.&lt;/td&gt;
&lt;td&gt;Dynamic analysis from multiple log source.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scheduled timings.&lt;/td&gt;
&lt;td&gt;Continuous monitoring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EC2 and VPC is monitored&lt;/td&gt;
&lt;td&gt;Multiple services are monitored.. even S3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Available in 14 region&lt;/td&gt;
&lt;td&gt;Available in 24 region&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free tier use of 90 days&lt;/td&gt;
&lt;td&gt;Free tier use of 30 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pricing based on number of assessment.&lt;/td&gt;
&lt;td&gt;Pricing based on volume of logs analysed.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MYkIkRM6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Inspector-Vs-GuardDuty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MYkIkRM6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Inspector-Vs-GuardDuty.png" alt="AWS Made Easy | AWS Inspector Vs AWS GuardDuty" title="AWS Made Easy | AWS Inspector Vs AWS GuardDuty"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Inspector Vs AWS Trusted Advisor¶
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AWS Inspector&lt;/th&gt;
&lt;th&gt;AWS Trusted Advisor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Agent-based&lt;/td&gt;
&lt;td&gt;Agent-less&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No impact on performance&lt;/td&gt;
&lt;td&gt;Improves performance by checking service limit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free tier&lt;/td&gt;
&lt;td&gt;Premium support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EC2 configuration&lt;/td&gt;
&lt;td&gt;AWS account &amp;amp; administrations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No cost recommendations&lt;/td&gt;
&lt;td&gt;Recommendations to optimize cost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scheduled&lt;/td&gt;
&lt;td&gt;Real time guidance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No impact on performance&lt;/td&gt;
&lt;td&gt;Improves performance by checking service limit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7O0flgIX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Inspector-Vs-Trusted-Advisor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7O0flgIX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-Inspector-Vs-Trusted-Advisor.png" alt="AWS Made Easy | AWS Inspector Vs AWS Trusted Advisor" title="AWS Made Easy | AWS Inspector Vs AWS Trusted Advisor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=PMsMGoeuLG0"&gt;How do I set up Amazon Inspector to run security assessments on my Amazon EC2 instances?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=HjuEtMrWc_w"&gt;AWS re:Invent 2015 | (SEC324) New! Introducing Amazon Inspector.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=RLBE4Tv7OJE"&gt;AWS Hands on Lab - Amazon Inspector.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=b5SFJhYl0lk"&gt;AWS Tutorial - Amazon Inspector - Overview.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackify.com/telemetry-tutorial/"&gt;What Is Telemetry? How Telemetry Works, Benefits of Telemetry, Challenges, Tutorial, and More.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/inspector/latest/userguide/inspector_supported_os_regions.html"&gt;Amazon Inspector supported operating systems and Regions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2016/04/amazon-inspector-security-vulnerability-assessment-service-now-generally-available/"&gt;Amazon Inspector, Security Vulnerability Assessment Service Now Generally Available.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/inspector/latest/userguide/inspector_introduction.html"&gt;What is Amazon Inspector?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/inspector/latest/userguide/inspector_getting-started.html"&gt;Getting started with Amazon Inspector.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/inspector/latest/userguide/inspector_assessments.html"&gt;Amazon Inspector assessment templates and assessment runs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.runpanther.io/aws-security-services/"&gt;6 AWS Services for Cloud Security Detection.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.wafcharm.com/en/blog/amazon-inspector-for-beginners/"&gt;Amazon Inspector for beginners&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/48136254/aws-trusted-adviser-vs-inspector/48136996"&gt;AWS trusted adviser vs Inspector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://juliabellmer.medium.com/aws-trusted-advisor-vs-aws-config-vs-aws-inspector-4a952bac38ec"&gt;AWS Trusted Advisor vs. AWS Config vs. AWS Inspector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.janbasktraining.com/blog/aws-inspector-vs-aws-trusted-advisor/"&gt;Difference between AWS Inspector and AWS Trusted Advisor&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me know if you run the AWS inspector assessment on your EC2 instance, and what are its findings 👇.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awsinspector</category>
    </item>
    <item>
      <title>The Dummies Guide to AWS KMS.</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Fri, 02 Apr 2021 07:11:48 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/the-dummies-guide-to-aws-kms-4afe</link>
      <guid>https://dev.to/animeshkbhadra/the-dummies-guide-to-aws-kms-4afe</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_Xxb9J8v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/07-AWS-KMS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_Xxb9J8v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/07-AWS-KMS.png" alt="AWS Made Easy | AWS KMS | Key Management Service" title="AWS Made Easy | AWS KMS | Key Management Service"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;This is the article you have been waiting for to gain knowledge on security, encryption, cipher text. All these topics puts a scare in a lot of us. You have always wished if somehow these topics just don't cross your road. Just like the black cat.&lt;/p&gt;

&lt;p&gt;I am going to explain you these topics with interesting visuals, charts and info graphics. This will help you to hold a conversation with your colleague when such scary topics are being discussed.&lt;/p&gt;

&lt;p&gt;In Short, if you want to score few marks of these topics in AWS Certification exams. If you want to have a conversation with your team mates next time, when these topics come up. This is the article you have been waiting for.&lt;/p&gt;

&lt;p&gt;AWS provides a managed service which does a lot of heavy lifting for us. This service is like Rubeus Hagrid, the guide to novice Harry porter, though the woods of The Forbidden Forest.&lt;/p&gt;

&lt;p&gt;This service provides a mechanism to encrypt and decrypt data, 2 of the most important task in encryption. It also helps us with envelope encryption. It can also generate the data keys for you.&lt;/p&gt;

&lt;p&gt;This service is everything you wished for when you wanted to make your application secure and your data encrypted. This service also automatically integrates with lots of other AWS service, making it easier to encrypt the data.&lt;/p&gt;

&lt;p&gt;Lets jump right in.. to the mystical world of AWS KMS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is encryption?¶
&lt;/h2&gt;

&lt;p&gt;Before you get into the journey to understanding the AWS provided service. You should understand what is encryption in its simplest form.&lt;/p&gt;

&lt;p&gt;As mentioned by Wikipedia, Encryption is&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Encryption is the process of encoding information. This process converts the original representation of the information, known as &lt;strong&gt;plaintext&lt;/strong&gt; , into an alternative form known as &lt;strong&gt;ciphertext&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can consider it like this, there is a black box, into which we pass a plain text and get an encrypted text, which no one can understand. This helps in keeping the data secure, if we delete the plain text now, no one can decode the encrypted text back.&lt;/p&gt;

&lt;p&gt;The process to get back the original plaintext differs on the basis of the encryption used.&lt;/p&gt;

&lt;p&gt;There are two types of encryption used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symmetric Encryption&lt;/li&gt;
&lt;li&gt;Asymmetric Encryption &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The name derives from the fact that if they are using the same key to encrypt or decrypt the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pSe2n9p1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Encryption-Comparision.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pSe2n9p1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Encryption-Comparision.png" alt="AWS Made Easy | Encryption type" title="AWS Made Easy | Encryption type"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Symmetric Encryption¶
&lt;/h3&gt;

&lt;p&gt;In symmetric encryption, we use the same key to encrypt and decrypt the data.&lt;/p&gt;

&lt;p&gt;Consider your home lock, it opens and closes with the same key. This is same as symmetric encryption.&lt;/p&gt;

&lt;h3&gt;
  
  
  Asymmetric Encryption¶
&lt;/h3&gt;

&lt;p&gt;In Asymmetric Encryption, we have to encrypt the data with a public key which is known to everyone, but the decrypt happens with a specific private key known only the authorized person. In this case, both the keys are different.&lt;/p&gt;

&lt;p&gt;Consider the bank locker, to open the locker, you need your key, and the bankers key. You cannot open with just one key. Asymmetric encryption is like the bank locker.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS KMS Definition¶
&lt;/h2&gt;

&lt;p&gt;As per AWS, a KMS is&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;AWS Key Management Service (AWS KMS) is a managed service that makes it easy for you to create and control customer master keys (CMKs), the encryption keys used to encrypt your data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the most apt definition for AWS KMS you will ever find. Trust me, I have searched. AWS KMS creates and controls the customer master keys (CMKs) only. For you to understand this is the master key which you have, and it can open any lock for you. This is the skeleton key for you.&lt;/p&gt;

&lt;p&gt;If you notice carefully in the definition, it does not mention about the storing of keys, it just mentioned create and control. As you go further in this article you will understand why is that the case.&lt;/p&gt;

&lt;p&gt;You might be getting an inkling, why is AWS KMS important after reading about the definition, encryption and its type. You can store a lot of data on AWS, using various services, namely AWS S3, RDS, EBS, etc. To keep the enterprise data on public platforms in a plain text form is not advisable.&lt;/p&gt;

&lt;p&gt;So let's jump into the world of AWS KMS, by learning about some key concepts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customer Master Keys (CMKs)¶
&lt;/h2&gt;

&lt;p&gt;Customer Master Keys (CMKs) are the core of AWS KMS. This is a logical representation of a master key. It is assumed that a CMKs have these metadata.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Key ID&lt;/li&gt;
&lt;li&gt;Creation Date&lt;/li&gt;
&lt;li&gt;Description&lt;/li&gt;
&lt;li&gt;Key State&lt;/li&gt;
&lt;li&gt;Key Materials&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You cannot see all these metadata upfront. CMKs are used to encrypt or decrypt up to 4KB of data. As there are different types of encryption, we have corresponding types of CMKs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symmetric CMKs

&lt;ul&gt;
&lt;li&gt;A 256 byte key, which is used for both encryption and decryption.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Asymmetric CMKs

&lt;ul&gt;
&lt;li&gt;represent the RSA Key Pair.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;The Symmetric CMKs keys, and the private key of Asymmetric CMKs never leave the AWS KMS unencrypted.&lt;/p&gt;

&lt;p&gt;The CMKs provide APIs for various programming languages, like Boto3 for Python, which can use the AWS KMS Api's to get the task done, in place of the actual physical key materials which is not visible in AWS KMS.&lt;/p&gt;

&lt;p&gt;As a user we only have to option to delete the CMKs but not modify any of the key metadata.&lt;/p&gt;

&lt;p&gt;AWS KMS supports 3 different type of CMKs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Customer Managed CMKs&lt;/li&gt;
&lt;li&gt;AWS Managed CMKs&lt;/li&gt;
&lt;li&gt;AWS Owned CMKs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AWS services manage to use the above 3 types of CMKs in different manner, some use only the Customer Managed CMKs, some use only AWS Managed CMKs or AWS Owned CMKs, and some gives the flexibility of all 3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sprG_DHh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/CMKS-Types.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sprG_DHh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/CMKS-Types.png" alt="AWS Made Easy | CMK Types" title="AWS Made Easy | CMK Types"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Customer Managed CMKs¶
&lt;/h3&gt;

&lt;p&gt;These are the CMKs which are created, owned and managed by you. These are under your full control.&lt;/p&gt;

&lt;p&gt;You can find the customer managed CMKs in the AWS Console. Just remember that Customer Managed CMKs has a monthly fee even in the free tier. A word of advice, after learning about customer managed CMKs, please delete the keys, not disable it.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Managed CMKs¶
&lt;/h3&gt;

&lt;p&gt;These are the CMKs which are automatically used by some AWS services when we decide to encrypt the data. These are completely in control of AWS, and you as a user have no control on these CMKs.&lt;/p&gt;

&lt;p&gt;AWS Managed CMKs are free to use in free tier. You may have to pay for excess usage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Keys¶
&lt;/h2&gt;

&lt;p&gt;The Keys used to encrypt data, is called a Data Keys. CMKs are used to generate, encrypt and decrypt the data keys. Please note, we are using CMKs to generate, encrypt and decrypt the &lt;strong&gt;data keys&lt;/strong&gt; and not the data itself.&lt;/p&gt;

&lt;p&gt;AWS KMS does not take the responsibility of storing, managing or tracking your data keys.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a data key¶
&lt;/h3&gt;

&lt;p&gt;When you use the AWS KMS APIs, for encryption, the generation of data keys happens automatically. You can explicitly create a data key by calling the API, &lt;code&gt;GenerateDataKey&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W9KYdLEL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.aws.amazon.com/kms/latest/developerguide/images/generate-data-key.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W9KYdLEL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.aws.amazon.com/kms/latest/developerguide/images/generate-data-key.png" alt="AWS Made Easy | Generate a data key" title="AWS Made Easy | Generate a data key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The API returns 2 things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Plain Text copy of the data key.&lt;/li&gt;
&lt;li&gt;The data Key encrypted with the CMKs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Encrypt a data key¶
&lt;/h3&gt;

&lt;p&gt;AWS KMS does not have a mechanism for you to encrypt the data key, You can use the OpenSSL library to encrypt the data with Data key, or use the AWS &lt;a href="https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/introduction.html"&gt;Encryption SDKs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hS_G2CdJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.aws.amazon.com/kms/latest/developerguide/images/encrypt-with-data-key.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hS_G2CdJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.aws.amazon.com/kms/latest/developerguide/images/encrypt-with-data-key.png" alt="AWS Made Easy | encrypt a data key" title="AWS Made Easy | encrypt a data key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The plain text data key generated above, can be used to encrypt the data using the OpenSSL Library or the encryption SDKs. The encrypted data can now be stored safely, but delete the plain text data key as soon as possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Decrypt a data key¶
&lt;/h3&gt;

&lt;p&gt;Now you have stored the encrypted data, at some point you want to decrypt the data, You can use the &lt;code&gt;decrypt&lt;/code&gt; API, which will decrypt the data key, and returns the plain text data key. This plain text data key can now be used to decrypt the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--thNyHSGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.aws.amazon.com/kms/latest/developerguide/images/decrypt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--thNyHSGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://docs.aws.amazon.com/kms/latest/developerguide/images/decrypt.png" alt="AWS Made Easy | decrypt a data key" title="AWS Made Easy | decrypt a data key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Envelope encryption¶
&lt;/h2&gt;

&lt;p&gt;By definition, Envelope Encryption is,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Envelope Encryption is a practice where the data is encrypted with a key (data key), and then the key (data key) in turn is again encrypted.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To understand the above statement more clearly, you can take the analogy of when you leave your house for a long time, you lock your important document and valuable in a safety lock. You then keep the keys to this safety lockers inside another room or lock. Finally, you lock the front of your door and leave.&lt;/p&gt;

&lt;p&gt;In above case the data (your valuable) &amp;amp; your key (safety lockers) are in the same place (your home), but you have the master key to the house (CMKs). This helps you leaving your house in peace.&lt;/p&gt;

&lt;p&gt;In AWS KMS, Customer Master Keys (CMKs) are the master keys, which never leave AWS KMS unencrypted.&lt;/p&gt;

&lt;p&gt;You can create a chain of such encryption cycle, and the reason why envelope encryption works is for this reason.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encrypting Data is a slow process, but encrypting just the data key is a fast process.&lt;/li&gt;
&lt;li&gt;Encryption of data keys, gives an added layer of security for you, and it helps you storing the encrypted data keys along with the data.&lt;/li&gt;
&lt;li&gt;Different encryption algorithms can be used to encrypt multiple keys in each layer of the envelop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--35Y7RhRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Envelope-Encryption.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--35Y7RhRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Envelope-Encryption.png" alt="AWS Made Easy | Envelope Encryption" title="AWS Made Easy | Envelope Encryption"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create A CMKs on AWS¶
&lt;/h2&gt;

&lt;p&gt;You are now well versed with the major concepts in AWS, now lets dive into how to create a CMKs and its usage.&lt;/p&gt;

&lt;p&gt;One thing you should note that a lot of old blogs mentions the AWS KMS as an option under AWS IAM, it is not the case now. AWS KMS is an independent service.&lt;/p&gt;

&lt;p&gt;The first step in AWS KMS is to create a CMKs. Creation of CMKs is a five step process.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure Key ⚙️&lt;/li&gt;
&lt;li&gt;Add Label 🏷️&lt;/li&gt;
&lt;li&gt;Define key administrative 🚶&lt;/li&gt;
&lt;li&gt;Define Key usage permissions 👨‍💻&lt;/li&gt;
&lt;li&gt;Review 🔍&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Lets get you a AWS KMS CMKs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create CMKs | Step 01 | Configure Key ⚙️¶
&lt;/h3&gt;

&lt;p&gt;Here is the screen for your reference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZsAbHUZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-01-Configure-Key.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZsAbHUZ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-01-Configure-Key.png" alt="AWS Made Easy | AWS KMS | Create CMKs | Configure Key Step" title="AWS Made Easy | AWS KMS | Create CMKs | Configure Key Step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You learned about Symmetric encryption &amp;amp; Asymmetric encryption, in the topic above &lt;a href="https://www.archerimagine.com/articles/aws/aws-kms.html#what-is-encryption"&gt;What is encryption?&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You have chosen one of those options for your own CMKs, lets keep is simple and choose Symmetric encryption, as you will use the same key to encrypt and decrypt data.&lt;/p&gt;

&lt;p&gt;The default &lt;strong&gt;Advanced Option&lt;/strong&gt; is selected as KMS, you can keep the same. The other 2 option are for giving your own Keys to encrypt the data or take it from CloudHSM.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create CMKs | Step 02 | Add Label 🏷️¶
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jEYPOmMH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-02-labels.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jEYPOmMH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-02-labels.png" alt="AWS Made Easy | AWS KMS | Create CMKs | Add label Step" title="AWS Made Easy | AWS KMS | Create CMKs | Add label step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me take you through this option one at a time.&lt;/p&gt;

&lt;p&gt;You have to give an &lt;strong&gt;Alias&lt;/strong&gt; first, this is the name you will use to reference this key in your code, or for any other service. Give a good name and a description of the Key. You cannot go to the next step without giving the &lt;strong&gt;Alias&lt;/strong&gt; name.&lt;/p&gt;

&lt;p&gt;The next option is to give a &lt;strong&gt;Tag&lt;/strong&gt; name, you can provide a key/value pair which you can easily reference in code or in service to identify the key in addition to the name you provided.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create CMKs | Step 03 | Define key administrative 🚶¶
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GgXbe-rG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-03-admin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GgXbe-rG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-03-admin.png" alt="AWS Made Easy | AWS KMS | Create CMKs | Admin Step" title="AWS Made Easy | AWS KMS | Create CMKs | Admin step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you are done with naming your keys, you have to find out off all the IAM user's or Roles who can be the Admin of these keys.&lt;/p&gt;

&lt;p&gt;AWS KMS CMKs administrators are those people who can administer the keys, but they cannot use the key for cryptographic operation, which make it important for the next step.&lt;/p&gt;

&lt;p&gt;Select the Administrator User or role, who will not be using it for cryptographic operation, and lets go to the next step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create CMKs | Step 04 | Define Key usage permissions 👨‍💻¶
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kntZC5Hx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-04-user.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kntZC5Hx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-04-user.png" alt="AWS Made Easy | AWS KMS | Create CMKs | User Step" title="AWS Made Easy | AWS KMS | Create CMKs | User step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have the administrators of your AWS KMS CMKs, now lets get one of the IAM role or user be selected as the user of the key. These selections enable this user with two extra policies.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Policy to use the CMK directly.&lt;/li&gt;
&lt;li&gt;Use the CMKs with the AWS Services.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Create CMKs | Step 05 | Review 🔍¶
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LhfSXcPi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-05-review.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LhfSXcPi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-05-review.png" alt="AWS Made Easy | AWS KMS | Create CMKs | Review Step" title="AWS Made Easy | AWS KMS | Create CMKs | Review step"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The final step for you in most of the AWS configuration is Review. Check all the details, and see the key policy document. What ever we discussed in the last two steps will now make sense to you.&lt;/p&gt;

&lt;p&gt;You analyze the key policy mentioned below, and understand what are the special permission given to the administrators and the user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Id": "key-consolepolicy-3",
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Enable IAM User Permissions",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789012:root"
            },
            "Action": "kms:*",
            "Resource": "*"
        },
        {
            "Sid": "Allow access for Key Administrators",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789012:user/XYZ"
            },
            "Action": [
                "kms:Create*",
                "kms:Describe*",
                "kms:Enable*",
                "kms:List*",
                "kms:Put*",
                "kms:Update*",
                "kms:Revoke*",
                "kms:Disable*",
                "kms:Get*",
                "kms:Delete*",
                "kms:TagResource",
                "kms:UntagResource",
                "kms:ScheduleKeyDeletion",
                "kms:CancelKeyDeletion"
            ],
            "Resource": "*"
        },
        {
            "Sid": "Allow use of the key",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789012:user/ABC"
            },
            "Action": [
                "kms:Encrypt",
                "kms:Decrypt",
                "kms:ReEncrypt*",
                "kms:GenerateDataKey*",
                "kms:DescribeKey"
            ],
            "Resource": "*"
        },
        {
            "Sid": "Allow attachment of persistent resources",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789012:user/ABC"
            },
            "Action": [
                "kms:CreateGrant",
                "kms:ListGrants",
                "kms:RevokeGrant"
            ],
            "Resource": "*",
            "Condition": {
                "Bool": {
                    "kms:GrantIsForAWSResource": "true"
                }
            }
        }
    ]
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;administrators

&lt;ul&gt;
&lt;li&gt;The administrators is &lt;code&gt;XYZ&lt;/code&gt; in the above policy, check carefully what you see.&lt;/li&gt;
&lt;li&gt;These administrators are given the Actions to most of the AWS KMS administrators an allow effect.&lt;/li&gt;
&lt;li&gt;This administrators do not have any encryption, decryption or generate key action associated with it.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;user.

&lt;ul&gt;
&lt;li&gt;The user is &lt;code&gt;ABC&lt;/code&gt; in the above policy, &lt;/li&gt;
&lt;li&gt;The user as you see is granted the Action of encrypt, decrypt, generate and other key related uses with an allow effect.&lt;/li&gt;
&lt;li&gt;The user also has an addition allow effective on the AWS KMS Grants, which is mostly used by AWS Services when encrypting data at rest.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;This makes you the owner of a CMK. Please keep this in mind, the AWS KMS CMKs are charged, so if you are finished learning delete the key immediately, and I would like to remind you, &lt;strong&gt;do not disable the key, delete the key&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M0Slvehx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-CMK-Creation.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0Slvehx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-CMK-Creation.png" alt="AWS Made Easy | AWS CMK Creation Steps" title="AWS Made Easy | AWS CMK Creation Steps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS KMS API¶
&lt;/h2&gt;

&lt;p&gt;When you have your CMKs configured, you obviously want to use it. You should wait a bit before using it. Let me explain to you a few of the AWS KMS APIs.&lt;/p&gt;

&lt;p&gt;There are many APIs in AWS KMS, the full list of AWS KMS api's are mentioned &lt;a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_Operations.html"&gt;here.&lt;/a&gt; We will not go through all of them, but the three most important once, which you can use in a fun manner in the next section.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GenerateDataKey&lt;/code&gt; - Returns a plain text and a cipher text version of a data key.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Encrypt&lt;/code&gt; - Encrypt the plain text using a CMKs&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Decrypt&lt;/code&gt; - Decrypt the cipher text which was encrypted with the &lt;code&gt;Encrypt&lt;/code&gt; API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The name is self describing but still let me explain you the little fundamental about the APIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  GenerateDataKey¶
&lt;/h3&gt;

&lt;p&gt;When you are using an SDKs, you generally do not need to use the &lt;code&gt;GenerateDataKey&lt;/code&gt;, because you can use the Key Id generated &lt;a href="https://www.archerimagine.com/articles/aws/aws-kms.html#create-cmks-step-02-add-label"&gt;above.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This API generates a symmetric data key for you, which you can use for client side encryption.&lt;/p&gt;

&lt;p&gt;It generates two keys for you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Plain text copy of the data key&lt;/li&gt;
&lt;li&gt;encrypted copy of the data key with the CMKs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the client side encryption of data is done and stored, the plain text copy of the data key can be deleted and the encrypted copy of the data key can be kept along with the encrypted data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GenerateDataKey&lt;/code&gt; always returns a unique data key on each call.&lt;/p&gt;

&lt;p&gt;There are different variations of the same API, which you can consider to use.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GenerateDataKeyWithoutPlaintext&lt;/code&gt; - Which will only generate the encrypted copy of the data key.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GenerateDataKeyPair&lt;/code&gt; - Generates the Asymmetric data key.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Encrypt¶
&lt;/h3&gt;

&lt;p&gt;Once you have the &lt;a href="https://www.archerimagine.com/articles/aws/aws-kms.html#create-cmks-step-02-add-label"&gt;Key id generated&lt;/a&gt;, you can use the &lt;code&gt;encrypt&lt;/code&gt; API to encrypt your data. This API just encrypts the plain text data into ciphertext using the CMKs we generated.&lt;/p&gt;

&lt;p&gt;This API has two primary use cases handled.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encrypt small amount of data, like a database password.&lt;/li&gt;
&lt;li&gt;It can be used to move encrypted data from one Region to another.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Decrypt¶
&lt;/h3&gt;

&lt;p&gt;The name itself tells you, it will decrypt the data we have encrypted till now. We do not need to pass the Key Id in the API, if we are symmetric encryption, which is our case anyway.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s14n09iJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-API.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s14n09iJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-KMS-API.png" alt="AWS Made Easy | AWS KMS APIs" title="AWS Made Easy | AWS KMS APIs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS KMS API in action with Boto3¶
&lt;/h3&gt;

&lt;p&gt;Finally the code which uses the &lt;strong&gt;Boto3&lt;/strong&gt; SDK to do all the good things for you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
kms = boto3.client('kms')
key_id = 'alias/test' # this should be present in the KMS
database_password = 'Lorem-ipsum-dolor-sit-amet.'
result = kms.encrypt(KeyId=key_id, Plaintext=database_password) # result will now have these fields
# ChiphertextBlob - encrypted data
encrypted_password = result['ChiphertextBlob']
decrypt_result = kms.decrypt(ChiphertextBlob=encrypted_password) # will have the password decrypted
decrypt_result['Plaintext']

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;key_id = 'alias/test'&lt;/code&gt; 

&lt;ul&gt;
&lt;li&gt;this is the key id you created &lt;a href="https://www.archerimagine.com/articles/aws/aws-kms.html#create-cmks-step-02-add-label"&gt;the label.&lt;/a&gt;, you have to add &lt;code&gt;alias/&lt;/code&gt; before the actual label.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;result = kms.encrypt(KeyId=key_id, Plaintext=database_password)&lt;/code&gt; 

&lt;ul&gt;
&lt;li&gt;You will call the &lt;code&gt;encrypt()&lt;/code&gt; API, passing the key id, and the text which has to be encrypted.&lt;/li&gt;
&lt;li&gt;This API is only used to encrypt small amount of data.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;encrypted_password = result['ChiphertextBlob']&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;You can retrieve the encrypted password which is mapped with a key value of &lt;code&gt;ChiphertextBlob&lt;/code&gt; in the result.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;decrypt_result = kms.decrypt(ChiphertextBlob=encrypted_password)&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;You can decrypt, the &lt;code&gt;encrypted_password&lt;/code&gt; using the &lt;code&gt;decrypt&lt;/code&gt; api.&lt;/li&gt;
&lt;li&gt;You were using symmetric encryption, this is the reason you are not passing the key id.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;decrypt_result['Plaintext']&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;You can retrieve the plain text password back from the key value of &lt;code&gt;Plaintext&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;The above is a very simplistic example of the use of Boto3 for &lt;code&gt;encrypt&lt;/code&gt; &amp;amp; &lt;code&gt;decrypt&lt;/code&gt; APIs. You can explore further once you have completed the AWS certification. For now the understanding of these three important APIs is enough.&lt;/p&gt;

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

&lt;p&gt;You might have always wondered about cloud computing, How does the data in the cloud is secured? Though there are multiple service are involved in AWS to provide that data security.&lt;/p&gt;

&lt;p&gt;You came to know about one of the building blocks in that data security infrastructure.&lt;/p&gt;

&lt;p&gt;You understood that encryption is the way of encoding information with a key so that you can transmit data securely. You also found that you can use the same or a different key for encrypting and decrypting.&lt;/p&gt;

&lt;p&gt;AWS KMS is a service which provides a way to create Customer master Keys (CMKs), which can be made by you, or AWS or owned by AWS. This key is the master keys, which you can use the data key or small plain text data.&lt;/p&gt;

&lt;p&gt;When encrypting large chunks of data, we cannot use the CMKs, but we need something called data keys, which can be generated using the CMKs we created. You can use these data keys to encrypt the data, and deleted the plain text data key. You can store the encrypted data keys with the data.&lt;/p&gt;

&lt;p&gt;AWS KMS provide different APIs to for you to generate the data key. AWS KMS does not give the option to encrypt and decrypt the data, You have to use the OpenSSL library, or the AWS Encryption SDKs. AWS KMS does not own the responsibility of storing the data key, you are the owner to store it.&lt;/p&gt;

&lt;p&gt;In encryption you also understood envelope encryption, where you can use multiple keys to encrypt the data. You can use the combination of symmetric and asymmetric encryption to encrypt the data.&lt;/p&gt;

&lt;p&gt;You followed the 5 step process to create an AWS KMS CMKs, You also found out about the three AWS KMS API, &lt;code&gt;GenerateDatakey&lt;/code&gt;, &lt;code&gt;Encrypt&lt;/code&gt; and &lt;code&gt;Decrypt&lt;/code&gt;. You also used the AWS Boto3 SDK for Python to create a sample understanding of the process to encrypt and decrypt data.&lt;/p&gt;

&lt;p&gt;Overall you have now a fair understanding of the AWS KMS. You can further enhance the reading of AWS KMS, by following the various articles provided in &lt;a href="https://www.archerimagine.com/articles/aws/aws-kms.html#reference"&gt;reference.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@alesnesetril"&gt;Ales Nesetril&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/technology"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=fmqzUCtC6Aw"&gt;AWS KMS​ - Key Management Service&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=xRIlk9_q-fE"&gt;AWS KMS - Encrypt &amp;amp; Decrypt DEMO | KMS pricing | KMS Key Rotation (Part 2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/overview.html"&gt;What is AWS Key Management Service?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Encryption"&gt;Encryption&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ico.org.uk/for-organisations/guide-to-data-protection/guide-to-the-general-data-protection-regulation-gdpr/encryption/what-types-of-encryption-are-there/"&gt;What types of encryption are there?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html"&gt;AWS Key Management Service concepts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html"&gt;Using grants&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/58850216/what-is-the-purpose-of-kmsgeneratedatakey-in-aws"&gt;What is the purpose of kms:GenerateDataKey in AWS?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me know if you used the AWS Boto3 SDK to encrypt and decrypt data. How was your experience, if you could not encrypt or decrypt the data, please give the error in the comment and I will try to help you.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>awskms</category>
    </item>
    <item>
      <title>Who really uses AWS IAM API keys?</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Mon, 29 Mar 2021 05:19:58 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/who-really-uses-aws-iam-api-keys-5cph</link>
      <guid>https://dev.to/animeshkbhadra/who-really-uses-aws-iam-api-keys-5cph</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b5LDFKbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/06-IAM-API-Keys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b5LDFKbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/06-IAM-API-Keys.png" alt="AWS Made Easy | AWS IAM API Keys" title="AWS Made Easy | AWS IAM API Keys"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Developer community uses the cloud technologies the most. In your conquest to learn about AWS, you have been focusing on configuring thing using the AWS console. As a developer, you may not find the use of AWS console efficient to do the tasks.&lt;/p&gt;

&lt;p&gt;Sounds like Neo's trapped in the matrix. It's you, but you didn't find Morphaeus. You have no knowledge of the existence of the RED pill to show you the truth.&lt;/p&gt;

&lt;p&gt;Soon you can access AWS Cloud with tools like CLIs, SDKs or HTTP APIs. These are the tools you completely understand. Even if you don't, sit tight we will make it easy to flow along.&lt;/p&gt;

&lt;p&gt;You will first create a user with programmatic access, then progress to configure the developer's machine to connect to the cloud. After this, you will get information from the cloud using programmatic access.&lt;/p&gt;

&lt;p&gt;Stay seated and enjoy this journey of programmatic access to the promised Earth of the Cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  IAM API Keys¶
&lt;/h2&gt;

&lt;p&gt;You have already found out that there are &lt;a href="https://www.archerimagine.com/articles/aws/general-aws.html#connection-type"&gt;three ways to connect to AWS&lt;/a&gt;. The AWS console is the most basic way to access. AWS CLIs and SDKs provide a much better way to access, as this can be controlled programmatically.&lt;/p&gt;

&lt;p&gt;To revise we will list does the various ways to access AWS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Console&lt;/li&gt;
&lt;li&gt;AWS SDKs&lt;/li&gt;
&lt;li&gt;AWS CLIs

&lt;ul&gt;
&lt;li&gt;Windows PowerShell&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;You can use any of the above methods to access AWS, all of them use the AWS APIs in the back-end. The way of access to AWS does not change the features of AWS.&lt;/p&gt;

&lt;p&gt;You might think, AWS Console is easy to use, there is a web interface, you type in the username and password, which allows access to AWS.&lt;/p&gt;

&lt;p&gt;How will you use the AWS using these programmatic ways.&lt;/p&gt;

&lt;h3&gt;
  
  
  IAM API Keys to the rescue¶
&lt;/h3&gt;

&lt;p&gt;You need to have access to IAM API keys to enable programmatic access to AWS. This API Keys is tied up with an IAM user, so you have to create an IAM user and enable the IAM API Keys.&lt;/p&gt;

&lt;p&gt;So let's dive into the world of creating and using the IAM API Keys.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to create IAM API Keys?¶
&lt;/h2&gt;

&lt;p&gt;The first step is to build an IAM user. You have already &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-users.html#iam-users-create-a-new-user"&gt;learned the creation of IAM User here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;IAM User creation is a five step process. We have to follow all the steps with a minor change in &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-users.html#iam-users-creation-step-1-add-user"&gt;Step 1&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can see below, we have to just select the option, &lt;strong&gt;Programmatic Access&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CQl8eCHK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/IAM-User-programmatic-access.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CQl8eCHK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/IAM-User-programmatic-access.png" alt="AWS Made Easy | AWS IAM User with API Keys" title="AWS Made Easy | AWS IAM User with API Keys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also enable this user to have an AWS Console access by enabling the option &lt;strong&gt;AWS Management console access&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You have to follow the remaining steps from the IAM user creation &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-users.html#iam-users-create-a-new-user"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the step five, &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-users.html#iam-users-creation-step-5-success"&gt;Success&lt;/a&gt;, you have to take some specific action.&lt;/p&gt;

&lt;p&gt;You might see in step five, your screen will look little different than the last time you created the user. We have two new field&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access Key ID&lt;/li&gt;
&lt;li&gt;Secret access key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will get these two fields only when you enable the IAM user with programmatic access.&lt;/p&gt;

&lt;p&gt;Please download the security credentials in CSV format, and keep it safe.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wumF995y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/IAM-User-API-Keys-Success.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wumF995y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/IAM-User-API-Keys-Success.png" alt="AWS Made Easy | AWS IAM User Success screen" title="AWS Made Easy | AWS IAM User Success screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Previous time you may have seen this screen. In this the user did not have the programmatic access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZdOUHvG---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/iam-user-creation-steps-06-success.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZdOUHvG---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/iam-user-creation-steps-06-success.png" alt="AWS Made Easy | IAM Users creation steps, success" title="AWS Made Easy | IAM Users creation steps, success"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have a user with IAM API keys enabled.&lt;/p&gt;

&lt;h3&gt;
  
  
  Properties of IAM API Keys¶
&lt;/h3&gt;

&lt;p&gt;You should keep in mind few important points about IAM API Keys.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The above user creation step is the only time you will see both &lt;strong&gt;Access Key ID&lt;/strong&gt; and &lt;strong&gt;Secret access key&lt;/strong&gt; together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access Key ID&lt;/strong&gt; is only visible in IAM User's security credentials.&lt;/li&gt;
&lt;li&gt;It is advised to key the security credentials downloaded in CSV format.&lt;/li&gt;
&lt;li&gt;Once lost, you cannot recreate the &lt;strong&gt;Secret access key&lt;/strong&gt; corresponding to the &lt;strong&gt;Access Key ID&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You have to deactivate the old &lt;strong&gt;Access Key ID&lt;/strong&gt; and create a new pair of &lt;strong&gt;Access Key ID&lt;/strong&gt; &amp;amp; &lt;strong&gt;Secret access key&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;You might have already figured this out, since the IAM API keys are tied to an IAM User, we cannot have it associated with &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-roles.html"&gt;IAM Roles&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The above combination should never be stored in an AWS EC2 instance, you should use &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-roles.html"&gt;IAM Roles&lt;/a&gt; for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to use the IAM API Keys?¶
&lt;/h2&gt;

&lt;p&gt;You can use these IAM API Keys in two major ways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS SDKs&lt;/li&gt;
&lt;li&gt;AWS CLIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will go through both these steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using IAM API Keys with AWS CLI.¶
&lt;/h3&gt;

&lt;p&gt;We can install the Python based AWS CLI with a simple command if you have &lt;code&gt;pip&lt;/code&gt; package manager.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install awscli

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

&lt;/div&gt;



&lt;p&gt;To use the AWS CLI you need to configure the AWS environment by running this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws configure

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

&lt;/div&gt;



&lt;p&gt;If you get four questions as an output than it proves that the AWS CLI is installed.&lt;/p&gt;

&lt;p&gt;The above command will ask four questions which you can provide the details from the above &lt;strong&gt;Access Key ID&lt;/strong&gt; &amp;amp; &lt;strong&gt;Secret access key&lt;/strong&gt; you created for the new IAM user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

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

&lt;/div&gt;



&lt;p&gt;Let me try to explain you the details about these 4 options.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Access Key ID [None] : fill the value you got for &lt;strong&gt;Access Key ID&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;AWS Secret Access Key [None]: fill the value you got for the &lt;strong&gt;Secret access key&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Default region name [None]: You should provide the region on which the AWS CLIs or SDKs should execute. &lt;/li&gt;
&lt;li&gt;Default output format [None]: JSON is generally the preferred option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above execution creates 2 file in &lt;code&gt;~/.aws&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-rw------- 1 user staff 116B Dec 24 23:43 credentials
-rw------- 1 user staff 44B Dec 24 23:43 config

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;credentials&lt;/code&gt; file contains this, you gave the &lt;strong&gt;Access Key ID&lt;/strong&gt; &amp;amp; the &lt;strong&gt;Secret access key&lt;/strong&gt; above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;config&lt;/code&gt; file has this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[default]
region = us-west-2
output = json

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

&lt;/div&gt;



&lt;p&gt;With this you can execute AWS CLI specific commands. Here is a reference of such &lt;a href="https://docs.aws.amazon.com/cli/latest/reference/"&gt;commands&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you have the CLI installed and configured, using the SDK is much easier.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using IAM API Keys with AWS SDKs.¶
&lt;/h3&gt;

&lt;p&gt;AWS support SDKs in many languages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C++&lt;/li&gt;
&lt;li&gt;Go&lt;/li&gt;
&lt;li&gt;Java&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;.NET&lt;/li&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;PHP&lt;/li&gt;
&lt;li&gt;Python &lt;/li&gt;
&lt;li&gt;Ruby&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will use the Python SDK for this example. The Python3 AWS SDK is called &lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html"&gt;Boto3&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should complete the AWS CLI installation before proceeding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Boto3 installation | QuickStart¶
&lt;/h3&gt;

&lt;p&gt;Python has a very good package manager called &lt;code&gt;pip&lt;/code&gt;, and we can install &lt;code&gt;boto3&lt;/code&gt; with a simple command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install boto3

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

&lt;/div&gt;



&lt;p&gt;Post this you need to add a few details to some configuration files if you have still not installed the AWS CLI. Create the &lt;code&gt;credentials&lt;/code&gt; and &lt;code&gt;config&lt;/code&gt; file in the &lt;code&gt;aws&lt;/code&gt; directory as shown above.&lt;/p&gt;

&lt;p&gt;Here is a sample code, which just list all the buckets on AWS S3. Even if you do not understand AWS S3 no worries. The below code will not give any errors if you do not have any S3 buckets. No error in the below code signifies that the AWS SDKs and CLIs are working in conjunction with each other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3

s3 = boto3.resource("s3")
for bucket in s3.buckets.all():
    print(bucket.name)

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

&lt;/div&gt;



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

&lt;p&gt;AWS Console if a great way to use AWS, but it becomes difficult to use only AWS Console for all the tasks. There are times when you may need to do the job more than once. Manually performing these repeated tasks is very difficult and subject to errors.&lt;/p&gt;

&lt;p&gt;AWS offers two additional access channels, AWS CLIs and SDK. These accesses require a user enabled with programmatic access. The same user can also have the console access with programmatic access.&lt;/p&gt;

&lt;p&gt;After you have created the user, you should note that you receive an Access Key ID and a Secret Access Key. These pairs of key are only available during user creation. This is the reason we should download this information in the CSV format, as this information is required multiple time for access.&lt;/p&gt;

&lt;p&gt;You now have all the raw materials to connect to AWS programmatically. The next step is to download the Python AWS CLI package and configure it. Once configured, you will see a folder in the home directory &lt;code&gt;~/.aws&lt;/code&gt;. This folder now has all the sufficient information to connect to AWS.&lt;/p&gt;

&lt;p&gt;The CLI is a powerful tool to use, if you still want the SDK, you can download the &lt;strong&gt;BOTO3&lt;/strong&gt; Python SDKs and use the sample code to access all the bucket in the S3 if you have created. If the above code executes without any error you should assume that the SDKs is installed.&lt;/p&gt;

&lt;p&gt;You can now use any of the methods to access AWS. Let me know your experience of accessing the AWS using CLIs or SDKS, was it easy or hard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Info Graphics¶
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aZ-aDggv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/IAM-API-Properties.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aZ-aDggv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/IAM-API-Properties.jpg" alt="AWS Made Easy | IAM API Key Properties" title="AWS Made Easy | API Key Properties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/tools/"&gt;AWS SDKs Browse by Programming Language&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html"&gt;Boto3 | Python SDK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/reference/"&gt;AWS CLI Command Reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>iam</category>
      <category>awsiam</category>
    </item>
    <item>
      <title>Doing AWS STS the right way.</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Sat, 20 Mar 2021 10:50:58 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/doing-aws-sts-the-right-way-15oj</link>
      <guid>https://dev.to/animeshkbhadra/doing-aws-sts-the-right-way-15oj</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OwEZui4S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/05-AWS-STS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OwEZui4S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/05-AWS-STS.png" alt="AWS Made Easy | AWS STS, Security Token Service" title="AWS Made Easy | AWS STS, Security Token Service"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;You have seen in the previous topic on &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-roles.html"&gt;IAM Roles&lt;/a&gt;, some users and resource can assume a role, moreover an IAM Roles are like a hat which anyone can wear and gets its power. One important part of this should bother you, how does AWS authenticate such users, if the user is a genuine or not.&lt;/p&gt;

&lt;p&gt;AWS STS of Security token service plays an important part in enabling &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-roles.html"&gt;IAM Roles&lt;/a&gt;. When you are using a cross account resource or any federated users, you can also use AWS STS to provide temporary user credentials.&lt;/p&gt;

&lt;p&gt;AWS STS though can be used to support mobile application using AWS resources, but it is advised to use AWS cognitio, which will be discussed in the future.&lt;/p&gt;

&lt;p&gt;You will learn what is AWS STS, what are its benefits, when to use it. You will also learn to use a specific Action/API called &lt;code&gt;assumerole&lt;/code&gt; to get access to an AWS resource for an AWS cross account.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS STS¶
&lt;/h2&gt;

&lt;p&gt;AWS STS (Security token service) as the name suggest, provides a security token for accessing a AWS resources. You may think AWS STS as the provider of temporary access.&lt;/p&gt;

&lt;p&gt;AWS STS has these specific properties when assigning temporary access&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It can range from few minutes to a few hours.&lt;/li&gt;
&lt;li&gt;Once the AWS STS provided temporary token expires, it cannot be reused at any point.&lt;/li&gt;
&lt;li&gt;You can invoke AWS STS only through AWS SDKs or AWS CLIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7I4jTfef--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-properties.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7I4jTfef--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-properties.png" alt="AWS Made Easy | AWS STS, Properties" title="AWS Made Easy | AWS STS, Properties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of AWS STS¶
&lt;/h3&gt;

&lt;p&gt;AWS STS solves a very specific problem for you, when you want someone to temporarily access your AWS resource without having concerns of revoking the permission.&lt;/p&gt;

&lt;p&gt;AWS STS provides a way to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You should not embedded long term AWS security credentials into an application.&lt;/li&gt;
&lt;li&gt;You should not create extra IAM identities, using IAM roles with AWS STS is enough to satisfy the temporary access requirement.&lt;/li&gt;
&lt;li&gt;You do not have to worry about deactivating the AWS STS credentials, 36 hours is the maximum you can set the AWS STS expiry time depending on the API invoked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bGsHZVfN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-Benefits.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bGsHZVfN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-Benefits.png" alt="AWS Made Easy | AWS STS, Benefits" title="AWS Made Easy | AWS STS, Benefits"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  When to use AWS STS¶
&lt;/h3&gt;

&lt;p&gt;You have now understood what is AWS STS, also what are the benefits of AWS STS. You might also have guessed the use cases for using AWS STS. Here if a breakdown for this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In Hybrid Cloud setup, where you have to give access to the non AWS account holder. These methods are generally used for giving access to 3rd party

&lt;ul&gt;
&lt;li&gt;SAML 2.0 Identity federation.&lt;/li&gt;
&lt;li&gt;Web Identity Federation. (Facebook, Github, etc.)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Cross Account roles, when you have to give your developer account a temporary access to your production account.&lt;/li&gt;
&lt;li&gt;IAM roles for AWS services.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Ki1KI8z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-UseCase.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Ki1KI8z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-UseCase.png" alt="AWS Made Easy | AWS STS, UseCase" title="AWS Made Easy | AWS STS, UseCase"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS STS Actions¶
&lt;/h3&gt;

&lt;p&gt;You should learn about these five common AWS STS Actions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;AssumeRole&lt;/code&gt; : This is used for getting cross account access.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AssumeRoleWithWebIdentity&lt;/code&gt; : This is using any 3rd party web IDP like Google or Facebook.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AssumeRoleWithSAML&lt;/code&gt; : This is for hybrid cloud, where you have an entity with SAML 2.0&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GetFederationToken&lt;/code&gt; : This is used by the AWS root account or any IAM user.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GetSessionToken&lt;/code&gt; : This is used by the AWS root account or any IAM user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a comparison for you on the above APIs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KfancbnE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-API-Comparision.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KfancbnE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/AWS-STS-API-Comparision.png" alt="AWS Made Easy | AWS STS, API Comparison" title="AWS Made Easy | AWS STS, API Comparison."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS STS | AssumeRole Action¶
&lt;/h2&gt;

&lt;p&gt;You have the basic understanding of the different Action provided by AWS STS. Let's now try to use &lt;code&gt;AssumeRole&lt;/code&gt; API to understand how this works.&lt;/p&gt;

&lt;p&gt;Here is what you are going to try, or what we call a problem definition.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You will have a user with no permission on the AWS Account. Now create an IAM Role, with AmazonS3FullAccess permission. Once you have the Role, edit the trust relationship to give ARN of the user which does not have any permission. Now using AWS Boto3 SDK you will make the user connect to AWS.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A pictorial representation of the step to help you understand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--psHWTGy---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Cross-Account-Role.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--psHWTGy---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/Cross-Account-Role.png" alt="AWS Made Easy | AWS STS, Cross Account AssumeRole" title="AWS Made Easy | AWS STS, Cross Account AssumeRole"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS STS | Create Role¶
&lt;/h3&gt;

&lt;p&gt;You have to follow all the steps mentioned in the article, &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-roles.html#how-to-create-an-aws-iam-role"&gt;IAM Roles&lt;/a&gt;. Once change would be this time we should select the &lt;strong&gt;Another AWS account&lt;/strong&gt; option. You may need to give the 12 digit account number.&lt;/p&gt;

&lt;p&gt;The above steps are the same we will use for cross account access. The steps will not change.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS STS | Change the trust relationship¶
&lt;/h3&gt;

&lt;p&gt;When you create the role like it is mentioned in the previous step, by default it will always point to the account root user, you have to change it to the ARN of the user you want to do a &lt;code&gt;AssumeRole&lt;/code&gt;. Here is how you can do it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the role.&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Trust Relationship&lt;/strong&gt; options, and select the &lt;em&gt;Edit trust relationship&lt;/em&gt; button.

&lt;ul&gt;
&lt;li&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J16kTlwp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.archerimagine.com/images/aws/IAM/edit-trust-relationship.png" alt="AWS Made Easy | AWS STS, STS | Edit Trust Relationship" title="AWS Made Easy | AWS STS, Edit Trust Relationship"&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;This will open a JSON Editor and edit the JSON for this particular user shown below, esp. the Principal, AWS option.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:user/Test"
      },
      "Action": "sts:AssumeRole",
      "Condition": {}
    }
  ]
}

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

&lt;/div&gt;



&lt;p&gt;You might be thinking, if we have to edit this option every time we have to assign to a new user, then how is this scalable?&lt;/p&gt;

&lt;p&gt;The answer is, most of the time we will add a particular group with the IAM role attached and the required user is added or removed from the group to control the access.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS STS | BOTO3 code to AssumeRole¶
&lt;/h3&gt;

&lt;p&gt;Now you have to write using the BOTO3 SDK provide for Python, the sample code to &lt;code&gt;AssumeRole&lt;/code&gt;. Here is the sample code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import boto3
import pprint
from boto3.session import Session

# Below is the ARN of the role.
arn = "arn:aws:iam::123456789012:role/account-s3-full-access"
session_name = "example-role"
client = boto3.client("sts")
account_id = client.get_caller_identity()["Account"]
print(account_id)

# Assume role takes the roles ARN and a sample session name
response = client.assume_role(RoleArn=arn, RoleSessionName=session_name)

pprint.pprint(response)

# Create an S3 resource that can access the account with the temporary credentials.
temp_credentials = response["Credentials"]

# Access the S3 as a resource passing the temporary credentials received from STS.
s3_resource = boto3.resource(
    "s3",
    aws_access_key_id=temp_credentials["AccessKeyId"],
    aws_secret_access_key=temp_credentials["SecretAccessKey"],
    aws_session_token=temp_credentials["SessionToken"],
)
print(f"Listing buckets for the assumed role's account:")
for bucket in s3_resource.buckets.all():
    print(bucket.name)

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

&lt;/div&gt;



&lt;p&gt;Once you run the above code, you should be getting the list of S3 buckets in your account. Though the user did not have access initially.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS STS | AssumeRole | Return Parameters¶
&lt;/h3&gt;

&lt;p&gt;You should be thinking what is returned by STS, here is the JSON response returned by calling &lt;code&gt;assume_role&lt;/code&gt; BOTO3 API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "AssumedRoleUser":{
      "Arn":"arn:aws:sts::123456789012:assumed-role/acc-s3-full-access/example-role",
      "AssumedRoleId":"AROAUXRIFYXT7BG3ENQGE:example-role"
   },
   "Credentials":{
      "AccessKeyId":"ASIAUXRIFYXTUVPIQWFL",
      "Expiration":datetime.datetime(2021,3,20,9,24,27,"tzinfo=tzutc())",
      "SecretAccessKey":"BsXYZCGNuemA8wevm6CnYVfZtNgdGaoOCJ4VwXnf",
      "SessionToken":"FwoGZXIvYXdzEEoaDFAVerghnmasN971Z76yKwAfJgq3tccU72Gj6Xl28zJwJIUS/UEEMtwYmxUDsplTKg0if/keQ9z1BdoPFdLsmDtUiWDnfvIkICUbCeVk+DKI4c9LtdIAXmhpssg4IAMncYFsmh+ylOdbbcud134TOkDkCtuZMkfKuUbIMG3lTq10k93DsiUFAoH5pqyLAa9IyqHUbKUxwwde0UAcUU1lNFMO/sTZI8kAIQNM4cpGMxdyPsYZaX5M1IGWqr2gPNLqLtKLvi1oIGMi33r+lP9GWX5W+Ich1MHUAfUfhgqIjXHjpmDQY5S0e/WOTBwrPLoorgXQlHMak="
   },
   "ResponseMetadata":{
      "HTTPHeaders":{
         "content-length":"1057",
         "content-type":"text/xml",
         "date":"Sat, 20 Mar 2021 08:24:27 GMT",
         "x-amzn-requestid":"72f38158-1d90-4619-a431-5a2fcf460a31"
      },
      "HTTPStatusCode":200,
      "RequestId":"72f38158-1d90-4619-a431-5a2fcf460a31",
      "RetryAttempts":0
   }
}

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

&lt;/div&gt;



&lt;p&gt;You should really be concerned about the &lt;code&gt;Credentials&lt;/code&gt; parameters which is returned. It basically provides 4 information.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AccessKeyId : The access key id, which is always required for programmatic access.&lt;/li&gt;
&lt;li&gt;Expiration : Generally it is 15 min, but can vary depending on the type of API being called.&lt;/li&gt;
&lt;li&gt;SecretAccessKey : The secret access key, which is also generated only once.&lt;/li&gt;
&lt;li&gt;SessionToken : As the name suggests, a unique way of identifying the session.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;You might have now understood that &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-roles.html"&gt;IAM Roles&lt;/a&gt; and AWS STS have a symbiotic relationship. AWS STS is required when you need to provide these range of access.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The cross account use case, ex. the developer account my need a temporary access to the production system.&lt;/li&gt;
&lt;li&gt;The Hybrid cloud use case, ex. On premise user, authenticated using SAML may need access to AWS resources.&lt;/li&gt;
&lt;li&gt;In Hybrid cloud use case and cross account use case, ex. Authenticating the user using the web identity providers.&lt;/li&gt;
&lt;li&gt;Sometimes IAM Services may need permission to another service, ex EC2 wants to write to a S3 bucket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above access is provided to you using the AWS STS because.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS STS provides short term credentials, which lives from a few minutes to some hours.&lt;/li&gt;
&lt;li&gt;We should not be bothered to revoke the access as you cannot reuse the expired access.&lt;/li&gt;
&lt;li&gt;AWS STS can be provided using the AWS SDKs or CLIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The real benefits of AWS STS are,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No need to embed long term credentials to the application.&lt;/li&gt;
&lt;li&gt;No need to create multiple identities for each access request.&lt;/li&gt;
&lt;li&gt;No need to revoke the access, as it expires automatically.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The various actions provided by AWS STS are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AssumeRole&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AssumeRoleWithWebIdentity&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;AssumeRoleWithSAML&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GetFederationToken&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GetSessionToken&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and we discussed &lt;code&gt;AssumeRole&lt;/code&gt; Action uses the cross account example, where you created an IAM role, edited the trust relationship and then the user assuming the role, by using the Boto3 SDKs. By doing this the IAM user from another account could access AWS resources for a short period of time.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;AssumeRole&lt;/code&gt; returns these parameters when a call is made it&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AccessKeyId &lt;/li&gt;
&lt;li&gt;Expiration &lt;/li&gt;
&lt;li&gt;SecretAccessKey &lt;/li&gt;
&lt;li&gt;SessionToken &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might recognize it returns all the parameters created for IAM user having programmatic access, i.e. AccessKeyId and SecretAccessKey. In addition, we get the SessionToken and an expiration time.&lt;/p&gt;

&lt;p&gt;Please provide you feedback if you have any other use case for AWS STS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@alesnesetril"&gt;Ales Nesetril&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/technology"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/security/how-to-use-a-single-iam-user-to-easily-access-all-your-accounts-by-using-the-aws-cli/"&gt;How to Use a Single IAM User to Easily Access All Your Accounts by Using the AWS CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devopslearning.medium.com/introduction-to-aws-security-token-service-sts-b3049aade3c1"&gt;Introduction to AWS Security Token Service(STS)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-api.html"&gt;Switching to an IAM role (AWS API)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html"&gt;Providing access to an IAM user in another AWS account that you own&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html"&gt;Requesting temporary security credentials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html"&gt;Switching to a role (console)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/DaisukeMiyamoto/2d9ed49dc7625adc41835beab7aad58e"&gt;Boto3 Python Gist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>sts</category>
      <category>awssts</category>
    </item>
    <item>
      <title>A foolproof guide to AWS IAM Roles</title>
      <dc:creator>Animesh Bhadra 🎯</dc:creator>
      <pubDate>Thu, 18 Mar 2021 04:19:34 +0000</pubDate>
      <link>https://dev.to/animeshkbhadra/a-foolproof-guide-to-aws-iam-roles-29m7</link>
      <guid>https://dev.to/animeshkbhadra/a-foolproof-guide-to-aws-iam-roles-29m7</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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2F04-IAM-Roles.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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2F04-IAM-Roles.png" title="AWS Made Easy | IAM Roles" alt="AWS Made Easy | IAM Roles"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;The FaceLess Men in GoT (Games of Thrones), hope you remember this character, or Raven/Mystique in X-Men. They both share a common power, what would that be?&lt;/p&gt;

&lt;p&gt;The power to change identity as they wish to accomplish the task at hand. This is what IAM Roles do in a very broad sense.&lt;/p&gt;

&lt;p&gt;You can also think of IAM roles as the Invisibility Cloak in Harry Potter, who ever acquires it becomes invisible.&lt;/p&gt;

&lt;p&gt;IAM Roles are just like a hat, which anyone within AWS can wear, and get the powers presented by the hat, and loses the powers as soon as the hat is removed. The hat does not discriminate between real users or hardware like EC2, anyone can wear this hat.&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2Flaura-thonne-unsplash.jpg" 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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2Flaura-thonne-unsplash.jpg" title="AWS Made Easy | A Magical Hat" alt="AWS Made Easy | A Magical Hat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will also see how IAM Roles can be used, how it is created and attached. You will also see how IAM user is a different concept than IAM Role.&lt;/p&gt;

&lt;h2&gt;
  
  
  IAM Roles¶
&lt;/h2&gt;

&lt;p&gt;An IAM role is an identity that you can create having very specific permissions. The only difference being you are not associating this policy to any particular user or services at the time of creation. This IAM role can be assumed by anyone who needs it, be it a user or an AWS resource.&lt;/p&gt;

&lt;p&gt;You might be thinking, which problem does IAM role solve which a normal IAM user or a new IAM policy cannot solve. So lets understand why we need the use of IAM Role.&lt;/p&gt;

&lt;h3&gt;
  
  
  IAM Roles for user¶
&lt;/h3&gt;

&lt;p&gt;When you are creating a user in your own account, you cannot give them all the permission as explained in &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-introduction.html" rel="noopener noreferrer"&gt;IAM Introduction&lt;/a&gt;, the principle of least privileges. You cannot have one or multiple users will super user permissions, you cannot have Batman in every city, only Gotham.&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2Fali-kokab-unsplash.jpg" 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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2Fali-kokab-unsplash.jpg" title="AWS Made Easy | BatMan" alt="AWS Made Easy | Batman"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition, we can also have non AWS accounts, like cross account want to access your AWS services, or the federated user, who may also need access to the AWS services in case of Hybrid Cloud.&lt;/p&gt;

&lt;p&gt;You have to consider many other use-case along with the above two, for understanding we cannot keep on creating IAM Users to address such diverse range of permission request.&lt;/p&gt;

&lt;h3&gt;
  
  
  IAM Roles for AWS Services¶
&lt;/h3&gt;

&lt;p&gt;You might have already read about &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-policy.html" rel="noopener noreferrer"&gt;IAM Policy&lt;/a&gt;, AWS resources cannot have IAM policy attach directly. There is another good policy, AWS credentials should not be stored on EC2 instances.&lt;/p&gt;

&lt;p&gt;If you consider the above two guidelines, it will not be possible for any AWS services to communicate with other AWS services / resources to complete the work.&lt;/p&gt;

&lt;h3&gt;
  
  
  IAM Roles to the rescue¶
&lt;/h3&gt;

&lt;p&gt;When you consider both the limitation of IAM User and AWS services, you can think we need some type of magic hat, which gives the sufficient power to both User or Service to execute the task it is elevated for. This is where magic happens with IAM Roles.&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2Falmos-bechtold-unsplash.jpg" 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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2Falmos-bechtold-unsplash.jpg" title="AWS Made Easy | Magic" alt="AWS Made Easy | Magic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use IAM Roles for:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One AWS service have to access another AWS service.

&lt;ul&gt;
&lt;li&gt;Example: Application running on EC2 may need to access S3.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;When you have a Hybrid Cloud implementation

&lt;ul&gt;
&lt;li&gt;User from On Premise may want to access AWS Cloud infrastructure.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;EC2 can assume a role only at the time of creation, but once it has a role attached, you can modify it using APIs, CLIs or console at any time. You can attach only 1 role to EC2 at any given time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of IAM Role¶
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You may need people from Hybrid cloud implementation to access the AWS account, you may need IAM Roles to be attached once these users are authorized to use SAML or Active directory.&lt;/li&gt;
&lt;li&gt;You may have production and development account in AWS, and your development team may be required to be elevated to access a production account to fix a bug. This can be done using IAM Roles.&lt;/li&gt;
&lt;li&gt;You have an application running on an EC2 instance, It needs access to S3, this can be achieved using IAM Role.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to create an AWS IAM Role¶
&lt;/h2&gt;

&lt;p&gt;AWS IAM Role creation is a three step process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 | Select the trusted entity¶
&lt;/h3&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-01.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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-01.png" title="AWS Made Easy | IAM Roles Creation | Step 1" alt="AWS Made Easy | IAM Role Creation | Step 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first step guides you choose which services or identities can assume the role, your options are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Services

&lt;ul&gt;
&lt;li&gt;The EC2 instance, lambda etc which needs access to other services.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Another AWS account

&lt;ul&gt;
&lt;li&gt;This is a cross account access, like a developer taking a production access etc.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Web Identity

&lt;ul&gt;
&lt;li&gt;Using OIDC to validate user, like the mobile phone apps.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;SAML 2.0 Federation

&lt;ul&gt;
&lt;li&gt;Using office resources as authentication parameters, like using service Active Directory.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;You can select &lt;strong&gt;AWS Services&lt;/strong&gt; for this experimentation, You can attach this to an EC2 instance, so that it can access the S3.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 | Attach permission policy¶
&lt;/h3&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-02.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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-02.png" title="AWS Made Easy | IAM Roles Creation | Step 2" alt="AWS Made Easy | IAM Role Creation | Step 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now select policy required to be attached, this step is same as the explained in &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-policy.html" rel="noopener noreferrer"&gt;IAM Policy&lt;/a&gt;. You have basically chosen from one of these 2 type&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Custom policy, created using the visual editor or JSON editor.&lt;/li&gt;
&lt;li&gt;AWS managed Policy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can select the &lt;strong&gt;AmazonS3ReadOnlyAccess&lt;/strong&gt; for attaching to EC2 instance as agreed in Step 1.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 | Review¶
&lt;/h3&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-03.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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-03.png" title="AWS Made Easy | IAM Roles Creation | Step 3" alt="AWS Made Easy | IAM Role Creation | Step 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have to provide these details to complete the IAM Role Creation process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Role Name

&lt;ul&gt;
&lt;li&gt;An explicit name, which can be used to attached to the EC2 instance.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Role description

&lt;ul&gt;
&lt;li&gt;A description about the role.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Trusted Entities

&lt;ul&gt;
&lt;li&gt;This is the service selected from &lt;strong&gt;Step 1&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Policies

&lt;ul&gt;
&lt;li&gt;The policies attached, in this case &lt;strong&gt;AmazonS3ReadOnlyAccess&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  How does the IAM roles looks after creation?¶
&lt;/h3&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-04.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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-Role-Creation-04.png" title="AWS Made Easy | IAM Roles Creation | Step 4" alt="AWS Made Easy | IAM Role Creation | Step 4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see above, this is how an IAM Role looks like after creation. The policy document looks exactly same as an &lt;a href="https://www.archerimagine.com/articles/aws/aws-iam-policy.html" rel="noopener noreferrer"&gt;IAM Policy&lt;/a&gt;. This you can also assume as a baton in a relay race, the service or the user can run with the permission as soon as it gets the policy in the form of an IAM Role.&lt;/p&gt;

&lt;h2&gt;
  
  
  IAM Roles Vs IAM Users¶
&lt;/h2&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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-User-Vs-Role.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%2Fwww.archerimagine.com%2Fimages%2Faws%2FIAM%2FIAM-User-Vs-Role.png" title="AWS Made Easy | IAM Roles Vs User" alt="AWS Made Easy | IAM Roles Vs User"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should see &lt;a href="https://www.youtube.com/watch?v=VclOgMtBXN4" rel="noopener noreferrer"&gt;this&lt;/a&gt; video tutorial on YouTube. This video explains much better, also the flow chart shown above should also clear your doubts&lt;/p&gt;

&lt;p&gt;You can see the logic is elementary,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you have a non living things, like EC2 etc., it gets an IAM Roles. No question asked.&lt;/li&gt;
&lt;li&gt;If it is a living thing, like a person, we have to ask two questions.

&lt;ul&gt;
&lt;li&gt;If the permission is temporary then he gets an IAM Roles, else he is an IAM User.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Hope this clears your mind about the difference between two confusing terms.&lt;/p&gt;

&lt;h2&gt;
  
  
  IAM Roles Vs IAM Policy¶
&lt;/h2&gt;

&lt;p&gt;IAM Roles and IAM Policy both have a JSON document identifying the rule. The only difference is the mention of &lt;strong&gt;Trusted Entities&lt;/strong&gt;.&lt;/p&gt;

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

&lt;p&gt;You might now be relieved by understanding the concept of IAM roles, as discussed we use IAM Roles for mainly three purposes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One AWS service using another service, like EC2 instance, wants to read from S3.&lt;/li&gt;
&lt;li&gt;In the hybrid environment, a non AWS user might need access to AWS resources temporarily.&lt;/li&gt;
&lt;li&gt;Cross account access, where a developer may need access to production account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should also think of an IAM Roles as a hat, which a person or services wears and it magically gets the permission and when it drops the hat, it comes back to original state.&lt;/p&gt;

&lt;p&gt;You also should think about EC2 instance, it should not store the IAM User credentials, they should be using the IAM Roles instead. The IAM Roles can be attached to an EC2 instance, during creation, and can be changed afterwards, but not attached after creation. You can attach only one IAM role to an EC2 instance and not multiple.&lt;/p&gt;

&lt;p&gt;You learned that IAM Role creation is a 3 step process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the trusted entity&lt;/li&gt;
&lt;li&gt;Attach permission policy&lt;/li&gt;
&lt;li&gt;Review&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The IAM Role has been just like IAM Policy document, a JSON document having statements.&lt;/p&gt;

&lt;p&gt;You can be confused with IAM Role and IAM User, we can simplify it, saying, if it is a resource we use an IAM Roles. If a physical user needs temporary access, it uses IAM Roles, otherwise it is an IAM User.&lt;/p&gt;

&lt;p&gt;You can comment and let me know if the IAM user is different than IAM Role.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference¶
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@alesnesetril" rel="noopener noreferrer"&gt;Ales Nesetril&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/technology" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@alesnesetril" rel="noopener noreferrer"&gt;Laura Thonne&lt;/a&gt; on &lt;a href="https://unsplash.com/" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@_alikokab_" rel="noopener noreferrer"&gt;Ali Kokab&lt;/a&gt; on &lt;a href="https://unsplash.com/" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Photo by &lt;a href="https://unsplash.com/@almosbech" rel="noopener noreferrer"&gt;Almos Bechtold&lt;/a&gt; on &lt;a href="https://unsplash.com/" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=VclOgMtBXN4" rel="noopener noreferrer"&gt;AWS IAM Overview - It’s Surprisingly Simple - Users vs Roles&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>iam</category>
      <category>awsiam</category>
    </item>
  </channel>
</rss>
