Giter Site home page Giter Site logo

aws-re-start-rdc-kinshasa-1 / aws-ec2-target-group-load-balancer-auto-scaling-group-setup-using-cloudformation Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 7 KB

This tutorial outlines the steps to create an EC2 instance, a target group, a load balancer, and an auto scaling group on AWS.

aws-ec2-target-group-load-balancer-auto-scaling-group-setup-using-cloudformation's Introduction

AWS-EC2-Target-Group-Load-Balancer-Auto-Scaling-Group-Setup-using-CloudFormation

This tutorial outlines the steps to create an EC2 instance, a target group, a load balancer, and an auto scaling group on AWS.

Prerequisites

  • AWS account with the necessary permissions.
  • AWS Command Line Interface (CLI) installed and configured or Access to the AWS Management Console.

CloudFormation Stack Setup

Step 1: EC2 Instances

Edit ec2-instances.yaml

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  EC2Instance1:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: ami-xxxxxxxxxxxxxxxxx  # Specify your AMI ID
      InstanceType: t2.micro
  EC2Instance2:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: ami-xxxxxxxxxxxxxxxxx  # Specify your AMI ID
      InstanceType: t2.micro

Deploy EC2 Instances

  • Using the CLI
aws cloudformation create-stack --stack-name EC2InstancesStack --template-body file://ec2-instances.yaml
  • Using the Management Console
  1. Open the AWS Management Console.

  2. Navigate to the CloudFormation service.

Screenshot 2024-03-03 034738

  1. Choose Create Stack.

Screenshot 2024-03-03 034755

  1. In the Select Template section, choose Upload a template file and upload the ec2-instances.yaml file.

Screenshot 2024-03-03 035042

  1. Choose Next.

  2. Enter a stack name (e.g., EC2InstancesStack) and provide any required parameters.

Screenshot 2024-03-03 035114

  1. Choose Next and follow the on-screen instructions to create the stack.

Step 2: Target Group

Edit target-group.yaml

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyTargetGroup:
    Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
    Properties:
      Port: 80
      Protocol: HTTP
      VpcId: vpc-xxxxxxxxxxxxxxxxx  # Specify your VPC ID

Deploy Target Group

  • Using the CLI
aws cloudformation create-stack --stack-name TargetGroupStack --template-body file://target-group.yaml
  • Using the Management Console
  1. Open the AWS Management Console.

  2. Navigate to the CloudFormation service.

  3. Choose Create Stack.

  4. In the Select Template section, choose Upload a template file and upload the target-group.yaml file.

  5. Choose Next.

  6. Enter a stack name (e.g., TargetGroupStack) and provide any required parameters.

  7. Choose Next and follow the on-screen instructions to create the stack.

Step 3: Load Balancer

Edit load-balancer.yaml

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyLoadBalancer:
    Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
    Properties:
      Subnets:
        - subnet-xxxxxxxxxxxxxxxxx  # Specify your subnet ID
        - subnet-yyyyyyyyyyyyyyyyy  # Specify your subnet ID
      SecurityGroups:
        - sg-xxxxxxxxxxxxxxxxx  # Specify your security group ID
      LoadBalancerAttributes:
        - Key: idle_timeout.timeout_seconds
          Value: '60'
      Name: MyLoadBalancer

Deploy Load Balancer

  • Using the CLI
aws cloudformation create-stack --stack-name LoadBalancerStack --template-body file://load-balancer.yaml
  • Using the Management Console
  1. Open the AWS Management Console.

  2. Navigate to the CloudFormation service.

  3. Choose Create Stack.

  4. In the Select Template section, choose Upload a template file and upload the load-balancer.yaml file.

  5. Choose Next.

  6. Enter a stack name (e.g., LoadBalancerStack) and provide any required parameters.

  7. Choose Next and follow the on-screen instructions to create the stack.

Step 4: Auto Scaling Group

Edit auto-scaling-group.yaml

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyAutoScalingGroup:
    Type: 'AWS::AutoScaling::AutoScalingGroup'
    Properties:
      LaunchConfigurationName: MyLaunchConfig
      MinSize: 2
      MaxSize: 5
      DesiredCapacity: 2
      VPCZoneIdentifier:
        - subnet-xxxxxxxxxxxxxxxxx  # Specify your subnet ID
        - subnet-yyyyyyyyyyyyyyyyy  # Specify your subnet ID

Deploy Auto Scaling Group

  • Using the CLI
aws cloudformation create-stack --stack-name AutoScalingGroupStack --template-body file://auto-scaling-group.yaml
  • Using the Management Console
  1. Open the AWS Management Console.

  2. Navigate to the CloudFormation service.

  3. Choose Create Stack.

  4. In the Select Template section, choose Upload a template file and upload the auto-scaling-group.yaml file.

  5. Choose Next.

  6. Enter a stack name (e.g., AutoScalingGroupStack) and provide any required parameters.

  7. Choose Next and follow the on-screen instructions to create the stack.

Step 5: Clean Up

Delete CloudFormation Stacks

  • Using the CLI
aws cloudformation delete-stack --stack-name EC2InstancesStack
aws cloudformation delete-stack --stack-name TargetGroupStack
aws cloudformation delete-stack --stack-name LoadBalancerStack
aws cloudformation delete-stack --stack-name AutoScalingGroupStack
  • Using the Management Console
  1. Open the AWS Management Console.

  2. Navigate to the CloudFormation service.

  3. Select the stacks created (EC2InstancesStack, TargetGroupStack, LoadBalancerStack, AutoScalingGroupStack).

  4. Choose Delete and confirm the deletion.

aws-ec2-target-group-load-balancer-auto-scaling-group-setup-using-cloudformation's People

Contributors

tranck04 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.