AWS Certified SysOps Administrator Practice Exam

Disable ads (and more) with a membership for a one time $4.99 payment

Prepare for the AWS Certified SysOps Administrator Exam. Utilize flashcards, multiple-choice questions, tips, and in-depth explanations. Get exam-ready!

Practice this question and more.


What can you do to gain access to logs located in /var/cfn/cfn-init-output.log when the EC2 instance terminates on failure?

  1. Set OnFailure=ROLLBACK in the CloudFormation template

  2. Set OnFailure=DO_NOTHING in the CloudFormation template

  3. Change the termination behavior in the EC2 instance settings

  4. Specify an alternate region for log storage

The correct answer is: Set OnFailure=DO_NOTHING in the CloudFormation template

To access logs in /var/cfn/cfn-init-output.log after an EC2 instance terminates on failure, the most suitable action is to set the OnFailure attribute to DO_NOTHING in the CloudFormation template. By specifying this option, you instruct CloudFormation to leave the resources in place instead of removing them when there's a failure during the stack update or creation process. As a result, the EC2 instance will not be terminated, and you can access the logs directly from the instance after examining the failure reason. This choice allows for post-failure troubleshooting, as the instance remains intact, and you can investigate the logs or configuration issues without losing the data or context that may help to resolve the problem. Other options such as using OnFailure=ROLLBACK would lead to the termination of the instance and the removal of associated resources, thereby making log retrieval impossible. Changing the termination behavior in EC2 settings or specifying an alternate region for log storage does not directly address the problem of accessing logs upon instance failure. Instead, those actions don't preserve the instance for log examination.