| « PreviousNext » | |
![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
This section walks you through how to launch an Amazon EC2 instance by using the key pair and security group created in the preceding sections, along with an AMI ID obtained from the Amazon EC2 console.
To launch an Amazon EC2 instance
Use the run-instances command to launch a single Amazon EC2 instance using AMI ami-554ac83c, a Microsoft Windows Server 2012 image.
The instance type is t1.micro. The key pair and security groups are those created previously.
Important
If you launch an instance that is not within the Free Usage Tier, you are billed after you launch the instance and charged for the time that the instance is running, even if it remains idle.
aws ec2 run-instances --image-id ami-554ac83c --min-count 1 --max-count 1 --key-name MyKeyPair --security-groups MySecurityGroup
{
"ownerId": "803981987763",
"groupSet": [
{
"groupName": "MySecurityGroup",
"groupId": "sg-903004f8"
}
],
"reservationId": "r-5875ca20",
"requestId": "e31dcf5d-ebcb-44e2-970b-3041bf898600",
"instancesSet": [
{
"productCodes": [],
"instanceId": "i-5203422c",
"imageId": "ami-554ac83c",
"keyName": "MyKeyPair",
"clientToken": "",
"amiLaunchIndex": 0,
"instanceType": "m1.small",
"groupSet": [
{
"groupName": "MySecurityGroup",
"groupId": "sg-903004f8"
}
],
"monitoring": {
"state": "disabled"
},
"platform": "windows",
"dnsName": "",
"stateReason": {
"message": "pending",
"code": "pending"
},
"virtualizationType": "hvm",
"privateDnsName": "",
"reason": "",
"blockDeviceMapping": [],
"placement": {
"groupName": "",
"tenancy": "default",
"availabilityZone": "us-east-1b"
},
"instanceState": {
"code": 0,
"name": "pending"
},
"launchTime": "2012-12-19T02:42:39.000Z",
"architecture": "x86_64",
"hypervisor": "xen",
"rootDeviceType": "ebs",
"rootDeviceName": "/dev/sda1"
}
]
}Use the describe-instances command to retrieve information about the instance.
aws ec2 describe-instances --instance-ids i-5203422c
After a few minutes, the instance will be up and running, as this excerpt of the return values from describe-instances shows:
"instanceState": {
"code": 16,
"name": "running"
},