Class DeploymentLifecycleLambdaTarget

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ecs.DeploymentLifecycleLambdaTarget
All Implemented Interfaces:
IDeploymentLifecycleHookTarget, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.113.0 (build fc68b25)", date="2025-08-20T12:34:42.364Z") @Stability(Stable) public class DeploymentLifecycleLambdaTarget extends software.amazon.jsii.JsiiObject implements IDeploymentLifecycleHookTarget
Use an AWS Lambda function as a deployment lifecycle hook target.

Example:

 import software.amazon.awscdk.services.lambda.*;
 Cluster cluster;
 TaskDefinition taskDefinition;
 Function lambdaHook;
 ApplicationTargetGroup blueTargetGroup;
 ApplicationTargetGroup greenTargetGroup;
 ApplicationListenerRule prodListenerRule;
 FargateService service = FargateService.Builder.create(this, "Service")
         .cluster(cluster)
         .taskDefinition(taskDefinition)
         .deploymentStrategy(DeploymentStrategy.BLUE_GREEN)
         .build();
 service.addLifecycleHook(DeploymentLifecycleLambdaTarget.Builder.create(lambdaHook, "PreScaleHook")
         .lifecycleStages(List.of(DeploymentLifecycleStage.PRE_SCALE_UP))
         .build());
 IEcsLoadBalancerTarget target = service.loadBalancerTarget(LoadBalancerTargetOptions.builder()
         .containerName("nginx")
         .containerPort(80)
         .protocol(Protocol.TCP)
         .alternateTarget(AlternateTarget.Builder.create("AlternateTarget")
                 .alternateTargetGroup(greenTargetGroup)
                 .productionListener(ListenerRuleConfiguration.applicationListenerRule(prodListenerRule))
                 .build())
         .build());
 target.attachToApplicationTargetGroup(blueTargetGroup);
 
  • Constructor Details

    • DeploymentLifecycleLambdaTarget

      protected DeploymentLifecycleLambdaTarget(software.amazon.jsii.JsiiObjectRef objRef)
    • DeploymentLifecycleLambdaTarget

      protected DeploymentLifecycleLambdaTarget(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • DeploymentLifecycleLambdaTarget

      @Stability(Stable) public DeploymentLifecycleLambdaTarget(@NotNull IFunction handler, @NotNull String id, @NotNull DeploymentLifecycleLambdaTargetProps props)
      Parameters:
      handler - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • bind

      @Stability(Stable) @NotNull public DeploymentLifecycleHookTargetConfig bind(@NotNull software.constructs.IConstruct scope)
      Bind this target to a deployment lifecycle hook.

      Specified by:
      bind in interface IDeploymentLifecycleHookTarget
      Parameters:
      scope - This parameter is required.
    • getRole

      @Stability(Stable) @NotNull public IRole getRole()
      The IAM role for the deployment lifecycle hook target.