Scaling policies (target tracking, step, simple) in AWS - Mini Project: Build & Apply
Create a launch configuration called MyAppLaunchConfig with image ID ami-12345678 and instance type t3.micro. Then create an Auto Scaling Group called MyAppASG using this launch configuration with minimum size 1, maximum size 5, and desired capacity 2.
Use aws_launch_configuration and aws_autoscaling_group resources. Set the exact names and values as specified.
Add a target tracking scaling policy named CPU50Percent to MyAppASG that keeps the average CPU utilization at 50%. Use the predefined metric ASGAverageCPUUtilization.
Use aws_autoscaling_policy with policy_type = "TargetTrackingScaling" and set target_value to 50.
Add a step scaling policy named ScaleUpHighCPU to MyAppASG that increases capacity by 2 when CPU usage exceeds 70%. Use a CloudWatch alarm named HighCPUAlarm that triggers when average CPU is above 70%.
Create a CloudWatch alarm for CPU > 70%. Then create a step scaling policy linked to this alarm that increases capacity by 2.
Add a simple scaling policy named ScaleDownLowCPU to MyAppASG that decreases capacity by 1 when CPU usage falls below 30%. Use a CloudWatch alarm named LowCPUAlarm that triggers when average CPU is below 30%.
Create a CloudWatch alarm for CPU < 30%. Then create a simple scaling policy linked to this alarm that decreases capacity by 1.