Posts

Showing posts with the label ecr

Guide to Setting Up CI/CD for NextJS with Jenkins, Gitlab, and AWS ECS

Image
Introduction In the previous article, I provided instructions on setting up CI/CD with Jenkins and Gitlab to deploy a NestJS project to AWS EKS. Now, I will provide similar guidance for deploying a project using the NextJS framework to AWS ECS, triggering an auto build on Jenkins when pushing code to Gitlab, and running tests for the project before deployment. A summary of the steps involved will be as follows: Build the Docker image for the NextJS project and push it to AWS ECR. Deploy that Docker image to AWS ECS. Set up Jenkins to connect with Gitlab. When code is pushed to Gitlab, Jenkins will trigger an auto build of the steps defined in the Jenkinsfile, including: Pulling the new code from Gitlab. Running tests for the project. If the test fails, stop the deployment process. If the test passes, proceed to the next step. Building the Docker image with the new code and pushing it to AWS ECR. Deploying to AWS ECS by restarting the service, which will use the latest Docker image to d...

Deploy docker image to AWS Lambda

Image
Introduction In my previous article, I provided instructions on using lambda to implement a function to resize images on demand; now, I will provide instructions on deploying a docker image to lambda. The advantage of using Lambda is pay on demand, suitable for types of projects newly released in the early stages when there are not yet many uses; deployment with Lambda helps simplify the process for the dev team to focus on feature development; resource management will be managed by AWS, and will automatically scale according to user usage needs. Detail Using AWS CDK, create the file lib/deploy-lambda-stack.ts import * as cdk from "aws-cdk-lib" import * as ecr from "aws-cdk-lib/aws-ecr" import * as iam from "aws-cdk-lib/aws-iam" import * as lambda from "aws-cdk-lib/aws-lambda" import { Construct } from "constructs" export class DeployLambdaStack extends cdk . Stack { constructor ( scope : Construct , id : ...

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...