How to create an AMI of an EC2 Instance from AWS CLI

Use the below command to create AMI of an EC2 Instance. Replace instanceid and name values accordingly.

aws ec2 create-image --instance-id INSTANCEID --name "image-of-server"

By default, EC2 Instance is shutdown to capture AMI to gaurantee a clean image. However if you do not want the server to reboot, you may specify the no-reboot option as shown below:

aws ec2 create-image --instance-id INSTANCEID --name "image-of-server" --no-reboot

You may optionally provide a value for description as:

aws ec2 create-image --instance-id INSTANCEID --name "image-of-server" --no-reboot --description "Monthly AMI"
See also  How to list all users of an IAM group