Lesson 3 of 4 ยท AWS with Terraform
Storage and load balancing
S3 stores object data, while an Application Load Balancer distributes HTTP or HTTPS traffic to application targets. They are different building blocks that often work together in a web architecture.
Example
resource "aws_s3_bucket" "assets" {
bucket = "training-assets-example"
}
resource "aws_lb" "app" {
name = "training-app"
load_balancer_type = "application"
subnets = [aws_subnet.public.id]
}Step by step
- Store files in an object store rather than an instance disk.
- Place public load balancers in suitable subnets.
- Route load-balancer traffic to explicit targets.
- Limit bucket and target access deliberately.
Common mistakes to avoid
- Putting an application load balancer in no subnet.
- Making a storage bucket public by default.