
上QQ阅读APP看书,第一时间看更新
Terminating our EC2 instance
As with most helloworld exercises, once the Hello World message is displayed, the goal is reached. It is now time to think about shutting down our server. Since in AWS we only pay for what we consume, freeing up unnecessary resources such as this server is a good strategy to make AWS very cost-effective.
We can do a clean shutdown of the Hello World service using the stop command, exit the virtual server, and terminate our instance, as follows:
[ec2-user@ip-172-31-22-234 ~]$ sudo stop helloworld helloworld stop/waiting [ec2-user@ip-172-31-22-234 ~]$ ec2-metadata --instance-id instance-id: i-d10e0e62 [ec2-user@ip-172-31-22-234 ~]$ exit logout $ aws ec2 terminate-instances --instance-ids i-d10e0e62 { "TerminatingInstances": [ { "InstanceId": "i-d10e0e62", "CurrentState": { "Code": 32, "Name": "shutting-down" }, "PreviousState": { "Code": 16, "Name": "running" } } ] }