You have an on-premise virtual machine and you create a replication job in AWS Server Migration Service (SMS) to migrate the VM to AWS.
Whenever an AMI is created from the SMS job, you need to launch an EC2 instance with the AMI and trigger a Jenkins job to perform the automation testing.
The instance will be terminated after the testing is finished.
Which method would you use to create the EC2 instance automatically for the testing?
Click on the arrows to vote for the correct answer
A. B. C. D. E.Correct Answer - D.
The combinations of CloudWatch Event rule and Lambda function can automatically launch EC2 instances with newly generated AMIs from SMS.
Check the details in https://docs.aws.amazon.com/server-migration-service/latest/userguide/cwe-sms.html.
Option A is incorrect: The Server Migration Service replication job generates an AMI after the job is finished.
However, it does not automatically launch EC2 instances.
Users have to do that by themselves.
Option B is incorrect: Because the Server Migration Service cannot send messages to an SNS topic.
Users should configure a CloudWatch Event rule to monitor the SMS job.
Option C is incorrect: Because AMIs generated from SMS do not have the AWS:SMS tag.
The CloudWatch Event rule should be used to check the AWS SMS job state change events.
Option D is CORRECT: The CloudWatch Event rule can monitor the following SMS events:
{
"source": [
"aws.sms"
],
"detail-type": [
"Server Migration Job State Change"
]
}
Then the Lambda function is triggered to launch a new instance using the AMI.
The requirement is to automatically create an EC2 instance for automation testing whenever an AMI is created from an AWS Server Migration Service (SMS) replication job. Once the testing is done, the instance needs to be terminated. To achieve this, there are several options to consider:
A. Configure the Server Migration Service replication job to automatically launch an EC2 instance with a launch template when the job finishes. This option is not suitable as it will launch an EC2 instance only when the replication job finishes, but the requirement is to launch an instance when an AMI is created.
B. Configure the Server Migration Service to send a message to an SNS notification with the AMI ID. This option only sends a notification with the AMI ID, but it does not automatically create an EC2 instance.
C. Set up a Lambda function as the subscriber to launch an EC2 instance. This option involves setting up a Lambda function that subscribes to the SNS topic that receives the AMI ID notification. When a message is received, the Lambda function will launch an EC2 instance with the AMI and trigger the Jenkins job. After the testing is complete, the Lambda function can terminate the instance. However, this approach can be complex and may require additional permissions to be set up for the Lambda function to interact with the AWS services involved.
D. Configure a CloudWatch Event to monitor newly generated AMIs with the tag AWS:SMS. Use a Lambda function to create an EC2 instance and pass the instance ID to the Jenkins job. This option involves configuring a CloudWatch Event that monitors newly generated AMIs with the AWS:SMS tag. When a new AMI is detected, a Lambda function is triggered, which creates an EC2 instance with the AMI and passes the instance ID to the Jenkins job. After the testing is complete, the Lambda function can terminate the instance. This approach is simpler than option C as it does not require setting up an SNS topic, and the Lambda function can be configured with minimal permissions.
E. Create a CloudWatch Event rule to monitor the AWS SMS job state changes. Use a Lambda function to get the new AMI ID and launch an EC2 instance. This option involves creating a CloudWatch Event rule that monitors the state changes of the AWS SMS job. When the job completes and a new AMI is created, a Lambda function is triggered, which gets the new AMI ID and launches an EC2 instance with the AMI. After the testing is complete, the Lambda function can terminate the instance. This approach is similar to option D but may be less efficient as it involves monitoring job state changes rather than monitoring AMI creation events directly.
Based on the requirements, option D is the most suitable approach. It provides a simple and efficient way to launch an EC2 instance automatically when a new AMI is created from the SMS replication job, and it can be easily integrated with the Jenkins job for automation testing.