# EcsDeploymentGroup

A CodeDeploy deployment group that orchestrates ECS blue-green deployments.

Extends: Construct › Resource › EcsDeploymentGroup
Implements: IResource, IEcsDeploymentGroup, IEnvironmentAware, IDeploymentGroupRef, IConstruct, IDependable

- CloudFormation: [`AWS::CodeDeploy::DeploymentGroup`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-codedeploy-deploymentgroup.html)
- L1 type: [`CfnDeploymentGroup`](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.html)
- Source: [`aws-codedeploy/lib/ecs/deployment-group.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codedeploy/lib/ecs/deployment-group.ts#L205)
- Type last changed: v2.241.0 · 2 Mar 2026

## Example

```ts
declare const myApplication: codedeploy.EcsApplication;
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.FargateTaskDefinition;
declare const blueTargetGroup: elbv2.ITargetGroup;
declare const greenTargetGroup: elbv2.ITargetGroup;
declare const listener: elbv2.IApplicationListener;

const service = new ecs.FargateService(this, 'Service', {
  cluster,
  taskDefinition,
  deploymentController: {
    type: ecs.DeploymentControllerType.CODE_DEPLOY,
  },
});

new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
  service,
  blueGreenDeploymentConfig: {
    blueTargetGroup,
    greenTargetGroup,
    listener,
  },
  deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
```

## Initializer

```ts
new EcsDeploymentGroup(scope: Construct, id: string, props: EcsDeploymentGroupProps)
```

## Construct Props

- `alarms`: [IAlarmRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_cloudwatch.IAlarmRef.html)[] = [] — The CloudWatch alarms associated with this Deployment Group.

  CodeDeploy will stop (and optionally roll back)
  a deployment if during it any of the alarms trigger.

  Alarms can also be added after the Deployment Group is created using the `#addAlarm` method.

- `application`: [IApplicationRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_codedeploy.IApplicationRef.html) — The reference to the CodeDeploy ECS Application that this Deployment Group belongs to.

  **Default:** One will be created for you.

- `autoRollback`: [AutoRollbackConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.AutoRollbackConfig.html) — The auto-rollback configuration for this Deployment Group.

  **Default:** default AutoRollbackConfig.

- `blueGreenDeploymentConfig`: [EcsBlueGreenDeploymentConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.EcsBlueGreenDeploymentConfig.html) (required) — The configuration options for blue-green ECS deployments.

- `deploymentConfig`: [IDeploymentConfigRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_codedeploy.IDeploymentConfigRef.html) = EcsDeploymentConfig.ALL_AT_ONCE — The Deployment Configuration this Deployment Group uses.

- `deploymentGroupName`: string — The physical, human-readable name of the CodeDeploy Deployment Group.

  **Default:** An auto-generated name will be used.

- `ignoreAlarmConfiguration`: boolean = false — Whether to skip the step of checking CloudWatch alarms during the deployment process.

- `ignorePollAlarmsFailure`: boolean = false — Whether to continue a deployment even if fetching the alarm status from CloudWatch failed.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The service Role of this Deployment Group.

  **Default:** A new Role will be created.

- `service`: [IBaseService](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.IBaseService.html) (required) — The ECS service to deploy with this Deployment Group.

## Properties

- `application`: [IEcsApplication](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.IEcsApplication.html) — The reference to the CodeDeploy ECS Application that this Deployment Group belongs to.

- `applicationName`: string — The name of the Application.

- `deploymentConfig`: [IEcsDeploymentConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.IEcsDeploymentConfig.html) — The Deployment Configuration this Group uses.

- `deploymentGroupArn`: string — The ARN of the Deployment Group.

- `deploymentGroupName`: string — The name of the Deployment Group.

- `deploymentGroupRef`: [DeploymentGroupReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_codedeploy.DeploymentGroupReference.html) — A reference to a DeploymentGroup resource.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The service Role of this Deployment Group.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `addAlarm(alarm: IAlarmRef): void` — Associates an additional alarm with this Deployment Group.

  **Parameters**

  - `alarm` — the alarm to associate with this Deployment Group.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromEcsDeploymentGroupAttributes(scope: Construct, id: string, attrs: EcsDeploymentGroupAttributes): IEcsDeploymentGroup` (static) — Reference an ECS Deployment Group defined outside the CDK app.

  Account and region for the DeploymentGroup are taken from the application.

  **Parameters**

  - `scope` — the parent Construct for this new Construct.
  - `id` — the logical ID of this new Construct.
  - `attrs` — the properties of the referenced Deployment Group.

  **Returns:** a Construct representing a reference to an existing Deployment Group

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
