Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam AWS Certified Solutions Architect - Professional All Questions

View all questions & answers for the AWS Certified Solutions Architect - Professional exam

Exam AWS Certified Solutions Architect - Professional topic 1 question 798 discussion

A company is running an application on several Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer. The load on the application varies throughout the day, and EC2 instances are scaled in and out on a regular basis. Log files from the EC2 instances are copied to a central
Amazon S3 bucket every 15 minutes. The security team discovers that log files are missing from some of the terminated EC2 instances.
Which set of actions will ensure that log files are copied to the central S3 bucket from the terminated EC2 instances?

  • A. Create a script to copy log files to Amazon S3, and store the script in a file on the EC2 instance. Create an Auto Scaling lifecycle hook and an Amazon EventBridge (Amazon CloudWatch Events) rule to detect lifecycle events from the Auto Scaling group. Invoke an AWS Lambda function on the autoscaling:EC2_INSTANCE_TERMINATING transition to send ABANDON to the Auto Scaling group to prevent termination, run the script to copy the log files, and terminate the instance using the AWS SDK.
  • B. Create an AWS Systems Manager document with a script to copy log files to Amazon S3. Create an Auto Scaling lifecycle hook and an Amazon EventBridge (Amazon CloudWatch Events) rule to detect lifecycle events from the Auto Scaling group. Invoke an AWS Lambda function on the autoscaling:EC2_INSTANCE_TERMINATING transition to call the AWS Systems Manager API SendCommand operation to run the document to copy the log files and send CONTINUE to the Auto Scaling group to terminate the instance.
  • C. Change the log delivery rate to every 5 minutes. Create a script to copy log files to Amazon S3, and add the script to EC2 instance user data. Create an Amazon EventBridge (Amazon CloudWatch Events) rule to detect EC2 instance termination. Invoke an AWS Lambda function from the EventBridge (CloudWatch Events) rule that uses the AWS CLI to run the user-data script to copy the log files and terminate the instance.
  • D. Create an AWS Systems Manager document with a script to copy log files to Amazon S3. Create an Auto Scaling lifecycle hook that publishes a message to an Amazon Simple Notification Service (Amazon SNS) topic. From the SNS notification, call the AWS Systems Manager API SendCommand operation to run the document to copy the log files and send ABANDON to the Auto Scaling group to terminate the instance.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
Reference:
https://docs.aws.amazon.com/autoscaling/ec2/userguide/configuring-lifecycle-hook-notifications.html

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
DLML
Highly Voted 2 years, 8 months ago
B is correct. Check out this aws blog. https://aws.amazon.com/blogs/infrastructure-and-automation/run-code-before-terminating-an-ec2-auto-scaling-instance/
upvoted 6 times
...
asfsdfsdf
Most Recent 2 years, 2 months ago
Selected Answer: B
Only A or B are valid I will choose B C - will drop logs if the instance is terminated D - not mention which transition to use A - is incorrect abandon will not stop the instance from terminating, so the script will not be executed
upvoted 2 times
...
ravisar
2 years, 6 months ago
B is correct. The difference between B and D are 1) SNS vs Event bridge 2) Life Cycle Abandon vs Continue. The SNS and Event bridge will work. For abandon vs Continue - (Action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure occur). You want to continue even if there is a time out, instead of abandoning the log file copying.
upvoted 4 times
...
saeidp
2 years, 8 months ago
B is correct. System Manager, EC2_INSTANCE_TERMINATING plus CONTINUE are the keywords
upvoted 2 times
...
tkanmani76
2 years, 8 months ago
D is right - https://docs.aws.amazon.com/autoscaling/ec2/userguide/adding-lifecycle-hooks.html - Refer to Default Result section - If the instance is terminating, both abandon and continue allow the instance to terminate. However, abandon stops any remaining actions, such as other lifecycle hooks, and continue allows any other lifecycle hooks to complete.
upvoted 2 times
...
m0h3n
2 years, 8 months ago
Ans: B SSM document is reliable way to copy the data from EC2 instance.
upvoted 3 times
...
Smartphone
2 years, 9 months ago
Looks like the Answer is A
upvoted 1 times
Smartphone
2 years, 9 months ago
Changing my answer here. B looks more close. The System Manager Document (script) to copy and run it through the lambda function, is the correct solution. https://github.com/aws-samples/aws-lambda-lifecycle-hooks-function https://github.com/aws-samples/aws-lambda-lifecycle-hooks-function/blob/master/cloudformation/template.yaml
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...