AWS EC2 Instance Cost-Saving: Automatic Start/Stop | DOP-C01 Exam Answer

Automating Start and Stop of EC2 Instances with "cost-saving" Tag | AWS DOP-C01 Exam Solution

Prev Question Next Question

Question

You work in a large organization and manage hundreds of EC2 instances in both non-production and production environments.

To reduce cost, you want to automatically stop and start some non-production EC2 instances at regular intervals.

For example, these instances should be stopped at 10:00PM every night and started at 6:30AM every morning.

All the selected EC2 instances already have a special tag called "cost-saving"

Which of the following actions would you choose to achieve the requirement? (Select TWO.)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answers : B and D.

Option A is incorrect because a single CloudWatch Event rule cannot have two cron expressions.

You would need two CloudWatch rules.

One rule is triggered every 10:00PM and the other one is scheduled every 6:30AM.

Option B is CORRECT because you can create two Lambda functions that find instances based on the "cost-saving" tag and then stop or start them.

These Lambda functions can be configured as targets in the related CloudWatch Event rules mentioned in Option.

D.Option C is incorrect because EC2 Savings Plan is a flexible pricing model if you commit to a certain amount of EC2 usage.

However, it cannot start or stop instances.

Option D is CORRECT because with the CloudWatch Event rules, you can periodically trigger a Lambda function to stop or start the selected instances.

Option E is incorrect because not every EC2 instance is suitable to be put in an Auto Scaling group.

Besides, as there may be a large number of non-production instances with the tag, it is inappropriate to put all the selected instances in ASGs.

Reference:

https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/

To automatically stop and start some non-production EC2 instances at regular intervals, the following actions can be taken:

A. Create a CloudWatch Event rule that is triggered periodically with two cron expressions.

This option is partially correct. CloudWatch Events can be used to trigger AWS Lambda functions, which can be used to stop and start EC2 instances. However, only creating a CloudWatch Event rule is not enough. The rule needs to be configured with two cron expressions that specify when to trigger the Lambda functions to stop and start the EC2 instances. Additionally, the Lambda functions must be created and configured to work with the EC2 instances that have the "cost-saving" tag.

B. Create two Lambda functions that are used to stop and start the EC2 instances with the "cost-saving" tag.

This option is also partially correct. Creating Lambda functions that stop and start EC2 instances is one way to achieve the requirement. However, as mentioned earlier, the Lambda functions must be triggered at specific times using cron expressions, and they must be configured to work with the EC2 instances that have the "cost-saving" tag.

C. Configure an EC2 Savings Plan that stops instances at 10:00PM and starts instances at 6:30AM if the instances have the "cost-saving" tag.

This option is incorrect. An EC2 Savings Plan is a pricing model that provides a discount on EC2 usage in exchange for a commitment to use a specific amount of EC2 usage over a term. It does not provide a way to automatically stop and start EC2 instances at specific times.

D. Configure two CloudWatch Event rules that self-trigger on an automated schedule using cron expressions. Add the Lambda function as the target.

This option is similar to option A, but it includes the additional step of adding the Lambda function as the target for the CloudWatch Event rules. This option is a correct way to achieve the requirement.

E. Add the instances under multiple Auto Scaling groups. Create a scheduled scaling policy that reduces the desired number to 0 at 10:00PM and increases the desired number to 1 at 6:30AM.

This option is also a correct way to achieve the requirement. However, it involves setting up Auto Scaling groups and creating scheduled scaling policies, which may be more complex than options A and B.

In summary, the two correct options to achieve the requirement are:

  • A. Create a CloudWatch Event rule that is triggered periodically with two cron expressions. Create the Lambda functions and configure them to work with the EC2 instances that have the "cost-saving" tag.
  • D. Configure two CloudWatch Event rules that self-trigger on an automated schedule using cron expressions. Add the Lambda function as the target.