AWS Certified SysOps Administrator - Associate: Troubleshooting EC2 Instance Software Issue with AWS CLI

Troubleshooting EC2 Instance Software Issue with AWS CLI

Question

You have an EC2 instance (i-01234567890123456) in production that has a software issue.

To troubleshoot the issue, you need to take an AMI from the instance using AWS CLI.

When the image is being created, the instance must not be rebooted.

Otherwise, some running scripts will be interrupted.

Which of the following AWS CLI commands would you use?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: B.

Option A is incorrect because, with the “--reboot” option, Amazon EC2 will shut down and reboot the instance when taking the image.

Option B is CORRECT because the “--no-reboot” option ensures that the EC2 instance does not reboot during image creation.

Option C is incorrect because the “--no-dry-run” option is a boolean attribute to control whether the operation is executed or not.

It does not avoid rebooting the instance.

Option D is incorrect because when no option is provided, the EC2 will reboot the instance while creating the image.

This behavior is not as expected.

References:

https://docs.aws.amazon.com/cli/latest/reference/ec2/create-image.html, https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html

The correct answer is B. aws ec2 create-image --instance-id i-01234567890123456 --name "My_Image" --no-reboot.

When creating an Amazon Machine Image (AMI) from an EC2 instance, the default behavior is to reboot the instance. This can cause running scripts to be interrupted, which is not ideal in a production environment. Therefore, to create an AMI without rebooting the instance, you need to use the --no-reboot option in the AWS CLI command.

The correct command to create an AMI without rebooting the instance is: aws ec2 create-image --instance-id i-01234567890123456 --name "My_Image" --no-reboot

Here's a breakdown of the command and its parameters:

  • aws ec2 create-image: This is the AWS CLI command to create an AMI from an EC2 instance.

  • --instance-id: This parameter specifies the ID of the EC2 instance that you want to create an AMI from.

  • i-01234567890123456: This is the actual instance ID. You would replace this with the actual ID of the instance you want to create an AMI from.

  • --name: This parameter specifies the name of the AMI that you want to create.

  • "My_Image": This is the actual name of the AMI. You would replace this with the actual name you want to give to the AMI.

  • --no-reboot: This parameter specifies that the instance should not be rebooted when creating the AMI. This is the option that ensures that running scripts are not interrupted.

Option A (--reboot) would cause the instance to be rebooted during the AMI creation process, which is not what we want. Option C (--no-dry-run) is not relevant to creating an AMI, and option D does not include the --no-reboot parameter, so it would also cause the instance to be rebooted.