DeploymentLifecycleLambdaTargetProps
- class aws_cdk.aws_ecs.DeploymentLifecycleLambdaTargetProps(*, lifecycle_stages, role=None)
Bases:
object
Configuration for a lambda deployment lifecycle hook.
- Parameters:
lifecycle_stages (
Sequence
[DeploymentLifecycleStage
]) – The lifecycle stages when this hook should be executed.role (
Optional
[IRole
]) – The IAM role that grants permissions to invoke the lambda target. Default: - A unique role will be generated for this lambda function.
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_lambda as lambda_ # cluster: ecs.Cluster # task_definition: ecs.TaskDefinition # lambda_hook: lambda.Function # blue_target_group: elbv2.ApplicationTargetGroup # green_target_group: elbv2.ApplicationTargetGroup # prod_listener_rule: elbv2.ApplicationListenerRule service = ecs.FargateService(self, "Service", cluster=cluster, task_definition=task_definition, deployment_strategy=ecs.DeploymentStrategy.BLUE_GREEN ) service.add_lifecycle_hook(ecs.DeploymentLifecycleLambdaTarget(lambda_hook, "PreScaleHook", lifecycle_stages=[ecs.DeploymentLifecycleStage.PRE_SCALE_UP] )) target = service.load_balancer_target( container_name="nginx", container_port=80, protocol=ecs.Protocol.TCP, alternate_target=ecs.AlternateTarget("AlternateTarget", alternate_target_group=green_target_group, production_listener=ecs.ListenerRuleConfiguration.application_listener_rule(prod_listener_rule) ) ) target.attach_to_application_target_group(blue_target_group)
Attributes
- lifecycle_stages
The lifecycle stages when this hook should be executed.
- role
The IAM role that grants permissions to invoke the lambda target.
- Default:
A unique role will be generated for this lambda function.