

# Working with deployment groups in CodeDeploy
<a name="deployment-groups"></a>

You can specify one or more deployment groups for a CodeDeploy application. Each application deployment uses one of its deployment groups. The deployment group contains settings and configurations used during the deployment. Most deployment group settings depend on the compute platform used by your application. Some settings, such as rollbacks, triggers, and alarms can be configured for deployment groups for any compute platform.

## Deployment groups in Amazon ECS compute platform deployments
<a name="deployment-group-ecs"></a>

In an Amazon ECS deployment, a deployment group specifies the Amazon ECS service, load balancer, optional test listener, and two target groups. It also specifies when to reroute traffic to the replacement task set and when to terminate the original task set and Amazon ECS application after a successful deployment.

## Deployment groups in AWS Lambda compute platform deployments
<a name="deployment-group-lambda"></a>

In an AWS Lambda deployment, a deployment group defines a set of CodeDeploy configurations for future deployments of an AWS Lambda function. For example, the deployment group specifies how to route traffic to a new version of a Lambda function. It also might specify alarms and rollbacks. A single deployment in an AWS Lambda deployment group can override one or more group configurations.

## Deployment groups in EC2/On-Premises Compute Platform deployments
<a name="deployment-group-server"></a>

In an EC2/On-Premises deployment, a deployment group is a set of individual instances targeted for a deployment. A deployment group contains individually tagged instances, Amazon EC2 instances in Amazon EC2 Auto Scaling groups, or both. 

In an in-place deployment, the instances in the deployment group are updated with the latest application revision. 

In a blue/green deployment, traffic is rerouted from one set of instances to another by deregistering the original instances from one or more load balancers and registering a replacement set of instances that typically has the latest application revision already installed.

You can associate more than one deployment group with an application in CodeDeploy. This makes it possible to deploy an application revision to different sets of instances at different times. For example, you might use one deployment group to deploy an application revision to a set of instances tagged `Test` where you ensure the quality of the code. Next, you deploy the same application revision to a deployment group with instances tagged `Staging` for additional verification. Finally, when you are ready to release the latest application to customers, you deploy to a deployment group that includes instances tagged `Production`.

You can also use multiple tag groups to further refine the criteria for the instances included in a deployment group. For information, see [Tagging instances for deployment groups in CodeDeploy](instances-tagging.md).

When you use the CodeDeploy console to create an application, you configure its first deployment group at the same time. When you use the AWS CLI to create an application, you create its first deployment group in a separate step.

To view a list of deployment groups already associated with your AWS account, see [View deployment group details with CodeDeploy](deployment-groups-view-details.md). 

For information about Amazon EC2 instance tags, see [Working with tags using the console](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#Using_Tags_Console). For information about on-premises instances, see [Working with on-premises instances for CodeDeploy](instances-on-premises.md). For information about Amazon EC2 Auto Scaling, see [Integrating CodeDeploy with Amazon EC2 Auto Scaling](integrations-aws-auto-scaling.md).

## Topics
<a name="topiclist-deployment-groups"></a>
+ [Create a deployment group with CodeDeploy](deployment-groups-create.md)
+ [View deployment group details with CodeDeploy](deployment-groups-view-details.md)
+ [Change deployment group settings with CodeDeploy](deployment-groups-edit.md)
+ [Configure advanced options for a deployment group](deployment-groups-configure-advanced-options.md)
+ [Delete a deployment group with CodeDeploy](deployment-groups-delete.md)

# Create a deployment group with CodeDeploy
<a name="deployment-groups-create"></a>

You can use the CodeDeploy console, the AWS CLI, the CodeDeploy APIs, or an CloudFormation template to create deployment groups. For information about using an CloudFormation template to create a deployment group, see [CloudFormation templates for CodeDeploy reference](reference-cloudformation-templates.md).

When you use the CodeDeploy console to create an application, you configure its first deployment group at the same time. When you use the AWS CLI to create an application, you create its first deployment group in a separate step.

As part of creating a deployment group, you must specify a service role. For more information, see [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md).

**Topics**
+ [Create a deployment group for an in-place deployment (console)](deployment-groups-create-in-place.md)
+ [Create a deployment group for an EC2/On-Premises blue/green deployment (console)](deployment-groups-create-blue-green.md)
+ [Create a deployment group for an Amazon ECS deployment (console)](deployment-groups-create-ecs.md)
+ [Set up a load balancer in Elastic Load Balancing for CodeDeploy Amazon EC2 deployments](deployment-groups-create-load-balancer.md)
+ [Set up a load balancer, target groups, and listeners for CodeDeploy Amazon ECS deployments](deployment-groups-create-load-balancer-for-ecs.md)
+ [Create a deployment group (CLI)](deployment-groups-create-cli.md)

# Create a deployment group for an in-place deployment (console)
<a name="deployment-groups-create-in-place"></a>

To use the CodeDeploy console to create a deployment group for an in-place deployment:

**Warning**  
Do not follow these steps if:  
You have not prepared your instances to be used in the first CodeDeploy deployment of an application. To set up your instances, follow the instructions in [Working with instances for CodeDeploy](instances.md), and then follow the steps in this topic.
You want to create a deployment group that uses a custom deployment configuration, but you have not yet created the deployment configuration. Follow the instructions in [Create a deployment configuration with CodeDeploy](deployment-configurations-create.md), and then follow the steps in this topic. 
You do not have a service role that trusts CodeDeploy with, at minimum, the trust and permissions described in [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md). To create and configure a service role, follow the instructions in [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md), and then follow the steps in this topic.
You want to select a Classic Load Balancer, Application Load Balancer, or Network Load Balancer in Elastic Load Balancing for the in-place deployment, but have not yet created it.

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, then choose **Applications**.

1. On the **Applications** page, choose the name of the application for which you want to create a deployment group.

1. On your application page, from the **Deployment groups** tab, choose **Create deployment group**.

1. In **Deployment group name**, enter a name that describes the deployment group.
**Note**  
If you want to use the same settings used in another deployment group (including the deployment group name; tags, Amazon EC2 Auto Scaling group names, or both; and the deployment configuration), specify those settings on this page. Although this new deployment group and the existing deployment group have the same name, CodeDeploy treats them as separate deployment groups, because they are each associated with separate applications.

1. In **Service role**, choose a service role that grants CodeDeploy access to your target instance.

1. In **Deployment type**, choose **In-place**.

1. In **Environment configuration**, do the following: 

   1. If you want to deploy your application to an Amazon EC2 Auto Scaling group, select **Amazon EC2 Auto Scaling groups**, and then choose the name of an Amazon EC2 Auto Scaling group to deploy your application revision to. When new Amazon EC2 instances are launched as part of an Amazon EC2 Auto Scaling group, CodeDeploy can deploy your revisions to the new instances automatically. You can add up to 10 Amazon EC2 Auto Scaling groups to a deployment group. For more information, see [Integrating CodeDeploy with Amazon EC2 Auto Scaling](integrations-aws-auto-scaling.md).

   1. 

      If you selected **Amazon EC2 Auto Scaling groups**, optionally select **Add a termination hook to Auto Scaling groups** to have CodeDeploy install a termination hook into your Auto Scaling group when you create or update the deployment group. When this hook is installed, CodeDeploy will perform termination deployments. For more information, see [Enabling termination deployments during Auto Scaling scale-in events](integrations-aws-auto-scaling.md#integrations-aws-auto-scaling-behaviors-hook-enable).

   1. If you want to tag your instances, select **Amazon EC2 instances** or **On-premises instances**. In the **Key** and **Value** fields, enter the values of the key-value pair you used to tag the instances. You can tag up to 10 key-value pairs in a single tag group.

      1. You can use wildcards in the **Value** field to identify all instances tagged in certain patterns, such as similar Amazon EC2 instance, cost center, and group names, and so on. For example, if you choose **Name** in the **Key** field and enter **GRP-\$1a** in the **Value** field, CodeDeploy identifies all instances that fit that pattern, such as **GRP-1a**, **GRP-2a**, and **GRP-XYZ-a**.

      1. The **Value** field is case sensitive. 

      1. To remove a key-value pair from the list, choose the remove icon.

      As CodeDeploy finds instances that match each specified key-value pair or Amazon EC2 Auto Scaling group name, it displays the number of matching instances. To see more information about the instances, click the number.

      If you want to refine the criteria for the deployed-to instances, choose **Add tag group** to create an tag group. You can create up to three tag groups with up to 10 key-value pairs each. When you use multiple tag groups in a deployment group, only instances that are identified by all the tag groups are included in the deployment group. That means an instance must match at least one of the tags in each of the groups to be included in the deployment group.

      For information about using tag groups to refine your deployment group, see [Tagging instances for deployment groups in CodeDeploy](instances-tagging.md).

1. In **Agent configuration with Systems Manager**, specify how you would like to install and update the CodeDeploy agent on the instances in your deployment group. For more information on the CodeDeploy agent, see [Working with the CodeDeploy agent](https://docs.aws.amazon.com/en_us/codedeploy/latest/userguide/codedeploy-agent.html). For more information about Systems Manager, see [What is Systems Manager?](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html)

   1. **Never**: Skip configuring the CodeDeploy installation with Systems Manager. Instances must have the agent installed to be used in deployments, so only choose this option if you will install the CodeDeploy agent another way.

   1. **Only once**: Systems Manager will install the CodeDeploy agent once on every instance in your deployment group.

   1. **Now and schedule updates**: Systems Manager will create an association with State Manager that installs the CodeDeploy agent on the schedule you configure. For more information about State Manager and associations, see [About State Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-state-about.html).

1. In **Deployment configuration**, choose a deployment configuration to control the rate at which instances are deployed to, such as one at a time or all at once. For more information about deployment configurations, see [Working with deployment configurations in CodeDeploy](deployment-configurations.md).

1. (Optional) In **Load balancer**, select **Enable load balancing**, and then from the lists, select the Classic Load Balancers, Application Load Balancer target groups, and Network Load Balancer target groups to manage traffic to the instances during the CodeDeploy deployment. You can select up to 10 Classic Load Balancers and 10 target groups, for a total of 20 items. Make sure that the Amazon EC2 instances that you want to deploy to are registered with the selected load balancers (Classic Load Balancers) or target groups (Application Load Balancers and Network Load Balancers).

   During a deployment, the original instances are deregistered from the selected load balancers and target groups to prevent traffic from being routed to these instances during the deployment. When the deployment is complete, each instance is re-registered with *all* the selected Classic Load Balancers and target groups.

   For more information about load balancers for CodeDeploy deployments, see [Integrating CodeDeploy with Elastic Load Balancing](integrations-aws-elastic-load-balancing.md).
**Warning**  
If you are configuring both Auto Scaling groups and an Elastic Load Balancing load balancers in this deployment group, and you want to [attach load balancers to the Auto Scaling groups](https://docs.aws.amazon.com/autoscaling/ec2/userguide/attach-load-balancer-asg.html), we recommend completing this attachment *before* creating the CodeDeploy deployment from this deployment group. Attempting to complete the attachment after creating the deployment may cause all the instances to become deregistered from the load balancers unexpectedly.

1. (Optional) Expand **Advanced** and configure any options you want to include in the deployment, such as Amazon SNS notification triggers, Amazon CloudWatch alarms, Auto Scaling options, or automatic rollbacks.

   For more information, see [Configure advanced options for a deployment group](deployment-groups-configure-advanced-options.md). 

1. Choose **Create deployment group**. 

# Create a deployment group for an EC2/On-Premises blue/green deployment (console)
<a name="deployment-groups-create-blue-green"></a>

To use the CodeDeploy console to create a deployment group for a blue/green deployment:

**Warning**  
Do not follow these steps if:  
You do not have instances with the CodeDeploy agent installed that you want to replace during the blue/green deployment process. To set up your instances, follow the instructions in [Working with instances for CodeDeploy](instances.md), and then follow the steps in this topic.
You want to create an application that uses a custom deployment configuration, but you have not yet created the deployment configuration. Follow the instructions in [Create a deployment configuration with CodeDeploy](deployment-configurations-create.md), and then follow the steps in this topic. 
You do not have a service role that trusts CodeDeploy with, at minimum, the trust and permissions described in [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md). To create and configure a service role, follow the instructions in [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md), and then follow the steps in this topic.
You have not created a Classic Load Balancer or an Application Load Balancer in Elastic Load Balancing for the registration of the instances in your replacement environment. For more information, see [Set up a load balancer in Elastic Load Balancing for CodeDeploy Amazon EC2 deployments](deployment-groups-create-load-balancer.md).

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, then choose **Applications**.

1. On the **Applications** page, choose the name of the application for which you want to create a deployment group.

1. On your application page, from the **Deployment groups** tab, choose **Create deployment group**.

1. In **Deployment group name**, enter a name that describes the deployment group.
**Note**  
If you want to use the same settings used in another deployment group (including the deployment group name, tags, Amazon EC2 Auto Scaling group names, and the deployment configuration), choose those settings on this page. Although this new deployment group and the existing deployment group have the same name, CodeDeploy treats them as separate deployment groups, because they are associated with separate applications.

1. In **Service role**, choose a service role that grants CodeDeploy access to your target instance.

1. In **Deployment type** choose **Blue/green**.

1. In **Environment configuration**, do the following:
   + Select the method to use to provide instances for your replacement environment. You have the following options:
     + **Automatically copy Amazon EC2 Auto Scaling group**: CodeDeploy creates an Amazon EC2 Auto Scaling group by copying one you specify.
     + **Manually provision instances**: You won't specify the instances for your replacement environment until you create a deployment. You must create the instances before you start the deployment. Instead, here you specify the instances you want to replace.
   + If you selected **Automatically copy Amazon EC2 Auto Scaling group**, optionally select **Add a termination hook to Auto Scaling groups** to have CodeDeploy install a termination hook into your Auto Scaling group when you create or update the deployment group. When this hook is installed, CodeDeploy will perform termination deployments. For more information, see [Enabling termination deployments during Auto Scaling scale-in events](integrations-aws-auto-scaling.md#integrations-aws-auto-scaling-behaviors-hook-enable).

1. In **Agent configuration with Systems Manager**, specify how you would like to install and update the CodeDeploy agent on the instances in your deployment group. For more information on the CodeDeploy agent, see [Working with the CodeDeploy agent](https://docs.aws.amazon.com/en_us/codedeploy/latest/userguide/codedeploy-agent.html). For more information about Systems Manager, see [What is Systems Manager?](https://docs.aws.amazon.com/systems-manager/latest/userguide/what-is-systems-manager.html)

   1. **Never**: Skip configuring the CodeDeploy installation with Systems Manager. Instances must have the agent installed to be used in deployments, so only choose this option if you will install the CodeDeploy agent another way.

   1. **Only once**: Systems Manager will install the CodeDeploy agent once on every instance in your deployment group.

   1. **Now and schedule updates**: Systems Manager will create an association with State Manager that installs the CodeDeploy agent on the schedule you configure. For more information about State Manager and associations, see [About State Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-state-about.html).

1. Depending on your choice in step 8, do one of the following:
   + If you chose **Automatically copy Amazon EC2 Auto Scaling group**: In **Amazon EC2 Auto Scaling group**, choose or enter the name of the Amazon EC2 Auto Scaling group you want to use as a template for the Amazon EC2 Auto Scaling group that is created for the instances in your replacement environment. The number of currently healthy instances in the Amazon EC2 Auto Scaling group you select is created in your replacement environment.
   + If you chose **Manually provision instances**: Select **Amazon EC2 Auto Scaling groups**, **Amazon EC2 Auto Scaling intances**, or both to specify instances to add to this deployment group. Enter Amazon EC2 Auto Scaling tag values or Amazon EC2 Auto Scaling group names to identify the instances in your original environment (that is, the instances you want to replace or that are running the current application revision). 

1. In **Load balancer**, select **Enable load balancing**, and then from the lists, select the Classic Load Balancers, Application Load Balancer target groups, and Network Load Balancer target groups that you want to register your replacement Amazon EC2 instances with. Each replacement instance will be registered with *all* the selected Classic Load Balancers and target groups. You can select up to 10 Classic Load Balancers and 10 target groups, for a total of 20 items.

   Traffic will be rerouted from the original to the replacement instances according to your chosen **Traffic rerouting** and **Deployment configuration** settings.

   For more information about load balancers for CodeDeploy deployments, see [Integrating CodeDeploy with Elastic Load Balancing](integrations-aws-elastic-load-balancing.md).
**Warning**  
If you are configuring both Auto Scaling groups and Elastic Load Balancing load balancers in this deployment group, and you want to [attach the load balancers to Auto Scaling groups](https://docs.aws.amazon.com/autoscaling/ec2/userguide/attach-load-balancer-asg.html), we recommend completing this attachment *before* creating the CodeDeploy deployment from this deployment group. Attempting to complete the attachment after creating the deployment may cause all the instances to become deregistered from the load balancers unexpectedly.

1. In **Deployment settings**, review the default options for rerouting traffic to the replacement environment, which deployment configuration to use for the deployment, and how instances in the original environment are handled after the deployment.

   If you want to change the settings, continue to the next step. Otherwise, skip to step 14.

1. To change the deployment settings for the blue/green deployment, choose any of the following settings.    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-blue-green.html)

1. (Optional) In **Advanced**, configure options you want to include in the deployment, such as Amazon SNS notification triggers, Amazon CloudWatch alarms, Auto Scaling options, or automatic rollbacks.

   For information about specifying advanced options in deployment groups, see [Configure advanced options for a deployment group](deployment-groups-configure-advanced-options.md). 

1. Choose **Create deployment group**. 

# Create a deployment group for an Amazon ECS deployment (console)
<a name="deployment-groups-create-ecs"></a>

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, then choose **Applications**.

1.  From the **Applications table**, choose the name of the application associated with the deployment group you want to edit. 

1.  On your application page, from **Deployment groups**, choose the name of the deployment group you want to edit. 

1. On your application page, from the **Deployment groups** tab, choose **Create deployment group**. For more information about what you need to create a deployment group for an Amazon ECS deployment, see [Before you begin an Amazon ECS deployment](deployment-steps-ecs.md#deployment-steps-prerequisites-ecs). 

1. In **Deployment group name**, enter a name that describes the deployment group.
**Note**  
If you want to use the same settings used in another deployment group (including the deployment group name and the deployment configuration), choose those settings on this page. Although this new group and the existing group might have the same name, CodeDeploy treats them as separate deployment groups, because each is associated with a separate application.

1. In **Service role**, choose a service role that grants CodeDeploy access to Amazon ECS. For more information, see [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md).

1.  From **Load balancer name**, choose the name of the load balancer that serves traffic to your Amazon ECS service. 

1.  From **Production listener port**, choose the port and protocol for the listener that serves production traffic to your Amazon ECS service. 

1.  (Optional) From **Test listener port**, choose the port and protocol of a test listener that serves traffic to the replacement task set in your Amazon ECS service during deployment. You can specify one or more Lambda funtions in the AppSpec file that run during the `AfterAllowTestTraffic` hook. The functions can run validation tests. If a validation test fails, a deployment rollback is triggered. If the validation tests succeed, the next hook in the deployment lifecycle, `BeforeAllowTraffic`, is triggered. If a test listener port is not specified, nothing happens during the `AfterAllowTestTraffic` hook. For more information, see [AppSpec 'hooks' section for an Amazon ECS deployment](reference-appspec-file-structure-hooks.md#appspec-hooks-ecs). 

1. From **Target group 1 name** and **Target group 2 name**, choose the target groups used to route traffic during your deployment. CodeDeploy binds one target group to your Amazon ECS service's original task set and the other to its replacement task set. For more information, see [Target Groups for Your Application Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html). 

1.  Choose **Reroute traffic immediately** or **Specify when to reroute traffic** to determine when to reroute traffic to your updated Amazon ECS service. 

    If you choose **Reroute traffic immediately**, then the deployment automatically reroutes traffic after the replacement task set is provisioned. 

    If you choose **Specify when to reroute traffic**, then choose the number of days, hours, and minutes to wait after the replacement task set is successfully provisioned. During this wait time, validation tests in Lambda functions specified in the AppSpec file are executed. If the wait time expires before traffic is rerouted, then the deployment status changes to `Stopped`. 

1.  For **Original revision termination**, choose the number of days, hours, and minutes to wait after a successful deployment before the original task set in your Amazon ECS service is terminated. 

1. (Optional) In **Advanced**, configure any options you want to include in the deployment, such as Amazon SNS notification triggers, Amazon CloudWatch alarms, or automatic rollbacks.

   For more information, see [Configure advanced options for a deployment group](deployment-groups-configure-advanced-options.md). 

# Set up a load balancer in Elastic Load Balancing for CodeDeploy Amazon EC2 deployments
<a name="deployment-groups-create-load-balancer"></a>

Before you run any blue/green deployment, or an in-place deployment for which you want to specify an optional load balancer in the deployment group, you must have created at least one Classic Load Balancer, Application Load Balancer, or Network Load Balancer in Elastic Load Balancing. For blue/green deployments, you use that load balancer to register the instances that make up your replacement environment. Instances in your original environment can optionally be registered with this same load balancer. For in-place deployments, the load balancer is used to deregister instances that are being worked on by CodeDeploy, and reregister them when the work is complete.

CodeDeploy supports blue/green and in-place deployment to Amazon EC2 instances behind muliple load balancers. For example, assume you have 200 Amazon EC2 instances, where 100 of them are registered with 2 Classic Load Balancers, and another 100 of them are registered with 4 target groups in 2 Application Load Balancers. In this scenario, CodeDeploy will allow you to do blue/green and in-place deployments to all 200 instances, even though they're spread across 2 Classic Load Balancers, 2 Application Load Balancers, and 4 target groups.

CodeDeploy supports up to 10 Classic Load Balancers and 10 target groups, for a total of 20 items.

To configure one or more Classic Load Balancers, follow the instructions in [Tutorial: Create a Classic Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-getting-started.html) in *User Guide for Classic Load Balancers*. Note the following:
+ In **Step 2: Define Load Balancer**, in **Create LB Inside**, choose the same VPC you selected when you created your instances.
+ In **Step 5: Register EC2 Instances with Your Load Balancer**, select the instances currently in your deployment group (in-place deployments) or that you have designated to be in your original environment (blue/green deployments).
+ In **Step 7: Create and Verify Your Load Balancer**, make a note of the DNS address of your load balancer.

  For example, if you named your load balancer `my-load-balancer`, your DNS address appears in a format such as `my-load-balancer-1234567890.us-east-2.elb.amazonaws.com`.

To configure one or more Application Load Balancers, follow the instructions in one of the following topics:
+ [Create an Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-application-load-balancer.html)
+ [Tutorial: Create an Application Load Balancer using the AWS CLI](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/tutorial-application-load-balancer-cli.html)

To configure one or more Network Load Balancers, follow the instructions in one of the following topics:
+  [Create a Network Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/create-network-load-balancer.html) 
+  [Tutorial: Create a Network Load Balancer using the AWS CLI](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancer-cli.html) 

# Set up a load balancer, target groups, and listeners for CodeDeploy Amazon ECS deployments
<a name="deployment-groups-create-load-balancer-for-ecs"></a>

 Before you run a deployment using the Amazon ECS compute platform, you must create an Application Load Balancer or a Network Load Balancer, two target groups, and one or two listeners. This topic shows you how to create an Application Load Balancer. For more information, see [Before you begin an Amazon ECS deployment](deployment-steps-ecs.md#deployment-steps-prerequisites-ecs). 

 One of the target groups directs traffic to your Amazon ECS application's original task set. The other target group directs traffic to its replacement task set. During deployment, CodeDeploy creates a replacement task set and reroutes traffic from the original task set to the new one. CodeDeploy determines which target group is used for each task set. 

 A listener is used by your load balancer to direct traffic to your target groups. One production listener is required. You can specify an optional test listener that directs traffic to your replacement task set while you run validation tests. 

 The load balancer must use a VPC with two public subnets in different Availability Zones. The following steps show you how to confirm your default VPC, create an Amazon EC2 Application Load Balancer, and then create two target groups for your load balancer. For more information, see [Target groups for your network load balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html). 

## Verify your default VPC, public subnets, and security group
<a name="deployment-groups-create-load-balancer-for-ecs-verify-vpc"></a>

 This topic shows how to create an Amazon EC2 Application Load Balancer, two target groups, and two ports that can be used during an Amazon ECS deloyment. One of the ports is optional and needed only if you direct traffic to a test port for validation tests during your deployment. 

1. Sign in to the AWS Management Console and open the Amazon VPC console at [https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/).

1. Verify the default VPC to use. In the navigation pane, choose **Your VPCs**. Note which VPC shows **Yes** in the **Default VPC** column. This is your default VPC. It contains default subnets that you use.

1. Choose **Subnets**. Make a note of the subnet IDs of two subnets that show **Yes** in the **Default subnet** column. You use these IDs when you create your load balancer.

1. Choose each subnet, and then choose the **Description** tab. Verify that the subnets you want to use are in different Availability Zones.

1. Choose the subnets, and then choose the **Route Table** tab. To verify that each subnet you want to use is a public subnet, confirm that a row with a link to an internet gateway is included in the route table.

1. Sign in to the AWS Management Console and open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. From the navigation pane, choose **Security Groups**.

1. Verify the security group you want to use is available and make a note of its group ID (for example, **sg-abcd1234**). You use this when you create your load balancer.

## Create an Amazon EC2 Application Load Balancer, two target groups, and listeners (console)
<a name="deployment-groups-create-load-balancer-for-ecs-console"></a>

To use the Amazon EC2 console to create an Amazon EC2 Application Load Balancer:

1. Sign in to the AWS Management Console and open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Load Balancers**. 

1. Choose **Create Load Balancer**.

1. Choose **Application Load Balancer**, and then choose **Create**.

1. In **Name**, enter the name of your load balancer.

1. In **Scheme**, choose **internet-facing**.

1. In **IP address type**, choose **ipv4**.

1. (Optional) Configure a second listener port for your load balancer. You can run deployment validation tests using test traffic that is served to this port.

   1. Under **Load Balancer Protocol**, choose **Add listener**.

   1. Under **Load Balancer Protocol** for the second listener, choose **HTTP**. 

   1. Under **Load Balancer Port**, enter **8080**.

1. Under **Availability Zones**, in **VPC**, choose the default VPC, and then select the two default subnets you want to use.

1. Choose **Next: Configure Security Settings**.

1. Choose **Next: Configure Security Groups**.

1. Choose **Select an existing security group**, choose the default security group, and then make a note of its ID.

1. Choose **Next: Configure Routing**.

1. In **Target group**, choose **New target group**, and configure your first target group: 

   1. In **Name**, enter a target group name (for example, **target-group-1**).

   1. In **Target type**, choose **IP**.

   1. In **Protocol** choose **HTTP**. In **Port**, enter **80**.

   1. Choose **Next: Register Targets**.

1. Choose **Next: Review**, and then choose **Create**.

**To create a second target group for your load balancer**

1. After your load balancer is provisioned, open the Amazon EC2 console. In the navigation pane, choose **Target Groups**.

1. Choose **Create target group**.

1. In **Name**, enter a target group name (for example, **target-group-2**).

1. In **Target type**, choose **IP**.

1. In **Protocol** choose **HTTP**. In **Port**, enter **80**.

1. In **VPC**, choose the default VPC.

1. Choose **Create**.
**Note**  
You must have two target groups created for your load balancer in order for your Amazon ECS deployment to run. You use the ARN of one of your target groups when you create your Amazon ECS service. For more information, see [Step 4: Create an Amazon ECS service](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-blue-green.html#create-blue-green-taskdef) in the *Amazon ECS User Guide*.

## Create an Amazon EC2 Application Load Balancer, two target groups, and listeners (CLI)
<a name="deployment-groups-create-load-balancer-for-ecs-cli"></a>

To create an Application Load Balancer using the AWS CLI:

1. Use the [create-load-balancer](https://docs.aws.amazon.com/cli/latest/reference/elbv2/create-load-balancer.html) command to create an Application Load Balancer. Specify two subnets that aren't in the same Availability Zone and a security group.

   ```
   aws elbv2 create-load-balancer --name bluegreen-alb \
   --subnets subnet-abcd1234 subnet-abcd5678 --security-groups sg-abcd1234 --region us-east-1
   ```

   The output includes the Amazon Resource Name (ARN) of the load balancer, in the following format:

   ```
   arn:aws:elasticloadbalancing:region:aws_account_id:loadbalancer/app/bluegreen-alb/e5ba62739c16e642
   ```

1. Use the [create-target-group](https://docs.aws.amazon.com/cli/latest/reference/elbv2/create-target-group.html) command to create your first target group. CodeDeploy routes this target group's traffic to the original or the replacement task set in your service.

   ```
   aws elbv2 create-target-group --name bluegreentarget1 --protocol HTTP --port 80 \
   --target-type ip --vpc-id vpc-abcd1234 --region us-east-1
   ```

   The output includes the ARN of the first target group, in the following format:

   ```
   arn:aws:elasticloadbalancing:region:aws_account_id:targetgroup/bluegreentarget1/209a844cd01825a4
   ```

1. Use the [create-target-group](https://docs.aws.amazon.com/cli/latest/reference/elbv2/create-target-group.html) command to create your second target group. CodeDeploy routes target group's traffic to the task set that is not served by your first target group. For example, if your first target group routes traffic to the original task set, this target group routes traffic to the replacement task set.

   ```
   aws elbv2 create-target-group --name bluegreentarget2 --protocol HTTP --port 80 \
   --target-type ip --vpc-id vpc-abcd1234 --region us-east-1
   ```

   The output includes the ARN of the second target group, in the following format:

   ```
   arn:aws:elasticloadbalancing:region:aws_account_id:targetgroup/bluegreentarget2/209a844cd01825a4
   ```

1. Use the [create-listener](https://docs.aws.amazon.com/cli/latest/reference/elbv2/create-listener.html) command to create a listener with a default rule that forwards production traffic to port 80.

   ```
   aws elbv2 create-listener --load-balancer-arn arn:aws:elasticloadbalancing:region:aws_account_id:loadbalancer/app/bluegreen-alb/e5ba62739c16e642 \
   --protocol HTTP --port 80 \
   --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:region:aws_account_id:targetgroup/bluegreentarget1/209a844cd01825a4 --region us-east-1
   ```

   The output includes the ARN of the listener, in the following format:

   ```
   arn:aws:elasticloadbalancing:region:aws_account_id:listener/app/bluegreen-alb/e5ba62739c16e642/665750bec1b03bd4
   ```

1. (Optional) Use the [create-listener](https://docs.aws.amazon.com/cli/latest/reference/elbv2/create-listener.html) command to create a second listener with a default rule that forwards test traffic to port 8080. You can run deployment validation tests using test traffic that is served this port.

   ```
   aws elbv2 create-listener --load-balancer-arn arn:aws:elasticloadbalancing:region:aws_account_id:loadbalancer/app/bluegreen-alb/e5ba62739c16e642 \
   --protocol HTTP --port 8080 \
   --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:region:aws_account_id:targetgroup/bluegreentarget2/209a844cd01825a4 --region us-east-1
   ```

   The output includes the ARN of the listener, in the following format:

   ```
   arn:aws:elasticloadbalancing:region:aws_account_id:listener/app/bluegreen-alb/e5ba62739c16e642/665750bec1b03bd4
   ```

# Create a deployment group (CLI)
<a name="deployment-groups-create-cli"></a>

To use the AWS CLI to create a deployment group, call the [create-deployment-group](https://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment-group.html) command, specifying:
+ The application name. To view a list of application names, call the [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) command.
+ A name for the deployment group. A deployment group with this name is created for the specified application. A deployment group can only be associated with one application.
+ Information about the tags, tag groups, or Amazon EC2 Auto Scaling group names that identify the instances to be included in the deployment group.
+ The Amazon Resource Name (ARN) identifier of the service role that allows CodeDeploy to act on behalf of your AWS account when interacting with other AWS services. To get the service role ARN, see [Get the service role ARN (CLI)](getting-started-create-service-role.md#getting-started-get-service-role-cli). For more information about service roles, see [Roles terms and concepts](https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-toplevel.html#roles-about-termsandconcepts) in *IAM User Guide*.
+ Information about the type of deployment, either in-place or blue/green, to associate with the deployment group.
+ (Optional) The name of an existing deployment configuration. To view a list of deployment configurations, see [View deployment configuration details with CodeDeploy](deployment-configurations-view-details.md). If not specified, CodeDeploy uses a default deployment configuration.
+ (Optional) Commands to create a trigger that pushes notifications about deployment and instance events to those who are subscribed to an Amazon Simple Notification Service topic. For more information, see [Monitoring deployments with Amazon SNS event notifications](monitoring-sns-event-notifications.md).
+ (Optional) Commands to add existing CloudWatch alarms to the deployment group that are activated if a metric specified in an alarm falls below or exceeds a defined threshold.
+ (Optional) Commands for a deployment to roll back to the last known good revision when a deployment fails or a CloudWatch alarm is activated.
+ (Optional) Commands for a deployment to generate lifecycle event hooks during an Auto Scaling scale-in event. For more information, see [How Amazon EC2 Auto Scaling works with CodeDeploy](integrations-aws-auto-scaling.md#integrations-aws-auto-scaling-behaviors).
+ For in-place deployments:
  + (Optional) The names of the Classic Load Balancers, Application Load Balancers, or Network Load Balancers in Elastic Load Balancing that manage traffic to the instances during the deployment processes.
+ For blue/green deployments:
  + Configuration of the blue/green deployment process:
    + How new instances in the replacement environment are provisioned.
    + Whether to reroute traffic to the replacement environment immediately or wait a specified period for traffic to be rerouted manually.
    + Whether instances in the original environment should be terminated. 
  + The names of the Classic Load Balancers, Application Load Balancers, or Network Load Balancers in Elastic Load Balancing to be used for instances registered in the replacement environment.
**Warning**  
If you are configuring both an Auto Scaling group and an Elastic Load Balancing load balancer in your deployment group, and you want to [attach the load balancer to the Auto Scaling group](https://docs.aws.amazon.com/autoscaling/ec2/userguide/attach-load-balancer-asg.html), we recommend completing this attachment *before* creating the CodeDeploy deployment from this deployment group. Attempting to complete the attachment after creating the deployment may cause all the instances to become deregistered from the load balancer unexpectedly.

# View deployment group details with CodeDeploy
<a name="deployment-groups-view-details"></a>

You can use the CodeDeploy console, the AWS CLI, or the CodeDeploy APIs to view details about all deployment groups associated with an application.

**Topics**
+ [View deployment group details (console)](#deployment-groups-view-details-console)
+ [View deployment group details (CLI)](#deployment-groups-view-details-cli)

## View deployment group details (console)
<a name="deployment-groups-view-details-console"></a>

To use the CodeDeploy console to view deployment group details:

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, then choose **Applications**.

1. On the **Applications** page, choose the application name associated with the deployment group. 
**Note**  
If no entries are displayed, make sure the correct region is selected. On the navigation bar, in the region selector, choose one of the regions listed in [Region and Endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html#codedeploy_region) in the *AWS General Reference*. CodeDeploy is supported in these regions only.

1. To view details about an individual deployment group, on the **Deployment groups** tab, choose the name of the deployment group.

## View deployment group details (CLI)
<a name="deployment-groups-view-details-cli"></a>

To use the AWS CLI to view deployment group details, call either the `get-deployment-group` command or the `list-deployment-groups` command.

To view details about a single deployment group, call the [get-deployment-group](https://docs.aws.amazon.com/cli/latest/reference/deploy/get-deployment-group.html) command, specifying: 
+ The application name associated with the deployment group. To obtain the application name, call the [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) command.
+ The deployment group name. To get the deployment group name, call the [list-deployment-groups](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-deployment-groups.html) command.

To view a list of deployment group names, call the [list-deployment-groups](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-deployment-groups.html) command, specifying the application name associated with the deployment groups. To get the application name, call the [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) command. 

# Change deployment group settings with CodeDeploy
<a name="deployment-groups-edit"></a>

You can use the CodeDeploy console, the AWS CLI, or the CodeDeploy APIs to change the settings of a deployment group.

**Warning**  
Do not use these steps if you want the deployment group to use a not-yet-created custom deployment group. Instead, follow the instructions in [Create a deployment configuration with CodeDeploy](deployment-configurations-create.md), and then return to this topic. Do not use these steps if you want the deployment group to use a different, not-yet-created service role. The service role must trust CodeDeploy with, at minimum, the permissions described in [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md). To create and configure a service role with the correct permissions, follow the instructions in [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md), and then return to this topic.

**Topics**
+ [Change deployment group settings (console)](#deployment-groups-edit-console)
+ [Change deployment group settings (CLI)](#deployment-groups-edit-cli)

## Change deployment group settings (console)
<a name="deployment-groups-edit-console"></a>

To use the CodeDeploy console to change deployment group settings:

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, then choose **Applications**.

1. In the list of applications, choose the name of the application that is associated with the deployment group you want to change.
**Note**  
If no entries are displayed, make sure the correct region is selected. On the navigation bar, in the region selector, choose one of the regions listed in [Region and Endpoints](https://docs.aws.amazon.com/general/latest/gr/rande.html#codedeploy_region) in the *AWS General Reference*. CodeDeploy is supported in these regions only.

1. Choose the **Deployment groups** tab, and then choose the name of the deployment group you want to change.

1. On the **Depoyment group** page, choose **Edit**.

1. Edit the deployment group options as needed.

   For information about deployment group components, see [Create a deployment group with CodeDeploy](deployment-groups-create.md).

1. Choose **Save changes**.

   

## Change deployment group settings (CLI)
<a name="deployment-groups-edit-cli"></a>

To use the AWS CLI to change deployment group settings, call the [update-deployment-group](https://docs.aws.amazon.com/cli/latest/reference/deploy/update-deployment-group.html) command, specifying:
+ For EC2/On-Premises and AWS Lambda deployments:
  + The application name. To view a list of application names, call the [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) command.
  + The current deployment group name. To view a list of deployment group names, call the [list-deployment-groups](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-deployment-groups.html) command.
  + (Optional) A different deployment group name.
  + (Optional) A different Amazon Resource Name (ARN) that corresponds to a service role that allows CodeDeploy to act on your AWS account's behalf when interacting with other AWS services. To get the service role ARN, see [Get the service role ARN (CLI)](getting-started-create-service-role.md#getting-started-get-service-role-cli). For more information about service roles, see [Roles terms and concepts](https://docs.aws.amazon.com/IAM/latest/UserGuide/cross-acct-access.html) in *IAM User Guide*.
  + (Optional) The name of the deployment configuration. To view a list of deployment configurations, see [View deployment configuration details with CodeDeploy](deployment-configurations-view-details.md). (If not specified, CodeDeploy uses a default deployment configuration.)
  + (Optional) Commands to add one or more existing CloudWatch alarms to the deployment group that are activated if a metric specified in an alarm falls below or exceeds a defined threshold.
  + (Optional) Commands for a deployment to roll back to the last known good revision when a deployment fails or a CloudWatch alarm is activated.
  + (Optional) Commands for a deployment to generate lifecycle event hooks during an Auto Scaling scale-in event. For more information, see [How Amazon EC2 Auto Scaling works with CodeDeploy](integrations-aws-auto-scaling.md#integrations-aws-auto-scaling-behaviors).
  + (Optional) Commands to create or update a trigger that publishes to a topic in Amazon Simple Notification Service, so that subscribers to that topic receive notifications about deployment and instance events in this deployment group. For information, see [Monitoring deployments with Amazon SNS event notifications](monitoring-sns-event-notifications.md).
+ For EC2/On-Premises deployments only:
  + (Optional) Replacement tags or tag groups that uniquely identify the instances to be included in the deployment group.
  + (Optional) The names of replacement Amazon EC2 Auto Scaling groups to be added to the deployment group.
+ For Amazon ECS deployments only:
  +  The Amazon ECS service to deploy. 
  +  Load balancer information, including the Application Load Balancer or Network Load Balancer, the target groups required for an Amazon ECS deployment, and production and optional test listener information. 

# Configure advanced options for a deployment group
<a name="deployment-groups-configure-advanced-options"></a>

When you create or update a deployment group, you can configure a number of options to provide more control and oversight over the deployments for that deployment group.

Use the information on this page to help you configure advanced options when you work with deployment groups in the following topics: 
+ [Create an application with CodeDeploy](applications-create.md)
+ [Create a deployment group with CodeDeploy](deployment-groups-create.md)
+ [Change deployment group settings with CodeDeploy](deployment-groups-edit.md)

**Amazon SNS notification triggers**: You can add triggers to a CodeDeploy deployment group to receive notifications about events related to deployments in that deployment group. These notifications are sent to recipients who are subscribed to an Amazon SNS topic you have made part of the trigger's action. 

You must have already set up the Amazon SNS topic to which this trigger will point, and CodeDeploy must have permission to publish to the topic from this deployment group. If you have not yet completed these setup steps, you can add triggers to the deployment group later. 

If you want to create a trigger now to receive notifications about deployment events in the deployment group for this application, choose **Create trigger**. 

If your deployment is to an Amazon EC2 instance, you can create notifications for and receive notifications about instances.

For more information, see [Monitoring deployments with Amazon SNS event notifications](monitoring-sns-event-notifications.md).

**Amazon CloudWatch alarms**: You can create a CloudWatch alarm that watches a single metric over a time period you specify and performs one or more actions based on the value of the metric relative to a given threshold over a number of time periods. For an Amazon EC2 deployment, you can create an alarm for an instance or Amazon EC2 Auto Scaling group that you are using in your CodeDeploy operations. For an AWS Lambda and an Amazon ECS deployment, you can create an alarm for errors in a Lambda function.

You can configure a deployment to stop when an Amazon CloudWatch alarm detects that a metric has fallen below or exceeded a defined threshold.

You must have already created the alarm in CloudWatch before you can add it to a deployment group.

1. To add alarm monitoring to the deployment group, in **Alarms**, choose **Add alarm**. 

1. Enter the name of a CloudWatch alarm you have already set up to monitor this deployment.

   You must enter the CloudWatch alarm exactly as it was created in CloudWatch. To view a list of alarms, open the CloudWatch console at [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/), and then choose **ALARM**.

Additional options:
+ If you want deployments to proceed without taking into account alarms you have added, choose **Ignore alarm configuration**.

  This choice is useful when you want to temporarily deactivate alarm monitoring for a deployment group without having to add the same alarms again later.
+ (Optional) If you want deployments to proceed in the event that CodeDeploy is unable to retrieve alarm status from Amazon CloudWatch, choose **Continue deployments even if alarm status is unavailable**.
**Note**  
This option corresponds to **ignorePollAlarmFailure** in the [AlarmConfiguration](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_AlarmConfiguration.html) object in the CodeDeploy API. 

For more information, see [Monitoring deployments with CloudWatch alarms in CodeDeploy](monitoring-create-alarms.md).



**Automatic rollbacks**: You can configure a deployment group or deployment to automatically roll back when a deployment fails or when a monitoring threshold you specify is met. In this case, the last known good version of an application revision is deployed. You can configure optional settings for a deployment group when you use the console to create an application, create a deployment group, or update a deployment group. When you create a new deployment, you can also choose to override the automatic rollback configuration that were specified for the deployment group. 
+ You can enable deployments to roll back to the most recent known good revision when something goes wrong by choosing one or both of the following:
  + **Roll back when a deployment fails**. CodeDeploy will redeploy the last known good revision as a new deployment.
  + **Roll back when alarm thresholds are met**. If you added an alarm to this application in the previous step, CodeDeploy will redeploy the last known good revision when one or more of the specified alarms is activated.
**Note**  
To temporarily ignore a rollback configuration, choose **Disable rollbacks**. This choice is useful when you want to temporarily disable automatic rollbacks without having to set up the same configuration again later.

  For more information, see [Redeploy and roll back a deployment with CodeDeploy](deployments-rollback-and-redeploy.md).

**Automatic updates to outdated instances**: Under certain circumstances, CodeDeploy may deploy an outdated revision of your application to your Amazon EC2 instances. For example, if your EC2 instances are launched into an Auto Scaling group (ASG) while a CodeDeploy deployment is underway, those instances receive the older revision of your application instead of the latest one. To bring those instances up to date, CodeDeploy automatically starts a follow-on deployment (immediatedly after the first) to update any outdated instances. If you'd like to change this default behavior so that outdated EC2 instances are left at the older revision, you can do so through the CodeDeploy API or the AWS Command Line Interface (CLI).

To configure automatic updates of outdated instances through the API, include the `outdatedInstancesStrategy` request parameter in the `UpdateDeploymentGroup` or `CreateDeploymentGroup` action. For details, see the *AWS CodeDeploy API Reference*.

To configure the automatic updates through the AWS CLI, use one of the following commands:

`aws deploy update-deployment-group arguments --outdated-instances-strategy UPDATE|IGNORE`

Or...

`aws deploy create-deployment-group arguments --outdated-instances-strategy UPDATE|IGNORE`

...where *arguments* is replaced with the arguments required for your deployment, and *UPDATE\$1IGNORE* is replaced with either `UPDATE` to enable auto-updates, or `IGNORE` to disable them.

Example:

`aws deploy update-deployment-group --application-name "MyApp" --current-deployment-group-name "MyDG" --region us-east-1 --outdated-instances-strategy IGNORE`

For details on these AWS CLI commands, see the *AWS CLI Command Reference*.

# Delete a deployment group with CodeDeploy
<a name="deployment-groups-delete"></a>

You can use the CodeDeploy console, the AWS CLI, or the CodeDeploy APIs to delete deployment groups associated with your AWS account.

**Warning**  
If you delete a deployment group, all details associated with that deployment group will also be deleted from CodeDeploy. The instances used in the deployment group will remain unchanged. This action cannot be undone.

**Topics**
+ [Delete a deployment group (console)](#deployment-groups-delete-console)
+ [Delete a deployment group (CLI)](#deployment-groups-delete-cli)

## Delete a deployment group (console)
<a name="deployment-groups-delete-console"></a>

To use the CodeDeploy console to delete a deployment group:

1. Sign in to the AWS Management Console and open the CodeDeploy console at [https://console.aws.amazon.com/codedeploy](https://console.aws.amazon.com/codedeploy).
**Note**  
Sign in with the same user that you set up in [Getting started with CodeDeploy](getting-started-codedeploy.md).

1. In the navigation pane, expand **Deploy**, then choose **Applications**.

1. In the list of applications, choose the name of the application associated with the deployment group.

1. On the **Application details** page, on the **Deployment groups** tab, choose the name of the deployment group you want to delete.

1. On the **Deployment details** page, choose **Delete**. 

1. When prompted, type the name of the deployment group to confirm you want to delete it, and then choose **Delete**.

## Delete a deployment group (CLI)
<a name="deployment-groups-delete-cli"></a>

To use the AWS CLI to delete a deployment group, call the [delete-deployment-group](https://docs.aws.amazon.com/cli/latest/reference/deploy/delete-deployment-group.html) command, specifying:
+ The name of the application associated with the deployment group. To view a list of application names, call the [list-applications](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-applications.html) command.
+ The name of the deployment group associated with the application. To view a list of deployment group names, call the [list-deployment-groups](https://docs.aws.amazon.com/cli/latest/reference/deploy/list-deployment-groups.html) command.