class DeploymentLifecycleLambdaTarget
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ECS.DeploymentLifecycleLambdaTarget |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#DeploymentLifecycleLambdaTarget |
![]() | software.amazon.awscdk.services.ecs.DeploymentLifecycleLambdaTarget |
![]() | aws_cdk.aws_ecs.DeploymentLifecycleLambdaTarget |
![]() | aws-cdk-lib » aws_ecs » DeploymentLifecycleLambdaTarget |
Implements
IDeployment
Use an AWS Lambda function as a deployment lifecycle hook target.
Example
import * as lambda from 'aws-cdk-lib/aws-lambda';
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const lambdaHook: lambda.Function;
declare const blueTargetGroup: elbv2.ApplicationTargetGroup;
declare const greenTargetGroup: elbv2.ApplicationTargetGroup;
declare const prodListenerRule: elbv2.ApplicationListenerRule;
const service = new ecs.FargateService(this, 'Service', {
cluster,
taskDefinition,
deploymentStrategy: ecs.DeploymentStrategy.BLUE_GREEN,
});
service.addLifecycleHook(new ecs.DeploymentLifecycleLambdaTarget(lambdaHook, 'PreScaleHook', {
lifecycleStages: [ecs.DeploymentLifecycleStage.PRE_SCALE_UP],
}));
const target = service.loadBalancerTarget({
containerName: 'nginx',
containerPort: 80,
protocol: ecs.Protocol.TCP,
alternateTarget: new ecs.AlternateTarget('AlternateTarget', {
alternateTargetGroup: greenTargetGroup,
productionListener: ecs.ListenerRuleConfiguration.applicationListenerRule(prodListenerRule),
}),
});
target.attachToApplicationTargetGroup(blueTargetGroup);
Initializer
new DeploymentLifecycleLambdaTarget(handler: IFunction, id: string, props: DeploymentLifecycleLambdaTargetProps)
Parameters
- handler
IFunction
- id
string
- props
Deployment
Lifecycle Lambda Target Props
Properties
Name | Type | Description |
---|---|---|
role | IRole | The IAM role for the deployment lifecycle hook target. |
role
Type:
IRole
The IAM role for the deployment lifecycle hook target.
Methods
Name | Description |
---|---|
bind(scope) | Bind this target to a deployment lifecycle hook. |
bind(scope)
public bind(scope: IConstruct): DeploymentLifecycleHookTargetConfig
Parameters
- scope
IConstruct
Returns
Bind this target to a deployment lifecycle hook.