Skip to content
v2.275.0

LambdaDeploymentGroup L2 construct ​

Example ​

ts
const config = new codedeploy.LambdaDeploymentConfig(this, 'CustomConfig', {
  trafficRouting: new codedeploy.TimeBasedCanaryTrafficRouting({
    interval: Duration.minutes(15),
    percentage: 5,
  }),
});

declare const application: codedeploy.LambdaApplication;
declare const alias: lambda.Alias;
const deploymentGroup = new codedeploy.LambdaDeploymentGroup(this, 'BlueGreenDeployment', {
  application,
  alias,
  deploymentConfig: config,
});
python
# application: codedeploy.LambdaApplication
# alias: lambda.Alias
config = codedeploy.LambdaDeploymentConfig(self, "CustomConfig",
    traffic_routing=codedeploy.TimeBasedCanaryTrafficRouting(
        interval=Duration.minutes(15),
        percentage=5
    )
)
deployment_group = codedeploy.LambdaDeploymentGroup(self, "BlueGreenDeployment",
    application=application,
    alias=alias,
    deployment_config=config
)
java
LambdaApplication application;
Alias alias;
LambdaDeploymentConfig config = LambdaDeploymentConfig.Builder.create(this, "CustomConfig")
        .trafficRouting(TimeBasedCanaryTrafficRouting.Builder.create()
                .interval(Duration.minutes(15))
                .percentage(5)
                .build())
        .build();
LambdaDeploymentGroup deploymentGroup = LambdaDeploymentGroup.Builder.create(this, "BlueGreenDeployment")
        .application(application)
        .alias(alias)
        .deploymentConfig(config)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
LambdaApplication application;
Alias alias;
var config = new LambdaDeploymentConfig(this, "CustomConfig", new LambdaDeploymentConfigProps {
    TrafficRouting = new TimeBasedCanaryTrafficRouting(new TimeBasedCanaryTrafficRoutingProps {
        Interval = Duration.Minutes(15),
        Percentage = 5
    })
});
var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
    Application = application,
    Alias = alias,
    DeploymentConfig = config
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var application LambdaApplication
var alias Alias
config := codedeploy.NewLambdaDeploymentConfig(this, jsii.String("CustomConfig"), &LambdaDeploymentConfigProps{
	TrafficRouting: codedeploy.NewTimeBasedCanaryTrafficRouting(&TimeBasedCanaryTrafficRoutingProps{
		Interval: awscdk.Duration_Minutes(jsii.Number(15)),
		Percentage: jsii.Number(5),
	}),
})
deploymentGroup := codedeploy.NewLambdaDeploymentGroup(this, jsii.String("BlueGreenDeployment"), &LambdaDeploymentGroupProps{
	Application: Application,
	Alias: Alias,
	DeploymentConfig: config,
})

Initializer ​

ts
new LambdaDeploymentGroup(scope: Construct, id: string, props: LambdaDeploymentGroupProps)
python
LambdaDeploymentGroup(scope: Construct, id: str, props: LambdaDeploymentGroupProps)
java
new LambdaDeploymentGroup(Construct scope, String id, LambdaDeploymentGroupProps props)
csharp
new LambdaDeploymentGroup(Construct scope, string id, LambdaDeploymentGroupProps props)
go
NewLambdaDeploymentGroup(Scope Construct, Id *string, Props LambdaDeploymentGroupProps)

Construct Props ​

alarmsoptionalIAlarmRef[]alarmsoptionaltyping.List[IAlarmRef]alarmsoptionalList<IAlarmRef>AlarmsoptionalIAlarmRef[]Alarmsoptional*[]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.

aliasAliasaliasAliasaliasAliasAliasAliasAliasAliasrequired#
Lambda Alias to shift traffic. Updating the version of the alias will trigger a CodeDeploy deployment.

[disable-awslint:ref-via-interface] since we need to modify the alias CFN resource update policy

applicationoptionalILambdaApplicationapplicationoptionalILambdaApplicationapplicationoptionalILambdaApplicationApplicationoptionalILambdaApplicationApplicationoptionalILambdaApplication#
The reference to the CodeDeploy Lambda Application that this Deployment Group belongs to.

Default: One will be created for you.

autoRollbackoptionalAutoRollbackConfigauto_rollbackoptionalAutoRollbackConfigautoRollbackoptionalAutoRollbackConfigAutoRollbackoptionalAutoRollbackConfigAutoRollbackoptionalAutoRollbackConfig#
The auto-rollback configuration for this Deployment Group.

Default: default AutoRollbackConfig.

deploymentConfigoptionalILambdaDeploymentConfigdeployment_configoptionalILambdaDeploymentConfigdeploymentConfigoptionalILambdaDeploymentConfigDeploymentConfigoptionalILambdaDeploymentConfigDeploymentConfigoptionalILambdaDeploymentConfig#
The Deployment Configuration this Deployment Group uses.

Default: LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES

deploymentGroupNameoptionalstringdeployment_group_nameoptionalstrdeploymentGroupNameoptionalStringDeploymentGroupNameoptionalstringDeploymentGroupNameoptional*string#
The physical, human-readable name of the CodeDeploy Deployment Group.

Default: An auto-generated name will be used.

ignoreAlarmConfigurationoptionalbooleanignore_alarm_configurationoptionalboolignoreAlarmConfigurationoptionalBooleanIgnoreAlarmConfigurationoptionalboolIgnoreAlarmConfigurationoptional*bool= false#
Whether to skip the step of checking CloudWatch alarms during the deployment process.
ignorePollAlarmsFailureoptionalbooleanignore_poll_alarms_failureoptionalboolignorePollAlarmsFailureoptionalBooleanIgnorePollAlarmsFailureoptionalboolIgnorePollAlarmsFailureoptional*bool= false#
Whether to continue a deployment even if fetching the alarm status from CloudWatch failed.
postHookoptionalIFunctionpost_hookoptionalIFunctionpostHookoptionalIFunctionPostHookoptionalIFunctionPostHookoptionalIFunction= None.#
The Lambda function to run after traffic routing starts.
preHookoptionalIFunctionpre_hookoptionalIFunctionpreHookoptionalIFunctionPreHookoptionalIFunctionPreHookoptionalIFunction= None.#
The Lambda function to run before traffic routing starts.
roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole#
The service Role of this Deployment Group.

Default: A new Role will be created.

Properties ​

The reference to the CodeDeploy Lambda Application that this Deployment Group belongs to.
applicationNamestringapplication_namestrapplicationNameStringApplicationNamestringApplicationName*string#
The name of the Application.
deploymentConfigILambdaDeploymentConfigdeployment_configILambdaDeploymentConfigdeploymentConfigILambdaDeploymentConfigDeploymentConfigILambdaDeploymentConfigDeploymentConfigILambdaDeploymentConfig#
The Deployment Configuration this Group uses.
deploymentGroupArnstringdeployment_group_arnstrdeploymentGroupArnStringDeploymentGroupArnstringDeploymentGroupArn*string#
The ARN of the Deployment Group.
deploymentGroupNamestringdeployment_group_namestrdeploymentGroupNameStringDeploymentGroupNamestringDeploymentGroupName*string#
The name of the Deployment Group.
deploymentGroupRefDeploymentGroupReferencedeployment_group_refDeploymentGroupReferencedeploymentGroupRefDeploymentGroupReferenceDeploymentGroupRefDeploymentGroupReferenceDeploymentGroupRefDeploymentGroupReference#
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.

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole#
The service Role of this Deployment Group.
stackStackstackStackstackStackStackStackStackStack#
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.
addPostHook(postHook: IFunction): voiddef add_post_hook(self, post_hook: IFunction) -> Nonepublic void addPostHook(IFunction postHook)public void AddPostHook(IFunction postHook)func AddPostHook(PostHook IFunction)#
Associate a function to run after deployment completes.
1 parameter

Parameters

  • postHookpost_hookpostHookpostHookPostHook — function to run after deployment completes.
addPreHook(preHook: IFunction): voiddef add_pre_hook(self, pre_hook: IFunction) -> Nonepublic void addPreHook(IFunction preHook)public void AddPreHook(IFunction preHook)func AddPreHook(PreHook IFunction)#
Associate a function to run before deployment begins.
1 parameter

Parameters

  • preHookpre_hookpreHookpreHookPreHook — function to run before deployment beings.
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).

fromLambdaDeploymentGroupAttributes(scope: Construct, id: string, attrs: LambdaDeploymentGroupAttributes): ILambdaDeploymentGroup@staticmethod def from_lambda_deployment_group_attributes(scope: Construct, id: str, attrs: LambdaDeploymentGroupAttributes) -> ILambdaDeploymentGrouppublic static ILambdaDeploymentGroup fromLambdaDeploymentGroupAttributes(Construct scope, String id, LambdaDeploymentGroupAttributes attrs)public static ILambdaDeploymentGroup FromLambdaDeploymentGroupAttributes(Construct scope, string id, LambdaDeploymentGroupAttributes attrs)func FromLambdaDeploymentGroupAttributes(Scope Construct, Id *string, Attrs LambdaDeploymentGroupAttributes) ILambdaDeploymentGroupstatic#
Import an Lambda Deployment Group defined either outside the CDK app, or in a different AWS region.

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

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

grantPutLifecycleEventHookExecutionStatus(grantee: IGrantable): Grantdef grant_put_lifecycle_event_hook_execution_status(self, grantee: IGrantable) -> Grantpublic Grant grantPutLifecycleEventHookExecutionStatus(IGrantable grantee)public Grant GrantPutLifecycleEventHookExecutionStatus(IGrantable grantee)func GrantPutLifecycleEventHookExecutionStatus(Grantee IGrantable) Grant#
Grant a principal permission to codedeploy:PutLifecycleEventHookExecutionStatus on this deployment group resource.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — to grant permission to.
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.