Skip to content
v2.273.0

ServerDeploymentGroup L2 construct ​

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

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),
});
python
# alb: elbv2.ApplicationLoadBalancer

listener = alb.add_listener("Listener", port=80)
target_group = listener.add_targets("Fleet", port=80)

deployment_group = codedeploy.ServerDeploymentGroup(self, "DeploymentGroup",
    load_balancer=codedeploy.LoadBalancer.application(target_group)
)
java
ApplicationLoadBalancer alb;

ApplicationListener listener = alb.addListener("Listener", BaseApplicationListenerProps.builder().port(80).build());
ApplicationTargetGroup targetGroup = listener.addTargets("Fleet", AddApplicationTargetsProps.builder().port(80).build());

ServerDeploymentGroup deploymentGroup = ServerDeploymentGroup.Builder.create(this, "DeploymentGroup")
        .loadBalancer(LoadBalancer.application(targetGroup))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
ApplicationLoadBalancer alb;

var listener = alb.AddListener("Listener", new BaseApplicationListenerProps { Port = 80 });
var targetGroup = listener.AddTargets("Fleet", new AddApplicationTargetsProps { Port = 80 });

var deploymentGroup = new ServerDeploymentGroup(this, "DeploymentGroup", new ServerDeploymentGroupProps {
    LoadBalancer = LoadBalancer.Application(targetGroup)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var alb ApplicationLoadBalancer

listener := alb.AddListener(jsii.String("Listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(80),
})
targetGroup := listener.AddTargets(jsii.String("Fleet"), &AddApplicationTargetsProps{
	Port: jsii.Number(80),
})

deploymentGroup := codedeploy.NewServerDeploymentGroup(this, jsii.String("DeploymentGroup"), &ServerDeploymentGroupProps{
	LoadBalancer: codedeploy.LoadBalancer_Application(targetGroup),
})

Initializer ​

ts
new ServerDeploymentGroup(scope: Construct, id: string, props?: ServerDeploymentGroupProps)
python
ServerDeploymentGroup(scope: Construct, id: str, props: typing.Optional[ServerDeploymentGroupProps] = None)
java
new ServerDeploymentGroup(Construct scope, String id, ServerDeploymentGroupProps props)
csharp
new ServerDeploymentGroup(Construct scope, string id, ServerDeploymentGroupProps? props = null)
go
NewServerDeploymentGroup(Scope Construct, Id *string, Props ServerDeploymentGroupProps)

Construct Props ​

alarmsIAlarmRef[]alarmstyping.List[IAlarmRef]alarmsList<IAlarmRef>AlarmsIAlarmRef[]Alarms*[]IAlarmRef= []#
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.

applicationIApplicationRefapplicationIApplicationRefapplicationIApplicationRefApplicationIApplicationRefApplicationIApplicationRef= A new Application will be create…#
The CodeDeploy EC2/on-premise Application this Deployment Group belongs to.
default

Default: A new Application will be created.

autoRollbackAutoRollbackConfigauto_rollbackAutoRollbackConfigautoRollbackAutoRollbackConfigAutoRollbackAutoRollbackConfigAutoRollbackAutoRollbackConfig= default AutoRollbackConfig.#
The auto-rollback configuration for this Deployment Group.
autoScalingGroupsIAutoScalingGroup[]auto_scaling_groupstyping.List[IAutoScalingGroup]autoScalingGroupsList<IAutoScalingGroup>AutoScalingGroupsIAutoScalingGroup[]AutoScalingGroups*[]IAutoScalingGroup= []#
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.

deploymentConfigIDeploymentConfigRefdeployment_configIDeploymentConfigRefdeploymentConfigIDeploymentConfigRefDeploymentConfigIDeploymentConfigRefDeploymentConfigIDeploymentConfigRef= ServerDeploymentConfig#OneAtATim…#
The EC2/on-premise Deployment Configuration to use for this Deployment Group.
default

Default: ServerDeploymentConfig#OneAtATime

deploymentGroupNamestringdeployment_group_namestrdeploymentGroupNameStringDeploymentGroupNamestringDeploymentGroupName*string= An auto-generated name will be u…#
The physical, human-readable name of the CodeDeploy Deployment Group.
default

Default: An auto-generated name will be used.

ec2InstanceTagsInstanceTagSetec2_instance_tagsInstanceTagSetec2InstanceTagsInstanceTagSetEc2InstanceTagsInstanceTagSetEc2InstanceTagsInstanceTagSet= No additional EC2 instances will…#
All EC2 instances matching the given set of tags when a deployment occurs will be added to this Deployment Group.
default

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

ignoreAlarmConfigurationbooleanignore_alarm_configurationboolignoreAlarmConfigurationBooleanIgnoreAlarmConfigurationboolIgnoreAlarmConfiguration*bool= false#
Whether to skip the step of checking CloudWatch alarms during the deployment process.
ignorePollAlarmsFailurebooleanignore_poll_alarms_failureboolignorePollAlarmsFailureBooleanIgnorePollAlarmsFailureboolIgnorePollAlarmsFailure*bool= false#
Whether to continue a deployment even if fetching the alarm status from CloudWatch failed.
installAgentbooleaninstall_agentboolinstallAgentBooleanInstallAgentboolInstallAgent*bool= 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.
loadBalancerLoadBalancerload_balancerLoadBalancerloadBalancerLoadBalancerLoadBalancerLoadBalancerLoadBalancerLoadBalancer= Deployment Group will not have a…deprecated#
- Use `loadBalancers` instead.

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

default

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

loadBalancersLoadBalancer[]load_balancerstyping.List[LoadBalancer]loadBalancersList<LoadBalancer>LoadBalancersLoadBalancer[]LoadBalancers*[]LoadBalancer= Deployment Group will not have l…#
CodeDeploy supports the deployment to multiple load balancers.

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

default

Default: Deployment Group will not have load balancers defined.

onPremiseInstanceTagsInstanceTagSeton_premise_instance_tagsInstanceTagSetonPremiseInstanceTagsInstanceTagSetOnPremiseInstanceTagsInstanceTagSetOnPremiseInstanceTagsInstanceTagSet= No additional on-premise instanc…#
All on-premise instances matching the given set of tags when a deployment occurs will be added to this Deployment Group.
default

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

roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole= A new Role will be created.#
The service Role of this Deployment Group.
terminationHookbooleantermination_hookboolterminationHookBooleanTerminationHookboolTerminationHook*bool= false#
Indicates whether the deployment group was configured to have CodeDeploy install a termination hook into an Auto Scaling group.

Properties ​

applicationIServerApplicationapplicationIServerApplicationapplicationIServerApplicationApplicationIServerApplicationApplicationIServerApplicationrequired#
applicationNamestringapplication_namestrapplicationNameStringApplicationNamestringApplicationName*stringrequired#
The name of the Application.
autoScalingGroupsIAutoScalingGroup[]auto_scaling_groupstyping.List[IAutoScalingGroup]autoScalingGroupsList<IAutoScalingGroup>AutoScalingGroupsIAutoScalingGroup[]AutoScalingGroups*[]IAutoScalingGroup#
deploymentConfigIServerDeploymentConfigdeployment_configIServerDeploymentConfigdeploymentConfigIServerDeploymentConfigDeploymentConfigIServerDeploymentConfigDeploymentConfigIServerDeploymentConfigrequired#
deploymentGroupArnstringdeployment_group_arnstrdeploymentGroupArnStringDeploymentGroupArnstringDeploymentGroupArn*stringrequired#
The ARN of the Deployment Group.
deploymentGroupNamestringdeployment_group_namestrdeploymentGroupNameStringDeploymentGroupNamestringDeploymentGroupName*stringrequired#
The name of the Deployment Group.
deploymentGroupRefDeploymentGroupReferencedeployment_group_refDeploymentGroupReferencedeploymentGroupRefDeploymentGroupReferenceDeploymentGroupRefDeploymentGroupReferenceDeploymentGroupRefDeploymentGroupReferencerequired#
A reference to a DeploymentGroup resource.
The environment this resource belongs to.
notes

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.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole#
The service Role of this Deployment Group.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

addAlarm(alarm: IAlarmRef): voiddef add_alarm(self, alarm: IAlarmRef) -> Nonepublic void addAlarm(IAlarmRef alarm)public void AddAlarm(IAlarmRef alarm)func AddAlarm(Alarm IAlarmRef)#
Associates an additional alarm with this Deployment Group.
1 parameter

Parameters

  • alarmalarmalarmalarmAlarm — the alarm to associate with this Deployment Group.
addAutoScalingGroup(asg: AutoScalingGroup): voiddef add_auto_scaling_group(self, asg: AutoScalingGroup) -> Nonepublic void addAutoScalingGroup(AutoScalingGroup asg)public void AddAutoScalingGroup(AutoScalingGroup asg)func AddAutoScalingGroup(Asg AutoScalingGroup)#
Adds an additional auto-scaling group to this Deployment Group.
1 parameter

Parameters

  • asgasgasgasgAsg — the auto-scaling group to add to this Deployment Group.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

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

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

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@staticmethod def from_server_deployment_group_attributes(scope: Construct, id: str, attrs: ServerDeploymentGroupAttributes) -> IServerDeploymentGrouppublic static IServerDeploymentGroup fromServerDeploymentGroupAttributes(Construct scope, String id, ServerDeploymentGroupAttributes attrs)public static IServerDeploymentGroup FromServerDeploymentGroupAttributes(Construct scope, string id, ServerDeploymentGroupAttributes attrs)func FromServerDeploymentGroupAttributes(Scope Construct, Id *string, Attrs ServerDeploymentGroupAttributes) IServerDeploymentGroupstatic#
Import an EC2/on-premise Deployment Group defined either outside the CDK app, or in a different region.
3 parameters · returns

Parameters

  • scopescopescopescopeScope — the parent Construct for this new Construct.
  • ididididId — the logical ID of this new Construct.
  • attrsattrsattrsattrsAttrs — the properties of the referenced Deployment Group.

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

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

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

  • xxxxX — Any object.

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

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func 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.