Linux command
aws-autoscaling 命令
趣味
复制后可按需替换文件名、目录或参数。
常用示例
Create an Auto Scaling group
aws autoscaling create-auto-scaling-group --auto-scaling-group-name [my-asg] --launch-template LaunchTemplateId=[lt-12345] --min-size [1] --max-size [5] --vpc-zone-identifier "[subnet-abc,subnet-def]"
List Auto Scaling groups
aws autoscaling describe-auto-scaling-groups
Update group capacity
aws autoscaling update-auto-scaling-group --auto-scaling-group-name [my-asg] --desired-capacity [3]
Set scaling policy
aws autoscaling put-scaling-policy --auto-scaling-group-name [my-asg] --policy-name [cpu-policy] --policy-type TargetTrackingScaling --target-tracking-configuration file://[config.json]
Describe instances
aws autoscaling describe-auto-scaling-instances
Attach a load balancer
aws autoscaling attach-load-balancer-target-groups --auto-scaling-group-name [my-asg] --target-group-arns [arn:aws:elasticloadbalancing:...]
Delete an Auto Scaling group
aws autoscaling delete-auto-scaling-group --auto-scaling-group-name [my-asg] --force-delete
说明
aws autoscaling manages Amazon EC2 Auto Scaling groups that automatically adjust the number of EC2 instances based on demand or schedules. Groups maintain application availability and allow automatic scaling up during demand spikes and scaling down to reduce costs. Launch templates or launch configurations define instance settings (AMI, instance type, security groups). Scaling policies determine when and how to scale based on metrics like CPU utilization or request count. Target tracking scaling maintains a specific metric value (e.g., 50% CPU). Step scaling adjusts capacity in steps based on alarm thresholds. Scheduled scaling changes capacity at specified times. Health checks (EC2 or ELB) detect unhealthy instances for automatic replacement. The health-check-grace-period prevents premature termination of instances still initializing.
参数
- create-auto-scaling-group
- Create a new Auto Scaling group
- describe-auto-scaling-groups
- List Auto Scaling groups and their configuration
- update-auto-scaling-group
- Modify group settings (capacity, health checks, etc.)
- delete-auto-scaling-group
- Delete an Auto Scaling group
- put-scaling-policy
- Create or update a scaling policy
- describe-scaling-activities
- View scaling activity history
- set-desired-capacity
- Set the desired number of instances
- attach-load-balancer-target-groups
- Attach target groups to the group
- create-launch-configuration
- Create a launch configuration (legacy)
- --auto-scaling-group-name _name_
- Name of the Auto Scaling group
- --launch-template _spec_
- Launch template ID or name and version
- --min-size _n_
- Minimum number of instances
- --max-size _n_
- Maximum number of instances
- --desired-capacity _n_
- Desired number of instances
- --vpc-zone-identifier _subnets_
- Comma-separated subnet IDs
- --health-check-type _type_
- EC2 or ELB health check type
- --health-check-grace-period _seconds_
- Seconds before health checks start
- --force-delete
- Delete even with running instances
FAQ
What is the aws-autoscaling command used for?
aws autoscaling manages Amazon EC2 Auto Scaling groups that automatically adjust the number of EC2 instances based on demand or schedules. Groups maintain application availability and allow automatic scaling up during demand spikes and scaling down to reduce costs. Launch templates or launch configurations define instance settings (AMI, instance type, security groups). Scaling policies determine when and how to scale based on metrics like CPU utilization or request count. Target tracking scaling maintains a specific metric value (e.g., 50% CPU). Step scaling adjusts capacity in steps based on alarm thresholds. Scheduled scaling changes capacity at specified times. Health checks (EC2 or ELB) detect unhealthy instances for automatic replacement. The health-check-grace-period prevents premature termination of instances still initializing.
How do I run a basic aws-autoscaling example?
Run `aws autoscaling create-auto-scaling-group --auto-scaling-group-name [my-asg] --launch-template LaunchTemplateId=[lt-12345] --min-size [1] --max-size [5] --vpc-zone-identifier "[subnet-abc,subnet-def]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does create-auto-scaling-group do in aws-autoscaling?
Create a new Auto Scaling group