Use Amazon CloudFront for dynamic Websites - 2
Tags: ec2, s3, clouldfront, elasticloadbalancing
Published: 2023-09-27 14:51:51

Please read my previous article **[Use Amazon CloudFront for dynamic Websites -1](https://dev.to/aws-builders/use-amazon-cloudfront-for-dynamic-websites-1-18bo)**

In this article, I am going to show you how to create a Target Group and an Application Load Balancer.

_**Let’s get started!**_

Please visit my **[GitHub Repository for S3 articles](https://github.com/awsmine/S3_projects)** on various topics being updated on constant basis.

## 3. Create a Target Group ***`my-TG`***.

##### 1.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cutmiqc8ypsblj6i5pfk.png)

##### 2.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlqxdi2fk0fz82sjy10k.png)

##### 3.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcd5va0fgt9dr4njtfnw.png)

##### 4.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0nrbvwjhysmz6sndk6h4.png)

##### 5. Under Advanced health check settings

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2lfatbrskvt0h5zkhpg.png)

##### 6.  Next button. 

##### 7. Register Targets:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vgyguuwb3oos8erofwfi.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5paj0jvog1fjmxa1r727.png)


##### 8. Click Create target group

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pcw4eo0r29ivhedhn40.png)

## 4. Create an application Load Balancer.

##### 1.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ttpt191325rkwwj5wn9x.png)

##### 2.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cyp9pvsnw60wvwiu6dud.png)

##### 3.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pqwl64ua10hrzvubqx9r.png)

##### 4.
- VPC: Select Default VPC
- Mappings: Select all zones

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s12ab0bi3d4zmstezw68.png)

##### 5. Remove the default security and Select the security group you created while launching an EC2 instance from the drop-down menu.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5mcvxq3v4cy43w99r8yi.png)

#### 6. Select the target group ***`my-TG`*** from the drop-down menu.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/62rgqphlxsmskmuipvcn.png)

##### 7. Summary

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34vxagzhocicf9qzr2cv.png)

##### 8. Click Create Load Balancer

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6u6hsozb020uu6ioms7f.png)

##### 9. Copy the DNS name of the ELB under Description section and paste it in your browser.

```
http://my-lb-823658786.us-east-1.elb.amazonaws.com/
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0euatlylwbd1w9x1s6f.png)


##### 10. refresh the page, and you can observe the ELB is equally splitting the traffic between the two instances. (Note the instance id and time changes each time you refresh the page.)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfvmbmham3uavyisdi8w.png)