HiveBrain v1.2.0
Get Started
← Back to all entries
gotchaMinor

what is difference between "sudo shutdown now" versus "aws ec2 stop-instances"

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
whatversusinstancesec2shutdowndifferencenowbetweenstopaws

Problem

When logged onto a AWS EC2 instance say some Ubuntu box and I issue

sudo shutdown now


how is that different from stopping the same instance using

aws ec2 stop-instances --instance-ids  $curr_instanceid --region $AWS_REGION


either way I see the instance gets into the state of stopped and it will transition into state running once this is run

aws ec2 start-instances --instance-ids   $curr_instanceid --region $AWS_REGION

Solution

Just to state the obvious for junior folks who might come across this: sudo shutdown now requires access to the operating system (via SSH keys, inbound security groups, etc), while aws ec2 stop-instances is an AWS CLI command which simply requires API authentication (via IAM credentials or STS tokens).

Aside from the obvious difference in invocation, the shutdown is the same.

When you stop or hibernate an instance, we shut it down. You can restart your instance at any time. Before stopping or hibernating an instance, make sure it is in a state from which it can be restarted. Stopping an instance does not preserve data stored in RAM, but hibernating an instance does preserve data stored in RAM. If an instance cannot hibernate successfully, a normal shutdown occurs.

Source: stop-instances documentation

The --hibernate flag defaults to false, so a normal shutdown is triggered immediately by your CLI command.

When --hibernate is true, the suspend-to-disk process differs from a regular shutdown (such as sudo shutdown now), and is further documented here.

Context

StackExchange DevOps Q#13155, answer score: 1

Revisions (0)

No revisions yet.