Skip to content

Instantly share code, notes, and snippets.

@markj-s
Last active January 11, 2023 19:01
Show Gist options
  • Save markj-s/68839780fc5570c629c7149c9aad666d to your computer and use it in GitHub Desktop.
Save markj-s/68839780fc5570c629c7149c9aad666d to your computer and use it in GitHub Desktop.
Create an AWS Load balancer

Create a load balancer for EC2

I created this guide for my own personal reference. All content related to the AWS console as of January 2023. This guide follows on from my EC2 Autoscaling guide which you may need to read first before completing all of the steps shown below.


  1. Navigate to the EC2 service page and locate "Load balancers" in the left side menu bar.
  2. Click on "Create load balancer".

image


On the next page, click on "Create" under the "Application Load Balancer".

image


On the "Create Application Load Balancer" page:

  1. Basic configuration section: Add a name for your load balancer and leave all other settings as default.
  2. Network mapping section: It is ok to use the default VPC (or use your own if you have one).
  3. Network mapping section: Select at least 2 subnets (you can also select all).
  4. Security Group section: Remove the default security group and add your own with any rules you may require to allow SSH, HTTP access etc.

image


In the "listeners and Routing" section, click on "create target group" (this will open a new page called "Target Groups" in a new browser tab/window).

image


On the "Target Groups" page, click on "Create target group".

image


  1. On the "Specify group details" page, add a name for your target group. All other settings can be left as default as shown in the below image.
  2. Click on "next".

image


  1. On the "Register targets" page, click on "Create target group".
  • You do not need to make any changes or add any instances as the auto scaling group will handle them.

image

  • Once the target group has been created, you can return back to the load balancer page to continue the configuration.

  1. At the "Listeners and routing" section, click on the refresh arrow.
  2. Next click on the drop down menu and select the name of the target group you created which should be visible.

image


Once you have selected your target group, scroll to the bottom of the page and click on "Create load balancer".

image


Your load balancer will now be "provisioning" and will take a few minutes before it is active. You can click on "View load balancer".

image


Once the load balancer is active, copy the address value shown under DNS Name and paste it into a new browser tab/window. At this point you will get a "503 Service Temporarily Unavailable" error message as we need to return back to our autoscaling group to associate the load balancer.

image


  1. Return back to "Auto Scaling Groups".
  2. Select your auto scaling group.
  3. Click "Edit".

image


Scroll down to the "Load balancing - optional" section.

  1. Click on the drop down menu and select the name of your target group.
  2. Scroll down to the bottom of the page and click "update".

image


Wait a few moments and then return back to your browser tab/window and refresh the page. You should now be able to see any content you added. Your load balancer has now been setup.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment