AWS CodeDeploy In-Place Deployment: Configuration and Best Practices

Using Load Balancer and Autoscaling for Highly Available and Elastic Environment

Prev Question Next Question

Question

CodeDeploy is being used by a small company for its project.

This project aims to analyze the customers' behaviors on how to choose new cars.

The team decides to use a load balancer and autoscaling for its EC2 instances as the project needs a highly available and elastic environment.

And at least 4 instances are supposed to work at the same time and the number may reach at 8 during the peak hour when there are some sales activities such as at Black Friday.

The company's AWS engineer wants to use the in-place deployment.

What below items should the AWS engineer do before creating the CodeDeploy Deployment Group in AWS console? Select 3.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answer - A , B and.

D.Options A and B are correct.

Please refer to the below AWS Doc Link:

https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-in-place.html

Option D is correct.

Please see the below screenshot.

Option E is incorrect: because tags are not required if the deployment target is the autoscaling group.

You could select the autoscaling group name as the target.

Please notice that if the target is EC2 instances, tags are needed in order for CodeDeploy to understand which instances to deploy to.

In-Place Deployments

During an in-place deployment, a load balancer prevents internet traffic from being routed to an
instance while itis being deployed to, and then makes the instance available for traffic again after the

deployment to that instance is complete.

Ia load balancer isn't used during an in-place deployment, internet traffic may still be directed to
an instance during the deployment process. As a result, your customers might encounter broken,
incomplete, or outdated web applications. When you use an Elastic Load Balancing load balancer with an
in-place deployment, instances in a deployment group are deregistered from a load balancer, updated
with the latest application revision, and then reregistered with the load balancer as part of the same

deployment group after the deployment is successful.

For an in-place deployment, you can specify a Classic Load Balancer, Application Load Balancer,
‘or Network Load Balancer. You can specify the load balancer as part of the deployment group's
configuration, or use a script provided by CodeDeploy to implement the load balancer.

Sure, I'd be happy to provide a detailed explanation of the items that the AWS engineer should do before creating the CodeDeploy Deployment Group in AWS console.

  1. Make sure that you have a service role that trusts AWS CodeDeploy with correct permissions. This should be done before creating the Deployment Group in CodeDeploy. IAM should be involved for that by creating a new role, and the role type is AWS Service.

When using CodeDeploy, a service role is required to allow CodeDeploy to interact with AWS resources such as EC2 instances, load balancers, and Auto Scaling groups. The service role should have the correct permissions to perform the required actions on these resources. Therefore, before creating the CodeDeploy Deployment Group in AWS console, the AWS engineer should make sure that there is a service role in place that trusts CodeDeploy and has the necessary permissions to interact with the AWS resources involved in the deployment.

To create a new service role, the AWS engineer can use the IAM console or AWS CLI. The AWS engineer should make sure to grant the necessary permissions to the service role based on the requirements of the deployment.

  1. Prepare an autoscaling group with Min 4 and Max 8 instances. Make sure that the autoscaling group has the correct autoscaling launch configurations attached. You can use the prebaked AMI to install some configuration packages for the instances.

For a highly available and elastic environment, it is recommended to use an Auto Scaling group in combination with a load balancer. An Auto Scaling group automatically scales the number of instances based on the demand, while a load balancer distributes the traffic across the instances.

Before creating the CodeDeploy Deployment Group, the AWS engineer should prepare an Auto Scaling group with the desired minimum and maximum number of instances. In this case, the minimum is 4 and the maximum is 8. The AWS engineer should also ensure that the Auto Scaling group has the correct launch configuration attached. A launch configuration specifies the instance type, AMI, security groups, and other settings for the instances in the Auto Scaling group.

To prepare the launch configuration, the AWS engineer can use a prebaked AMI with some configuration packages installed. The AWS engineer can create the AMI using an EC2 instance, install the required packages, and then create an AMI from the instance.

  1. Make sure the correct SNS topic is created because when CodeDeploy Deployment Group is being created, one SNS topic is required to subscribe to the CodeDeploy application, which is a mandatory step.

CodeDeploy uses Amazon SNS (Simple Notification Service) to send notifications about the deployment status. Therefore, before creating the CodeDeploy Deployment Group, the AWS engineer should make sure that the correct SNS topic is created.

When creating the CodeDeploy Deployment Group, the AWS engineer needs to provide an SNS topic to subscribe to the CodeDeploy application. This is a mandatory step and ensures that notifications about the deployment status are sent to the specified topic.

To create an SNS topic, the AWS engineer can use the SNS console or AWS CLI. The AWS engineer should make sure to grant the necessary permissions to the SNS topic based on the requirements of the deployment.

  1. Make sure that the Elastic Load Balancer is already set up, no matter it is a Classic Load Balancer, Application Load Balancer, or Network Load Balancer as the ELB will be used in the CodeDeploy Deployment Group.

As mentioned earlier, a load balancer is recommended for a highly available and elastic environment. Therefore, before creating the CodeDeploy Deployment Group, the AWS engineer should make sure that the load balancer is already set up.

There are three types of load balancers in AWS: Classic Load Balancer, Application Load Balancer, and Network Load Balancer. The AWS engineer should choose the appropriate