<?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: arvind singharpuria</title>
    <description>The latest articles on DEV Community by arvind singharpuria (@arvind644).</description>
    <link>https://dev.to/arvind644</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%2F415344%2F03264dde-5244-46d3-8cc5-6e7267aea1f3.jpg</url>
      <title>DEV Community: arvind singharpuria</title>
      <link>https://dev.to/arvind644</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arvind644"/>
    <language>en</language>
    <item>
      <title>AWS Networking - VPC</title>
      <dc:creator>arvind singharpuria</dc:creator>
      <pubDate>Wed, 14 Feb 2024 11:54:34 +0000</pubDate>
      <link>https://dev.to/arvind644/aws-networking-vpc-4jk3</link>
      <guid>https://dev.to/arvind644/aws-networking-vpc-4jk3</guid>
      <description>&lt;h2&gt;
  
  
  VPC Networking Components :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Subnet&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Internet Gateway&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Route Table&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Security Group&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NACL&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DHCP Option Set&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NAT Gateway&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Egress only Internet Gateway&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Elastic IP Addresses&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VPC End Points&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VPC Peering&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Subnet
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When you create a &lt;strong&gt;subnet&lt;/strong&gt;, you specify the CIDE block for the subnet, which is a subset of the VPC CIDR block.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each &lt;strong&gt;subnet&lt;/strong&gt; must reside entirely within one Availability Zone and cannot span zones.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Internet Gateway
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An &lt;strong&gt;Internet Gateway&lt;/strong&gt; is a horizontally scaled, redundant and highly available VPC component that allows communication between instances in your VPC and the internet.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is therefore imposes no availability risks or bandwidth constraints on your network traffic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Route Table
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A route table contains a set of rules, called routes, that are used to determine where network traffic is directed.&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A &lt;strong&gt;security group&lt;/strong&gt; acts a s a virtual firewall for your instance to control inbound and outbound traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you launch an instance in a VPC, you can assign up to five security group to the instance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  NACL
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;network access control list (ACL)&lt;/strong&gt; is an optional layer of security for our VPC that acts as a firewall for controlling traffic in and out of one or more subnets.&lt;/p&gt;

&lt;h3&gt;
  
  
  DHCP Option Set
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Dynamic Host Configuration Protocol (DHCP)&lt;/strong&gt; provides a standard for passing configuration information to hosts on a TCP/IP network.&lt;/p&gt;

&lt;h3&gt;
  
  
  NAT Gateway
&lt;/h3&gt;

&lt;p&gt;You can use a &lt;strong&gt;network address translation (NAT)&lt;/strong&gt; gateway to enable instances in a &lt;strong&gt;private subnet&lt;/strong&gt; to connect to the internet or other AWS services, but prevent the internet from initiating a connection with those instances.&lt;/p&gt;

&lt;h3&gt;
  
  
  Egress only Internet Gateway
&lt;/h3&gt;

&lt;p&gt;An &lt;strong&gt;Egress only Internet Gateway&lt;/strong&gt; is a horizontally scaled, redundant, and highly available VPC component that allows outbound communication &lt;strong&gt;over IPv6&lt;/strong&gt; from instances in your VPC to the internet and prevents the internet from initiating an IPv6 connection with your instances.&lt;/p&gt;

&lt;h3&gt;
  
  
  Elastic IP Addresses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An &lt;strong&gt;Elastic IP Addresses&lt;/strong&gt; is a static IPv4 address designed for dynamic cloud computing. &lt;strong&gt;An Elastic IP Addresses&lt;/strong&gt; is associated with your AWS account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With an Elastic IP Addresses, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  VPC End Points
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;VPC endpoint&lt;/strong&gt; enables you to privately connect your VPC to supported AWs services.&lt;/p&gt;

&lt;p&gt;VPC endpoint services powered by &lt;strong&gt;PrivateLink&lt;/strong&gt; without requiring an internet gateway, NAT device, VPN connection, or AWS Direct Connect connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  VPC Peering
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A &lt;strong&gt;VPC peering&lt;/strong&gt; connection is a networking connection between wo VPCs that enables you to route traffic between them using private eIPv4 addresses or IPv6 addresses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instances in either VPC can communicate with each other as if they are within the same network.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lets discuss some of this in more detailed way
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Default VPC
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;172.31.0.0/16 CIDR block is assigned to the VPC.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;65,536 private IPv4 addresses.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;One subnet (size /20) per Availability Zone is created&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;4096 addresses per subnet&lt;/li&gt;
&lt;li&gt;5 are reserved by AWS&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Internet gateway&lt;/strong&gt; is created and attached to the default VPC.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default &lt;strong&gt;security group&lt;/strong&gt; and associate it with your default VPC.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default &lt;strong&gt;NACL&lt;/strong&gt; and associate it with your default VPC.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Default &lt;strong&gt;DHCP options&lt;/strong&gt; set for your AWs account with your default VPC.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Security Groups are firewall rules that are attached to the network interfaces of the AWS resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rules:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inbound Rules&lt;/li&gt;
&lt;li&gt;Outbound Rule&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SGs are stateful&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The traffic that is allowed is automatically allowed to go out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;up to 5 Security Groups can be assigned to a resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can't add a deny rules&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All rules are evaluated for the traffic coming in.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a packet does not match any rule, then a a packet is not allowed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Network ACLs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Security features at the subnet level.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A NACL can be attached to multiple subnets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A NACL has a numbered list of rules that are evaluated in the ascending order *lowest first)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explicit Allow or Deny&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inbound&lt;/li&gt;
&lt;li&gt;Outbound&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once a packet matches a rule. no further rules are processed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;NaCL is stateless:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need inbound and outbound rules.&lt;/li&gt;
&lt;li&gt;This is because the NACLs operate at the OSI layer 4.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h3&gt;
  
  
  &lt;strong&gt;NAT Gateways&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can use a network address translation (NAT) gateway to enable instances in a private subnet to connect to the internet or other AWS services, but prevent the internet from initiating a connection with those instances.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You will need a Public Subnet to put the NAT Gateway in.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will need an Elastic IP address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update "Route Table" of the private subnet to direct the internet traffic to the NAT gateway.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each NAT gateway is created in a specific Availability Zone and implemented with redundancy in that zone.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  NAT Instance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Provides NAT service (like NAT Gateway).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Managed by customer as an EC2 instance, The performance depends on the size of the EC2 instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Not Highly Available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating NAT instance -&amp;gt; Use Community AMI (search for NAT)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NAT instance in placed un the public subnet,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update Route Table of the private subnet to direct the internet traffic to the NAT gateway.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rW-lazdo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1707059728166/e687583c-c3d9-4cd0-92bf-49f4aac96779.png%2520align%3D%2522center%2522" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rW-lazdo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1707059728166/e687583c-c3d9-4cd0-92bf-49f4aac96779.png%2520align%3D%2522center%2522" alt="" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating VPC Components Using AWS CLI
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Things we are going to made :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VPC&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2 or 3 subnets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Internet Gateway -associate it with one of the subnet to create public subnet&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;security group&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EC 2 instance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSH to EC2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;create a VPC&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-vpc &lt;span class="nt"&gt;--cidr-block&lt;/span&gt; 192.168.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;copy &lt;strong&gt;VpcId&lt;/strong&gt; from the output of previous command.&lt;/p&gt;

&lt;p&gt;ex &lt;code&gt;VpcId: ID = vpc-00d41a71782c5eef&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now create subnet :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-subnet &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; vpc-[ID] &lt;span class="nt"&gt;--cidr-block&lt;/span&gt; 192.168.0.0/24
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and replace ID with &lt;strong&gt;00d41a71782c5eef (something like this)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;so , the command will become :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-subnet &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; vpc-00d41a71782c5eef &lt;span class="nt"&gt;--cidr-block&lt;/span&gt; 192.168.0.0/24
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;copy the &lt;strong&gt;subnetId&lt;/strong&gt; from the output of the previous command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use this command to describe your route table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 describe-route-tables &lt;span class="nt"&gt;--route-table-id&lt;/span&gt; rtb-XXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it will look like this : &lt;code&gt;"SubnetId" : "subnet-XXXXXXXXXX"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now, create another subnet using same command and copy its SubnetId.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now create internet gateway :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-internet-gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And copy the &lt;code&gt;InternetGatewayId&lt;/code&gt;. It is looking something like this &lt;code&gt;"igw-XXXXXXXXXXXX"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Currently our IGW is in &lt;strong&gt;detached mode&lt;/strong&gt;. Now attach it to VPC. For doing that we need vpc id and internet gateway id&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 aatch-internet-gateway &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; vpc-XXXXXX &lt;span class="nt"&gt;--internet-gateway-id&lt;/span&gt; &lt;span class="nt"&gt;--igw-XXXXXX&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;now, create a routing table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-route-table &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; vpc-XXXXXXXXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you will see 2 routing table in Route Tables section, the first one is the default one, don't delete that.&lt;/p&gt;

&lt;p&gt;copy the &lt;code&gt;RouteTableId&lt;/code&gt; from the output. It looks like this &lt;code&gt;rtb-XXXXXXXX&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-route &lt;span class="nt"&gt;--route-table-id&lt;/span&gt; rtb-XXXX &lt;span class="nt"&gt;--destination0cidr-block&lt;/span&gt; 0.0.0.0./0 &lt;span class="nt"&gt;--gateway-id&lt;/span&gt; igw-XXXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get two routes, one is local route. (it is maintained by AWS). And other is the route we just created for IGW for connecting it to internet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now assoicate this particular route table to desired subnet.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 associate-route-table &lt;span class="nt"&gt;--subnet-id&lt;/span&gt; subnet-XXXXX123 &lt;span class="nt"&gt;--route-table-id&lt;/span&gt; rtb-XXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get this as output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;{&lt;/span&gt;
 &lt;span class="s2"&gt;"AssociationId"&lt;/span&gt;: &lt;span class="s2"&gt;"rtbassoc-XXXXX"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command associate the route table with subnet and will make subnet-XXXXX123 a public subnet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now assign a public ip address to that subnet id.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 modify-subnet-attribute &lt;span class="nt"&gt;--subnet-id&lt;/span&gt; subnet-XXXXX123 &lt;span class="nt"&gt;--map-public-ip-on-launch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now create a security group :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-security-group &lt;span class="nt"&gt;--group-name&lt;/span&gt; SG_SSHAccess &lt;span class="nt"&gt;--description&lt;/span&gt; &lt;span class="s2"&gt;"SSH access"&lt;/span&gt; &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; vpc-XXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get something this like this in output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="s2"&gt;"GroupId"&lt;/span&gt;: &lt;span class="s2"&gt;"sg-XXXXX"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy that &lt;code&gt;GroupId&lt;/code&gt; and save it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now we will add inbound rules to this security group to allow ssh.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 authorize-security-group-ingress &lt;span class="nt"&gt;--group-id&lt;/span&gt; sg-XXXXX &lt;span class="nt"&gt;--protocol&lt;/span&gt; tcp &lt;span class="nt"&gt;--port&lt;/span&gt; 22 &lt;span class="nt"&gt;--cidr&lt;/span&gt; 0.0.0.0/0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now create a EC2 instance.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 run-instances &lt;span class="nt"&gt;--image-id&lt;/span&gt; ami-XXXXXX &lt;span class="nt"&gt;--count&lt;/span&gt; 1 &lt;span class="nt"&gt;--instance-type&lt;/span&gt; t2.micfro &lt;span class="nt"&gt;--key-name&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;your-aws-ssh-key] &lt;span class="nt"&gt;--security-group-ids&lt;/span&gt; sg-XXXXX &lt;span class="nt"&gt;--subnet-id&lt;/span&gt; subnet-XXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy &lt;code&gt;InstanceId&lt;/code&gt; from the output.&lt;/p&gt;

&lt;p&gt;Run this command to describe your ec2 instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 describe-instances &lt;span class="nt"&gt;--instance-id&lt;/span&gt; XXXXXX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Express.js deployment in AWS Lambda</title>
      <dc:creator>arvind singharpuria</dc:creator>
      <pubDate>Mon, 11 Jul 2022 17:12:19 +0000</pubDate>
      <link>https://dev.to/arvind644/expressjs-deployment-in-aws-lambda-14ak</link>
      <guid>https://dev.to/arvind644/expressjs-deployment-in-aws-lambda-14ak</guid>
      <description>&lt;p&gt;We are using this express code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'

const express = require('express')
const app = express()

app.get('/', (req, res) =&amp;gt; res.send('Hello world!'))

const port = process.env.PORT || 3000
app.listen(port, () =&amp;gt;
  console.log(`Server is listening on port ${port}.`)
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you save that code snippet as &lt;em&gt;app.js&lt;/em&gt; in a new folder, you are just three steps away from having a simple Express app:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new Node.js project. To do this, run the &lt;code&gt;npm init -y&lt;/code&gt; command in your terminal. Just make sure you navigated to the folder that contains &lt;code&gt;app.js&lt;/code&gt; first.&lt;/li&gt;
&lt;li&gt;Install the Express module from NPM by running the &lt;code&gt;npm install express --save&lt;/code&gt; command from terminal.&lt;/li&gt;
&lt;li&gt;Run the &lt;code&gt;node app.js&lt;/code&gt; command, and you should see “Server is listening on port 3000.” as a response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your express app is ready now. Go to &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Application deployment
&lt;/h2&gt;

&lt;p&gt;We are going to deply or application in aws lambda.&lt;/p&gt;

&lt;p&gt;Now we need to do some changes in code to make it production ready. You need to export your &lt;code&gt;app&lt;/code&gt; instead of starting the server using &lt;code&gt;app.listen&lt;/code&gt;. Your &lt;code&gt;app.js&lt;/code&gt; should look like the following code listing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'

const express = require('express')

const app = express()
app.get('/', (req, res) =&amp;gt; res.send('Hello world!'))

module.exports = app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That would break a local Express server, but you can add &lt;code&gt;app.local.js&lt;/code&gt; file with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'

const app = require('./app')
const port = process.env.PORT || 3000
app.listen(port, () =&amp;gt;
  console.log(`Server is listening on port ${port}.`)
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then run the local server using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node app.local.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now make a AWS Lambda wrapper for your Express app. With Claudia, you can do so by running this code in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;claudia generate-serverless-express-proxy --express-module app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step generated a file named &lt;code&gt;lambda.js&lt;/code&gt;, with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'
const awsServerlessExpress = require('aws-serverless-express')
const app = require('./app')
const binaryMimeTypes = [
  'application/octet-stream',
  'font/eot',
  'font/opentype',
  'font/otf',
  'image/jpeg',
  'image/png',
  'image/svg+xml'
]
const server = awsServerlessExpress
  .createServer(app, null, binaryMimeTypes)
exports.handler = (event, context) =&amp;gt;
  awsServerlessExpress.proxy(server, event, context
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you only need to deploy your Express app (with &lt;code&gt;lambda.js&lt;/code&gt; file) to AWS Lambda and API Gateway using the &lt;code&gt;claudia create&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;claudia create --handler lambda.handler --deploy-proxy-api --region eu-central-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a few moments, the command finished and printed the following response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "lambda": {
    "role": "awesome-serverless-expressjs-app-executor",
    "name": "awesome-serverless-expressjs-app",
    "region": "eu-central-1"
  },
  "api": {
    "id": "iltfb5bke3",
    "url": "https://iltfb5bke3.execute-api.eu-central-1.amazonaws.com/latest"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you visit the link from that response in your browser, it prints “Hello world!” It worked! 🙀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---_lP3Pam--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/875/1%2AvEl8mct7Hz-HWJ6_N9Gyqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---_lP3Pam--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://miro.medium.com/max/875/1%2AvEl8mct7Hz-HWJ6_N9Gyqw.png" alt="https://miro.medium.com/max/875/1*vEl8mct7Hz-HWJ6_N9Gyqw.png" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome. This is your Serverless Express app deployed now.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to deploy react website in AWS S3 in 7 Steps</title>
      <dc:creator>arvind singharpuria</dc:creator>
      <pubDate>Mon, 11 Jul 2022 16:53:14 +0000</pubDate>
      <link>https://dev.to/arvind644/how-to-deploy-react-website-in-aws-s3-in-7-steps-1n88</link>
      <guid>https://dev.to/arvind644/how-to-deploy-react-website-in-aws-s3-in-7-steps-1n88</guid>
      <description>&lt;p&gt;In this tutorial, we will host a React website in AWS S3&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a react application locally&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create a react application, you have to install node and npm first. To install both:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Downloads&lt;/strong&gt;: &lt;a href="https://nodejs.org/en/"&gt;https://nodejs.org&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once installed, open your terminal or vscode terminal and write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
cd my-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open &lt;code&gt;localhost:3000&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Build website to deploy&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now run this command to make production builds :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We actually deploy this build folder in production environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create an AWS account&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Create aws acount  &lt;a href="https://aws.amazon.com/"&gt;aws.amazon.com&lt;/a&gt; or go to your aws account.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create an S3 bucket&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Sign in to your AWS account. Open S3 from your AWS console. Click “&lt;strong&gt;Create Bucket&lt;/strong&gt;”.&lt;/p&gt;

&lt;p&gt;If you are planning to use domain name for your website, be sure to create bucket with same name.&lt;/p&gt;

&lt;p&gt;Enter a bucket name and click “Create”.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5: Configure static website hosting in S3&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Go to S3 bucket properties and enable “Static Website Hosting”. Select “Use this bucket to host a website”. Give “index.html” as the index document and error document.&lt;/p&gt;

&lt;p&gt;Make a note of your &lt;strong&gt;endpoint&lt;/strong&gt;. This is the URL using which you can access your website. Once you are done, click Save.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Set S3 bucket read permissions to public&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now go to bucker ‘Permissions” and paste the below code :&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": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::&amp;lt;your_bucket_name&amp;gt;/*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Upload website contents to S3&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now you have to upload the contents of your build folder to your S3 bucket.&lt;/p&gt;

&lt;p&gt;Open your S3 bucket and click “Upload”. &lt;/p&gt;

&lt;p&gt;Drag and drop the contents of your build folder to the upload window. Check if all the contents of your build folder is present, including sub-folders and files. Once your verify this, click “Upload”.&lt;/p&gt;

&lt;p&gt;Awesome. Your website is live now.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>high level design vs low level design.</title>
      <dc:creator>arvind singharpuria</dc:creator>
      <pubDate>Wed, 23 Dec 2020 14:41:50 +0000</pubDate>
      <link>https://dev.to/arvind644/high-level-design-vs-low-level-design-2hpe</link>
      <guid>https://dev.to/arvind644/high-level-design-vs-low-level-design-2hpe</guid>
      <description>&lt;p&gt;Lets talk about high level design vs low level design.&lt;/p&gt;

&lt;h2&gt;
  
  
  high level design
&lt;/h2&gt;

&lt;p&gt;it refers to the overall system design. It includes the description of system architecture, database design, services, platforms and relationship among modules. It is created first before low level design&lt;/p&gt;

&lt;h2&gt;
  
  
  low level design
&lt;/h2&gt;

&lt;p&gt;it refers to component level design process. It describes detailed information of each and every module which means it includes actual logic for every system component and it goes into each module specification. it is created after high level design.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;features of High level design&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;overall system design&lt;/li&gt;
&lt;li&gt;shows brief functionality of each module&lt;/li&gt;
&lt;li&gt;it is created by solution architect&lt;/li&gt;
&lt;li&gt;input criteria is software requirement specifications&lt;/li&gt;
&lt;li&gt;output criteria is database design, functional design and review record.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;features of low level design&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;component level design process&lt;/li&gt;
&lt;li&gt;shows detailed functional logic of the module&lt;/li&gt;
&lt;li&gt;it is created by designers and developers&lt;/li&gt;
&lt;li&gt;input criteria is high level design&lt;/li&gt;
&lt;li&gt;output criteria is program specification and unit test plan.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Low level design is very useful for going to next level of becoming a good developer. This is helpful when you are looking at requirement and you're actually thinking about how to code them out. There will be ordering, cache eviction and much more.&lt;/p&gt;

&lt;p&gt;While high level design gives a brief overview for whole implementation process. Simply it converts the business/client requirement into high level solution.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
