Posts

Showing posts with the label ecs

Using AWS ECS Fargate Horizontal Auto Scaling

Image
Introduction In previous articles, I have provided instructions on using AWS ECS Fargate to deploy a NestJS Docker image utilizing S3 Service; you can review them to understand the basic concepts before proceeding. In this article, I will guide you through configuring auto scaling to automatically increase or decrease the number of instances based on demand. Prerequisites In the NestJS project, to easily test the auto-scaling feature, it is necessary to create an API with a relatively long processing time to drive CPU usage up during execution. I will create a simple API as follows for testing; you can add it to your project or replace it with any equivalent API of your choice. Afterward, build the Docker image and push it to AWS ECR. import {   Controller ,   Get ,   ParseIntPipe ,   Query , } from '@nestjs/common' @ Controller ( 'test' ) export class TestController {   @ Get ( 'sum' )   async sum (@ Query ( 'value' , ParseIntPipe ) value : number...

Using AWS ECS Fargate with Cloudfront and WAF

Image
Introduction I have already presented the concepts of AWS ECS in my previous post, which you can review for more information. In this article, I will guide you on how to deploy a docker image with AWS ECS on Cloudfront using WAF, monitored by Cloudwatch. Additionally, we will setup alerts to automatically send emails and notifications to Telegram when a WAF rule is matched. Prerequisites You can continue using the NestJS source code that I guided you through in previous articles or use your own project. After pushing the docker image to ECR, please proceed to the following sections. Detail The workflow will be as follows: Requests are sent to Cloudfront. Here, the rules in WAF take effect to block requests with security issues, preventing them from reaching our Load Balancer. Cloudwatch will aggregate results based on metrics; if the required threshold is reached, it will send an email and a notification to Telegram for alerting. If the request has no issues, Cloudfront will attach a s...