{"id":755,"date":"2026-11-03T10:29:47","date_gmt":"2026-11-03T10:29:47","guid":{"rendered":"https:\/\/velanremoteitsupport.com\/blog\/?post_type=techtips&#038;p=755"},"modified":"2026-11-03T10:29:48","modified_gmt":"2026-11-03T10:29:48","slug":"deploy-steps-node-js-app-aws-fargate","status":"publish","type":"techtips","link":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/","title":{"rendered":"Deploy a Node.js App to AWS Fargate, Step by Step"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">AWS ECS Fargate is a container service from AWS. You can run Docker containers without managing a server or underlying infrastructure.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>The service is suitable for deploying&nbsp;<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Microservices<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Web applications<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Batch jobs<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>Key Features of AWS ECS Fargate:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Manages the underlying infrastructure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Scales containers based on application needs and configured rules.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pay-as-you-go model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Integrates with Elastic Load Balancing, Amazon RDS, and IAM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Isolates workloads and connects to AWS security measures.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>To deploy a Node.js application<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Containerize the Node.js app<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Push the image to <strong>ECR<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Define a <strong>task definition<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use an ALB with HTTPS to run it as an ECS service.<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-1 wp-block-paragraph\"><strong>Client \u2192 HTTPS \u2192 ALB \u2192 HTTP \u2192 ECS Service (Fargate Tasks) \u2192 Node.js Container<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>Supporting AWS Services:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Amazon ECR \u2013 Stores Docker images.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CloudWatch Logs \u2013 Collects application logs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">AWS IAM \u2013 Manages access permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">AWS Certificate Manager \u2013 Offers the HTTPS SSL\/TLS certificate.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For image deployment: Docker Image \u2192 Amazon ECR \u2192 ECS Fargate Task&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For application traffic: Client \u2192 HTTPS \u2192 ALB \u2192 HTTP \u2192 ECS Fargate \u2192 Node.js Container<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For application logging: Node.js Container \u2192 CloudWatch Logs<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:17px\"><strong><strong>Prerequisites<\/strong><\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AWS account with permissions for ECS, ECR, IAM, EC2\/VPC, ELB, and CloudWatch&nbsp;<\/li>\n\n\n\n<li>AWS CLI v2 configured (aws configure) and Docker installed locally&nbsp;<\/li>\n\n\n\n<li>A VPC with at least two public subnets (for the ALB) in different Availability Zones&nbsp;<\/li>\n\n\n\n<li>A Node.js app that listens on a known port (example: 3000) and exposes a health endpoint such as \/health&nbsp;<\/li>\n\n\n\n<li>Optional: a domain and an ACM certificate for HTTPS<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"font-size:17px\"><strong>Set variables used throughout:&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">bash&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">export AWS_REGION=ap-south-1&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">export ACCOUNT_ID=$(aws sts get-caller-identity &#8211;query Account &#8211;output text)&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">export APP=node-app&nbsp;<\/p>\n\n\n\n<div class=\"schema-how-to wp-block-yoast-how-to-block\"><p class=\"schema-how-to-description\"><\/p> <ul class=\"schema-how-to-steps\"><li class=\"schema-how-to-step\" id=\"how-to-step-1793693036813\"><strong class=\"schema-how-to-step-name\"><strong>Step 1: Containerize the Application<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">Dockerfile (multi-stage, non-root):\u00a0<br>dockerfile\u00a0<br>FROM node:20-alpine AS deps\u00a0<br>WORKDIR \/app\u00a0<br>COPY package*.json .\/\u00a0<br>RUN npm ci &#8211;omit=dev\u00a0<br>\u00a0<br>FROM node:20-alpine\u00a0<br>WORKDIR \/app\u00a0<br>ENV NODE_ENV=production\u00a0<br>COPY &#8211;from=deps \/app\/node_modules .\/node_modules\u00a0<br>COPY . .\u00a0<br>USER node\u00a0<br>EXPOSE 3000\u00a0<br>CMD [&#8220;node&#8221;, &#8220;server.js&#8221;]\u00a0<br>Add a .dockerignore containing node_modules, .git, and .env.\u00a0<br>Make sure the app binds to all interfaces, not just localhost:\u00a0<br>js\u00a0<br>app.listen(process.env.PORT || 3000, &#8216;0.0.0.0&#8217;);\u00a0<br>app.get(&#8216;\/health&#8217;, (req, res) => res.status(200).send(&#8216;ok&#8217;));<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793693227302\"><strong class=\"schema-how-to-step-name\"><strong>Step 2: Configure an ECR Repository and Upload the Image<\/strong><br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws ecr create-repository &#8211;repository-name $APP &#8211;image-scanning-configuration scanOnPush=true\u00a0<br>\u00a0<br>aws ecr get-login-password &#8211;region $AWS_REGION | \\\u00a0<br>\u00a0\u00a0docker login &#8211;username AWS &#8211;password-stdin ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\u00a0<br>\u00a0<br>docker build -t $APP .\u00a0<br>docker tag $APP:latest ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v1\u00a0<br>docker push ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v1\u00a0<br>Use immutable, versioned tags (e.g., v1 or a Git SHA) rather than relying on latest.\u00a0<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793693250172\"><strong class=\"schema-how-to-step-name\"><strong>Step 3: IAM Task Execution Role Creation<\/strong><br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws iam create-role &#8211;role-name ecsTaskExecutionRole \\\u00a0<br>\u00a0\u00a0&#8211;assume-role-policy-document &#8216;{\u00a0<br>&#8220;Version&#8221;:&#8221;2012-10-17&#8243;,\u00a0<br>&#8220;Statement&#8221;:[{&#8220;Effect&#8221;:&#8221;Allow&#8221;,&#8221;Principal&#8221;:{&#8220;Service&#8221;:&#8221;ecs-tasks.amazonaws.com&#8221;},&#8221;Action&#8221;:&#8221;sts:AssumeRole&#8221;}]\u00a0<br>\u00a0\u00a0}&#8217;\u00a0<br>\u00a0<br>aws iam attach-role-policy &#8211;role-name ecsTaskExecutionRole \\\u00a0<br>\u00a0\u00a0&#8211;policy-arn arn:aws:iam::aws:policy\/service-role\/AmazonECSTaskExecutionRolePolicy<br><br><strong>Skip this if the account already has &#8220;ecsTaskExecutionRole&#8221;.<br><\/strong>For secrets from &#8220;Secrets Manager&#8221; or &#8220;SSM Parameter Store&#8221;, add a policy granting read access to those specific resources.<br>If the app itself calls &#8220;AWS services (S3, SQS)&#8221;, create a separate task role with least-privilege permissions.<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793693279117\"><strong class=\"schema-how-to-step-name\"><strong>Step 4: Create the Cluster and Log Group<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws ecs create-cluster &#8211;cluster-name $APP-cluster\u00a0<br>aws logs create-log-group &#8211;log-group-name \/ecs\/$APP\u00a0<br>aws logs put-retention-policy &#8211;log-group-name \/ecs\/$APP &#8211;retention-in-days 30<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696022079\"><strong class=\"schema-how-to-step-name\"><strong>Step 5: Register the Task Definition<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">task-def.json:\u00a0<br>json\u00a0<br>{\u00a0<br>\u00a0\u00a0&#8220;family&#8221;: &#8220;node-app&#8221;,\u00a0<br>\u00a0\u00a0&#8220;networkMode&#8221;: &#8220;awsvpc&#8221;,\u00a0<br>\u00a0\u00a0&#8220;requiresCompatibilities&#8221;: [&#8220;FARGATE&#8221;],\u00a0<br>\u00a0\u00a0&#8220;cpu&#8221;: &#8220;256&#8221;,\u00a0<br>\u00a0\u00a0&#8220;memory&#8221;: &#8220;512&#8221;,\u00a0<br>\u00a0\u00a0&#8220;executionRoleArn&#8221;: &#8220;arn:aws:iam::&lt;ACCOUNT_ID>:role\/ecsTaskExecutionRole&#8221;,\u00a0<br>\u00a0\u00a0&#8220;containerDefinitions&#8221;: [\u00a0<br>{\u00a0<br>\u00a0\u00a0 &#8220;name&#8221;: &#8220;node-app&#8221;,\u00a0<br>\u00a0\u00a0 &#8220;image&#8221;: &#8220;&lt;ACCOUNT_ID>.dkr.ecr.ap-south-1.amazonaws.com\/node-app:v1&#8221;,\u00a0<br>\u00a0\u00a0 &#8220;essential&#8221;: true,\u00a0<br>\u00a0\u00a0 &#8220;portMappings&#8221;: [{ &#8220;containerPort&#8221;: 3000, &#8220;protocol&#8221;: &#8220;tcp&#8221; }],\u00a0<br>\u00a0\u00a0 &#8220;environment&#8221;: [{ &#8220;name&#8221;: &#8220;NODE_ENV&#8221;, &#8220;value&#8221;: &#8220;production&#8221; }],\u00a0<br>\u00a0\u00a0 &#8220;secrets&#8221;: [\u00a0<br>\u00a0\u00a0\u00a0\u00a0 { &#8220;name&#8221;: &#8220;DB_PASSWORD&#8221;, &#8220;valueFrom&#8221;: &#8220;arn:aws:secretsmanager:ap-south-1:&lt;ACCOUNT_ID>:secret:node-app\/db-xxxxxx&#8221; }\u00a0<br>\u00a0\u00a0 ],\u00a0<br>\u00a0\u00a0 &#8220;healthCheck&#8221;: {\u00a0<br>\u00a0\u00a0\u00a0\u00a0 &#8220;command&#8221;: [&#8220;CMD-SHELL&#8221;, &#8220;wget -qO- http:\/\/localhost:3000\/health || exit 1&#8221;],\u00a0<br>\u00a0\u00a0\u00a0\u00a0 &#8220;interval&#8221;: 30, &#8220;timeout&#8221;: 5, &#8220;retries&#8221;: 3, &#8220;startPeriod&#8221;: 15\u00a0<br>\u00a0\u00a0 },\u00a0<br>\u00a0\u00a0 &#8220;logConfiguration&#8221;: {\u00a0<br>\u00a0\u00a0\u00a0\u00a0 &#8220;logDriver&#8221;: &#8220;awslogs&#8221;,\u00a0<br>\u00a0\u00a0\u00a0\u00a0 &#8220;options&#8221;: {\u00a0<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;awslogs-group&#8221;: &#8220;\/ecs\/node-app&#8221;,\u00a0<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;awslogs-region&#8221;: &#8220;ap-south-1&#8221;,\u00a0<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8220;awslogs-stream-prefix&#8221;: &#8220;ecs&#8221;\u00a0<br>\u00a0\u00a0\u00a0\u00a0 }\u00a0<br>\u00a0\u00a0 }\u00a0<br>}\u00a0<br>\u00a0\u00a0]\u00a0<br>}\u00a0<br>Replace the &lt;ACCOUNT_ID> placeholders, then register:\u00a0<br>bash\u00a0<br>aws ecs register-task-definition &#8211;cli-input-json file:\/\/task-def.json\u00a0<br>Note: alpine images include wget through BusyBox, which the health check above relies on.\u00a0<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696082107\"><strong class=\"schema-how-to-step-name\"><strong>Step 6: Create Security Groups<\/strong>\u00a0<br><br><strong>ALB security group:<\/strong> inbound 80 and 443 from 0.0.0.0\/0\u00a0<br><strong>Task security group:<\/strong> inbound 3000 <strong>only from the ALB security group<\/strong>\u00a0<br><br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws ec2 create-security-group &#8211;group-name alb-sg &#8211;description &#8220;ALB&#8221; &#8211;vpc-id &lt;VPC_ID>\u00a0<br>aws ec2 create-security-group &#8211;group-name task-sg &#8211;description &#8220;ECS tasks&#8221; &#8211;vpc-id &lt;VPC_ID>\u00a0<br>\u00a0<br>aws ec2 authorize-security-group-ingress &#8211;group-id &lt;ALB_SG> &#8211;protocol tcp &#8211;port 443 &#8211;cidr 0.0.0.0\/0\u00a0<br>aws ec2 authorize-security-group-ingress &#8211;group-id &lt;ALB_SG> &#8211;protocol tcp &#8211;port 80 &#8211;cidr 0.0.0.0\/0\u00a0<br>aws ec2 authorize-security-group-ingress &#8211;group-id &lt;TASK_SG> &#8211;protocol tcp &#8211;port 3000 &#8211;source-group &lt;ALB_SG><br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696144853\"><strong class=\"schema-how-to-step-name\"><strong>Step 7: Create the Load Balancer, Target Group, and Listeners<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws elbv2 create-load-balancer &#8211;name $APP-alb &#8211;subnets &lt;SUBNET_1> &lt;SUBNET_2> &#8211;security-groups &lt;ALB_SG>\u00a0<br>\u00a0<br>aws elbv2 create-target-group &#8211;name $APP-tg &#8211;protocol HTTP &#8211;port 3000 \\\u00a0<br>\u00a0\u00a0&#8211;vpc-id &lt;VPC_ID> &#8211;target-type ip \\\u00a0<br>\u00a0\u00a0&#8211;health-check-path \/health &#8211;health-check-interval-seconds 30\u00a0<br>The target type must be ip for Fargate with awsvpc networking.\u00a0<br>Create the listeners (HTTPS forwards to the app, HTTP redirects to HTTPS):\u00a0<br>bash\u00a0<br>aws elbv2 create-listener &#8211;load-balancer-arn &lt;ALB_ARN> &#8211;protocol HTTPS &#8211;port 443 \\\u00a0<br>\u00a0\u00a0&#8211;certificates CertificateArn=&lt;ACM_CERT_ARN> \\\u00a0<br>\u00a0\u00a0&#8211;ssl-policy ELBSecurityPolicy-TLS13-1-2-2021-06 \\\u00a0<br>\u00a0\u00a0&#8211;default-actions Type=forward,TargetGroupArn=&lt;TG_ARN>\u00a0<br>\u00a0<br>aws elbv2 create-listener &#8211;load-balancer-arn &lt;ALB_ARN> &#8211;protocol HTTP &#8211;port 80 \\\u00a0<br>\u00a0\u00a0&#8211;default-actions &#8216;Type=redirect,RedirectConfig={Protocol=HTTPS,Port=443,StatusCode=HTTP_301}&#8217;\u00a0<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696164564\"><strong class=\"schema-how-to-step-name\"><strong>Step 8: Create the ECS Service<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws ecs create-service \\\u00a0<br>\u00a0\u00a0&#8211;cluster $APP-cluster \\\u00a0<br>\u00a0\u00a0&#8211;service-name $APP-service \\\u00a0<br>\u00a0\u00a0&#8211;task-definition node-app \\\u00a0<br>\u00a0\u00a0&#8211;desired-count 2 \\\u00a0<br>\u00a0\u00a0&#8211;launch-type FARGATE \\\u00a0<br>\u00a0\u00a0&#8211;network-configuration &#8220;awsvpcConfiguration={subnets=[&lt;SUBNET_1>,&lt;SUBNET_2>],securityGroups=[&lt;TASK_SG>],assignPublicIp=ENABLED}&#8221; \\\u00a0<br>\u00a0\u00a0&#8211;load-balancers &#8220;targetGroupArn=&lt;TG_ARN>,containerName=node-app,containerPort=3000&#8221; \\\u00a0<br>\u00a0\u00a0&#8211;health-check-grace-period-seconds 30 \\\u00a0<br>\u00a0\u00a0&#8211;deployment-configuration &#8220;deploymentCircuitBreaker={enable=true,rollback=true},minimumHealthyPercent=100,maximumPercent=200&#8221;\u00a0<br>Notes:\u00a0<br>For production, place tasks in <strong>private subnets<\/strong> with a NAT gateway (or VPC endpoints for ECR, S3, and CloudWatch Logs) and set assignPublicIp=DISABLED.\u00a0<br>The deployment circuit breaker automatically rolls back failed deployments.<\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696182630\"><strong class=\"schema-how-to-step-name\"><strong>Step 9: Point DNS to the ALB<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">Create a Route 53 alias record (or a CNAME at your DNS provider) from app.example.com to the ALB DNS name.\u00a0<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696196612\"><strong class=\"schema-how-to-step-name\"><strong>Step 10: Configure Auto Scaling<\/strong>\u00a0<br><\/strong> <p class=\"schema-how-to-step-text\">bash\u00a0<br>aws application-autoscaling register-scalable-target \\\u00a0<br>\u00a0\u00a0&#8211;service-namespace ecs &#8211;scalable-dimension ecs:service:DesiredCount \\\u00a0<br>\u00a0\u00a0&#8211;resource-id service\/APP-cluster\/APP-service &#8211;min-capacity 2 &#8211;max-capacity 6\u00a0<br>\u00a0<br>aws application-autoscaling put-scaling-policy \\\u00a0<br>\u00a0\u00a0&#8211;service-namespace ecs &#8211;scalable-dimension ecs:service:DesiredCount \\\u00a0<br>\u00a0\u00a0&#8211;resource-id service\/APP-cluster\/APP-service \\\u00a0<br>\u00a0\u00a0&#8211;policy-name cpu-target &#8211;policy-type TargetTrackingScaling \\\u00a0<br>\u00a0\u00a0&#8211;target-tracking-scaling-policy-configuration &#8216;{\u00a0<br>&#8220;TargetValue&#8221;: 60.0,\u00a0<br>&#8220;PredefinedMetricSpecification&#8221;: {&#8220;PredefinedMetricType&#8221;: &#8220;ECSServiceAverageCPUUtilization&#8221;},\u00a0<br>&#8220;ScaleInCooldown&#8221;: 120, &#8220;ScaleOutCooldown&#8221;: 60\u00a0<br>\u00a0\u00a0}&#8217;<br><\/p> <\/li><li class=\"schema-how-to-step\" id=\"how-to-step-1793696213020\"><strong class=\"schema-how-to-step-name\"><strong>Step 11: Deploy Updates<\/strong><\/strong> <p class=\"schema-how-to-step-text\"><br>bash\u00a0<br>docker build -t $APP . &amp;&amp; docker tag $APP:latest ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v2\u00a0<br>docker push ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v2\u00a0<br># Update the image tag in task-def.json, register a new revision, then:\u00a0<br>aws ecs update-service &#8211;cluster $APP-cluster &#8211;service $APP-service &#8211;task-definition node-app\u00a0<br>ECS performs a rolling deployment. For automation, use GitHub Actions or AWS CodePipeline with the same build, push, register, and update sequence.\u00a0<br><br><strong>Validate<\/strong>\u00a0<br>bash\u00a0<br>aws ecs describe-services &#8211;cluster $APP-cluster &#8211;services $APP-service \\\u00a0<br>\u00a0\u00a0&#8211;query &#8220;services[0].{running:runningCount,desired:desiredCount,events:events[0:3]}&#8221;\u00a0<br>curl -I https:\/\/app.example.com\/health\u00a0<br>aws logs tail \/ecs\/$APP &#8211;follow<br><\/p> <\/li><\/ul><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>Security and Operations Best Practices&nbsp;<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep secrets in &#8220;Secrets Manager&#8221; or &#8220;SSM Parameter Store&#8221;. Never in the image or plain environment variables.&nbsp;<\/li>\n\n\n\n<li>For tasks and least-privilege task roles, use private subnets.<\/li>\n\n\n\n<li>Enable &#8220;ECR image scanning.&#8221; Use specific base image versions.&nbsp;<\/li>\n\n\n\n<li>Run as a non-root user. Configure read-only root filesystem wherever the app allows it.&nbsp;<\/li>\n\n\n\n<li>Set &#8220;CloudWatch&#8221; alarms to monitor CPU, memory, unhealthy host count and ALB 5xx errors.&nbsp;<\/li>\n\n\n\n<li>Activate &#8220;Container Insights&#8221; to analyze metrics at the cluster level.&nbsp;<\/li>\n\n\n\n<li>Tagging all resources helps with cost tracking.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>Troubleshooting Common AWS ECS Fargate Node.js Deployment Errors<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Symptom&nbsp;<\/strong><\/td><td><strong>Likely Cause&nbsp;<\/strong><\/td><td><strong>Fix&nbsp;<\/strong><\/td><\/tr><tr><td>Task stops with&nbsp;CannotPullContainerError&nbsp;<\/td><td>No route to ECR, or missing execution role permissions&nbsp;<\/td><td>Enable a public IP or NAT\/VPC endpoints; verify the execution role policy.<\/td><\/tr><tr><td>Targets show unhealthy&nbsp;<\/td><td>Wrong health check path\/port, or app bound to localhost.<\/td><td>Bind to 0.0.0.0, confirm \/health returns 200, and check the task security group.<\/td><\/tr><tr><td>The task exits immediately.&nbsp;<\/td><td>App crash or missing environment variables.<\/td><td>Check \/ecs\/node-app logs and the stopped task reason.<\/td><\/tr><tr><td>OutOfMemoryError \/ task&nbsp;&nbsp;killed (exit 137)&nbsp;<\/td><td>Memory limit too low.<\/td><td>Increase task memory and tune Node&#8217;s&nbsp;&nbsp;&#8211;max-old-space-size .<\/td><\/tr><tr><td>Deployment stuck or rollingback.<\/td><td>Failing health checks on the new revision.<\/td><td>Review logs and the circuit breaker events; fixand redeploy.<\/td><\/tr><tr><td>502\/503 from ALB&nbsp;<\/td><td>No healthy targets or app timeout.<\/td><td>Check target health and increase the idle timeout if needed.&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"font-size:17px\"><strong><strong><strong>Conclusion<\/strong><\/strong><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Teams can set up and manage Node.js applications easily with AWS ECS Fargate. Also, continuous observation helps your application stay reliable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Many businesses do not have a committed monitoring team or sufficient experience to solve technical issues. In such cases, partnering with an MSP agency offers you the right support.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Velan Remote IT Support is a leading managed services provider with <strong><a href=\"https:\/\/velanremoteitsupport.com\/outsourced-managed-aws-cloud-services\" data-type=\"link\" data-id=\"https:\/\/velanremoteitsupport.com\/outsourced-managed-aws-cloud-services\">certified AWS experts<\/a><\/strong> to deliver top-quality AWS solutions for application development companies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Contact us for a consultation at info@velanremoteitsupport.com.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-columns alignwide is-layout-flex wp-container-core-columns-is-layout-92126d18 wp-block-columns-is-layout-flex\" style=\"margin-bottom:0\">\n<div class=\"wp-block-column has-text-color has-background has-link-color wp-elements-2 is-layout-flow wp-block-column-is-layout-flow\" style=\"color:#000000;background-color:#d1d1e1;padding-top:2em;padding-right:2em;padding-bottom:2em;padding-left:2em\">\n<h4 id=\"family\" class=\"wp-block-heading\" style=\"font-size:17px\"><strong><strong>&nbsp;Hire a cloud support team from Velan to manage your AWS environment.<\/strong><br><\/strong><\/h4>\n\n\n\n<p class=\"has-normal-font-size wp-block-paragraph\" style=\"line-height:1.5\">AWS managed services ensure highly available cloud systems and applications through continuous monitoring and maintenance support.<br><\/p>\n\n\n\n<div class=\"wp-block-buttons alignfull is-horizontal is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-7d812b4c wp-block-buttons-is-layout-flex\">\n<div style=\"--wp--block-button--width: 25;\" class=\"wp-block-button is-style-fill has-custom-width wp-block-button__width wp-block-button__width-25\"><a class=\"wp-block-button__link has-white-color has-text-color has-background no-border-radius wp-element-button\" href=\"https:\/\/velanremoteitsupport.com\/contact-remote-managed-it-service-provider\" style=\"background-color:#000000\"><strong>Talk to AWS expert<\/strong><\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:17px\"><strong>Read questions and answers about AWS<\/strong><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1793697613584\"><strong class=\"schema-faq-question\"><strong>What is AWS ECS pricing?<\/strong><br><\/strong> <p class=\"schema-faq-answer\">ECS has no direct orchestration charge. You only pay for the underlying compute infrastructure and associated AWS resources.<br><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1793697625788\"><strong class=\"schema-faq-question\"><strong>My company needs AWS services. How can you help with it?<\/strong><br><\/strong> <p class=\"schema-faq-answer\">Our cloud consultants assess your objectives, workload, and security requirements. We then suggest suitable services that can deliver better results. Our team also offers cloud cost optimization services to reduce cloud bills while improving performance.\u00a0<br><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1793697641332\"><strong class=\"schema-faq-question\"><strong>What is covered in your AWS cloud advisory services for IT firms?<\/strong><br><\/strong> <p class=\"schema-faq-answer\">Before starting a project, we provide a detailed assessment of your IT infrastructure and goals. We create a practical strategy that can deliver maximum ROI. Our team onboards quickly and delivers solutions based on your requirements.<br><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS ECS Fargate is a container service from AWS. You can run Docker containers without managing a server or underlying infrastructure.&nbsp; The service is suitable for deploying&nbsp; Microservices Web applications Batch jobs Key Features of AWS ECS Fargate: Manages the underlying infrastructure. Scales containers based on application needs and configured rules. Pay-as-you-go model. Integrates with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":764,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"techtips_category":[6],"class_list":["post-755","techtips","type-techtips","status-publish","has-post-thumbnail","hentry","techtips_category-technical-tips-from-the-managed-service-providers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Deploying Node.js Apps to AWS ECS Fargate | Step-by-Step Guide<\/title>\n<meta name=\"description\" content=\"Step-by-step guide to Dockerize your Node.js app, push the image to Amazon ECR, and run it on ECS Fargate without managing a single server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploying Node.js Apps to AWS ECS Fargate | Step-by-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Step-by-step guide to Dockerize your Node.js app, push the image to Amazon ECR, and run it on ECS Fargate without managing a single server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloud, DevOps &amp; Managed It Service Blog From Top Consultants\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-03T10:29:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/velanremoteitsupport.com\/blog\/wp-content\/uploads\/2026\/11\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/\",\"name\":\"Deploying Node.js Apps to AWS ECS Fargate | Step-by-Step Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg\",\"datePublished\":\"2026-11-03T10:29:47+00:00\",\"dateModified\":\"2026-11-03T10:29:48+00:00\",\"description\":\"Step-by-step guide to Dockerize your Node.js app, push the image to Amazon ECR, and run it on ECS Fargate without managing a single server.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697613584\"},{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697625788\"},{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697641332\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#primaryimage\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg\",\"contentUrl\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg\",\"width\":1200,\"height\":628,\"caption\":\"Architecture diagram for deploying a Node.js application on AWS ECS using serverless Fargate across Multi-AZ environments.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tech Tips\",\"item\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Deploy a Node.js App to AWS Fargate, Step by Step\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/\",\"name\":\"Cloud, DevOps &amp; Managed It Service Blog From Top Consultants\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697613584\",\"position\":1,\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697613584\",\"name\":\"What is AWS ECS pricing?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"ECS has no direct orchestration charge. You only pay for the underlying compute infrastructure and associated AWS resources.<br>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697625788\",\"position\":2,\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697625788\",\"name\":\"My company needs AWS services. How can you help with it?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Our cloud consultants assess your objectives, workload, and security requirements. We then suggest suitable services that can deliver better results. Our team also offers cloud cost optimization services to reduce cloud bills while improving performance.\u00a0<br>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697641332\",\"position\":3,\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#faq-question-1793697641332\",\"name\":\"What is covered in your AWS cloud advisory services for IT firms?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Before starting a project, we provide a detailed assessment of your IT infrastructure and goals. We create a practical strategy that can deliver maximum ROI. Our team onboards quickly and delivers solutions based on your requirements.<br>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"HowTo\",\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#howto-1\",\"name\":\"Deploy a Node.js App to AWS Fargate, Step by Step\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/\"},\"description\":\"\",\"step\":[{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793693036813\",\"name\":\"Step 1: Containerize the Application\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Dockerfile (multi-stage, non-root):\u00a0dockerfile\u00a0FROM node:20-alpine AS deps\u00a0WORKDIR \\\/app\u00a0COPY package*.json .\\\/\u00a0RUN npm ci --omit=dev\u00a0\u00a0FROM node:20-alpine\u00a0WORKDIR \\\/app\u00a0ENV NODE_ENV=production\u00a0COPY --from=deps \\\/app\\\/node_modules .\\\/node_modules\u00a0COPY . .\u00a0USER node\u00a0EXPOSE 3000\u00a0CMD [\\\"node\\\", \\\"server.js\\\"]\u00a0Add a .dockerignore containing node_modules, .git, and .env.\u00a0Make sure the app binds to all interfaces, not just localhost:\u00a0js\u00a0app.listen(process.env.PORT || 3000, '0.0.0.0');\u00a0app.get('\\\/health', (req, res) => res.status(200).send('ok'));\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793693227302\",\"name\":\"Step 2: Configure an ECR Repository and Upload the Image\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws ecr create-repository --repository-name $APP --image-scanning-configuration scanOnPush=true\u00a0\u00a0aws ecr get-login-password --region $AWS_REGION | \\\\\u00a0\u00a0\u00a0docker login --username AWS --password-stdin ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\u00a0\u00a0docker build -t $APP .\u00a0docker tag $APP:latest ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\\\/$APP:v1\u00a0docker push ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\\\/$APP:v1\u00a0Use immutable, versioned tags (e.g., v1 or a Git SHA) rather than relying on latest.\u00a0\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793693250172\",\"name\":\"Step 3: IAM Task Execution Role Creation\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws iam create-role --role-name ecsTaskExecutionRole \\\\\u00a0\u00a0\u00a0--assume-role-policy-document '{\u00a0\\\"Version\\\":\\\"2012-10-17\\\",\u00a0\\\"Statement\\\":[{\\\"Effect\\\":\\\"Allow\\\",\\\"Principal\\\":{\\\"Service\\\":\\\"ecs-tasks.amazonaws.com\\\"},\\\"Action\\\":\\\"sts:AssumeRole\\\"}]\u00a0\u00a0\u00a0}'\u00a0\u00a0aws iam attach-role-policy --role-name ecsTaskExecutionRole \\\\\u00a0\u00a0\u00a0--policy-arn arn:aws:iam::aws:policy\\\/service-role\\\/AmazonECSTaskExecutionRolePolicySkip this if the account already has \\\"ecsTaskExecutionRole\\\".For secrets from \\\"Secrets Manager\\\" or \\\"SSM Parameter Store\\\", add a policy granting read access to those specific resources.If the app itself calls \\\"AWS services (S3, SQS)\\\", create a separate task role with least-privilege permissions.\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793693279117\",\"name\":\"Step 4: Create the Cluster and Log Group\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws ecs create-cluster --cluster-name $APP-cluster\u00a0aws logs create-log-group --log-group-name \\\/ecs\\\/$APP\u00a0aws logs put-retention-policy --log-group-name \\\/ecs\\\/$APP --retention-in-days 30\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696022079\",\"name\":\"Step 5: Register the Task Definition\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"task-def.json:\u00a0json\u00a0{\u00a0\u00a0\u00a0\\\"family\\\": \\\"node-app\\\",\u00a0\u00a0\u00a0\\\"networkMode\\\": \\\"awsvpc\\\",\u00a0\u00a0\u00a0\\\"requiresCompatibilities\\\": [\\\"FARGATE\\\"],\u00a0\u00a0\u00a0\\\"cpu\\\": \\\"256\\\",\u00a0\u00a0\u00a0\\\"memory\\\": \\\"512\\\",\u00a0\u00a0\u00a0\\\"executionRoleArn\\\": \\\"arn:aws:iam:::role\\\/ecsTaskExecutionRole\\\",\u00a0\u00a0\u00a0\\\"containerDefinitions\\\": [\u00a0{\u00a0\u00a0\u00a0 \\\"name\\\": \\\"node-app\\\",\u00a0\u00a0\u00a0 \\\"image\\\": \\\".dkr.ecr.ap-south-1.amazonaws.com\\\/node-app:v1\\\",\u00a0\u00a0\u00a0 \\\"essential\\\": true,\u00a0\u00a0\u00a0 \\\"portMappings\\\": [{ \\\"containerPort\\\": 3000, \\\"protocol\\\": \\\"tcp\\\" }],\u00a0\u00a0\u00a0 \\\"environment\\\": [{ \\\"name\\\": \\\"NODE_ENV\\\", \\\"value\\\": \\\"production\\\" }],\u00a0\u00a0\u00a0 \\\"secrets\\\": [\u00a0\u00a0\u00a0\u00a0\u00a0 { \\\"name\\\": \\\"DB_PASSWORD\\\", \\\"valueFrom\\\": \\\"arn:aws:secretsmanager:ap-south-1::secret:node-app\\\/db-xxxxxx\\\" }\u00a0\u00a0\u00a0 ],\u00a0\u00a0\u00a0 \\\"healthCheck\\\": {\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"command\\\": [\\\"CMD-SHELL\\\", \\\"wget -qO- http:\\\/\\\/localhost:3000\\\/health || exit 1\\\"],\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"interval\\\": 30, \\\"timeout\\\": 5, \\\"retries\\\": 3, \\\"startPeriod\\\": 15\u00a0\u00a0\u00a0 },\u00a0\u00a0\u00a0 \\\"logConfiguration\\\": {\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"logDriver\\\": \\\"awslogs\\\",\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"options\\\": {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"awslogs-group\\\": \\\"\\\/ecs\\\/node-app\\\",\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"awslogs-region\\\": \\\"ap-south-1\\\",\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \\\"awslogs-stream-prefix\\\": \\\"ecs\\\"\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0 }\u00a0}\u00a0\u00a0\u00a0]\u00a0}\u00a0Replace the  placeholders, then register:\u00a0bash\u00a0aws ecs register-task-definition --cli-input-json file:\\\/\\\/task-def.json\u00a0Note: alpine images include wget through BusyBox, which the health check above relies on.\u00a0\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696082107\",\"name\":\"Step 6: Create Security Groups\u00a0 ALB security group: inbound 80 and 443 from 0.0.0.0\\\/0\u00a0 Task security group: inbound 3000 only from the ALB security group\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws ec2 create-security-group --group-name alb-sg --description \\\"ALB\\\" --vpc-id \u00a0aws ec2 create-security-group --group-name task-sg --description \\\"ECS tasks\\\" --vpc-id \u00a0\u00a0aws ec2 authorize-security-group-ingress --group-id  --protocol tcp --port 443 --cidr 0.0.0.0\\\/0\u00a0aws ec2 authorize-security-group-ingress --group-id  --protocol tcp --port 80 --cidr 0.0.0.0\\\/0\u00a0aws ec2 authorize-security-group-ingress --group-id  --protocol tcp --port 3000 --source-group\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696144853\",\"name\":\"Step 7: Create the Load Balancer, Target Group, and Listeners\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws elbv2 create-load-balancer --name $APP-alb --subnets   --security-groups \u00a0\u00a0aws elbv2 create-target-group --name $APP-tg --protocol HTTP --port 3000 \\\\\u00a0\u00a0\u00a0--vpc-id  --target-type ip \\\\\u00a0\u00a0\u00a0--health-check-path \\\/health --health-check-interval-seconds 30\u00a0The target type must be ip for Fargate with awsvpc networking.\u00a0Create the listeners (HTTPS forwards to the app, HTTP redirects to HTTPS):\u00a0bash\u00a0aws elbv2 create-listener --load-balancer-arn  --protocol HTTPS --port 443 \\\\\u00a0\u00a0\u00a0--certificates CertificateArn= \\\\\u00a0\u00a0\u00a0--ssl-policy ELBSecurityPolicy-TLS13-1-2-2021-06 \\\\\u00a0\u00a0\u00a0--default-actions Type=forward,TargetGroupArn=\u00a0\u00a0aws elbv2 create-listener --load-balancer-arn  --protocol HTTP --port 80 \\\\\u00a0\u00a0\u00a0--default-actions 'Type=redirect,RedirectConfig={Protocol=HTTPS,Port=443,StatusCode=HTTP_301}'\u00a0\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696164564\",\"name\":\"Step 8: Create the ECS Service\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws ecs create-service \\\\\u00a0\u00a0\u00a0--cluster $APP-cluster \\\\\u00a0\u00a0\u00a0--service-name $APP-service \\\\\u00a0\u00a0\u00a0--task-definition node-app \\\\\u00a0\u00a0\u00a0--desired-count 2 \\\\\u00a0\u00a0\u00a0--launch-type FARGATE \\\\\u00a0\u00a0\u00a0--network-configuration \\\"awsvpcConfiguration={subnets=[,],securityGroups=[],assignPublicIp=ENABLED}\\\" \\\\\u00a0\u00a0\u00a0--load-balancers \\\"targetGroupArn=,containerName=node-app,containerPort=3000\\\" \\\\\u00a0\u00a0\u00a0--health-check-grace-period-seconds 30 \\\\\u00a0\u00a0\u00a0--deployment-configuration \\\"deploymentCircuitBreaker={enable=true,rollback=true},minimumHealthyPercent=100,maximumPercent=200\\\"\u00a0Notes:\u00a0For production, place tasks in private subnets with a NAT gateway (or VPC endpoints for ECR, S3, and CloudWatch Logs) and set assignPublicIp=DISABLED.\u00a0The deployment circuit breaker automatically rolls back failed deployments.\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696182630\",\"name\":\"Step 9: Point DNS to the ALB\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"Create a Route 53 alias record (or a CNAME at your DNS provider) from app.example.com to the ALB DNS name.\u00a0\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696196612\",\"name\":\"Step 10: Configure Auto Scaling\u00a0\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0aws application-autoscaling register-scalable-target \\\\\u00a0\u00a0\u00a0--service-namespace ecs --scalable-dimension ecs:service:DesiredCount \\\\\u00a0\u00a0\u00a0--resource-id service\\\/APP-cluster\\\/APP-service --min-capacity 2 --max-capacity 6\u00a0\u00a0aws application-autoscaling put-scaling-policy \\\\\u00a0\u00a0\u00a0--service-namespace ecs --scalable-dimension ecs:service:DesiredCount \\\\\u00a0\u00a0\u00a0--resource-id service\\\/APP-cluster\\\/APP-service \\\\\u00a0\u00a0\u00a0--policy-name cpu-target --policy-type TargetTrackingScaling \\\\\u00a0\u00a0\u00a0--target-tracking-scaling-policy-configuration '{\u00a0\\\"TargetValue\\\": 60.0,\u00a0\\\"PredefinedMetricSpecification\\\": {\\\"PredefinedMetricType\\\": \\\"ECSServiceAverageCPUUtilization\\\"},\u00a0\\\"ScaleInCooldown\\\": 120, \\\"ScaleOutCooldown\\\": 60\u00a0\u00a0\u00a0}'\"}]},{\"@type\":\"HowToStep\",\"url\":\"https:\\\/\\\/velanremoteitsupport.com\\\/blog\\\/techtips\\\/deploy-steps-node-js-app-aws-fargate\\\/#how-to-step-1793696213020\",\"name\":\"Step 11: Deploy Updates\",\"itemListElement\":[{\"@type\":\"HowToDirection\",\"text\":\"bash\u00a0docker build -t $APP . && docker tag $APP:latest ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\\\/$APP:v2\u00a0docker push ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\\\/$APP:v2\u00a0# Update the image tag in task-def.json, register a new revision, then:\u00a0aws ecs update-service --cluster $APP-cluster --service $APP-service --task-definition node-app\u00a0ECS performs a rolling deployment. For automation, use GitHub Actions or AWS CodePipeline with the same build, push, register, and update sequence.\u00a0Validate\u00a0bash\u00a0aws ecs describe-services --cluster $APP-cluster --services $APP-service \\\\\u00a0\u00a0\u00a0--query \\\"services[0].{running:runningCount,desired:desiredCount,events:events[0:3]}\\\"\u00a0curl -I https:\\\/\\\/app.example.com\\\/health\u00a0aws logs tail \\\/ecs\\\/$APP --follow\"}]}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deploying Node.js Apps to AWS ECS Fargate | Step-by-Step Guide","description":"Step-by-step guide to Dockerize your Node.js app, push the image to Amazon ECR, and run it on ECS Fargate without managing a single server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/","og_locale":"en_US","og_type":"article","og_title":"Deploying Node.js Apps to AWS ECS Fargate | Step-by-Step Guide","og_description":"Step-by-step guide to Dockerize your Node.js app, push the image to Amazon ECR, and run it on ECS Fargate without managing a single server.","og_url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/","og_site_name":"Cloud, DevOps &amp; Managed It Service Blog From Top Consultants","article_modified_time":"2026-11-03T10:29:48+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/velanremoteitsupport.com\/blog\/wp-content\/uploads\/2026\/11\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/","name":"Deploying Node.js Apps to AWS ECS Fargate | Step-by-Step Guide","isPartOf":{"@id":"https:\/\/velanremoteitsupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#primaryimage"},"image":{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#primaryimage"},"thumbnailUrl":"https:\/\/velanremoteitsupport.com\/blog\/wp-content\/uploads\/2026\/11\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg","datePublished":"2026-11-03T10:29:47+00:00","dateModified":"2026-11-03T10:29:48+00:00","description":"Step-by-step guide to Dockerize your Node.js app, push the image to Amazon ECR, and run it on ECS Fargate without managing a single server.","breadcrumb":{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697613584"},{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697625788"},{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697641332"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#primaryimage","url":"https:\/\/velanremoteitsupport.com\/blog\/wp-content\/uploads\/2026\/11\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg","contentUrl":"https:\/\/velanremoteitsupport.com\/blog\/wp-content\/uploads\/2026\/11\/3_Configuring-AWS-ECS-Fargate-for-a-Node.jpg","width":1200,"height":628,"caption":"Architecture diagram for deploying a Node.js application on AWS ECS using serverless Fargate across Multi-AZ environments."},{"@type":"BreadcrumbList","@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/velanremoteitsupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Tech Tips","item":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/"},{"@type":"ListItem","position":3,"name":"Deploy a Node.js App to AWS Fargate, Step by Step"}]},{"@type":"WebSite","@id":"https:\/\/velanremoteitsupport.com\/blog\/#website","url":"https:\/\/velanremoteitsupport.com\/blog\/","name":"Cloud, DevOps &amp; Managed It Service Blog From Top Consultants","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/velanremoteitsupport.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697613584","position":1,"url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697613584","name":"What is AWS ECS pricing?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"ECS has no direct orchestration charge. You only pay for the underlying compute infrastructure and associated AWS resources.<br>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697625788","position":2,"url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697625788","name":"My company needs AWS services. How can you help with it?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Our cloud consultants assess your objectives, workload, and security requirements. We then suggest suitable services that can deliver better results. Our team also offers cloud cost optimization services to reduce cloud bills while improving performance.\u00a0<br>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697641332","position":3,"url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#faq-question-1793697641332","name":"What is covered in your AWS cloud advisory services for IT firms?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Before starting a project, we provide a detailed assessment of your IT infrastructure and goals. We create a practical strategy that can deliver maximum ROI. Our team onboards quickly and delivers solutions based on your requirements.<br>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"HowTo","@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#howto-1","name":"Deploy a Node.js App to AWS Fargate, Step by Step","mainEntityOfPage":{"@id":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/"},"description":"","step":[{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793693036813","name":"Step 1: Containerize the Application\u00a0","itemListElement":[{"@type":"HowToDirection","text":"Dockerfile (multi-stage, non-root):\u00a0dockerfile\u00a0FROM node:20-alpine AS deps\u00a0WORKDIR \/app\u00a0COPY package*.json .\/\u00a0RUN npm ci --omit=dev\u00a0\u00a0FROM node:20-alpine\u00a0WORKDIR \/app\u00a0ENV NODE_ENV=production\u00a0COPY --from=deps \/app\/node_modules .\/node_modules\u00a0COPY . .\u00a0USER node\u00a0EXPOSE 3000\u00a0CMD [\"node\", \"server.js\"]\u00a0Add a .dockerignore containing node_modules, .git, and .env.\u00a0Make sure the app binds to all interfaces, not just localhost:\u00a0js\u00a0app.listen(process.env.PORT || 3000, '0.0.0.0');\u00a0app.get('\/health', (req, res) => res.status(200).send('ok'));"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793693227302","name":"Step 2: Configure an ECR Repository and Upload the Image","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws ecr create-repository --repository-name $APP --image-scanning-configuration scanOnPush=true\u00a0\u00a0aws ecr get-login-password --region $AWS_REGION | \\\u00a0\u00a0\u00a0docker login --username AWS --password-stdin ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\u00a0\u00a0docker build -t $APP .\u00a0docker tag $APP:latest ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v1\u00a0docker push ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v1\u00a0Use immutable, versioned tags (e.g., v1 or a Git SHA) rather than relying on latest.\u00a0"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793693250172","name":"Step 3: IAM Task Execution Role Creation","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws iam create-role --role-name ecsTaskExecutionRole \\\u00a0\u00a0\u00a0--assume-role-policy-document '{\u00a0\"Version\":\"2012-10-17\",\u00a0\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ecs-tasks.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]\u00a0\u00a0\u00a0}'\u00a0\u00a0aws iam attach-role-policy --role-name ecsTaskExecutionRole \\\u00a0\u00a0\u00a0--policy-arn arn:aws:iam::aws:policy\/service-role\/AmazonECSTaskExecutionRolePolicySkip this if the account already has \"ecsTaskExecutionRole\".For secrets from \"Secrets Manager\" or \"SSM Parameter Store\", add a policy granting read access to those specific resources.If the app itself calls \"AWS services (S3, SQS)\", create a separate task role with least-privilege permissions."}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793693279117","name":"Step 4: Create the Cluster and Log Group\u00a0","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws ecs create-cluster --cluster-name $APP-cluster\u00a0aws logs create-log-group --log-group-name \/ecs\/$APP\u00a0aws logs put-retention-policy --log-group-name \/ecs\/$APP --retention-in-days 30"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696022079","name":"Step 5: Register the Task Definition\u00a0","itemListElement":[{"@type":"HowToDirection","text":"task-def.json:\u00a0json\u00a0{\u00a0\u00a0\u00a0\"family\": \"node-app\",\u00a0\u00a0\u00a0\"networkMode\": \"awsvpc\",\u00a0\u00a0\u00a0\"requiresCompatibilities\": [\"FARGATE\"],\u00a0\u00a0\u00a0\"cpu\": \"256\",\u00a0\u00a0\u00a0\"memory\": \"512\",\u00a0\u00a0\u00a0\"executionRoleArn\": \"arn:aws:iam:::role\/ecsTaskExecutionRole\",\u00a0\u00a0\u00a0\"containerDefinitions\": [\u00a0{\u00a0\u00a0\u00a0 \"name\": \"node-app\",\u00a0\u00a0\u00a0 \"image\": \".dkr.ecr.ap-south-1.amazonaws.com\/node-app:v1\",\u00a0\u00a0\u00a0 \"essential\": true,\u00a0\u00a0\u00a0 \"portMappings\": [{ \"containerPort\": 3000, \"protocol\": \"tcp\" }],\u00a0\u00a0\u00a0 \"environment\": [{ \"name\": \"NODE_ENV\", \"value\": \"production\" }],\u00a0\u00a0\u00a0 \"secrets\": [\u00a0\u00a0\u00a0\u00a0\u00a0 { \"name\": \"DB_PASSWORD\", \"valueFrom\": \"arn:aws:secretsmanager:ap-south-1::secret:node-app\/db-xxxxxx\" }\u00a0\u00a0\u00a0 ],\u00a0\u00a0\u00a0 \"healthCheck\": {\u00a0\u00a0\u00a0\u00a0\u00a0 \"command\": [\"CMD-SHELL\", \"wget -qO- http:\/\/localhost:3000\/health || exit 1\"],\u00a0\u00a0\u00a0\u00a0\u00a0 \"interval\": 30, \"timeout\": 5, \"retries\": 3, \"startPeriod\": 15\u00a0\u00a0\u00a0 },\u00a0\u00a0\u00a0 \"logConfiguration\": {\u00a0\u00a0\u00a0\u00a0\u00a0 \"logDriver\": \"awslogs\",\u00a0\u00a0\u00a0\u00a0\u00a0 \"options\": {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"awslogs-group\": \"\/ecs\/node-app\",\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"awslogs-region\": \"ap-south-1\",\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"awslogs-stream-prefix\": \"ecs\"\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0 }\u00a0}\u00a0\u00a0\u00a0]\u00a0}\u00a0Replace the  placeholders, then register:\u00a0bash\u00a0aws ecs register-task-definition --cli-input-json file:\/\/task-def.json\u00a0Note: alpine images include wget through BusyBox, which the health check above relies on.\u00a0"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696082107","name":"Step 6: Create Security Groups\u00a0 ALB security group: inbound 80 and 443 from 0.0.0.0\/0\u00a0 Task security group: inbound 3000 only from the ALB security group\u00a0","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws ec2 create-security-group --group-name alb-sg --description \"ALB\" --vpc-id \u00a0aws ec2 create-security-group --group-name task-sg --description \"ECS tasks\" --vpc-id \u00a0\u00a0aws ec2 authorize-security-group-ingress --group-id  --protocol tcp --port 443 --cidr 0.0.0.0\/0\u00a0aws ec2 authorize-security-group-ingress --group-id  --protocol tcp --port 80 --cidr 0.0.0.0\/0\u00a0aws ec2 authorize-security-group-ingress --group-id  --protocol tcp --port 3000 --source-group"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696144853","name":"Step 7: Create the Load Balancer, Target Group, and Listeners\u00a0","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws elbv2 create-load-balancer --name $APP-alb --subnets   --security-groups \u00a0\u00a0aws elbv2 create-target-group --name $APP-tg --protocol HTTP --port 3000 \\\u00a0\u00a0\u00a0--vpc-id  --target-type ip \\\u00a0\u00a0\u00a0--health-check-path \/health --health-check-interval-seconds 30\u00a0The target type must be ip for Fargate with awsvpc networking.\u00a0Create the listeners (HTTPS forwards to the app, HTTP redirects to HTTPS):\u00a0bash\u00a0aws elbv2 create-listener --load-balancer-arn  --protocol HTTPS --port 443 \\\u00a0\u00a0\u00a0--certificates CertificateArn= \\\u00a0\u00a0\u00a0--ssl-policy ELBSecurityPolicy-TLS13-1-2-2021-06 \\\u00a0\u00a0\u00a0--default-actions Type=forward,TargetGroupArn=\u00a0\u00a0aws elbv2 create-listener --load-balancer-arn  --protocol HTTP --port 80 \\\u00a0\u00a0\u00a0--default-actions 'Type=redirect,RedirectConfig={Protocol=HTTPS,Port=443,StatusCode=HTTP_301}'\u00a0"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696164564","name":"Step 8: Create the ECS Service\u00a0","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws ecs create-service \\\u00a0\u00a0\u00a0--cluster $APP-cluster \\\u00a0\u00a0\u00a0--service-name $APP-service \\\u00a0\u00a0\u00a0--task-definition node-app \\\u00a0\u00a0\u00a0--desired-count 2 \\\u00a0\u00a0\u00a0--launch-type FARGATE \\\u00a0\u00a0\u00a0--network-configuration \"awsvpcConfiguration={subnets=[,],securityGroups=[],assignPublicIp=ENABLED}\" \\\u00a0\u00a0\u00a0--load-balancers \"targetGroupArn=,containerName=node-app,containerPort=3000\" \\\u00a0\u00a0\u00a0--health-check-grace-period-seconds 30 \\\u00a0\u00a0\u00a0--deployment-configuration \"deploymentCircuitBreaker={enable=true,rollback=true},minimumHealthyPercent=100,maximumPercent=200\"\u00a0Notes:\u00a0For production, place tasks in private subnets with a NAT gateway (or VPC endpoints for ECR, S3, and CloudWatch Logs) and set assignPublicIp=DISABLED.\u00a0The deployment circuit breaker automatically rolls back failed deployments."}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696182630","name":"Step 9: Point DNS to the ALB\u00a0","itemListElement":[{"@type":"HowToDirection","text":"Create a Route 53 alias record (or a CNAME at your DNS provider) from app.example.com to the ALB DNS name.\u00a0"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696196612","name":"Step 10: Configure Auto Scaling\u00a0","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0aws application-autoscaling register-scalable-target \\\u00a0\u00a0\u00a0--service-namespace ecs --scalable-dimension ecs:service:DesiredCount \\\u00a0\u00a0\u00a0--resource-id service\/APP-cluster\/APP-service --min-capacity 2 --max-capacity 6\u00a0\u00a0aws application-autoscaling put-scaling-policy \\\u00a0\u00a0\u00a0--service-namespace ecs --scalable-dimension ecs:service:DesiredCount \\\u00a0\u00a0\u00a0--resource-id service\/APP-cluster\/APP-service \\\u00a0\u00a0\u00a0--policy-name cpu-target --policy-type TargetTrackingScaling \\\u00a0\u00a0\u00a0--target-tracking-scaling-policy-configuration '{\u00a0\"TargetValue\": 60.0,\u00a0\"PredefinedMetricSpecification\": {\"PredefinedMetricType\": \"ECSServiceAverageCPUUtilization\"},\u00a0\"ScaleInCooldown\": 120, \"ScaleOutCooldown\": 60\u00a0\u00a0\u00a0}'"}]},{"@type":"HowToStep","url":"https:\/\/velanremoteitsupport.com\/blog\/techtips\/deploy-steps-node-js-app-aws-fargate\/#how-to-step-1793696213020","name":"Step 11: Deploy Updates","itemListElement":[{"@type":"HowToDirection","text":"bash\u00a0docker build -t $APP . && docker tag $APP:latest ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v2\u00a0docker push ACCOUNTID.dkr.ecr.AWS_REGION.amazonaws.com\/$APP:v2\u00a0# Update the image tag in task-def.json, register a new revision, then:\u00a0aws ecs update-service --cluster $APP-cluster --service $APP-service --task-definition node-app\u00a0ECS performs a rolling deployment. For automation, use GitHub Actions or AWS CodePipeline with the same build, push, register, and update sequence.\u00a0Validate\u00a0bash\u00a0aws ecs describe-services --cluster $APP-cluster --services $APP-service \\\u00a0\u00a0\u00a0--query \"services[0].{running:runningCount,desired:desiredCount,events:events[0:3]}\"\u00a0curl -I https:\/\/app.example.com\/health\u00a0aws logs tail \/ecs\/$APP --follow"}]}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/techtips\/755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/techtips"}],"about":[{"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/types\/techtips"}],"author":[{"embeddable":true,"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/comments?post=755"}],"version-history":[{"count":8,"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/techtips\/755\/revisions"}],"predecessor-version":[{"id":763,"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/techtips\/755\/revisions\/763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/media\/764"}],"wp:attachment":[{"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/media?parent=755"}],"wp:term":[{"taxonomy":"techtips_category","embeddable":true,"href":"https:\/\/velanremoteitsupport.com\/blog\/wp-json\/wp\/v2\/techtips_category?post=755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}