← 返回命令列表

Linux command

aws-ec2 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Launch a new EC2 instance

aws ec2 run-instances --image-id [ami-0c55b159cbfafe1f0] --instance-type [t2.micro] --key-name [my-key]

List all instances

aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,State.Name,InstanceType]" --output table

Stop a running instance

aws ec2 stop-instances --instance-ids [i-1234567890abcdef0]

Start a stopped instance

aws ec2 start-instances --instance-ids [i-1234567890abcdef0]

Terminate an instance

aws ec2 terminate-instances --instance-ids [i-1234567890abcdef0]

Create a security group

aws ec2 create-security-group --group-name [my-sg] --description "[My security group]" && aws ec2 authorize-security-group-ingress --group-name [my-sg] --protocol tcp --port 22 --cidr 0.0.0.0/0

Create a key pair

aws ec2 create-key-pair --key-name [my-key] --query "KeyMaterial" --output text > [my-key.pem]

说明

aws ec2 is the AWS CLI interface for Amazon Elastic Compute Cloud (EC2), providing programmatic access to scalable compute capacity. EC2 enables launching virtual servers, configuring networking and security, and managing storage. EC2 commands cover instance lifecycle management, Amazon Machine Images (AMIs), Elastic Block Store (EBS) volumes, VPC networking, security groups, and key pairs. The service supports on-demand, reserved, and spot pricing models.

FAQ

What is the aws-ec2 command used for?

aws ec2 is the AWS CLI interface for Amazon Elastic Compute Cloud (EC2), providing programmatic access to scalable compute capacity. EC2 enables launching virtual servers, configuring networking and security, and managing storage. EC2 commands cover instance lifecycle management, Amazon Machine Images (AMIs), Elastic Block Store (EBS) volumes, VPC networking, security groups, and key pairs. The service supports on-demand, reserved, and spot pricing models.

How do I run a basic aws-ec2 example?

Run `aws ec2 run-instances --image-id [ami-0c55b159cbfafe1f0] --instance-type [t2.micro] --key-name [my-key]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more aws-ec2 examples?

This page includes 7 examples for aws-ec2, plus related commands for nearby Linux tasks.