<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kumarmishra on Medium]]></title>
        <description><![CDATA[Stories by Kumarmishra on Medium]]></description>
        <link>https://medium.com/@kumarmishra651?source=rss-3aa4ed433f9d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Yw0ZXpr3a8x08jm3gCTU4g.jpeg</url>
            <title>Stories by Kumarmishra on Medium</title>
            <link>https://medium.com/@kumarmishra651?source=rss-3aa4ed433f9d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:22:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kumarmishra651/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AWS Defence System — NACL and Security Groups !!]]></title>
            <link>https://medium.com/@kumarmishra651/aws-defence-system-nacl-and-security-groups-5f9858a8a573?source=rss-3aa4ed433f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f9858a8a573</guid>
            <dc:creator><![CDATA[Kumarmishra]]></dc:creator>
            <pubDate>Tue, 26 Dec 2023 19:21:21 GMT</pubDate>
            <atom:updated>2023-12-26T19:23:00.831Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS Defence System — NACL and Security Groups !!</h3><p>Network Access Control Lists (NACLs) in the context of Amazon Web Services (AWS) are a type of security control that operates at the subnet level. NACLs are stateless, numbered sets of rules that dictate what traffic is allowed or denied at the subnet level. Each subnet in a VPC (Virtual Private Cloud) must be associated with a NACL, and by default, a subnet associates with the default NACL, which allows all inbound and outbound traffic.</p><p>Here’s a brief overview of applying NACLs at different levels:</p><p>1. Public Subnet Level:<br> — In a typical AWS architecture, you might have a VPC with multiple subnets, some of which are public and others private.<br> — The NACL associated with a public subnet can be configured to allow or deny specific types of traffic entering or leaving that subnet.<br> — For a public subnet, you might configure rules to allow incoming traffic on specific ports (e.g., HTTP on port 80, HTTPS on port 443) to enable access to resources like web servers.</p><p>2. Private Subnet Level:<br> — Similarly, NACLs can be applied to private subnets to control the traffic entering or leaving those subnets.<br> — For a private subnet, you might have more restrictive rules, allowing outbound traffic for necessary communication (e.g., outbound traffic to a database server or external services) while denying incoming traffic that should not reach resources in the private subnet directly from the internet.</p><p>NACLs are applied at the subnet level, and you can customize the rules for both public and private subnets based on your specific security requirements. It’s common to have different NACL configurations for public and private subnets within a VPC to enforce security policies according to the network architecture.</p><p>NACL Rule Numbers:</p><p>In Network Access Control Lists (NACLs) in Amazon VPC, rules are evaluated based on their rule numbers. Each rule in a NACL is associated with a unique rule number, and these rule numbers determine the order in which the rules are evaluated. The rule numbers must be unique within a NACL, and they range from 1 to 32766.</p><p>Here are some key points about NACL rule numbers and their order of execution:</p><p>1. Rule Evaluation Order:<br> — NACLs have separate inbound and outbound rules, and each rule is evaluated in order based on its rule number.<br> — The rules are processed starting with the lowest rule number and proceeding in ascending order.<br> — The first rule that matches the traffic (based on source/destination IP, protocol, and port range) is applied, and further rule evaluation stops.</p><p>2. Implicit Deny:<br> — By default, if there is no rule that explicitly allows the traffic, it is implicitly denied.<br> — This means that you need to have explicit allow rules for the desired traffic, or it will be denied by default.</p><p>3. Stateless Nature:<br> — NACLs are stateless, which means that for a bidirectional communication (e.g., a response to an outbound request), you need to have both inbound and outbound rules allowing the traffic.</p><p>4. Rule Number Range:<br> — Rule numbers must be unique within a NACL and can range from 1 to 32766. You cannot have two rules with the same rule number in the same NACL.</p><p>5. Editing Rules:<br> — When you edit a NACL and add a new rule, it’s inserted at the specified rule number, and the existing rules are renumbered accordingly.</p><p>Here’s a simple example to illustrate rule execution order:</p><p>Rule Number :<br>Rule 100: Allow Inbound SSH from 203.0.113.0/24<br>Rule 200: Allow Inbound HTTP from 0.0.0.0/0<br>Rule 300: Deny All Inbound Traffic</p><p>Outbound Rules:<br>Rule 100: Allow Outbound All Traffic</p><p>In the above example, inbound traffic is evaluated first. If the traffic matches Rule 100, it is allowed. If it matches Rule 200, it is allowed. If it doesn’t match Rule 100 or Rule 200, it is denied by Rule 300. Outbound traffic is allowed by Rule 100 for all traffic.</p><p>What happens when Traffic is allowed at SGs and not in NACL and vice versa ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*zM4dqcAblcNo0987iwQ1lA.png" /></figure><p>Understanding the order of execution is crucial when configuring NACLs to ensure that the desired traffic is allowed and that security policies are appropriately enforced.</p><p>Security Groups (SGs) and Network Access Control Lists (NACLs) are both used for controlling network traffic in Amazon VPC, but they operate at different layers and have distinct functionalities. Understanding how they work together can help in designing effective and secure network architectures.</p><p>1. Security Groups (SGs):<br> — Layer: SGs operate at the instance (virtual machine) level, which is a higher layer in the networking stack.<br> — Stateful: SGs are stateful, meaning that if you allow inbound traffic, the corresponding outbound traffic is automatically allowed, and vice versa.<br> — Allow Principle: SGs follow the “allow” principle, meaning that you explicitly specify what traffic is allowed, and all other traffic is implicitly denied.<br> — Rules Applied to Instances:SG rules are applied directly to instances.</p><p>2. Network Access Control Lists (NACLs):<br> — Layer: NACLs operate at the subnet level, which is a lower layer in the networking stack.<br> — Stateless: NACLs are stateless, meaning that inbound and outbound rules are separate, and you must define rules for both directions independently.<br> — Allow/Deny Rules: NACLs have both allow and deny rules, and they are explicit about what traffic is allowed and what is denied.<br> — Rules Applied to Subnets: NACL rules are applied to entire subnets, affecting all instances in that subnet.</p><p>Now, let’s consider scenarios where traffic is blocked at one level and allowed at another:</p><p>1. Traffic Blocked at SG, Allowed at NACL:<br> — Suppose you have an SG that blocks inbound traffic on a specific port to an instance.<br> — If the NACL associated with the subnet allows inbound traffic on that port, the traffic will be allowed at the subnet level, even though the SG blocked it for the specific instance.</p><p>2. Traffic Blocked at NACL, Allowed at SG:<br> — Conversely, if the NACL denies inbound traffic on a specific port to the entire subnet, no instance in that subnet will be able to receive traffic on that port.<br> — However, if the SG associated with an instance allows inbound traffic on that port, the traffic will be allowed for that specific instance, bypassing the subnet-level block.</p><p>It’s important to note that both SGs and NACLs play a role in the overall security posture of your VPC, and they complement each other. In practice, it’s common to use SGs for higher-level, instance-specific controls, and NACLs for broader, subnet-level controls. By combining these two mechanisms, you can create a layered security approach that helps enforce the principle of least privilege and provides defense in depth for your AWS infrastructure.</p><p>Happy Learning …Jai Hind ..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f9858a8a573" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VPC is easy !]]></title>
            <link>https://medium.com/@kumarmishra651/vpc-is-easy-692fcbb38476?source=rss-3aa4ed433f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/692fcbb38476</guid>
            <dc:creator><![CDATA[Kumarmishra]]></dc:creator>
            <pubDate>Sun, 24 Dec 2023 19:51:57 GMT</pubDate>
            <atom:updated>2023-12-24T19:51:57.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>VPC is easy !</h3><p>I heard a lot of people saying AWS VPC is a complex concept. So, i made it easy for my self and want to share with all of you guys !!</p><p>1. Your House (Your VPC):<br> <br> Your house represents your VPC — an enclosed area where you have control.</p><p>2. Gated Community (AWS Cloud):<br> <br> The gated community is the entire AWS Cloud. It contains many houses (VPCs) where each house has its unique space.</p><p>3. Fence around Your House (VPC Configuration):<br> <br> The fence signifies the configuration of your VPC, separating your space from others.</p><p>4. Rooms Inside Your House (Subnets):<br> <br> Within your house, different rooms represent subnets inside your VPC. These rooms serve different purposes, just like subnets perform distinct functions within your VPC.</p><p>5. Public Subnet (Main Living Room):<br> <br> Consider the main living room as a public subnet within your house. It’s accessible to guests from the outside (internet) through specific entry points (doors or windows).</p><p>6. Private Subnet (Bedrooms and Private Spaces):<br> <br> Bedrooms and other private areas symbolize private subnets. These areas are only accessible to people inside the house and not directly accessible from the outside.</p><p>7. Your Personal Security Guard (NACLs) and Gate Access (Security Groups):<br> <br> The security guard (NACLs) monitors and controls who enters different parts of your house (VPC), dictating what they can do in those areas.</p><p>8. Route Table (House Map):<br> <br> Imagine the route table as a house map guiding guests (packets of data) about which paths to take to reach specific rooms (subnets). It directs traffic flow within your house based on predefined rules.</p><p>9. Internet Gateway (Main Entrance):<br> <br> The main entrance acts as the internet gateway, permitting guests (internet traffic) to enter your house and directly access the main living room (public subnet) as directed by the route table.</p><p>10. NAT Gateway (Front Desk Receptionist):<br> <br> Picture the NAT Gateway as a front desk receptionist. Outbound internet traffic from private areas (private subnets) passes through this receptionist to access the outside world (internet). However, inbound connections initiated from the internet can’t directly reach private areas (bedrooms).</p><p>11. Your Private Security Rules (NACLs):<br> <br> Your personal security rules (NACLs) act like additional security measures in specific areas of your house. They provide an extra layer of control over who enters or exits certain rooms (subnets), allowing or blocking specific types of traffic.</p><p>In Summary:</p><p>In AWS VPC, a public subnet is reachable from the outside (internet), while private subnets are like rooms not directly accessible from the outside. The route table guides traffic within your VPC, the internet gateway serves as the main entrance, and the NAT Gateway acts as a receptionist allowing outbound traffic from private areas but blocking unsolicited inbound connections. Additionally, NACLs function as personalized security rules, enhancing control over traffic in specific subnets.</p><p>Let’s visualize the flow of traffic from an Internet Gateway (IGW) to the security group of an application while incorporating a Load Balancer in an AWS environment.</p><p>Traffic Flow with Load Balancer:</p><p>1. Internet Gateway (IGW):<br> <br> — An IGW acts as the entry point allowing internet traffic to enter your VPC.</p><p>2. Load Balancer:<br> <br> — A Load Balancer sits between the internet and your application servers, distributing incoming traffic across multiple servers to enhance performance, scalability, and reliability.</p><p>3. Security Groups:<br> <br> — Security Groups act as virtual firewalls controlling inbound and outbound traffic for instances associated with them.</p><p>Traffic Flow Steps:</p><p>1. Incoming Internet Traffic:<br> <br> — Incoming traffic from the internet reaches the Load Balancer’s public endpoint.</p><p>2. Load Balancer’s Role:<br> <br> — The Load Balancer receives incoming requests and distributes them among backend instances (servers) registered with it.<br> <br> — It performs health checks on these instances to ensure they’re available and capable of handling requests.</p><p>3. Security Groups (for Instances):<br> <br> — Instances (servers) behind the Load Balancer are associated with specific Security Groups.<br> <br> — Security Groups define inbound and outbound traffic rules for these instances.</p><p>4. Security Groups Rules:<br> <br> — Inbound rules in the Security Groups for instances allow traffic only from the Load Balancer on specific ports required by the application (e.g., HTTP/HTTPS).</p><p>5. Traffic from Load Balancer to Instances:<br> <br> — The Load Balancer sends incoming traffic to the instances based on its distribution algorithm.<br> <br> — As traffic reaches the instances, it passes through the Security Groups’ inbound rules, allowing only the expected traffic from the Load Balancer.</p><p>6. Outbound Traffic:<br> <br> — When instances process requests, their outbound traffic flows back through the Security Groups’ outbound rules.<br> <br> — Outbound traffic might include responses sent to the Load Balancer, which then relays them back to the requester (client).</p><p>This setup ensures that incoming traffic from the internet is routed through the Load Balancer and reaches the instances securely, as defined by the Security Group rules, creating a robust and controlled flow of traffic within the AWS environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ewkrE29ICk0bcsjdHNkxA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=692fcbb38476" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of EC2 and First Hand’s on !!]]></title>
            <link>https://medium.com/@kumarmishra651/basics-of-ec2-and-first-hands-on-4eb46e9f88b0?source=rss-3aa4ed433f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4eb46e9f88b0</guid>
            <dc:creator><![CDATA[Kumarmishra]]></dc:creator>
            <pubDate>Sat, 23 Dec 2023 19:57:48 GMT</pubDate>
            <atom:updated>2023-12-23T19:57:48.516Z</atom:updated>
            <content:encoded><![CDATA[<h3>Basics of EC2 and First Hand’s on !!</h3><h3>The Big Idea: Virtual Computers in the Cloud</h3><p>Think of EC2 as a magical store where you can rent computers whenever you need them. These computers exist in the cloud, which means they aren’t physical machines sitting on your desk but are located in Amazon’s vast data centers.</p><h3>Renting Computers (Instances):</h3><p>Choosing a Computer Type (Instance Type): Just like choosing a laptop or a desktop based on its power, you can choose the “type” of virtual computer you want to rent. Different types offer various amounts of memory, processing power, storage, and specialized capabilities.</p><p>Launching Your Virtual Computer: Once you decide which type of computer you need, you “launch” it from the EC2 store. This virtual computer is called an “instance.” When you launch an instance, it’s like bringing a computer to life in the cloud.</p><h3>Doing Things with Your Virtual Computer:</h3><p>Installing Software: Your instance is like a blank slate. You can install any operating system (like Windows or Linux) and software applications you want to run on it, just like you would on your own computer.</p><p>Running Programs and Services: You can use your instance to run websites, applications, databases, or any other software. It’s like having your personal server that can do various tasks for you.</p><h3>Paying for What You Use:</h3><p>Pay-As-You-Go: The beauty of EC2 is that you only pay for the time you use your instance. When you’re done with your virtual computer, you can “stop” or “terminate” it, and you won’t be charged for it anymore.</p><p>Scalability: If you suddenly need more virtual computers because your workload increases (like more website visitors), you can easily “scale up” by launching additional instances. Similarly, if you don’t need as many, you can “scale down” by stopping or terminating some instances.</p><h3>Summary:</h3><p>Amazon EC2 is like having a magical cloud-based rental store for virtual computers. You choose the type of computer you need, bring it to life in the cloud, use it to run your programs or services, and only pay for the time you use it. It’s flexible, scalable, and convenient, just like renting computers on demand!</p><p>Hand’s On-</p><p>Installing Jenkins on an EC2 instance in your AWS Free Tier account involves several steps. Below is a step-by-step guide:</p><h3>Step 1: Launch an EC2 Instance</h3><p>Sign in to the AWS Management Console: Navigate to the EC2 Dashboard.</p><p>Launch Instance: Click on “Launch Instance” and select an Amazon Linux 2 AMI or Ubuntu Server (choose a Free Tier eligible AMI), i went with Ubuntu.</p><p>Choose Instance Type: Select an instance type eligible for the Free Tier.</p><p>Configure Instance: Leave default settings or adjust as needed. Ensure that the security group allows inbound traffic on port 8080 (for Jenkins access).</p><p>Add Tags, Configure Security Group, Review: Add any tags if necessary, configure security group settings (allow inbound traffic on port 8080), and review your instance settings.</p><p>Launch Instance: Create or use an existing key pair to access the instance securely via SSH.</p><h3>Step 2: Connect to the EC2 Instance via SSH</h3><p>Use SSH to connect to your EC2 instance. Open a terminal or command prompt and use the following command:</p><pre>ssh -i /path/to/your/keypair.pem ec2-user@&lt;Your_EC2_Public_IP&gt;</pre><p>Replace /path/to/your/keypair.pem with the path to your private key pair file, and &lt;Your_EC2_Public_IP&gt; with your EC2 instance&#39;s public IP address.</p><h3>Step 3: Install Jenkins on the EC2 Instance</h3><p>For Ubuntu:</p><p>Update the package list:</p><pre>sudo apt update</pre><p>Install OpenJDK 17 (or another version), i choose open jdk 17:</p><pre>sudo apt install openjdk-11-jdk</pre><p>Install Jenkins:</p><pre>sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \<br>  https://pkg.jenkins.io/debian/jenkins.io-2023.key<br>echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \<br>  https://pkg.jenkins.io/debian binary/ | sudo tee \<br>  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null<br>sudo apt-get update<br>sudo apt-get install jenkins</pre><p>Start the Jenkins service:</p><pre>sudo systemctl start jenkins</pre><p>Enable Jenkins to start on boot:</p><pre>sudo systemctl enable jenkins</pre><h3>Step 4: Access Jenkins Web Interface</h3><p>Open your web browser and enter:</p><pre>http://&lt;Your_EC2_Public_IP&gt;:8080</pre><p>Replace &lt;Your_EC2_Public_IP&gt; with your EC2 instance&#39;s public IP address.</p><p>Follow the on-screen instructions to complete the Jenkins setup, including unlocking Jenkins using the initial password found in /var/lib/jenkins/secrets/initialAdminPassword.</p><p>Now, you should have Jenkins installed and running on your AWS EC2 instance, accessible through the web browser. Follow the setup steps in the Jenkins web interface to complete the configuration.</p><p>refer the screenshot attached for the help, Happy Learning ..Jai Hind..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dcY9C9EXU_Lb2AocofotEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQKCIOHmIuWGvK9_NqyuSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2X05u2khmSc4ZT_9WylpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQj04hxSqoRHTQFvXp9v4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K41PvbR_s5yMEBV9mKR0SQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWzgEW3fzpIxMl2ca19b6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NuENAGbqX5DF_-L2vYlGUg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4eb46e9f88b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New Learning AWS IAM Service]]></title>
            <link>https://medium.com/@kumarmishra651/new-learning-aws-iam-service-b483e23d46e6?source=rss-3aa4ed433f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b483e23d46e6</guid>
            <dc:creator><![CDATA[Kumarmishra]]></dc:creator>
            <pubDate>Fri, 22 Dec 2023 19:34:25 GMT</pubDate>
            <atom:updated>2023-12-22T19:34:25.614Z</atom:updated>
            <content:encoded><![CDATA[<p>I know this very basics, but still i would like to explain this as this is an important service of AWS.</p><p>I hope this will help the new learner !!</p><p>AWS Identity and Access Management (IAM) is a service that enables you to manage access to AWS services and resources securely. It’s like a control center that helps you control who (users) can do what (actions) with which resources in your AWS environment.</p><p>Let’s consider a real-world analogy:</p><p>Imagine you own a company with various departments, each having its own set of rooms and equipment. To manage access to these areas, you have different keys and access cards:</p><p>IAM Users: These are like your company employees. Each employee has a unique identity (username) and a set of permissions that define what they can or cannot do within your company’s environment (AWS account).</p><p>IAM Groups: Think of these as departments within your company. You can group users together based on their roles or responsibilities. For instance, you might have a “Developers” group, an “Admins” group, and a “Marketing” group. Each group has a specific set of permissions attached.</p><p>IAM Policies: These are like access rules or permissions attached to either individual users or groups. Policies define what actions (such as read, write, delete) users or groups can perform on specific AWS resources (like EC2 instances, S3 buckets, or databases). For instance, you might create a policy that allows members of the “Developers” group to launch EC2 instances but doesn’t permit them to delete resources.</p><p>Let’s take look of real world example:</p><p>Let’s say you have an AWS account (like your company), and within that, you have various resources (like your company’s departments, rooms, and equipment). You want to grant different employees (IAM users) access to these resources but control what each employee can do.</p><p>For instance:</p><p>Santosh (IAM user) from the “Developers” group should be able to launch EC2 instances (create virtual servers) but not modify networking settings.</p><p>Riya (IAM user) from the “Marketing” group should be able to read from an S3 bucket (access files) but not delete anything.</p><p>You create IAM policies to grant these specific permissions to the respective users or groups.</p><p>In summary, IAM helps you control access to your AWS resources securely by managing users, groups, roles, and their associated permissions. It follows the principle of least privilege, ensuring users have only the necessary permissions to perform their tasks, thereby enhancing security within your AWS environment.</p><p>Now let’s move to hand’s on -</p><p>I am a DevOps engineer in a start up, one new employee join and he raised a Jira ticket to get the AWS access with no permission as of now.</p><p>I will perform the below task:</p><ol><li>I will create a IAM USER(emp-2023).</li><li>I will select “I want to create a IAM USER”.</li><li>In the console password i will select “Auto generated password” so that it will be easy for me to share and along with that i will check the box saying “User Must create a new password at next sign-in”. In this way emp-2023 will create a new password for him and it will be easy for him. — Authentication part is completed i took care of that well …yeah!!</li><li>Now Authorization part — Set permissions , I will do not attach any policy here as user should not have any access :-) I will simply click on next.</li><li>Now Review and create will get displayed on the screen.</li><li>Here AWS will attached his own managed policy named as “IAMuserChangePassword” so that emp-2023 can change the password once he login.</li><li>I will click on Create User.</li></ol><p>I will share his (emp-2023) login details and he will reset his password.</p><p>Please Refer the images for better clarity-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YkWDD6Aw1OwPb3OIU3qLXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WVnkNtlm1xu38aqO4SY2-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I_Ol-RzXl16tNIYqsx1xUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CrRay1Htp6gC2IkVAHkfQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGZCqQ4kImzM2yNEjJIpGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1mmNgILht5DdQrxNstu9Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hFiviDEvnSEU4Zv10Yrtxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_owSpOz4ktBGJxsJI5iuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-HB0Wg7JbxYRVoZg_7coTQ.png" /></figure><p>I know after that he will go to his manager that i don’t have any access.</p><p>Again he will Raise a Jira ticket for permission say (s3 full permission).</p><p>As a DevOps engineer or cloud engineer i will attach one more Policy to this user and he will be happy.</p><p>Suppose, four more employee joined and now i this start we have 2 developers and 2 data scientist.</p><p>Then it will be difficult for me to manage each and individual users.</p><p>Here IAM Groups comes into picture.</p><p>I am a smart DevOps Engineer, so what i will do is i will create two groups say “Developer’s Group” and “Scientist Group” i will add all developers in one group and all scientist in one group and i will attach policy to that group, so all will be happy.</p><p>Now let’s assume one day one request came to to me that Data scientist’s need to create EC2 machine so that they can run the algorithms.</p><p>I will simply attach one more permission to this group and again they will be happy.</p><p>For sure, i will be covering the custom policy in next learning and Role.</p><p>Till then Happy learning ….Jai Hind.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b483e23d46e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Static Keyword]]></title>
            <link>https://medium.com/@kumarmishra651/java-static-keyword-3437e058357f?source=rss-3aa4ed433f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3437e058357f</guid>
            <dc:creator><![CDATA[Kumarmishra]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 07:35:05 GMT</pubDate>
            <atom:updated>2023-08-27T07:35:05.181Z</atom:updated>
            <content:encoded><![CDATA[<p>Many times i have seen people struggling with “Static Keywords” in Java while implementation and in Interview. Lets clear this topic today..</p><p>Points to remember for “Static” Keyword in Java-</p><ul><li>“Static” keyword in java is mainly used for memory management.</li><li>We can apply “Static” with Variable, Methods, Blocks and nested classes.</li></ul><p>Lets understand the “Static” Keyword with with respect to our real life example:-</p><p><strong>Traffic Lights -</strong></p><p>Imagine a scenario where you’re at an intersection controlled by traffic lights. Each traffic light has three signals: red, yellow, and green.</p><p>Now, let’s relate this scenario to the concept of static in Java:</p><p><strong>1. Static Variable (Traffic Light Colors):</strong></p><p>Think of the colors of the traffic lights (red, yellow, and green) as static variables. These colors don’t change based on individual cars passing by; they are the same for all vehicles at that intersection. Similarly, a static variable in Java is shared among all instances (objects) of a class and remains constant throughout the program’s execution.</p><pre>public class StaticVariableExample {<br>    // Static variable<br>    static int instanceCount = 0;<br><br>    // Constructor<br>    public StaticVariableExample() {<br>        instanceCount++; // Increment the static variable on each object creation<br>    }<br><br>    public static void main(String[] args) {<br>        // Creating instances of the class<br>        StaticVariableExample obj1 = new StaticVariableExample();<br>        StaticVariableExample obj2 = new StaticVariableExample();<br>        StaticVariableExample obj3 = new StaticVariableExample();<br><br>        // Accessing the static variable using class name<br>        System.out.println(&quot;Total instances created: &quot; + StaticVariableExample.instanceCount);<br>    }<br>}<br><br><br><br>output - Total instances created: 3</pre><p><strong>Explanation :</strong></p><p>1. Three instances of the `StaticVariableExample` class (`obj1`, `obj2`, and `obj3`) are created using the constructor. Each time an instance is created, the `instanceCount` static variable is incremented.</p><p>2. After creating all three instances, the `main` method prints the value of the `instanceCount` static variable using `StaticVariableExample.instanceCount`.</p><p>Since three instances were created, the `instanceCount` variable is incremented three times, resulting in a final value of 3. That’s why the output shows “Total instances created: 3”.</p><p><strong>2. Static Method (Traffic Light Instructions):</strong></p><p>Consider the instructions given by the traffic lights: “Stop” (red), “Prepare to Stop” (yellow), and “Go” (green). These instructions are not specific to any car; they’re associated with the traffic light itself. Similarly, a static method in Java is associated with the class and can be called without creating an instance. It provides functionality that’s common to the entire class.</p><pre>class MathHelper {<br>    static int add(int a, int b) { // Static method<br>        return a + b;<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        int sum = MathHelper.add(5, 3); // Calling static method using class name<br>        System.out.println(&quot;Sum: &quot; + sum);<br>    }<br>}<br><br><br>output - Sum: 8</pre><p><strong>Explanation:</strong></p><p>1. The `main` method in the `Main` class calls the static method `MathHelper.add(5, 3)` to add 5 and 3 together.<br>2. The `add` method is calculating the sum (5 + 3), which is 8.<br>3. The result, which is 8, is assigned to the `sum` variable.<br>4. The `System.out.println` statement prints “Sum: 8” .</p><p><strong>3. Static Block (Traffic Light Initialization):</strong></p><p>When a new set of traffic lights is installed, the signals start with a default state (maybe red). This initial setup is similar to the concept of a static block in Java. The static block runs when the class is loaded into the memory and is used to perform initialization for static variables or execute other static tasks.</p><pre>class StaticInitialization {<br>    static int staticVar;<br>    <br>    static {<br>        staticVar = 42; // Static block to initialize staticVar<br>        System.out.println(&quot;Static block executed.&quot;);<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        System.out.println(&quot;Value of staticVar: &quot; + StaticInitialization.staticVar);<br>    }<br>}<br><br><br>output - Static block executed.<br>Value of staticVar: 42</pre><p><strong>Explanation:</strong></p><p>1. The static block in the `StaticInitialization` class is executed when the class is loaded into memory. In this block, the value of `staticVar` is set to 42, and the message “Static block executed.” is printed to the console.</p><p>2. The `main` method in the `Main` class is called.</p><p>3. The `System.out.println` statement in the `main` method prints “Value of staticVar: 42” to the console, which is the value assigned to `staticVar` in the static block.</p><p><strong>4. Static Nested Class (Pedestrian Signal):</strong></p><p>Imagine there’s a pedestrian signal associated with the traffic light. It’s a separate component but still related to the traffic light system. In Java, a static nested class is similar — it’s a class defined within another class, but it’s not tied to instances of the outer class.</p><pre>class Outer {<br>    static class Nested {<br>        void display() {<br>            System.out.println(&quot;Inside static nested class&quot;);<br>        }<br>    }<br>}<br><br>public class Main {<br>    public static void main(String[] args) {<br>        Outer.Nested nestedObj = new Outer.Nested();<br>        nestedObj.display();<br>    }<br>}<br><br><br>output - Inside static nested class</pre><p><strong>Explanation:</strong></p><p>1. The `main` method in the `Main` class starts executing.</p><p>2. Inside the `main` method, an instance of the static nested class `Nested` is created using the syntax `Outer.Nested nestedObj = new Outer.Nested();`.</p><p>3. The `display` method of the `Nested` class is called using the `nestedObj` instance.</p><p>4. The `display` method prints “Inside static nested class” to the console.</p><p>So, the output will be “Inside static nested class”.</p><p><strong>Question — Why is the Java main method static ?</strong></p><p>Answer — In Java, the `main` method is made `static` for specific reasons related to program execution and the way Java handles classes and objects. Here’s why the `main` method is required to be `static`:</p><p><strong>1. Entry Point for the Program:</strong><br> The `main` method serves as the entry point for the Java program. When you run a Java program, the Java Virtual Machine (JVM) starts executing code from the `main` method. Since there is no instance of the class when the program starts, the `main` method needs to be accessible without creating an object. Making it `static` allows the method to be called directly using the class name.</p><p><strong>2. Static Context:</strong><br> The `main` method is executed in the context of the class, not in the context of any instance of the class. Therefore, it needs to be `static` so that it can be invoked without creating an instance of the class. In other words, when the program starts, no objects of the class exist yet, but the `main` method needs to be available for execution.</p><p><strong>3. Class Loading and Initialization:</strong><br> In Java, the class containing the `main` method needs to be loaded and initialized before the `main` method can be called. Since these steps happen at the class level and not at the instance level, the `main` method must be `static` to be callable in this context.</p><p><strong>4. Simplicity and Consistency:</strong><br> Making the `main` method `static` simplifies the program structure. It ensures that the entry point is defined consistently across all Java programs, regardless of the number of instances or other complexities within the class.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3437e058357f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerization of a python Django Web Application]]></title>
            <link>https://medium.com/@kumarmishra651/dockerization-of-a-python-django-web-application-acd6f6475f89?source=rss-3aa4ed433f9d------2</link>
            <guid isPermaLink="false">https://medium.com/p/acd6f6475f89</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[dockerization]]></category>
            <dc:creator><![CDATA[Kumarmishra]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 19:29:19 GMT</pubDate>
            <atom:updated>2023-07-25T19:29:19.667Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dockerize a python Django Web Application</h3><p>Before Jumping to Dockerizing a Django web Application</p><p>Let’s understand the flow of Django app.</p><p>Steps to create a simple Django application.</p><ol><li>Install Python and Django:<br>- If you don’t have Python installed, download and install the latest version from the official website (<a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a>).<br>- After installing Python, open your command prompt or terminal and install Django using the following command:</li></ol><pre>pip install django</pre><p>2. Create a Django Project:<br> - Choose a location on your computer where you want to create your Django application. Let’s call it “devops” for this example.<br>-Open your command prompt or terminal and navigate to the chosen location.<br>- Create a new Django project using the following command:</p><pre>django-admin startproject devops</pre><p>3. Enter the Project Directory:<br>- Change into the newly created project directory using the cd command</p><pre>cd my_django_app</pre><p>4. Start the Development Server:<br>- To make sure everything is set up correctly, run the development server using the following command:</p><pre>python manage.py runserver</pre><p>5. Create a Django App:<br>- While the project is the overall container, you need to create a Django “app” within the project to build your application’s specific features.<br>- Open a new terminal (keeping the server running) and use the following command to create an app named “myapp” (you can replace “myapp” with a name of your choice):</p><pre>python manage.py startapp myapp</pre><p>6. Define Models:<br>- Inside the newly created “myapp” directory, you’ll find a file named models.py. This is where you define your data models using Python classes. For example, if you are building a simple blog, you might create a model for &quot;Post&quot; with fields like &quot;title,&quot; &quot;content,&quot; and &quot;publish_date.&quot;</p><p>7. Create and Apply Migrations:<br>- Migrations are like a record of changes you make to your models. To create the initial migration files, run the following commands:</p><pre>python manage.py makemigrations<br>python manage.py migrate</pre><p>8. Create Views and Templates:<br>- In the “myapp” directory, create a file named views.py. Views are Python functions that handle HTTP requests and return responses. You can define functions to display data from your models or interact with users.<br>- Additionally, create a folder named “templates” inside the “myapp” directory. Inside this folder, create HTML files to represent the web pages of your application. Django will use these templates to render data from your views.</p><p>9. Configure URLs:<br>- In the “myapp” directory, create a file named urls.py. This file is used to map URLs to your views. Define URL patterns for the different web pages of your application.</p><p>10. Register the App in Project Settings:<br>- Open the settings.py file inside the &quot;devops&quot; directory. Find the INSTALLED_APPS list and add your &quot;myapp&quot; app to the list. It should look like below.</p><pre>INSTALLED_APPS = [<br>    # other apps...<br>    &#39;myapp&#39;,<br>]</pre><p>Previously we used to download all the dependencies, create an artifact and download the same and provide it to other teams like Testing team.</p><p>And suppose Testing team is using some other OS or some different flavor of OS then this used to give error and people used to say Application is not working..</p><p>Now in this era we have docker which makes this job easier and efficient.</p><p>With help of Docker we are binding and packing the application to run on any where.</p><p>Suppose Testing team need to run the application they need to just use few command like Docker run and Docker build — Done.</p><p>How this Happens -</p><p>Developers will write the code and when done, DevOps Team will come into picture for the packing.</p><p>As a DevOps engineer, one should be aware about the flow of the application(if not its fine, Developer can help) either it is Python Django application or any other application.</p><p>After understanding the flow of the application DevOps engineer will create a Docker file.<br>Example:</p><pre>FROM ubuntu<br><br>WORKDIR /app<br><br>COPY requirements.txt /app<br>COPY devops /app<br><br>RUN apt-get update &amp;&amp; \<br>    apt-get install -y python3 python3-pip &amp;&amp; \<br>    pip install -r requirements.txt &amp;&amp; \<br>    cd devops<br><br>ENTRYPOINT [&quot;python3&quot;]<br>CMD [&quot;manage.py&quot;, &quot;runserver&quot;, &quot;0.0.0.0:8000&quot;]<br><br><br><br></pre><p>Let’s go through line by line of Docker file.</p><pre>FROM ubuntu</pre><p>This is the base image of docker file, this image is the main region of providing the isolation from the other container, but it will use the host machine resources.</p><pre>WORKDIR /app</pre><p>Now we will choose a work directory, so here /app is the working directory</p><p>where all the code will get copied, and we can make it as a standard practice as well, this helps us a lot when we are working in a big team.</p><pre>COPY requirements.txt /app</pre><p>We have to copy the requirement.txt in /app, this requirement.txt file will have all the requirements/dependencies which will help our application to run.</p><p>Using these two, Code and dependencies we will form a package or binary of the application.</p><pre>RUN apt-get update &amp;&amp; \<br>    apt-get install -y python3 python3-pip &amp;&amp; \<br>    pip install -r requirements.txt &amp;&amp; \<br>    cd devops</pre><p>As our application is python application and we have chosen base image as Ubuntu, we have to install python so that it can run the application smoothly.</p><p>To download the dependencies we are having</p><pre>pip install -r requirements.txt</pre><p>which will install all the dependencies.</p><p>At last we will provide the entry point for our application</p><pre>ENTRYPOINT [&quot;python3&quot;]<br>CMD [&quot;manage.py&quot;, &quot;runserver&quot;, &quot;0.0.0.0:8000&quot;]</pre><p>Entry point and CMD both can be used as start command for the application, both can serve as start command.</p><p>Where as main difference is you can’t change the “ENTRYPOINT” and “CMD” is configurable.</p><p>Let’s understand with an example -</p><p>Suppose for some one 8000 port is already in use, how they are going to run this ? They will simply change the port number in the “CMD” that’s the reason this is configurable.<br>At the same time we don’t want to change the run configuration for the application that’s why we will keep “python3&#39; in the “ENTRYPOINT” as this non configurable we shouldn’t change this.</p><p>Now we are ready to run the application.</p><ol><li>We will create a simple EC2 instance, as below</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-c4ypn9VdBUQnYVgLniYg.png" /><figcaption>EC2 Instance</figcaption></figure><p>2. Connect to EC2 with SSH.</p><p>3. Clone the GitHub repository.</p><p>4. Navigate to the clone directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEa0WXoU_5fP2ctXkUIQmQ.png" /></figure><p>5. Now give command as below to run</p><pre>python-web-app$ docker run -it 2wtyw5262de1</pre><p>This start run the application, we will be able to see Django service / Application running but we will not be able to notice anything on the browser, because we are running this application on a EC2 host.</p><p>We need to add one inbound rule in the EC2 security group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-dicVtGqBXcKTwrtsS_nKA.png" /><figcaption>Adding inbound Traffic rule to security group</figcaption></figure><p>One other thing, we need to map the port using the below command</p><pre>python-web-app$ docker run -p 8000:8000 -it 2wtyw5262de1</pre><p>Now when we will try to refresh the page we will be able to see the running application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yw0C8uaGDeKMN-qnWukWmw.png" /><figcaption>Django Application</figcaption></figure><p>Happy Learning ..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acd6f6475f89" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>