<?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 Michael Alex on Medium]]></title>
        <description><![CDATA[Stories by Michael Alex on Medium]]></description>
        <link>https://medium.com/@michaelalexalex123?source=rss-32af03092885------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*odBkhOICsOrqjKlMl-xp_w.png</url>
            <title>Stories by Michael Alex on Medium</title>
            <link>https://medium.com/@michaelalexalex123?source=rss-32af03092885------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 23:52:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michaelalexalex123/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[Provisioning VPC using AWS Cloudformation]]></title>
            <link>https://awstip.com/provisioning-vpc-using-aws-cloudformation-7f6affc36a4e?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f6affc36a4e</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 20:17:47 GMT</pubDate>
            <atom:updated>2024-02-22T14:11:53.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOWAgqJuLTgcJHBx54yMFg.jpeg" /></figure><h3>Introduction</h3><p>AWS CloudFormation to create a Virtual Private Cloud (VPC) offers numerous advantages in terms of efficiency, scalability, and consistency for infrastructure deployment. By defining infrastructure as code (IaC), CloudFormation enables users to provision and manage resources in a programmatic and automated manner. This not only reduces the likelihood of human errors but also promotes repeatability and ease of replication across different environments.</p><h3>Steps:</h3><ol><li>Open Cloud Formation documentation</li></ol><p>2. Select “Working with Template” and click “Template anatomy” and you will see the Yaml version. <br><strong>Note the only session you need to create your resources is the resource session and copy and paste in your IDE.</strong></p><pre>AWSTemplateFormatVersion: &quot;version date&quot;<br><br>Description:<br>  String<br><br>Metadata:<br>  template metadata<br><br>Parameters:<br>  set of parameters<br><br>Resources:<br>  set of resources<br><br>Outputs:<br>  set of outputs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrG64-slKtnrZuzlE-c3Mg.png" /></figure><p>3. The first we need is the “template version” and we can find this in “Format version” under “template anatomy”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrG64-slKtnrZuzlE-c3Mg.png" /></figure><pre>AWSTemplateFormatVersion: &quot;2010-09-09&quot;</pre><p>4. For “Description” we can type a comment:</p><pre>Description: This template creates vpc with public and private subnets</pre><p>5. For “Parameters”, select “Parameters” and use it to create cidr for vpc and subnets.<br>Scroll down to “General requirements for parameters” and copy the Yaml script:</p><pre>Parameters:<br>  ParameterLogicalID:     // Call it any name<br>    Type: DataType  //Scroll down to see types<br>    ParameterProperty: value</pre><pre>Parameters:<br>  VpcCIDR:<br>    Default: 10.0.0.0/16<br>    Description: Please enter the ip range (CIDR notation) for this vpc   // It is a decription of the parameters<br>    ParameterProperty: value<br>    Type: String<br><br>  PublicSubnet1CIDR:<br>    Default: 10.0.0.0/24<br>    Description: Please enter the ip range for the public subnet 1  // It is a decription of the parameters<br>    ParameterProperty: value<br>    Type: String<br><br>  PublicSubnet2CIDR:<br>      Default: 10.0.1.0/24<br>      Description: Please enter the ip range for the public subnet 2 // It is a decription of the parameters<br>      ParameterProperty: value<br>      Type: String<br><br>  PrivateSubnet1CIDR:<br>        Default: 10.0.2.0/24<br>        Description: Please enter the ip range for the private subnet 1// It is a decription of the parameters<br>        ParameterProperty: value<br>        Type: String<br><br>  PrivateSubnet2CIDR:<br>        Default: 10.0.3.0/24<br>        Description: Please enter the ip range for the private subnet 2// It is a decription of the parameters<br>        ParameterProperty: value<br>        Type: String<br><br>  PrivateSubnet3CIDR:<br>        Default: 10.0.4.0/24<br>        Description: Please enter the ip range for the private subnet 3// It is a decription of the parameters<br>        ParameterProperty: value<br>        Type: String<br>  <br>  PrivateSubnet4CIDR:<br>        Default: 10.0.5.0/24<br>        Description: Please enter the ip range for the private subnet 4// It is a decription of the parameters<br>        ParameterProperty: value<br>        Type: String<br><br># The below perimeter is to configure the range of ip addresses that can ssh into our EC2<br>  SSHLocation:<br>    AllowedPattern: &#39;(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})&#39;<br>    ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.<br>    Default: 0.0.0.0/0<br>    Description: The IP address range that can be used to access the web server using SSH.<br>    MaxLength: &#39;18&#39;<br>    MinLength: &#39;9&#39;<br>    Type: String</pre><p>6. The next thing we have to do is to create our resources. We will go to the cloud formation documentation and search for “Template reference” and select “Resource and property reference”.<br><strong>NB: Before you can create infrastructure using cloud formation, you must follow the steps of creating it on the console.<br></strong>The steps for creating a VPC with subnets are as follows:<br>1. Create a VPC<br>2. Create Internet Gateway<br>3. Attach the Internet Gateway to the VPC<br>4. Create the Public Subnets<br>5. Craete Route Table<br>6. Add Public Route to the Route Table<br>7. Associate the Public Subnets with the Public Route Table<br>8. Create the Private Subnets<br>9. Create the Security Groups</p><p>7. Scroll to EC2 and Select VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QaRzRIvxvTO3r_4GtIl-A.png" /></figure><p>8. Copy and paste the Yaml script</p><pre>Type: AWS::EC2::VPC<br>Properties:<br>  CidrBlock: String<br>  EnableDnsHostnames: Boolean<br>  EnableDnsSupport: Boolean<br>  InstanceTenancy: String<br>  Ipv4IpamPoolId: String<br>  Ipv4NetmaskLength: Integer<br>  Tags: <br>    - Tag</pre><p>9. We will be using the following template as we will not be needing all the properties:</p><pre>Resources:<br># Create VPC<br>  VPC:<br>    Type: AWS::EC2::VPC<br>    Properties:<br>      CidrBlock: <br>      EnableDnsHostnames: <br>      EnableDnsSupport: <br>      InstanceTenancy: <br>      Tags:<br>        - Key: <br>          Value: <br><br># Create Internet Gateway<br>  InternetGateway:<br>    Type: AWS::EC2::InternetGateway<br>    Properties:<br>      Tags:<br>        - Key: <br>          Value: <br><br># Attach Internet Gateway to VPC<br>  InternetGatewayAttachment:<br>    Type: AWS::EC2::VPCGatewayAttachment<br>    Properties:<br>      InternetGatewayId: <br>      VpcId: <br><br># Create Public Subnet1<br>  PublicSubnet1:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: <br>      CidrBlock:<br>      MapPublicIpOnLaunch:<br>      Tags:<br>        - Key: <br>          Value: <br>      VpcId:<br><br># Create Public Subnet2<br>  PublicSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone:<br>      CidrBlock:<br>      MapPublicIpOnLaunch:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Route Table<br>  PublicRouteTable:<br>    Type: AWS::EC2::RouteTable<br>    Properties:<br>      Tags:<br>        - Key: <br>          Value:<br>      VpcId:<br><br># Add a Public Route to the Route Table<br>  PublicRoute:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      DestinationCidrBlock:<br>      GatewayId:<br>      RouteTableId:<br><br># Associate Public Subnet1 with Public Route Table<br>  PublicSubnet1RouteTableAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId:<br>      SubnetId:<br><br># Associate Public Subnet2 with Public Route Table<br>  PublicSubnet2RouteTableAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId:<br>      SubnetId:<br><br># Create Private Subnet1<br>  PrivateSubnet1:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: <br>      CidrBlock: <br>      MapPublicIpOnLaunch:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Private Subnet2<br>  PrivateSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone:<br>      CidrBlock:<br>      MapPublicIpOnLaunch:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Private Subnet3<br>  PrivateSubnet3:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone:<br>      CidrBlock:<br>      MapPublicIpOnLaunch:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Private Subnet4<br>  PrivateSubnet4:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone:<br>      CidrBlock: <br>      MapPublicIpOnLaunch:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Security Group for the Application Load Balancer <br>  ALBSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription: <br>      SecurityGroupIngress:<br>        - IpProtocol: <br>          FromPort:<br>          ToPort:<br>          CidrIp:<br>        - IpProtocol:<br>          FromPort:<br>          ToPort:<br>          CidrIp:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Security Group for the Bastion Host aka Jump Box<br>  SSHSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription:<br>      SecurityGroupIngress:<br>        - IpProtocol:<br>          FromPort:<br>          ToPort:<br>          CidrIp:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Security Group for the Web Server<br>  WebServerSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription:<br>      SecurityGroupIngress:<br>        - IpProtocol:<br>          FromPort: <br>          ToPort: <br>          SourceSecurityGroupId:<br>        - IpProtocol:<br>          FromPort:<br>          ToPort:<br>          SourceSecurityGroupId:<br>        - IpProtocol:<br>          FromPort:<br>          ToPort:<br>          SourceSecurityGroupId:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:<br><br># Create Security Group for the DataBase<br>  DataBaseSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription:<br>      SecurityGroupIngress:<br>        - IpProtocol:<br>          FromPort:<br>          ToPort:<br>          SourceSecurityGroupId:<br>      Tags:<br>        - Key:<br>          Value:<br>      VpcId:</pre><p>10. Whenever we want to Reference another resource, we use “Intrinsic function”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1NiZQ3VQLCyqUjrJh4A1g.png" /></figure><p>11. Here is a structure of how the complete template should look like.</p><pre>AWSTemplateFormatVersion: 2010-09-09<br><br>Description: This template creates vpc with public and private subnets<br><br># The following metadata is used to group the parameters<br>Metadata:<br>  AWS::CloudFormation::Interface: <br>    ParameterGroups:<br>      - <br>        Label: <br>          default: &quot;VPC CIDR&quot;<br>        Parameters: <br>          - VpcCIDR<br>      - <br>        Label: <br>          default: &quot;Subnet CIDR&quot;<br>        Parameters:<br>          - PublicSubnet1CIDR<br>          - PublicSubnet2CIDR<br>          - PrivateSubnet1CIDR<br>          - PrivateSubnet2CIDR<br>          - PrivateSubnet3CIDR<br>          - PrivateSubnet4CIDR<br>      - <br>        Label: <br>          default: &quot;SSH CIDR&quot;<br>        Parameters: <br>          - SSHLocation<br><br># Parameters are used to to build flexible CloudFormation templates<br>Parameters:<br>  VpcCIDR:<br>    Default: 10.0.0.0/16<br>    Description: Please enter the IP range (CIDR notation) for this VPC<br>    Type: String<br><br>  PublicSubnet1CIDR:<br>    Default: 10.0.0.0/24<br>    Description: Please enter the IP range (CIDR notation) for the public subnet 1<br>    Type: String<br><br>  PublicSubnet2CIDR:<br>    Default: 10.0.1.0/24<br>    Description: Please enter the IP range (CIDR notation) for the public subnet 2<br>    Type: String<br><br>  PrivateSubnet1CIDR:<br>    Default: 10.0.2.0/24<br>    Description: Please enter the IP range (CIDR notation) for the private subnet 1<br>    Type: String<br><br>  PrivateSubnet2CIDR:<br>    Default: 10.0.3.0/24<br>    Description: Please enter the IP range (CIDR notation) for the private subnet 2<br>    Type: String<br><br>  PrivateSubnet3CIDR:<br>    Default: 10.0.4.0/24<br>    Description: Please enter the IP range (CIDR notation) for the private subnet 3<br>    Type: String<br><br>  PrivateSubnet4CIDR:<br>    Default: 10.0.5.0/24<br>    Description: Please enter the IP range (CIDR notation) for the private subnet 4<br>    Type: String<br><br>  SSHLocation:<br>    AllowedPattern: &#39;(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})&#39;<br>    ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.<br>    Default: 0.0.0.0/0<br>    Description: The IP address range that can be used to access the web server using SSH.<br>    MaxLength: &#39;18&#39;<br>    MinLength: &#39;9&#39;<br>    Type: String<br><br>Resources:<br># Create VPC<br>  VPC:<br>    Type: AWS::EC2::VPC<br>    Properties:<br>      CidrBlock: !Ref VpcCIDR<br>      EnableDnsHostnames: true<br>      EnableDnsSupport: true<br>      InstanceTenancy: default<br>      Tags:<br>        - Key: Name<br>          Value: Test VPC<br><br># Create Internet Gateway<br>  InternetGateway:<br>    Type: AWS::EC2::InternetGateway<br>    Properties:<br>      Tags:<br>        - Key: Name<br>          Value: Test IGW<br><br># Attach Internet Gateway to VPC<br>  InternetGatewayAttachment:<br>    Type: AWS::EC2::VPCGatewayAttachment<br>    Properties:<br>      InternetGatewayId: !Ref InternetGateway<br>      VpcId: !Ref VPC<br><br># Create Public Subnet1<br>  PublicSubnet1:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Select [ 0, !GetAZs &#39;&#39; ]<br>      CidrBlock: !Ref PublicSubnet1CIDR<br>      MapPublicIpOnLaunch: true<br>      Tags:<br>        - Key: Name<br>          Value: Public Subnet 1<br>      VpcId: !Ref VPC<br><br># Create Public Subnet2<br>  PublicSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Select [ 1, !GetAZs &#39;&#39; ]<br>      CidrBlock: !Ref PublicSubnet2CIDR<br>      MapPublicIpOnLaunch: true<br>      Tags:<br>        - Key: Name<br>          Value: Public Subnet 2<br>      VpcId: !Ref VPC<br><br># Create Route Table<br>  PublicRouteTable:<br>    Type: AWS::EC2::RouteTable<br>    Properties:<br>      Tags:<br>        - Key: Name<br>          Value: Public Route Table<br>      VpcId: !Ref VPC<br><br># Add a Public Route to the Route Table<br>  PublicRoute:<br>    Type: AWS::EC2::Route<br>    Properties:<br>      DestinationCidrBlock: 0.0.0.0/0<br>      GatewayId: !Ref InternetGateway<br>      RouteTableId: !Ref PublicRouteTable<br><br># Associate Public Subnet1 with Public Route Table<br>  PublicSubnet1RouteTableAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PublicRouteTable<br>      SubnetId: !Ref PublicSubnet1<br><br># Associate Public Subnet2 with Public Route Table<br>  PublicSubnet2RouteTableAssociation:<br>    Type: AWS::EC2::SubnetRouteTableAssociation<br>    Properties:<br>      RouteTableId: !Ref PublicRouteTable<br>      SubnetId: !Ref PublicSubnet2<br><br># Create Private Subnet1<br>  PrivateSubnet1:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Select [ 0, !GetAZs  &#39;&#39; ]<br>      CidrBlock: !Ref PrivateSubnet1CIDR<br>      MapPublicIpOnLaunch: false<br>      Tags:<br>        - Key: Name<br>          Value: Private Subnet 1 | App Tier<br>      VpcId: !Ref VPC<br><br># Create Private Subnet2<br>  PrivateSubnet2:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Select [ 1, !GetAZs &#39;&#39; ]<br>      CidrBlock: !Ref PrivateSubnet2CIDR<br>      MapPublicIpOnLaunch: false<br>      Tags:<br>        - Key: Name<br>          Value: Private Subnet 2 | App Tier<br>      VpcId: !Ref VPC<br><br># Create Private Subnet3<br>  PrivateSubnet3:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Select [ 0, !GetAZs  &#39;&#39; ]<br>      CidrBlock: !Ref PrivateSubnet3CIDR<br>      MapPublicIpOnLaunch: false<br>      Tags:<br>        - Key: Name<br>          Value: Private Subnet 3 | Database Tier<br>      VpcId: !Ref VPC<br><br># Create Private Subnet4<br>  PrivateSubnet4:<br>    Type: AWS::EC2::Subnet<br>    Properties:<br>      AvailabilityZone: !Select [ 1, !GetAZs &#39;&#39; ]<br>      CidrBlock: !Ref PrivateSubnet4CIDR<br>      MapPublicIpOnLaunch: false<br>      Tags:<br>        - Key: Name<br>          Value: Private Subnet 4 | Database Tier<br>      VpcId: !Ref VPC<br><br># Create Security Group for the Application Load Balancer <br>  ALBSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription: Enable HTTP/HTTPS access on port 80/443<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: &#39;80&#39;<br>          ToPort: &#39;80&#39;<br>          CidrIp: &quot;0.0.0.0/0&quot;<br>        - IpProtocol: tcp<br>          FromPort: 443<br>          ToPort: 443<br>          CidrIp: 0.0.0.0/0<br>      Tags:<br>        - Key: Name<br>          Value: ALB Security Group<br>      VpcId: !Ref VPC<br><br># Create Security Group for the Bastion Host aka Jump Box<br>  SSHSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription: SSH Security Group<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: 22<br>          ToPort: 22<br>          CidrIp: !Ref SSHLocation<br>      Tags:<br>        - Key: Name<br>          Value: SSH Security Group<br>      VpcId: !Ref VPC<br><br># Create Security Group for the Web Server<br>  WebServerSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription: Enable HTTP/HTTPS access via port 80/443 locked down to the load balancer SG + SSH access via port 22 locked down SSH SG<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: &#39;80&#39;<br>          ToPort: &#39;80&#39;<br>          SourceSecurityGroupId: !Ref ALBSecurityGroup<br>        - IpProtocol: tcp<br>          FromPort: 443<br>          ToPort: 443<br>          SourceSecurityGroupId: !Ref ALBSecurityGroup<br>        - IpProtocol: tcp<br>          FromPort: &#39;22&#39;<br>          ToPort: &#39;22&#39;<br>          SourceSecurityGroupId: !Ref SSHSecurityGroup<br>      Tags:<br>        - Key: Name<br>          Value: WebServer Security Group<br>      VpcId: !Ref VPC<br><br># Create Security Group for the DataBase<br>  DataBaseSecurityGroup:<br>    Type: &#39;AWS::EC2::SecurityGroup&#39;<br>    Properties:<br>      GroupDescription: Open database for access<br>      SecurityGroupIngress:<br>        - IpProtocol: tcp<br>          FromPort: &#39;3306&#39;<br>          ToPort: &#39;3306&#39;<br>          SourceSecurityGroupId: !Ref WebServerSecurityGroup<br>      Tags:<br>        - Key: Name<br>          Value: DataBase Security Group<br>      VpcId: !Ref VPC<br><br>Outputs:<br># Export VPC ID<br>  VPC:<br>    Description: VPC ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-VPC<br>    Value: !Ref VPC<br><br># Export Public Subnet 1 <br>  PublicSubnet1:<br>    Description: Public Subnet 1 ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-PublicSubnet1<br>    Value: !Ref PublicSubnet1<br><br># Export Public Subnet 2<br>  PublicSubnet2:<br>    Description: Public Subnet 2 ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-PublicSubnet2<br>    Value: !Ref PublicSubnet2<br><br># Export Private Subnet 1<br>  PrivateSubnet1:<br>    Description: Private Subnet 1 ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-PrivateSubnet1<br>    Value: !Ref PrivateSubnet1<br><br># Export Private Subnet 2<br>  PrivateSubnet2:<br>    Description: Private Subnet 2 ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-PrivateSubnet2<br>    Value: !Ref PrivateSubnet2<br><br># Export Private Subnet 3<br>  PrivateSubnet3:<br>    Description: Private Subnet 3 ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-PrivateSubnet3<br>    Value: !Ref PrivateSubnet3<br><br># Export Private Subnet 4<br>  PrivateSubnet4:<br>    Description: Private Subnet 4 ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-PrivateSubnet4<br>    Value: !Ref PrivateSubnet4<br><br># Export ALB Security Group ID<br>  ALBSecurityGroup:<br>    Description: Application Load Balancer Security Group ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-ALBSecurityGroup<br>    Value: !Ref ALBSecurityGroup<br><br># Export SSH Security Group ID<br>  SSHSecurityGroup:<br>    Description: SSH Security Group ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-SSHSecurityGroup<br>    Value: !Ref SSHSecurityGroup<br><br># Export WebServer Security Group ID<br>  WebServerSecurityGroup:<br>    Description: Webserver Security Group ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-WebServerSecurityGroup<br>    Value: !Ref WebServerSecurityGroup<br><br># Export DataBase Security Group ID<br>  DataBaseSecurityGroup:<br>    Description: DataBase Security Group ID<br>    Export:<br>      Name: !Sub ${AWS::StackName}-DataBaseSecurityGroup<br>    Value: !Ref DataBaseSecurityGroup</pre><h3>Conclusion</h3><p>The templated approach of AWS CloudFormation allows users to codify their VPC configurations, making it easier to version, document, and collaborate on infrastructure changes. This results in a more streamlined and controlled development lifecycle, enhancing the overall agility of the organization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f6affc36a4e" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/provisioning-vpc-using-aws-cloudformation-7f6affc36a4e">Provisioning VPC using AWS Cloudformation</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Provisioning a Production Grade 2-Tier Architecture on AWS]]></title>
            <link>https://awstip.com/provisioning-a-production-grade-2-tier-architecture-on-aws-e347dcc2285f?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/e347dcc2285f</guid>
            <category><![CDATA[autoscaling-group]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[load-balancer]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Mon, 05 Feb 2024 19:44:03 GMT</pubDate>
            <atom:updated>2024-02-07T14:58:19.039Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/611/0*VTwJyNFSwivTDl_J.png" /></figure><h3>Introduction</h3><p>Provisioning a production-grade 2-tier architecture on Amazon Web Services (AWS) is a critical step in ensuring robust, scalable, and reliable infrastructure for hosting web applications. This architectural model typically involves a separation of presentation (frontend) and application (backend) tiers, optimizing performance, and facilitating easier maintenance and updates. AWS offers a comprehensive suite of services to seamlessly deploy and manage such architectures, including compute instances, load balancers, databases, and networking tools. By leveraging AWS’s infrastructure-as-a-service (IaaS) capabilities, organizations can achieve high availability, fault tolerance, and efficient scaling to meet the demands of a dynamic and evolving digital landscape. This introductory process involves thoughtful resource planning, security considerations, and efficient utilization of AWS services to create a resilient foundation for hosting production workloads.</p><h3>Steps</h3><p>Search for VPC and click.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GosUNNvoUE3VJmJQbvcwKA.png" /></figure><p>Click on VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJ3oG0ROrNpjV0fTY5vCfg.png" /></figure><p>Click on “Create VPC”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8RE5gnKXRWyDUJB-fmu0Aw.png" /></figure><p>Click “VPC and more”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2S-sWDQn0a51qDErf0avcw.png" /></figure><p>This is how the map looks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERxwRYcr6BVIRBNQIec7kw.png" /></figure><p>Leave the folowing settings on default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBIP25zxEpdcQVNoz9fGxg.png" /></figure><p>Choose 2 “availability zones”, 2 “public subnets”, 2 “private subnets”, 1 “NAT gateway” per availability zone</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wb5wrPRDaFo_I-YwmXwZ7Q.png" /></figure><p>Leave the rest as default and click “Create VPC”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mI8FsY5VBiZd6zTv8eTxSA.png" /></figure><p>You will see the following been created and click “view VPC”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-_gnHxnmADGGZ_kX5WgSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hIV8On6BbaBaSnODgAnlw.png" /></figure><p>This is what will be displayed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s3G2wrEDe_veEdqilJmJZQ.png" /></figure><p>Under “Resource map”, you will see the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abyprQiPqnWDMz_zW4mrxA.png" /></figure><p>Click on “Your VPC”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dqb-ucPt7J3ULq2ii3azig.png" /></figure><p>Newly created VPC has been provisioned successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjEXA2P8PALNb42zDSIumw.png" /></figure><p>Search for ec2 and click</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKqosGyOCEFJQF0kYzqUPA.png" /></figure><p>Scroll to “Auto Scaling Groups” and click</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3X_N49u2BOcnk5djyV-nA.png" /></figure><p>Click “Create Auto Scaling group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_b4SFvSDEYQCy1moSgMEHw.png" /></figure><p>Click “Create a Launch template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lb0J6g-du16O4Iagj16Sg.png" /></figure><p>Give your template a name, you can add a description</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdCfSBhNP2cVLLr4Gc51dA.png" /></figure><p>Choose an AMI.In our case we are using ubuntu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zh1fvlxpOuZTCpPbjy7NDg.png" /></figure><p>Choose an instance type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HIEGbPoMdXNnIdmSCzOrBA.png" /></figure><p>Sekect an existing security group or create a new one and click “Create Launch template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hV5ZFRn9nB-yPttLSCW3Lw.png" /></figure><p>Here is what will be displayed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttJ_isgZMDhqUy9lYxaiDQ.png" /></figure><p>Click on “View Launch template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBCLYvEL2kkRcyMFXL5f1g.png" /></figure><p>Now we can go back to our “Auto Scaling groups” page and name Auto scaling group. Then select the template created above</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mfx0VgU_4LxAm42y09zBTA.png" /></figure><p>leave other settings at default and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tuvn6ivKjtpvvP1GRibrnw.png" /></figure><p>Leave “Instance type requirements” at default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MstX5t-9iSauzEq0nXXzkA.png" /></figure><p>Under “Network” select 2 availability zones which have private subnets and click Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3Du0bwSKc_46LAQ_qUQtA.png" /></figure><p>Select “No load balancer” because from the architecture, load balancer must be in the public subnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cO442MwE0HVyaaCk3mpCWQ.png" /></figure><p>Leave other settings at default and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mn8qgChzZgxnUwGWBu-jUQ.png" /></figure><p>Leave “Desired Capacity” at “2”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GL1xE5WiQppXvP_kDIAm5g.png" /></figure><p>Minimum desired capacity at 1 and Max desired capacit at 4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2T_Vl6NE87kvWOJ2RnomYA.png" /></figure><p>Leave others at default and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JRdWGLJCJD2c7_ijWvNHZg.png" /></figure><p>Click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N5BXzbju4L8UVaw6qdVLyQ.png" /></figure><p>Click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B95hncEOfIql2aR3P8rU-w.png" /></figure><p>Preview and click “Create Auto Scaling group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g40ErxC2naDcNmdDLnLfrg.png" /></figure><p>Auto Scaling group has been provisioned successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxIjHIKbLySCRKuX0PEL2A.png" /></figure><p>Click on Instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P2H4J5WlWLx6Bd8jGzLvkA.png" /></figure><p>Two instances will be displayed, both with private IPV4 address but no public IPV4 address. Also note that they are both in different availability zones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqn6QnATR03G69juZ6f_rQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXE4KxWc6iZUBi23jJmSig.png" /></figure><p>Now, to create a bastion host (jump server), click on “Launch instances”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*306axfdlNzIishOUxITm1w.png" /></figure><p>Provide a name for the bastion host</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgicZgOhizEcMh7aal8fBQ.png" /></figure><p>Choose an instance type and keypair</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJjst66UCKNTGDfGO3TolQ.png" /></figure><p>Select a security group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HEizwt4raKR42Ojeys2Gsg.png" /></figure><p>Leave other settings at default and click “Launch instances”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GNQOo9H3ptfc01AByxHkUA.png" /></figure><p>Instance has been launched successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYay69j9DlH_xS2O0HnKBQ.png" /></figure><p>Click on “Create Load Balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EbW0k1ZeSb0_tOUFcG6Wbw.png" /></figure><p>Select “Application Load Balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBxo48kBEWS9I0sNzwpj0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_N0y7B07Xl_zgjN4f_Z79A.png" /></figure><p>Navigate to “Create target group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCCcXTGCHwUF6LDqSmzFzA.png" /></figure><p>“Select instances”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T69rT7kcQrVYNZuogCi8kg.png" /></figure><p>Provide target group a name, leave port at “80” and use IPV4 as IP address type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgXKOq55CYfhrOl5rBeJgQ.png" /></figure><p>Leave other settings at default and click next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7z3HZSG_q6pSioUzLVVrA.png" /></figure><p>Select the autoscaling instances, provide a port of 8000 and click “include as pending below”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OuYx7mfUrlmRt1hQCVxxdg.png" /></figure><p>Review the targets and ports assigned and click “Create target group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DkhFynu4G_3zyztkFMPitg.png" /></figure><p>It is observed that both registered targets are unhealthy and that is because there is no app running in them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37mGzPyA5MWtfCCdDH4AeQ.png" /></figure><p>NOTE: CHANGE 8000 to 3000. IT IS AN ERROR</p><p>Create a Load balancer and provide a name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhA3-Ty0urTgkZc2YJl6CA.png" /></figure><p>Select the VPC created earlier and 2 subnets associated with it. Ensure both ate public subnets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDES1RBMLjpbXo8nczd76g.png" /></figure><p>Ensure the port is 80 and select the target group created earlier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SLg0XSIYxGHMHcW-y1Qtcg.png" /></figure><p>leave other settings at default and click “Create load balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKZmcKiedihsReNMQG13dw.png" /></figure><p>Click “View load balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUTA1F94dqVYXM19JU7WfA.png" /></figure><p>Load balancer has been created successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mHKNox3E4n_vqX8kTOLRAg.png" /></figure><p>The next thing we have to do is to provision a bastion host or jump server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXQek2xFu7RICwzQtvb-FA.png" /></figure><p>Select a AMI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iwCvVvsPuyXfV2A-K_KTBQ.png" /></figure><p>Select “Instance type”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qBXMYEV0STIAMxwq8dVdjg.png" /></figure><p>Select “VPC” earlier created and make sure to choose a public subnet. Then enable “Auto-assign public IP”, select security group and Click on “Launch instance”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2_iRFTgFxzc5Vai68QuVA.png" /></figure><p>Here, bastion host has been provisioned</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JbmwWpa9tlEaQVuaYQMEhQ.png" /></figure><p>Click on “Connect” to ssh into the server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxqx6ivWG8O2zx001XDA5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jsMbUhzrN1f-BVCtbBNSwQ.png" /></figure><p>Paste the ssh command on your local machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P9tHiQZQ7su41bsWSBCQ4Q.png" /></figure><p>Perform a secure copy to transfer keypair from local machine to the bastion host</p><pre> sudo scp -i &quot;/mnt/c/Users/alexm/Downloads/alex.pem&quot; /mnt/c/Users/alexm/Downloads/alex.pem ubuntu<br>@ec2-18-234-185-203.compute-1.amazonaws.com:~</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-_PTBCMUzx2x-gsinW5lSA.png" /></figure><p>In the bastion host, confirm if the keypair is present</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0dR8Fe0Ds3JPc_MoQKSXg.png" /></figure><p>Add a name to the two auto-scaled servers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JnCn2DONhAkfdkEEvAyB7w.png" /></figure><p>Select the first server and connect via terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NcgVE9XY8K40eQCksaaKYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jvgtsd-Ym3iI1v2aqsFyw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ECS93art43jFnSXeu5wTpQ.png" /></figure><p>Install next.js<br>To know how to go the installation, visit <a href="https://medium.com/@michaelalexalex123/installation-of-next-js-on-an-ec2-instance-0afbe29d910f">https://medium.com/@michaelalexalex123/installation-of-next-js-on-an-ec2-instance-0afbe29d910f</a></p><p>Because the app runs on port 3000 we must open port 3000 on instance Security Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boEiPttJZxg0-BImUUiVxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bvw9UXpUH65lPCCdJvl1OQ.png" /></figure><p>Copy the DNS name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MgmBPhJL6xFSpGQhQ9lvA.png" /></figure><p>Paste DNS name on the browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*evLHFrYjyDzT01skTdephA.png" /></figure><h3>Conclusion</h3><p>In conclusion, provisioning a production-grade 2-tier architecture on Amazon Web Services empowers organizations to establish a robust and scalable foundation for hosting web applications. The comprehensive suite of AWS services facilitates efficient resource allocation, ensuring high availability and fault tolerance. By strategically separating frontend and backend components, this architectural model enhances performance, ease of maintenance, and scalability. Through meticulous planning and consideration of security measures, businesses can confidently deploy and manage their infrastructure, adapting to the evolving demands of the digital landscape. AWS’s commitment to providing a flexible and reliable cloud computing environment further solidifies its position as a preferred platform for building and maintaining production-grade architectures that meet the rigorous demands of modern applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e347dcc2285f" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/provisioning-a-production-grade-2-tier-architecture-on-aws-e347dcc2285f">Provisioning a Production Grade 2-Tier Architecture on AWS</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installation and Creation of a Database using MongoDB on an EC2 Instance]]></title>
            <link>https://awstip.com/installation-and-creation-of-a-database-using-mongodb-on-an-ec2-instance-4872d8b53dfe?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/4872d8b53dfe</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 21:14:46 GMT</pubDate>
            <atom:updated>2024-02-05T17:43:53.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*LheMJi47RJYNBzSD.png" /></figure><h3>Introduction</h3><p>Installing MongoDB on an Amazon EC2 instance involves a straightforward process to set up the popular NoSQL database on the cloud infrastructure. Begin by connecting to your EC2 instance via SSH, and then proceed with the installation by adding the MongoDB repository and GPG key. After updating the package list, install MongoDB using the package manager. Once installed, start the MongoDB service and enable it to run on system boot. The final step involves connecting to the MongoDB server to verify the installation and interact with the database using tools like the mongosh shell. This enables developers and system administrators to harness the power of MongoDB&#39;s flexible and scalable document-oriented storage in their AWS environments, facilitating efficient data management and retrieval for diverse applications.</p><h3>Steps</h3><p>You can use the MongoDB official documentation</p><p><a href="https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/#std-label-install-mdb-community-ubuntu">Install MongoDB Community Edition on Ubuntu - Database Manual - MongoDB Docs</a></p><p>OR</p><ol><li>Import the public key used by the package management system</li></ol><pre>sudo apt-get install gnupg curl<br></pre><p>To import the MongoDB public GPG key from</p><pre>curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \<br>   sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \<br>   --dearmor</pre><p>2. Create a list file for MongoDB</p><pre>echo &quot;deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse&quot; | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list</pre><p>3. Reload local package database</p><pre>sudo apt-get update</pre><p>4. Install the MongoDB packages</p><p>To install the latest stable version, issue the following</p><pre>sudo apt-get install -y mongodb-org</pre><p>Optional. Although you can specify any available version of MongoDB, apt-get will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, you can pin the package at the currently installed version:</p><pre>echo &quot;mongodb-org hold&quot; | sudo dpkg --set-selections<br>echo &quot;mongodb-org-database hold&quot; | sudo dpkg --set-selections<br>echo &quot;mongodb-org-server hold&quot; | sudo dpkg --set-selections<br>echo &quot;mongodb-mongosh hold&quot; | sudo dpkg --set-selections<br>echo &quot;mongodb-org-mongos hold&quot; | sudo dpkg --set-selections<br>echo &quot;mongodb-org-tools hold&quot; | sudo dpkg --set-selections</pre><p>5. Init System</p><pre>ps --no-headers -o comm 1</pre><p>6. Start MongoDB</p><pre>sudo systemctl start mongod</pre><p>If you receive an error similar to the following when starting <a href="https://www.mongodb.com/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">mongod:</a></p><p>Failed to start mongod.service: Unit mongod.service not found.</p><p>Run the following command first</p><pre>sudo systemctl daemon-reload</pre><p>Then run the start command above again.</p><p>7. Verify that MongoDB has started successfully.</p><pre>sudo systemctl status mongod</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDXe2hJhdNrLNuSDDsVaeA.png" /></figure><p>You can optionally ensure that MongoDB will start following a system reboot by issuing the following command</p><pre>sudo systemctl enable mongod</pre><p>8. Begin using MongoDB</p><pre><br>mongosh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNgVij3C30B8v4xgRFCDHg.png" /></figure><p>9. Switch to the desired database or create a new one</p><pre>use mynewdatabase</pre><p>Now, you can insert data into a collection within the database. If the collection doesn’t exist, MongoDB will create it for you. For example:</p><pre>db.mynewcollection.insertOne({ name: &quot;John Doe&quot;, age: 30, city: &quot;Example City&quot; })</pre><p>Replace mynewcollection with the name you want for your new collection.</p><ol><li>Verify that the data has been inserted by querying the collection:</li></ol><pre>db.mynewcollection.find()</pre><p>You should see the document you inserted.</p><p>To show the list of databases use:</p><pre>show dbs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmxi6x3Ea018ascb58VWKw.png" /></figure><h3>Conclusion</h3><p>In conclusion, the installation of MongoDB on an EC2 instance is a pivotal step toward leveraging the capabilities of a robust NoSQL database in a cloud environment. MongoDB offers flexibility and scalability, making it well-suited for a variety of applications. By following the installation process outlined on the EC2 instance, users can seamlessly integrate MongoDB into their projects, unlocking efficient and scalable data storage solutions. The ability to effortlessly create databases and collections, manage data, and interact with the MongoDB server provides a solid foundation for developers and system administrators to build and maintain powerful, data-driven applications on the Amazon Web Services platform. As MongoDB continues to evolve, this installation process on EC2 instances remains a fundamental gateway to harnessing the full potential of modern, scalable database solutions in the cloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4872d8b53dfe" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/installation-and-creation-of-a-database-using-mongodb-on-an-ec2-instance-4872d8b53dfe">Installation and Creation of a Database using MongoDB on an EC2 Instance</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installation of Next.Js on an EC2 Instance]]></title>
            <link>https://awstip.com/installation-of-next-js-on-an-ec2-instance-0afbe29d910f?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/0afbe29d910f</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 20:06:35 GMT</pubDate>
            <atom:updated>2024-02-05T17:43:48.377Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cji5uooOgEu8NyiMS-9nxA.png" /></figure><h3>Introduction</h3><p>Installing Next.js on an EC2 (Elastic Compute Cloud) instance is a pivotal step in setting up a dynamic and performant web application. Next.js, a React framework, brings the advantages of server-side rendering and seamless client-side navigation, making it an ideal choice for building modern and responsive web applications. Deploying Next.js on an EC2 instance allows developers to harness the scalability and configurability of the AWS cloud. By integrating Next.js with EC2, developers can create and deploy React applications with ease, taking advantage of server-side rendering for improved performance and SEO optimization. This installation not only ensures a reliable foundation for web development but also capitalizes on the scalable infrastructure of EC2 to meet the demands of evolving and dynamic web projects.</p><h3>Steps</h3><ol><li>Provision of an EC2 instance</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5gkhWhxQQO_sdm8CoidZg.png" /></figure><p>2. Install node.js and npm</p><blockquote>Note: Use Node version 18</blockquote><pre>sudo apt update<br>cd ~<br>curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh<br>nano /tmp/nodesource_setup.sh<br>sudo bash /tmp/nodesource_setup.sh<br>sudo apt install nodejs<br>node -v</pre><p>3. Create a new directory for your Next.js project</p><pre>mkdir my-nextjs-app<br>cd my-nextjs-app</pre><p>3. Open a terminal or command prompt and run the following command to create a new NextJS app</p><pre>npx create-next-app</pre><p>4. Move into the project directory</p><pre>cd my-app</pre><p>5. Now, use npm run dev command to start the development server.</p><p>This command triggers the development mode, which includes features like hot code reloading, error reporting, and other optimizations for a smoother development experience.</p><pre>npm run dev</pre><p>6. By default, it will start the server on <a href="http://localhost:3000/">http://public_ip:3000/</a>. You can access your Next.js application at this address in your web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jg2lFN2rflScFl7Gn3_tiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWm3tWHHENaauc1JLA9RgA.png" /></figure><h3>Conclusion</h3><p>In conclusion, the installation of Next.js on an EC2 instance represents a strategic fusion of a powerful React framework with the scalable cloud computing capabilities offered by AWS. This integration empowers developers to craft modern and efficient web applications that leverage server-side rendering and seamless client-side navigation. By deploying Next.js on an EC2 instance, developers benefit from the flexibility and scalability of AWS, ensuring their applications can handle varying workloads with optimal performance. This synergy between Next.js and EC2 not only simplifies the deployment process but also provides a robust foundation for building responsive and feature-rich web applications in a dynamic and ever-evolving digital landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0afbe29d910f" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/installation-of-next-js-on-an-ec2-instance-0afbe29d910f">Installation of Next.Js on an EC2 Instance</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installation of Express.Js on an EC2 Instance]]></title>
            <link>https://awstip.com/installation-of-express-js-on-an-ec2-instance-e7759c7c6a86?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7759c7c6a86</guid>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 19:29:37 GMT</pubDate>
            <atom:updated>2024-02-05T17:43:43.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*js5fGWuxAdekbGaKjNIazA.png" /></figure><h3>Introduction</h3><p>The installation of Express.js on an EC2 (Elastic Compute Cloud) instance is a fundamental step in setting up a robust and scalable web server for Node.js applications. Express.js, a popular and lightweight web application framework for Node.js, simplifies the development of web applications by providing a minimal and flexible set of tools for building robust APIs and web servers. EC2, on the other hand, is a scalable cloud computing service offered by Amazon Web Services (AWS). Combining Express.js with an EC2 instance allows developers to deploy and host their Node.js applications in a scalable and customizable environment. This introduction aims to highlight the significance of installing Express.js on an EC2 instance as a crucial initial step in building and deploying web applications on the AWS cloud.</p><h3>Steps</h3><ol><li>Provision an EC2 instance</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mkQGHZDh-cXyUAGeV7HnWg.png" /></figure><p>2. Install node.js and npm</p><blockquote>Note: Use Node version 18</blockquote><pre>sudo apt update<br>cd ~<br>curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh<br>nano /tmp/nodesource_setup.sh<br>sudo bash /tmp/nodesource_setup.sh<br>sudo apt install nodejs<br>node -v</pre><p>3. Initialize a Node.js project</p><pre>npm init -y</pre><p>4. Install Express.js</p><pre>npm install express</pre><p>5. Create a new file, let’s call it server.js, and add the following code to create a basic Express server</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const port = 3000; // You can use any available port<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Hello, Express!&#39;);<br>});<br><br>app.listen(port, () =&gt; {<br>  console.log(`Server is running on http://localhost:${port}`);<br>});</pre><p>6. Run the server</p><pre>node server.js</pre><p>7. Open your web browser and navigate to http://public_ip:3000/ (or the port you specified in the server.js file). You should see the message &quot;Hello, Express!&quot; displayed in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j5xz4R0GlmfGqaZDWCfEQw.png" /></figure><p>That’s it! You have successfully installed Express.js and created a simple server. You can now build upon this foundation to create more complex web applications using Express.js.</p><h3>Conclusion</h3><p>In conclusion, the installation of Express.js on an EC2 instance lays the foundation for a powerful and scalable web server infrastructure. By leveraging the capabilities of Express.js within the flexible and scalable environment provided by EC2, developers can create and deploy robust Node.js applications with ease. The combination of Express.js and EC2 offers the agility and scalability needed to accommodate varying workloads, ensuring optimal performance and responsiveness for web applications. This integration exemplifies the synergy between a lightweight and efficient web framework like Express.js and the scalable cloud computing capabilities of AWS’s EC2, providing developers with a reliable platform for deploying and managing their applications in a dynamic and evolving digital landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7759c7c6a86" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/installation-of-express-js-on-an-ec2-instance-e7759c7c6a86">Installation of Express.Js on an EC2 Instance</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installation of Angular.Js on an EC2 Instance]]></title>
            <link>https://awstip.com/installation-of-angular-js-on-an-ec2-instance-7e60e4882d16?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e60e4882d16</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 18:53:02 GMT</pubDate>
            <atom:updated>2024-02-05T17:40:31.344Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*LBqZAae88bhSPQSX.jpg" /></figure><h3>Introduction</h3><p>AngularJS, developed by Google, stands as a potent front-end JavaScript framework that empowers the creation of dynamic, single-page web applications. Utilizing the Model-View-Controller (MVC) architecture, AngularJS streamlines the development of complex web applications by offering a structured framework and an array of powerful tools. As businesses increasingly turn to cloud solutions, Amazon EC2 emerges as a reliable hosting platform within the AWS ecosystem. This guide aims to provide a concise and effective walkthrough for installing AngularJS on an EC2 instance, allowing developers to harness the framework’s capabilities and seamlessly integrate dynamic features into their web applications. With a focus on simplicity and scalability, this installation process facilitates the utilization of AngularJS in the cloud, offering a robust foundation for building responsive and interactive web solutions.</p><h3>Steps</h3><ol><li>Provision of an EC2 instance</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sn9sGbuyedZ5tqLWSl9Jcg.png" /></figure><p>2. Install node.js and npm</p><blockquote>Note: Use Node version 18</blockquote><pre>sudo apt update<br>cd ~<br>curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh<br>nano /tmp/nodesource_setup.sh<br>sudo bash /tmp/nodesource_setup.sh<br>sudo apt install nodejs<br>node -v</pre><p>3. Install Angular</p><pre>npm install -g @angular/cli</pre><p>4. Create a new Angular application</p><pre>ng new my-angular-app</pre><p>5. Navigate to the project folder</p><pre>cd my-angular-app</pre><p>6. Serve the Angular application</p><pre>ng serve --host 0.0.0.0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3O6uTP4GvT6GpunmuynmbA.png" /></figure><p>7. Open your web browser and navigate to <a href="http://public/">http://public</a>_ip:4200/. You should see your Angular application running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmG5BcGxKWlll98pEoVEUQ.png" /></figure><h3>Conclusion</h3><p>In conclusion, the installation of AngularJS on an Amazon EC2 instance offers a seamless integration of a powerful front-end framework into the scalable and reliable AWS cloud environment. By following the steps outlined in this guide, developers can quickly set up AngularJS and unlock its capabilities to build dynamic and responsive single-page web applications. Leveraging the Model-View-Controller architecture and the tools provided by AngularJS, businesses can enhance their web applications with structured code and improved user experiences. As the intersection of cloud computing and web development continues to shape the digital landscape, the combination of AngularJS and EC2 stands as a robust solution, empowering developers to create feature-rich applications that meet the demands of today’s dynamic online landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e60e4882d16" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/installation-of-angular-js-on-an-ec2-instance-7e60e4882d16">Installation of Angular.Js on an EC2 Instance</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set Up a Scaled and Load-Balanced Web App]]></title>
            <link>https://awstip.com/set-up-a-scaled-and-load-balanced-web-app-e9b4c4118ba8?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9b4c4118ba8</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[elastic-load-balancer]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[auto-scaling-groups]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Sat, 03 Feb 2024 16:29:22 GMT</pubDate>
            <atom:updated>2024-02-05T17:40:27.008Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*P9TCAHRdNudr63tC.png" /></figure><h3>Introduction</h3><p>Auto-scaling, EC2 instances, and Load Balancers are integral components in the realm of cloud computing, offering dynamic and efficient solutions for managing workloads and ensuring high availability of applications. Auto-scaling enables the automatic adjustment of the number of EC2 instances based on demand, optimizing resource utilization and minimizing costs. EC2 instances, as virtual servers in the Amazon Web Services (AWS) cloud, serve as the building blocks for various applications. Attaching instances to a Load Balancer ensures even distribution of incoming traffic, enhancing the overall performance and reliability of applications. Together, these technologies form a robust and flexible infrastructure that adapts to changing demands, providing a scalable and resilient foundation for modern cloud-based architectures.</p><h3>Steps</h3><ol><li>Navigate to the “Auto Scaling Groups” on AWS console</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azzN2vS3EW6Z_h4aBGoIRQ.png" /></figure><p>2. Click on “Create Auto Scaling Group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t3RtCGr2XQdHsnjELlpKKQ.png" /></figure><p>3. Create a custom name and click “Create launch template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGMDCtxdem4G_e56wB_Wsw.png" /></figure><p>4. Provide a name for Launch template</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubJuh62L4PhpxdHdYMtHvg.png" /></figure><p>5. Choose an AMI, but in our case we are selecting ubuntu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*onZn8qpngXZ9c88Vvy1zeg.png" /></figure><p>6. Choose an “Instance type” and “Key pair”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUqivSQOUE8ptZQ9t0Z07g.png" /></figure><p>7. Leave “Subnet” at default and select a “Security group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ktwJCSwZ76kj3tFJEPWjg.png" /></figure><p>8. Click on “Advanced details”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZf3fjmi42--fy_K3dBVFw.png" /></figure><p>9. Copy and paste the following html script on the “User data”</p><pre>#!/bin/bash<br><br># Update package list and install Nginx<br>sudo apt update<br>sudo apt install -y nginx<br><br># Create a directory for the website<br>sudo mkdir -p /var/www/mywebsite<br>sudo chown -R $USER:$USER /var/www/mywebsite<br><br># Create a simple HTML file with CSS<br>cat &lt;&lt;EOF &gt; /var/www/mywebsite/index.html<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;My Website&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Welcome to My Website!&lt;/h1&gt;<br>    &lt;p&gt;This is a simple static website deployed with Nginx.&lt;/p&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>EOF<br><br>cat &lt;&lt;EOF &gt; /var/www/mywebsite/style.css<br>body {<br>    font-family: Arial, sans-serif;<br>    background-color: #f4f4f4;<br>    color: #333;<br>    margin: 20px;<br>}<br><br>h1 {<br>    color: #0066cc;<br>}<br>EOF<br><br># Create Nginx server block configuration<br>cat &lt;&lt;EOF | sudo tee /etc/nginx/sites-available/mywebsite<br>server {<br>    listen 80;<br>    server_name mywebsite.local;<br><br>    root /var/www/mywebsite;<br>    index index.html;<br><br>    location / {<br>        try_files \$uri \$uri/ =404;<br>    }<br>}<br>EOF<br><br># Enable the site configuration<br>sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled<br><br># Remove default Nginx configuration<br>sudo rm /etc/nginx/sites-enabled/default<br><br># Restart Nginx to apply changes<br>sudo systemctl restart nginx<br><br>echo &quot;Website deployed successfully. Access it at http://mywebsite.local/&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FB5EhO8A7l2ykkFfu4uPkw.png" /></figure><p>10. Template has been created successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0QvBvrtiV73mwW81pWLhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xVEoa7ik4zDbYdAz58WXfA.png" /></figure><p>11. Reload the auto-scaling page and choose a “Launch template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1R1FcA5oaRNdsNFaZyMhmA.png" /></figure><p>12. Leave other settings as default and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMumzwsPCWH3LlzLPalYMw.png" /></figure><p>13. Under “Network”, select two “availability zones” and “subnets”. Then click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBkVf3kbHG0n261vm7XRlA.png" /></figure><p>14. Select “Attach a new load balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVKkBk-IcHskcxW1omtsPg.png" /></figure><p>15. Choose “Application Load Balancer” as your “ELB”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdGlUPG0hhsHDMZIHp96xw.png" /></figure><p>16. We have “Availability zones and subnets” already selected earlier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syYEBfenb3hJW8wd3TSwvQ.png" /></figure><p>17. Create a new “target group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9rorjq9jktegOC2DB3MPuw.png" /></figure><p>18. Provide a “name” for target group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O9n8ZNI83MZ4BUHKGdjw8A.png" /></figure><p>19. Select “No VPC Lattice Service”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGJZ-z_NZo0QxhJki0yx_g.png" /></figure><p>20. Leave other settings at default and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1N4VZ8X4Nvkz6XRAsjzQeA.png" /></figure><p>21. Choose “1” as your group size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4avxtFGAXch1XupW9MEUUQ.png" /></figure><p>22. “Minimum desired capacity” should be “1” while Max desired can be any number 3, 4, 5 or more number of instances you want to scale out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvYnG-FPnVwKEP4PcSU38g.png" /></figure><p>23. Leave other settings as default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*psi10RTJrhu_H1lhcsTBAA.png" /></figure><p>24. Click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhN1OVFOmD0a3zmfWwGlvw.png" /></figure><p>25. Click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGaaZe3KcZLCZ4w4LpWiJA.png" /></figure><p>26. Review and click “Create Auto Scaling Group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kus5IHEayK9bGFDDgSw4bg.png" /></figure><p>27. Auto Scaling group named “test-autoscaling-demo” will be created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_6d8Hzp9u3EMgkltoBI6A.png" /></figure><p>28. Select the Auto Scaling group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tH0Ppak66C4M3Svrp0HN7w.png" /></figure><p>29. Under “Details” copy “Public IP”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I5736vsE-bhyvPwV4IO1MA.png" /></figure><p>30. Paste on a browser and your website will be displayed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18e3EUyluBRUIwmhoXMrwQ.png" /></figure><p>31. To test if the Load Balancer works, go to “Load balancers”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Zh1q8_UdY2QjjgBUnPqEg.png" /></figure><p>32. Copy the DNS name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTkweBjcGAGsze1z5UvVXQ.png" /></figure><p>33. Paste on browser and the website displays</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1C38VcZO9JLmMFW6LZF0w.png" /></figure><h3>Conclusion</h3><p>In conclusion, the seamless integration of auto-scaling, EC2 instances, and Load Balancers presents a powerful combination for achieving scalability, flexibility, and reliability in cloud computing environments. Auto-scaling enables the dynamic adjustment of resources to meet fluctuating demand, ensuring optimal performance and cost-effectiveness. EC2 instances serve as the backbone, offering a versatile and scalable solution for hosting applications. The attachment of instances to Load Balancers enhances application availability by distributing incoming traffic evenly. Together, these components contribute to the creation of a resilient, adaptive, and high-performing infrastructure that meets the evolving needs of modern applications in the cloud. This holistic approach facilitates efficient management of workloads, providing a foundation for building robust and responsive systems in the ever-changing landscape of cloud computing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9b4c4118ba8" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/set-up-a-scaled-and-load-balanced-web-app-e9b4c4118ba8">Set Up a Scaled and Load-Balanced Web App</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elastic Load Balancer Demo In AWS]]></title>
            <link>https://awstip.com/elastic-load-balancer-demo-in-aws-c3de604b071e?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3de604b071e</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[elastic-load-balancer]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 08:04:12 GMT</pubDate>
            <atom:updated>2024-02-02T14:00:38.021Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/667/0*ZUh-6th8Z1K4JLHC" /></figure><h3>Introduction</h3><p>Embark on a streamlined journey to optimize your application’s performance with the Elastic Load Balancer (ELB) to Amazon Elastic Compute Cloud (EC2) integration in AWS. To configure ELB to EC2, first, navigate to the AWS Management Console and access the EC2 Dashboard. Identify the instances you want to include in the load balancer, ensuring they are configured and running. Then, move to the EC2 Load Balancers section and create a new load balancer, specifying the desired protocol and port settings. Next, configure the health check settings to ensure seamless traffic distribution. Associate the load balancer with your chosen instances, and once set up, monitor the performance and adjust settings as needed. This step-by-step demonstration will empower you to efficiently balance workloads and enhance the resilience of your applications on AWS.</p><h3>Steps</h3><ol><li>Provision two AWS servers and Click on Load Balancers</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KpjojVAy0w6sgmxs-IN_xg.png" /></figure><p>Kindly note that in configuring EC2 instance, for the respective instances with automate the installation of nginx webserver and deployment of a simple web page using:</p><p>Userdata for server 1</p><pre>#!/bin/bash<br><br># Update package list and install Nginx<br>sudo apt update<br>sudo apt install -y nginx<br><br># Create a welcome page with HTML and CSS<br>sudo sh -c &#39;cat &lt;&lt;EOF &gt; /var/www/html/index.html<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Welcome to Server 1&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: Arial, sans-serif;<br>            background-color: #f4f4f4;<br>            text-align: center;<br>            margin: 20vh 0;<br>        }<br>        h1 {<br>            color: #333;<br>            border-bottom: 2px solid #333;<br>            padding-bottom: 10px;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Welcome to Server 1&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>EOF&#39;<br><br># Start Nginx<br>sudo systemctl start nginx<br><br># Enable Nginx to start on boot<br>sudo systemctl enable nginx</pre><p>Userdata for server 2</p><pre>#!/bin/bash<br><br># SERVER 2<br><br># Update package list and install Nginx<br>sudo apt update<br>sudo apt install -y nginx<br><br># Create a welcome page with HTML and CSS<br>sudo sh -c &#39;cat &lt;&lt;EOF &gt; /var/www/html/index.html<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Welcome to Server 2&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: Arial, sans-serif;<br>            background-color: #f4f4f4;<br>            text-align: center;<br>            margin: 20vh 0;<br>        }<br>        h1 {<br>            color: #333;<br>            border-bottom: 2px solid #333;<br>            padding-bottom: 10px;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Welcome to Server 2&lt;/h1&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>EOF&#39;<br><br># Start Nginx<br>sudo systemctl start nginx<br><br># Enable Nginx to start on boot<br>sudo systemctl enable nginx</pre><p>2. Click on “Create load balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNWmKhDOZmcZVnmMShNXxQ.png" /></figure><p>3. Navigate to “Application Load Balancer” and click “Create”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JpDppqbWuGM53_OJUOUMkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c_9TLMrynQTSPm5WmtP4kg.png" /></figure><p>4. Give a name to your load balancer and leave “scheme” as “internet-facing”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THMkiB35Tt83Ml96E6zdbQ.png" /></figure><p>5. Add a security group that has port 80 allowed and click on “Create target group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RpYCsAa6TpSE6en2QkxSuA.png" /></figure><p>6. In “Basic configuration” choose “instances”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHHsCFrNTPduT2XcBnDWcg.png" /></figure><p>7. Add a “name” dedicated to your target group, add “protocol” precisely port 80 and select “IPv4”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mq6vII6AKTTXKXECntU2hg.png" /></figure><p>8. Leave other settings as default and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1aVe0p5Z5av2b0pSYvNjA.png" /></figure><p>9. We select the instances we want to associate with the target group an select “include as pending below”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*se6_CxMDtDGC4hOD4upujg.png" /></figure><p>10. Then click “Create target group”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TOKZ3Y5HFqRASGHR5Ntzyw.png" /></figure><p>11. Go back to load balancer page, reload and add target group we just created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QztS2vs8TvyDQkjxQ4lFQ.png" /></figure><p>12. Leave other configurations as default and click “Create load balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1-xdSuWrrlGXkYy6rU9Dw.png" /></figure><p>13. Click “View load balancer”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bHT9sKgQMa_zxe_INIjp-w.png" /></figure><p>14. Now the application load balancer has been created. Then we select it and copy the “DNS name”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WoGT9uPSC6QkSDMgH_F5Og.png" /></figure><p>15. Paste DNS name to the browser and reload continously. It will be observed that the DNS name directs traffic to both server 1 and server 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9i3RF1aZ10pNAYK80ByZiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKW5Ih9gtCF3Xb-YcCmwKA.png" /></figure><h3>Conclusion</h3><p>In conclusion, the Elastic Load Balancer (ELB) to Amazon Elastic Compute Cloud (EC2) integration in AWS offers a robust solution for optimizing application performance, ensuring high availability, and simplifying the management of workloads. By following the outlined steps, users can seamlessly configure ELB to distribute traffic intelligently across multiple EC2 instances, promoting efficient resource utilization and enhancing the overall reliability of their applications. The flexibility and scalability provided by ELB empower businesses to adapt to changing workloads and user demands, ultimately delivering a seamless and responsive user experience. As you navigate the AWS cloud environment, mastering the configuration of ELB to EC2 becomes a key component in achieving a resilient and high-performing application infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3de604b071e" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/elastic-load-balancer-demo-in-aws-c3de604b071e">Elastic Load Balancer Demo In AWS</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshooting “Failed to Connect to Your Instance” Response on EC2]]></title>
            <link>https://awstip.com/troubleshooting-failed-to-connect-to-your-instance-response-on-ec2-92428837ea4a?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/92428837ea4a</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Mon, 29 Jan 2024 10:59:07 GMT</pubDate>
            <atom:updated>2024-01-29T19:32:58.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XUTeGC8J42-rZMjuXfeYFQ.png" /></figure><h3>Introduction</h3><p>Encountering a “Failed to connect to your instance” error typically indicates a problem establishing a connection between your client and the target server or virtual machine instance. This error can be caused by various issues such as network problems, incorrect authentication credentials, firewall restrictions, or server misconfigurations.</p><p>But if all these were configured correctly, what could be the solution to the challenge? It could be the permission granted and this can be configured using the steps below.</p><h3>Steps</h3><ol><li>Navigate to the “Security credentials”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20SWD_ErTRoZhMbUY542Mw.png" /></figure><p>2. Click on “Users”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCx6vkaNHxc0naEagogcpQ.png" /></figure><p>3. Click the user account that needs ssh connection permission. In our case it “Alex”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJLXzU9CYQk9eb0yZaYcOA.png" /></figure><p>4. Click on “Add permission”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uwld2MBD5zQ5jaWmViPmIg.png" /></figure><p>5. Select “Attach policies directly” and search for “EC2InstanceConnect”, select it and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZoXWkYJv6tBwlaKpec1aQ.png" /></figure><p>6. Click “Add permission”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pZV5TYrQrIEs3jLUI1SobQ.png" /></figure><p>7. You will see the new permission added to the list of permissions granted to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNoTe5yZ7U5xdt-gIQHr2Q.png" /></figure><p>8. On the User’s Account, navigate to the EC2 instance and click on “Connect”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtU0v1LPXG8SPMMPMriscA.png" /></figure><p>9. Click on “Connect” again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwmskrHdv4VjFNNe85Yhmg.png" /></figure><p>10. Now instance connection has been established</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-9VD_0Rt6BflZGQYGKPkg.png" /></figure><h3>Conclusion</h3><p>In conclusion, resolving the “Failed to Connect to Your Instance” issue on Amazon EC2 often involves meticulously managing permissions. . If you encounter persistent connection problems, inspect the IAM (Identity and Access Management) roles and policies to guarantee that the associated permissions grant the necessary access rights. Utilizing AWS Identity and Access Management effectively ensures that your EC2 instances have the appropriate permissions, fostering a secure and reliable connection environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92428837ea4a" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/troubleshooting-failed-to-connect-to-your-instance-response-on-ec2-92428837ea4a">Troubleshooting “Failed to Connect to Your Instance” Response on EC2</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Provisioning Cloud Infrastructures (EC2 and RDS)Using Terraform]]></title>
            <link>https://awstip.com/provisioning-cloud-infrastructures-ec2-and-rds-using-terraform-e99b07595fca?source=rss-32af03092885------2</link>
            <guid isPermaLink="false">https://medium.com/p/e99b07595fca</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Michael Alex]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 14:23:06 GMT</pubDate>
            <atom:updated>2024-01-26T19:06:55.640Z</atom:updated>
            <content:encoded><![CDATA[<h3>Provisioning Cloud Infrastructures (EC2 and RDS) Using Terraform</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lYXPw5m3YVKC97Lw.jpg" /></figure><h3>Introduction</h3><p>Provisioning cloud infrastructures, specifically EC2 instances and RDS databases, using Terraform involves defining a Terraform configuration file that specifies the desired resources and their configurations. For EC2 instances, this typically includes defining the instance type, key pair, security groups, and any additional settings. For RDS, parameters such as database engine, instance class, storage, and security configurations are specified. The Terraform script utilizes the AWS provider to interact with the AWS API, ensuring the creation and management of the specified resources. Variables and modules can be employed to parameterize and organize the code for reusability and scalability. Upon execution of the Terraform commands, the infrastructure is automatically provisioned in the cloud, adhering to the defined specifications, allowing for efficient and repeatable deployment of EC2 instances and RDS databases in the AWS environment.</p><h3>Steps</h3><ol><li>On local machine, install terraform</li></ol><pre># Add the HashiCorp GPG key<br>curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg<br><br># Add the official HashiCorp Linux repository<br>echo &quot;deb [signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main&quot; | sudo tee /etc/apt/sources.list.d/hashicorp.list &gt; /dev/null<br><br># Update package lists and install Terraform<br>sudo apt-get update &amp;&amp; sudo apt-get install terraform</pre><p>2. Create two directories (EC2 and RDS) and navigate to the EC2 directory</p><pre>mkdir EC2<br>mkdir RDS<br>cd EC2</pre><p>3. Create an ec2.tf file</p><pre># This was gotten from Provider in https://registry.terraform.io/providers/hashicorp/aws/latest/docs<br><br>provider &quot;aws&quot; {<br>  region     = &quot;eu-west-2&quot;<br>  access_key = &quot;####################&quot;<br>  secret_key = &quot;#####################&quot;<br>}<br><br># create default vpc if one does not exit<br>resource &quot;aws_default_vpc&quot; &quot;default_vpc&quot; {<br><br>  tags = {<br>    Name = &quot;default vpc&quot;<br>  }<br>}<br><br><br># use data source to get all avalablility zones in region<br>data &quot;aws_availability_zones&quot; &quot;available_zones&quot; {}<br><br><br># create default subnet if one does not exit<br>resource &quot;aws_default_subnet&quot; &quot;default_az1&quot; {<br>  availability_zone = data.aws_availability_zones.available_zones.names[0]<br><br>  tags = {<br>    Name = &quot;default subnet&quot;<br>  }<br>}<br><br><br># create security group for the ec2 instance<br>resource &quot;aws_security_group&quot; &quot;ec2_security_group&quot; {<br>  name        = &quot;ec2 security group&quot;<br>  description = &quot;allow access on ports 80 and 22&quot;<br>  vpc_id      = aws_default_vpc.default_vpc.id<br><br>  ingress {<br>    description = &quot;http access&quot;<br>    from_port   = 80<br>    to_port     = 80<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  ingress {<br>    description = &quot;ssh access&quot;<br>    from_port   = 22<br>    to_port     = 22<br>    protocol    = &quot;tcp&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = &quot;-1&quot;<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  tags = {<br>    Name = &quot;ec2 security group&quot;<br>  }<br>}<br><br><br><br><br># use data source to get a registered amazon linux 2 ami<br>data &quot;aws_ami&quot; &quot;ubuntu&quot; {<br>  most_recent = true<br><br>  filter {<br>    name   = &quot;name&quot;<br>    values = [&quot;ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*&quot;]<br>  }<br><br>  filter {<br>    name   = &quot;virtualization-type&quot;<br>    values = [&quot;hvm&quot;]<br>  }<br><br>  owners = [&quot;099720109477&quot;] # Canonical<br>}<br><br><br><br># launch the ec2 instance and install website<br>resource &quot;aws_instance&quot; &quot;ec2_instance&quot; {<br>  ami                    = data.aws_ami.ubuntu.id<br>  instance_type          = &quot;t2.micro&quot;<br>  subnet_id              = aws_default_subnet.default_az1.id<br>  vpc_security_group_ids = [aws_security_group.ec2_security_group.id]<br>  key_name               = &quot;sternpay_keypair&quot;<br><br>  tags = {<br>    Name = &quot;test-server&quot;<br>  }<br>}<br><br><br># print the ec2&#39;s public ipv4 address<br>output &quot;public_ipv4_address&quot; {<br>  value = aws_instance.ec2_instance.public_ip<br>}<br><br><br>################################################################################################<br># create default subnet if one does not exit<br>resource &quot;aws_default_subnet&quot; &quot;subnet_az1&quot; {<br>  availability_zone = data.aws_availability_zones.available_zones.names[0]<br><br>  tags = {<br>    Name = &quot;db subnet 1&quot;<br>  }<br>}<br><br># create default subnet if one does not exit<br>resource &quot;aws_default_subnet&quot; &quot;subnet_az2&quot; {<br>  availability_zone = data.aws_availability_zones.available_zones.names[1]<br><br>  tags = {<br>    Name = &quot;default subnet 2&quot;<br>  }<br>}<br><br><br># create security group for the database<br>resource &quot;aws_security_group&quot; &quot;database_security_group&quot; {<br>  name        = &quot;database security group&quot;<br>  description = &quot;enable mysql/aurora access on port 3306&quot;<br>  vpc_id      = aws_default_vpc.default_vpc.id<br><br>  ingress {<br>    description = &quot;PostgreSQL access&quot;<br>    from_port   = 5432<br>    to_port     = 5432<br>    protocol    = &quot;tcp&quot;<br>  }<br><br>  egress {<br>    from_port   = 0<br>    to_port     = 0<br>    protocol    = -1<br>    cidr_blocks = [&quot;0.0.0.0/0&quot;]<br>  }<br><br>  tags = {<br>    Name = &quot;database security group&quot;<br>  }<br>}<br><br><br># create the subnet group for the rds instance<br>resource &quot;aws_db_subnet_group&quot; &quot;database_subnet_group_1&quot; {<br>  name        = &quot;database-subnets&quot;<br>  subnet_ids  = [aws_default_subnet.subnet_az1.id, aws_default_subnet.subnet_az2.id]<br>  description = &quot;subnets for database instance&quot;<br><br>  tags = {<br>    Name = &quot;database-subnets-1&quot;<br>  }<br>}<br><br><br># Create the RDS instance<br>resource &quot;aws_db_instance&quot; &quot;db_instance&quot; {<br>  engine         = &quot;postgres&quot;<br>  engine_version = &quot;11.16&quot; # Specify the desired PostgreSQL version<br><br>  multi_az = false # Set to true for Multi-AZ deployment, if needed<br><br>  identifier = &quot;sternpay-postgres-db&quot; # Unique identifier for the RDS instance<br>  username   = &quot;devops&quot;<br>  password   = &quot;#################&quot;<br><br>  instance_class    = &quot;db.t2.micro&quot; # Specify the instance type<br>  allocated_storage = 20            # Specify the allocated storage in GB<br><br>  db_subnet_group_name = aws_db_subnet_group.database_subnet_group_1.name # Name of the DB subnet group<br><br>  vpc_security_group_ids = [aws_security_group.database_security_group.id] # List of security group IDs<br><br>  availability_zone   = data.aws_availability_zones.available_zones.names[0]<br>  db_name             = &quot;sternpaydb&quot;<br>  skip_final_snapshot = true<br><br>  # Additional optional parameters can be added based on your requirements<br>  publicly_accessible     = false # Set to true if you want the RDS instance to be publicly accessible<br>  storage_type            = &quot;gp2&quot; # Specify the storage type<br>  backup_retention_period = 7     # Specify the backup retention period in days<br>}</pre><p>Input your access key, secret key and password where you have “#########”</p><p>4. Initialize terraform</p><pre>terraform init</pre><p>5. Format terraform</p><pre>terraform fmt</pre><p>6. Perform a dry run</p><pre>terraform plan</pre><p>7. Create infrastructure using</p><pre>terraform apply</pre><p>8. Ec2 and RDS will be provisioned automatically</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gm8vONYoIgM5VFYZDMsHyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3IlPLDZlXeK_eALk_1Evfg.png" /></figure><p>9. If you choose to destroy the infrastructure provisioned</p><pre>terraform destroy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I41jPRsUos2EcJWix1MmZA.png" /></figure><h3>Conclusion</h3><p>In conclusion, provisioning cloud infrastructures with Terraform for EC2 instances and RDS databases offers a robust and efficient approach to managing cloud resources. Terraform’s declarative syntax simplifies the definition of infrastructure as code, allowing users to express their desired state and configuration parameters in a concise manner. The AWS provider integration ensures seamless communication with the AWS API, enabling the automatic creation and management of EC2 instances and RDS databases. This approach not only enhances scalability and repeatability but also facilitates version control and collaboration through code repositories. By leveraging Terraform, organizations can streamline the deployment process, maintain consistency across environments, and adapt to evolving infrastructure requirements with ease, ultimately optimizing the provisioning of cloud resources on AWS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e99b07595fca" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/provisioning-cloud-infrastructures-ec2-and-rds-using-terraform-e99b07595fca">Provisioning Cloud Infrastructures (EC2 and RDS)Using Terraform</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>