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

Exam AWS Certified DevOps Engineer - Professional DOP-C02 All Questions

View all questions & answers for the AWS Certified DevOps Engineer - Professional DOP-C02 exam

Exam AWS Certified DevOps Engineer - Professional DOP-C02 topic 1 question 28 discussion

A developer is maintaining a fleet of 50 Amazon EC2 Linux servers. The servers are part of an Amazon EC2 Auto Scaling group, and also use Elastic Load Balancing for load balancing.
Occasionally, some application servers are being terminated after failing ELB HTTP health checks. The developer would like to perform a root cause analysis on the issue, but before being able to access application logs, the server is terminated.
How can log collection be automated?

  • A. Use Auto Scaling lifecycle hooks to put instances in a Pending:Wait state. Create an Amazon CloudWatch alarm for EC2 Instance Terminate Successful and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
  • B. Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an AWS Config rule for EC2 Instance-terminate Lifecycle Action and trigger a step function that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
  • C. Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon CloudWatch subscription filter for EC2 Instance Terminate Successful and trigger a CloudWatch agent that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
  • D. Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
madperro
Highly Voted 1 year, 5 months ago
Selected Answer: D
D is the easiest solution.
upvoted 10 times
...
Ravi_Bulusu
Most Recent 1 week, 1 day ago
Option A is the most efficient and straightforward approach to automate log collection and prevent premature termination of EC2 instances by using Auto Scaling lifecycle hooks, CloudWatch alarms, Lambda functions, and SSM to gather and store logs in Amazon S3 before the instance is terminated.
upvoted 1 times
...
Saudis
1 week, 6 days ago
it is D not C because CloudWatch agent can not invokes a script
upvoted 1 times
...
jamesf
3 months, 3 weeks ago
Selected Answer: D
D as the EC2 is Terminating and Cloudwatch Agent should be not running and cannot collect the logs
upvoted 1 times
...
Rahul369
5 months, 1 week ago
Selected Answer: C
It must be 'C' as CloudWatch Agent will push the logs to a particular CloudWatch log group.
upvoted 1 times
...
dzn
9 months, 1 week ago
Selected Answer: D
Terminating:Wait refers to a state in which an instance is determined to be terminated by the Auto Scaling group as part of the termination process and is temporarily put on hold before it is actually terminated. This state pauses the termination process and provides an opportunity to perform custom actions (logging, graceful shutdown, data backup, etc).
upvoted 2 times
hoazgazh
7 months, 2 weeks ago
why not C bro
upvoted 1 times
...
...
thanhnv142
10 months ago
D is correct: Using Eventbridge in combination with lambda is a common practice. A: Cloudwatch alarm only alert, no action so it cannot trigger lambda (when this question came out, it could not) B: AWS config rule cannot triger a script. C: cloudwatch agent itself does not have any direct action on the host but collecting logs
upvoted 4 times
...
Jaguaroooo
10 months, 3 weeks ago
C is also a good choice in this question. Why? you need to have a CW agent installed on the hosts to be able to collect logs from the servers before termination.
upvoted 1 times
davdan99
10 months, 3 weeks ago
I think we can't select C because it says that it invokes the cloudwatch agent after the EC2 instance is terminated. It can't collect the logs from terminated EC2 Instance.
upvoted 2 times
...
...
bcx
1 year, 6 months ago
Selected Answer: D
D is the correct one IMHO. ASG actions are not logged to cloudwatch logs to use a filter, and if so it would be complicated to extract the data. The canonical way is to rely in an EventBridge event.
upvoted 3 times
...
levster
1 year, 6 months ago
D "When a scale-in event occurs, a lifecycle hook pauses the instance before it is terminated and sends you a notification using Amazon EventBridge. While the instance is in the wait state, you can invoke an AWS Lambda function or connect to the instance to download logs or other data before the instance is fully terminated. " https://aws.amazon.com/blogs/infrastructure-and-automation/run-code-before-terminating-an-ec2-auto-scaling-instance/
upvoted 4 times
...
vherman
1 year, 6 months ago
Selected Answer: D
D for sure 100%
upvoted 1 times
...
haazybanj
1 year, 6 months ago
Selected Answer: D
D. Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected. With this solution, you can use an Auto Scaling lifecycle hook to put instances in a wait state before termination. This provides an opportunity to collect logs before the instance is terminated. The solution can use an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action to trigger an AWS Lambda function that will execute an SSM Run Command script. The script can collect logs and push them to Amazon S3 before completing the lifecycle action and allowing the instance to terminate. This solution provides a way to collect logs before instances are terminated, allowing for root cause analysis of issues.
upvoted 4 times
...
ParagSanyashiv
1 year, 7 months ago
Selected Answer: D
D seems to be more relevant for this scenario
upvoted 1 times
...
henryyvr
1 year, 7 months ago
Note that there is a similar question on Tutorial Dojo and the answer is to "trigger cloudwatch agent"
upvoted 1 times
ipsingh
1 year, 6 months ago
read this link and you will understand that C is wrong option- https://aws.amazon.com/blogs/infrastructure-and-automation/run-code-before-terminating-an-ec2-auto-scaling-instance/
upvoted 1 times
...
...
henryyvr
1 year, 7 months ago
Selected Answer: C
should be C
upvoted 2 times
beanxyz
1 year, 2 months ago
No way. Cloudwatch subscription filter is normally used to send cloudwatch log to kinesis firehose stream so that it can be consumed by other tools such as Splunk. If you need to invoke a lambda, the easiest way is to use event rule.
upvoted 2 times
...
...
ele
1 year, 7 months ago
Selected Answer: D
D sure
upvoted 1 times
...
alce2020
1 year, 7 months ago
Selected Answer: D
I think is D
upvoted 1 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 ...