Disable stop protection for AWS EC2 instance

To Nha Notes | Dec. 1, 2022, 3:10 p.m.

To change AWS EC2 instance type to scale up or down, we stop the instance at first then choose Instance Settings/Change Instance Type from right click on selected instance.

To stop an AWS EC2 instance, we just select wanted instance and click stop, but some time It will not allowed stop because the instance has been enabled stop protection. Normally we got stopped with error message as following. 

Trying to stop and terminate an instance, but it has a warning: "The instance 'i-0e571b9423e63be86' may not be stopped. Modify its 'disableApiStop' instance attribute and try again."

To disable stop instance, execute below command via aws cli:

aws ec2 modify-instance-attribute --instance-id <YOUR_INSTANCE_ID>  --no-disable-api-stop --profile <YOUR_AWS_PROFILE>

Check more AWs EC2 attributes here https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/modify-instance-attribute.html

References

https://repost.aws/questions/QUzA79S41yTjGywlt8a_pZVQ/i-am-not-able-to-stop-or-terminate-the-server