7 explain below with examples ? Auto Scaling Group • Load Balancer • Target Group • Bastion Host or Jump Server - suryav1012/surya-aws-notes GitHub Wiki

Auto Scaling Group

An Auto Scaling Group (ASG) is a collection of EC2 instances that are launched as a group based on a common configuration. The ASG ensures that the desired number of instances are running at all times by automatically launching new instances when demand increases and terminating instances when demand decreases.

Key features of an ASG include:

  • Specifying a minimum, maximum, and desired capacity for the group
  • Automatically launching new instances when demand increases
  • Automatically terminating instances when demand decreases
  • Distributing instances across multiple Availability Zones
  • Automatically replacing unhealthy instances

Example:

Resources:
  MyAutoScalingGroup:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      AvailabilityZones: 
        - us-east-1a
        - us-east-1b
      LaunchConfigurationName: !Ref MyLaunchConfig
      MaxSize: 5
      MinSize: 1
      DesiredCapacity: 2
      HealthCheckType: ELB
      HealthCheckGracePeriod: 300
      TargetGroupARNs:
        - !Ref MyTargetGroup

Load Balancer

An Elastic Load Balancer (ELB) is used to distribute incoming traffic across multiple EC2 instances. The ELB monitors the health of the instances and only sends traffic to healthy instances. There are three types of ELBs:

  • Application Load Balancer - routes traffic based on advanced rules at the application layer
  • Network Load Balancer - routes traffic at the connection level (layer 4)
  • Classic Load Balancer - legacy load balancer that routes traffic at layer 4 or 7

Example:

Resources:
  MyLoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Scheme: internet-facing
      SecurityGroups:
        - !Ref MyLoadBalancerSG
      Subnets:
        - !Ref PublicSubnet1
        - !Ref PublicSubnet2

Target Group

A Target Group is used to route requests to one or more registered targets, such as EC2 instances, containers, or IP addresses. The load balancer checks the health of the targets and only sends traffic to healthy targets.

Example:

Resources:
  MyTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      HealthCheckPath: /health
      Name: my-targets
      Port: 80
      Protocol: HTTP
      VpcId: !Ref VPC

Bastion Host or Jump Server

A Bastion Host is a special-purpose EC2 instance that is used to provide secure access to other instances in a private subnet. It is typically used for SSH or RDP access to instances that do not have a public IP address. The Bastion Host is placed in a public subnet and has a security group that allows inbound SSH or RDP traffic from a specific IP range.

Example:

Resources:
  BastionHost:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: ami-0cff7528ff583bf9a 
      InstanceType: t2.micro
      KeyName: my-key-pair
      NetworkInterfaces:
        - AssociatePublicIpAddress: "true"
          DeviceIndex: "0"
          GroupSet: 
            - !Ref BastionHostSG
          SubnetId: !Ref PublicSubnet
      UserData:
        Fn::Base64: !Sub |
          #!/bin/bash
          yum update -y
          yum install -y httpd
          systemctl start httpd
          systemctl enable httpd

In this example, the Bastion Host is placed in a public subnet and has a security group that allows inbound SSH traffic. The user data script installs and starts the Apache web server.

Citations: [1] https://www.cloudzero.com/blog/aws-auto-scaling/ [2] https://spot.io/resources/aws-autoscaling/understanding-ec2-auto-scaling-groups/ [3] https://granulate.io/blog/ec2-auto-scaling-examples-challenges/ [4] https://www.geeksforgeeks.org/create-and-configure-the-auto-scaling-group-in-ec2/ [5] https://avinetworks.com/glossary/auto-scaling/ [6] https://www.simplilearn.com/tutorials/aws-tutorial/aws-auto-scaling [7] https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html [8] https://community.juniper.net/discussion/vpn-problem-with-fortigate