What should a solutions architect recommend to automate the application deployment process with the LEAST amount of operational overhead?
Configure Amazon EventBridge to invoke an AWS Lambda function when a new EC2 instance is launched into the Auto Scaling group. Code the Lambda function to associate the EC2 instances with the CodeDeploy deployment group.
Write a script to suspend Amazon EC2 Auto Scaling operations before the deployment of new code. When the deployment is complete, create a new AMI and configure the Auto Scaling group’s launch template to use the new AMI for new launches. Resume Amazon EC2 Auto Scaling operations.
Create a new AWS CodeBuild project that creates a new AMI that contains the new code. Configure CodeBuild to update the Auto Scaling group’s launch template to the new AMI. Run an Amazon EC2 Auto Scaling instance refresh operation.
Create a new AMI that has the CodeDeploy agent installed. Configure the Auto Scaling group’s launch template to use the new AMI. Associate the CodeDeploy deployment group with the Auto Scaling group instead of the EC2 instances.
Explanations:
Using Amazon EventBridge and AWS Lambda to associate EC2 instances with the CodeDeploy deployment group adds complexity and operational overhead, as the Lambda function must be maintained. Additionally, AWS CodeDeploy can automatically manage instance association when linked directly to the Auto Scaling group.
Suspending and resuming Auto Scaling introduces significant manual steps, which is inefficient. While creating an AMI with new code and updating the launch template could work, this approach involves complex steps and delays scaling events during deployments.
While CodeBuild can create a new AMI and update the launch template, this approach adds extra steps by relying on CodeBuild and an instance refresh. This solution is less efficient and adds unnecessary overhead compared to directly associating the Auto Scaling group with CodeDeploy.
Creating an AMI with the CodeDeploy agent pre-installed and associating the Auto Scaling group with CodeDeploy directly is the simplest and most automated solution. This minimizes operational overhead by letting CodeDeploy handle instance registration automatically.