SOA-C02 Question 161
Select 3You are managing an AWS environment and need to automate the process of stopping EC2 instances that have been running for more than 7 days. You want to implement this solution using AWS native services while ensuring it runs on a daily schedule. Which combination of steps will achieve this?
- A
Create an Amazon EventBridge rule with a cron expression to trigger daily.
- B
Create an AWS Lambda function that identifies EC2 instances running for more than 7 days and stops them.
- C
Use AWS Config to create a custom rule that stops EC2 instances older than 7 days.
- D
Attach the Lambda function to the EventBridge rule as the target.
- E
Use AWS Systems Manager to define a maintenance window that stops EC2 instances older than 7 days.
Show answer and explanation
Correct answers: A, B, D
Explanation
To automate the stopping of EC2 instances running for more than 7 days, you can use Amazon EventBridge to schedule a daily trigger and a Lambda function to perform the logic of identifying and stopping the instances. The EventBridge rule must be configured to invoke the Lambda function as its target. This approach provides a simple and effective solution using AWS native services while adhering to best practices for task scheduling and automation.
- A. Correct.
Correct: EventBridge can be used to create rules with cron expressions for scheduled tasks, such as triggering a Lambda function daily.
- B. Correct.
Correct: AWS Lambda can execute the logic to identify and stop EC2 instances running for more than 7 days.
- C. Incorrect.
Incorrect: AWS Config monitors resource compliance but does not natively stop EC2 instances. It is not suitable for this use case.
- D. Correct.
Correct: The Lambda function must be set as the target of the EventBridge rule to execute the stop operation when the rule is triggered.
- E. Incorrect.
Incorrect: AWS Systems Manager maintenance windows are for scheduling operational tasks but are not directly linked to this specific automation scenario.