Question #648
A company operates its application in the us-east-1 Region with separate accounts for development, staging, and production environments. All environments utilize stateful Amazon EC2 instances and Amazon RDS PostgreSQL databases ranging from 600 GB to 900 GB. The development and staging teams operate during business hours on weekdays, while production runs continuously. The company aims to minimize costs without increasing operational overhead. All resources are tagged with an 'Environment' key indicating their respective environment.
What should a solutions architect recommend to achieve cost reduction with the LEAST operational effort?
Create an Amazon EventBridge rule that triggers daily. Configure it to invoke a single AWS Lambda function that starts or stops instances based on the tag, day, and time.
Create an Amazon EventBridge rule that triggers every weekday evening to invoke an AWS Lambda function stopping instances based on the tag. Create a second rule triggering every weekday morning to invoke another Lambda function starting instances based on the tag.
Create an Amazon EventBridge rule that triggers every weekday evening to invoke a Lambda function terminating instances based on the tag. Create a second rule triggering every weekday morning to invoke another Lambda function restoring instances from backups based on the tag.
Create an Amazon EventBridge rule that triggers hourly. Configure it to invoke a single Lambda function that terminates or restores instances from backups based on the tag, day, and time.
Explanation
Option B is correct because:
1. State Preservation: Stopping (not terminating) EC2 instances retains their state, which is critical for stateful applications. Options C and D incorrectly suggest terminating instances, which destroys data.
2. Operational Simplicity: Two EventBridge rules (one for stopping in the evening, one for starting in the morning) with separate Lambda functions are easier to manage than a single Lambda with time-based logic (Option A). This reduces code complexity and potential errors.
3. Cost Optimization: Stopping non-production instances during off-hours reduces EC2 and RDS costs (RDS can be stopped separately if configured).
4. Tag-Based Automation: Using the 'Environment' tag ensures only development/staging resources are targeted, leaving production untouched.
Other options fail because:
- A: A single daily Lambda would require internal time-check logic, increasing complexity.
- C/D: Terminating instances loses state, and restoring from backups adds overhead.
Key Points:
- Use start/stop (not terminate) for stateful instances.
- Separate EventBridge rules for start/stop times simplify automation.
- Tags enable environment-specific resource management.
Answer
The correct answer is: B