官术网_书友最值得收藏!

  • Effective DevOps with AWS
  • Yogesh Raheja Giuseppe Borgese Nathaniel Felsen
  • 310字
  • 2021-07-23 16:27:29

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-01864b4c \
--image-id ami-cfe4b2b0
{
"Instances": [
{
"Monitoring": {
"State": "disabled"
},
"PublicDnsName": "",
"StateReason": {
"Message": "pending",
"Code": "pending"
},
"State": {
"Code": 0,
"Name": "pending"
},
"EbsOptimized": false,
"LaunchTime": "2018-08-08T06:38:43.000Z",
"PrivateIpAddress": "172.31.22.52",
"ProductCodes": [],
"VpcId": "vpc-4cddce2a",
"CpuOptions": {
"CoreCount": 1,
"ThreadsPerCore": 1
},
"StateTransitionReason": "",
"InstanceId": "i-057e8deb1a4c3f35d",
"ImageId": "ami-cfe4b2b0",
"PrivateDnsName": "ip-172-31-22-52.ec2.internal",
"KeyName": "EffectiveDevOpsAWS",
"SecurityGroups": [
{
"GroupName": "HelloWorld",
"GroupId": "sg-01864b4c"
}
],
"ClientToken": "",
"SubnetId": "subnet-6fdd7927",
"InstanceType": "t2.micro",
"NetworkInterfaces": [
{
"Status": "in-use",
"MacAddress": "0a:d0:b9:db:7b:38",
"SourceDestCheck": true,
"VpcId": "vpc-4cddce2a",
"Description": "",
"NetworkInterfaceId": "eni-001aaa6b5c7f92b9f",
"PrivateIpAddresses": [
{
"PrivateDnsName": "ip-172-31-22-
52.ec2.internal",
"Primary": true,
"PrivateIpAddress": "172.31.22.52"
}
],
"PrivateDnsName": "ip-172-31-22-52.ec2.internal",
"Attachment": {
"Status": "attaching",
"DeviceIndex": 0,
"DeleteOnTermination": true,
"AttachmentId": "eni-attach-0428b549373b9f864",
"AttachTime": "2018-08-08T06:38:43.000Z"
},
"Groups": [
{
"GroupName": "HelloWorld",
"GroupId": "sg-01864b4c"
}
],
"Ipv6Addresses": [],
"OwnerId": "094507990803",
"SubnetId": "subnet-6fdd7927",
"PrivateIpAddress": "172.31.22.52"
}
],
"SourceDestCheck": true,
"Placement": {
"Tenancy": "default",
"GroupName": "",
"AvailabilityZone": "us-east-1c"
},
"Hypervisor": "xen",
"BlockDeviceMappings": [],
"Architecture": "x86_64",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"AmiLaunchIndex": 0
}
],
"ReservationId": "r-09a637b7a3be11d8b",
"Groups": [],
"OwnerId": "094507990803"
}

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-057e8deb1a4c3f35d
{
"InstanceStatuses": [
{
"InstanceId": "i-057e8deb1a4c3f35d",
"InstanceState": {
"Code": 16,
"Name": "running"
},
"AvailabilityZone": "us-east-1c",
"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:

$ aws ec2 describe-instance-status --instance-ids i-057e8deb1a4c3f35d --output text| grep -i SystemStatus

SYSTEMSTATUS ok
主站蜘蛛池模板: 庄河市| 砚山县| 海盐县| 五台县| 精河县| 惠来县| 太仓市| 泾川县| 永泰县| 雷山县| 行唐县| 上栗县| 平塘县| 呼伦贝尔市| 都安| 登封市| 老河口市| 黎平县| 青田县| 吉安市| 苍山县| 开封市| 辉县市| 梁山县| 峨眉山市| 二手房| 和顺县| 高阳县| 托里县| 湟中县| 蓬溪县| 仙桃市| 威宁| 高邮市| 禄劝| 墨玉县| 永仁县| 永仁县| 凤台县| 裕民县| 炉霍县|