Launching an EC2 instance

We now have all the information required to launch our instance; let's finally launch it as follows:

$ aws ec2 run-instances 
--instance-type t2.micro
--key-name EffectiveDevOpsAWS
--security-group-ids sg-11d4fe68
--image-id ami-a4c7edb2
{
"OwnerId": "511912822958",
"ReservationId": "r-6d7c15c1",
"Groups": [],
"Instances": [
{
"Monitoring": {
"State": "disabled"
},
"PublicDnsName": "",
"RootDeviceType": "ebs",
"State": {
"Code": 0,
"Name": "pending"
},
"EbsOptimized": false,
"LaunchTime": "2017-07-31T08:39:12.000Z",
"PrivateIpAddress": "172.31.27.66",
"ProductCodes": [],
"VpcId": "vpc-f7dc4093",
"StateTransitionReason": "",
"InstanceId": "i-97000624",
"ImageId": "ami-a4c7edb2",
"PrivateDnsName": "ip-172-31-27-66.ec2.internal",
"KeyName": "EffectiveDevOpsAWS",
"SecurityGroups": [
{
"GroupName": "HelloWorld",
"GroupId": "sg-11d4fe68"
}
],
"ClientToken": "",
"SubnetId": "subnet-4f3bdb17",
"InstanceType": "t2.micro",
"NetworkInterfaces": [
{
"Status": "in-use",
"MacAddress": "0e:fd:f8:18:bb:0f",
"SourceDestCheck": true,
"VpcId": "vpc-f7dc4093",
"Description": "",
"NetworkInterfaceId": "eni-1d23a243",
"PrivateIpAddresses": [
{
"PrivateDnsName": "ip-172-31-
2766.ec2.internal",
"Primary": true,
"PrivateIpAddress": "172.31.27.66"
}
],
"PrivateDnsName": "ip-172-31-27-66.ec2.internal",
"Attachment": {
"Status": "attaching",
"DeviceIndex": 0,
"DeleteOnTermination": true,
"AttachmentId": "eni-attach-6398c28f",
"AttachTime": "2017-07-31T08:39:12.000Z"
},
"Groups": [
{
"GroupName": "HelloWorld",
"GroupId": "sg-11d4fe68"
}
],
"SubnetId": "subnet-4f3bdb17",
"OwnerId": "511912822958",
"PrivateIpAddress": "172.31.27.66"
}
],
"SourceDestCheck": true,
"Placement": {
"Tenancy": "default",
"GroupName": "",
"AvailabilityZone": "us-east-1a"
},
"Hypervisor": "xen",
"BlockDeviceMappings": [],
"Architecture": "x86_64",
"StateReason": {
"Message": "pending",
"Code": "pending"
},
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"AmiLaunchIndex": 0
}
]
}

You can track the progress of the instance creation. To do that, get the instance ID provided in the output of the aws ec2 run-instances command and run the following command:

$ aws ec2 describe-instance-status --instance-ids i-97000624
{
"InstanceStatuses": [
{
"InstanceId": "i-97000624",
"InstanceState": {
"Code": 16,
"Name": "running"
},
"AvailabilityZone": "us-east-1a",
"SystemStatus": {
"Status": "initializing",
"Details": [
{
"Status": "initializing",
"Name": "reachability"
}
]
},
"InstanceStatus": {
"Status": "initializing",
"Details": [
{
"Status": "initializing",
"Name": "reachability"
}
]
}
}
]
}

The instance will be ready once the Status under SystemStatus changes from initializing to ok.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset