# ServerDeploymentGroup

A CodeDeploy Deployment Group that deploys to EC2/on-premise instances.

Extends: Construct › Resource › ServerDeploymentGroup
Implements: IResource, IServerDeploymentGroup, 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/server/deployment-group.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts#L268)
- Type last changed: v2.241.0 · 2 Mar 2026

## Example

```ts
declare const alb: elbv2.ApplicationLoadBalancer;
const listener = alb.addListener('Listener', { port: 80 });
const targetGroup = listener.addTargets('Fleet', { port: 80 });

const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
  loadBalancer: codedeploy.LoadBalancer.application(targetGroup),
});
```

## Initializer

```ts
new ServerDeploymentGroup(scope: Construct, id: string, props?: ServerDeploymentGroupProps)
```

## 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) = A new Application will be created. — The CodeDeploy EC2/on-premise Application this Deployment Group belongs to.

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

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

- `autoScalingGroups`: [IAutoScalingGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.IAutoScalingGroup.html)[] = [] — The auto-scaling groups belonging to this Deployment Group.

  Auto-scaling groups can also be added after the Deployment Group is created
  using the `#addAutoScalingGroup` method.

  [disable-awslint:ref-via-interface] is needed because we update userdata
  for ASGs to install the codedeploy agent.

- `deploymentConfig`: [IDeploymentConfigRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_codedeploy.IDeploymentConfigRef.html) = ServerDeploymentConfig#OneAtATime — The EC2/on-premise Deployment Configuration to use for this Deployment Group.

  **Default:** ServerDeploymentConfig#OneAtATime

- `deploymentGroupName`: string = An auto-generated name will be used. — The physical, human-readable name of the CodeDeploy Deployment Group.

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

- `ec2InstanceTags`: [InstanceTagSet](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.InstanceTagSet.html) = No additional EC2 instances will be added to the Deployment Group. — All EC2 instances matching the given set of tags when a deployment occurs will be added to this Deployment Group.

  **Default:** No additional EC2 instances will be added to the Deployment Group.

- `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.

- `installAgent`: boolean = true — If you've provided any auto-scaling groups with the `#autoScalingGroups` property, you can set this property to add User Data that installs the CodeDeploy agent on the instances.

- `loadBalancer`: [LoadBalancer](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.LoadBalancer.html) = Deployment Group will not have a load balancer defined. — - Use `loadBalancers` instead.

  Can be created from either a classic Elastic Load Balancer,
  or an Application Load Balancer / Network Load Balancer Target Group.

  **Default:** Deployment Group will not have a load balancer defined.

- `loadBalancers`: [LoadBalancer](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.LoadBalancer.html)[] = Deployment Group will not have load balancers defined. — CodeDeploy supports the deployment to multiple load balancers.

  Specify either multiple Classic Load Balancers, or
  Application Load Balancers / Network Load Balancers Target Groups.

  **Default:** Deployment Group will not have load balancers defined.

- `onPremiseInstanceTags`: [InstanceTagSet](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.InstanceTagSet.html) = No additional on-premise instances will be added to the Deployment Group. — All on-premise instances matching the given set of tags when a deployment occurs will be added to this Deployment Group.

  **Default:** No additional on-premise instances will be added to the Deployment Group.

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

- `terminationHook`: boolean = false — Indicates whether the deployment group was configured to have CodeDeploy install a termination hook into an Auto Scaling group.

## Properties

- `application`: [IServerApplication](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.IServerApplication.html) (required)

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

- `autoScalingGroups`: [IAutoScalingGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.IAutoScalingGroup.html)[]

- `deploymentConfig`: [IServerDeploymentConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.IServerDeploymentConfig.html) (required)

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

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

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

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — 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) (required) — The tree node.

- `PROPERTY_INJECTION_ID`: string (required) (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) (required) — 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.

- `addAutoScalingGroup(asg: AutoScalingGroup): void` — Adds an additional auto-scaling group to this Deployment Group.

  **Parameters**

  - `asg` — the auto-scaling group to add to 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`).

- `fromServerDeploymentGroupAttributes(scope: Construct, id: string, attrs: ServerDeploymentGroupAttributes): IServerDeploymentGroup` (static) — Import an EC2/on-premise Deployment Group defined either outside the CDK app, or in a different region.

  **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.
