
Master autoscaling with Terraform on AWS Fargate by deploying a test API and worker, using CloudWatch metrics to scale CPU and memory, and compare costs with EC2.
Explore the local setup of a Flask-based API and worker using Python, Docker, and docker-compose, with an entrypoint and dockerfile for SQS-driven workloads.
Review a lean Flask app with a ping endpoint used as a health check. Demonstrate CPU and memory stress tests to trigger Fargate autoscaling and outline an SQS worker.
Install and manage terraform versions with tfenv, including installing 1.6.6, listing versions, switching active versions, and preparing for AWS infrastructure deployment.
Configure an AWS profile to enable Terraform and AWS CLI access for deploying the lab environment, then verify identity with AWS STS get-caller-identity and set env.tfvars.
Run base terraform scripts to build foundational AWS infrastructure, explain each step with diagrams for learners new to AWS and Terraform, and preview modules on AWS Fargate and autoscaling.
Apply pre init terraform to create state and logs, then build a multi-subnet VPC with private and public networks, security groups, and an ALB; configure SNS for alerts.
Create an SQS queue with a Terraform module by passing queue name and delay, initialize and apply, then verify in AWS SQS and run docker compose to test the worker.
Configure a real-domain load balancer by creating a Route 53 hosted zone, delegating NS records, and validating an AWS Certificate Manager certificate, while verifying DNS with nslookup and dig.
Apply Terraform to deploy an application load balancer with a verified domain certificate, Route 53 A record, and aliases; configure ALB logs, SSL listeners, and SNS alarms.
Route DNS to Route 53, where an A record points to an application load balancer, which forwards requests to the AWS Fargate deployment via a target group.
Explore AWS Fargate as a serverless, pay-as-you-go option within ECS, compare it with EC2, and learn how to run containerized applications via tasks, services, and clusters using Docker images.
Build a docker image and push it to AWS ECR repository using prepared bash scripts, configure region and URI in env.sh, and prepare for Terraform code in the next lecture.
Explore the Fargate Terraform module, including ECS cluster setup, capacity providers, and a task definition template. Compare VPC network mode implications and Linux runtime platform choices.
Configure two AWS IAM roles for ECS: execution role for starting containers and task role for the application; attach policies for ECS task execution, SSM access, and SQS permissions.
Define an ecs service in Terraform with name, cluster, task definition references, and desired count, plus network, ecs exec mode, security, and load balancer considerations, including assign public IP decisions.
Explore a Fargate task definition template in a Terraform module, covering memory and CPU limits, port 5000, log group and stream, health checks, and environment with SSM secrets.
Explore the target group Terraform module and its implementation for a Fargate deployment, detailing target type IP, registration delay, health checks, and listener rules that route traffic by host header.
Explore part two of the target group terraform module and code by defining network and application load balancer states, and connecting load balancer, target group, and Fargate cluster with Terraform.
Apply Terraform to deploy a Fargate app, then verify the ECS cluster, service, tasks, and load balancer in the AWS console; review Route 53, target groups, and logs.
Explore AWS Fargate autoscaling, starting with target metric value and CloudWatch alarm-based step adjustments, and learn practical Terraform examples for ECS CPU, memory, and SQS metrics.
Learn when autoscaling is appropriate for variable web traffic, balance CPU and memory needs, and implement dynamic autoscaling with AWS Fargate, Terraform, and SQS auto scaling policy.
Learn to deploy autoscaling for AWS Fargate with a predefined Terraform module, configuring ECS target tracking for memory and CPU, and min/max capacities with CloudWatch alarms.
Explore testing predefined CPU and memory autoscaling in AWS Fargate by running stress-ng inside an ECS container, monitoring with CloudWatch alarms, and observing task count changes and scaling history.
Explore target tracking autoscaling in AWS Fargate, including how the current ratio and cooldowns limit scale-out speed, CloudWatch intervals, and selecting metrics such as memory utilization or backlog per instance.
Implement step autoscaling for AWS Fargate with Terraform by configuring step adjustments, cooldowns, and CloudWatch alarms to scale containers based on CPU utilization.
Configure a step autoscaling policy for a Fargate service with Terraform, implementing scale out at 70% CPU and scale in at 20% CPU, with CloudWatch alarms.
Configure autoscaling with predefined custom sqs metrics by sequentially applying cpu, memory, and sqs policies, deploy and test a worker that processes queue messages using a supervisor-managed container.
Explore terraform based AWS Fargate autoscaling using a customized backlog per instance metric, defined as messages in queue divided by running ECS tasks, with a target of ten.
Test autoscaling using a predefined custom SQS metric in practice, sending bursts of messages to trigger scale-out and scale-in, and observe container launches, CloudWatch alarms, and backlogs.
Master autoscaling with CPU and memory targets, stress testing, and CloudWatch alarms, plus step autoscaling and backlog per instance metrics for SQS, while noting AWS Fargate cost considerations.
Compare AWS Fargate costs to EC2 using the pricing calculator in Frankfurt, focusing on CPU and memory pricing; the example shows Fargate about 2.3x more expensive than EC2.
Compare x86 and ARM architectures using AWS Fargate, noting Graviton efficiency, docker image considerations, and price savings with compute savings plans for one-year upfront commits.
Explore cost optimization for AWS Fargate by using a hybrid setup of base Fargate and Fargate spot containers, assess production viability, and note the ARM limitation.
Assess cost optimization strategies for AWS Fargate and traffic fluctuations, compare with EC2 options (on-demand, ARM, saving plans, spot), and decide when Terraform autoscaling makes sense.
What you'll learn:
How to deploy Web API application and SQS worker at AWS Cloud using AWS Fargate and Terraform
AWS ECS base components and how to deploy them using Terrafom
What is autoscaling and how it works at AWS Fargate
How to create autoscaling policies using target metric values + Terraform
How to create autoscaling policies using predefined step increments + CloudWatch alarms + Terrafom
How to create autoscaling policy based on a custom CloudWatch metric for scaling workers
How to use AWS Fargate wisely - CPU architectures, savings plans, and hybrid Fargate Spot systems as strategies for for cost reduction
Requirements:
Active AWS account
Some active web domain
Basic knowledge at using docker and web programming
Basic knowledge at Terraform
AWS basic conceptions, e.g VPC, EC2, subnets, security groups...
AWS ECS basics.
Short description:
This course is designed to guide you through the practical implementation of autoscaling using Terraform and AWS Fargate. It discovers how to optimize resource use effectively and ensure seamless application performance, all while managing costs wisely. ATTENTION - it is not the course where I will be writing code from zero, as it will take 6 hours to do it - it is the course where you will get ready code and solutions + clear explanations how to use it.
COURSE STRUCTURE:
The course consists of 5 sections:
In the 1st section we will create a test web application and test worker, forming the lab environment for hands-on auto scaling practice. No prior knowledge of those technologies are required.
In the 2d section we will create a base AWS infrastructure - all stuff related to the network, and additional services required for our lab environment - ALB, SNS, SQS, CW. Finally we will configure the real domain for our application using Route 53 and CM. Almost all that would be done rather fast, as we will be using ready terrafom modules.
The 3d section focuses on AWS Fargate. Here, we'll explore the core components of AWS Fargate and deploy our test API application, working towards achieving our desired final architecture.
The 4th section is the heart of our course, where we'll dive deep into autoscaling. We'll explore various autoscaling strategies, including target metric values and predefined step increments using CloudWatch alarms. You'll learn to work with CPU and memory utilization metrics and even create an autoscaling policy based on a custom CloudWatch metric for scaling workers.
In the final, 5th section, we'll discuss the costs involved with AWS Fargate, compare it with EC2 pricing and discuss how to navigate via Fargate limitations. You'll learn strategies to use this technology wisely, ensuring your expenses stay low while maximizing its benefits. We'll cover topics such as CPU architectures, savings plans, and hybrid Fargate Spot systems.
Who this course is for:
Anyone who is interested at autoscaling or who is responsible for Web resources:
Software engineer
DevOps
Admin
CTO
CEO