Creating a Lambda function for consuming life cycle hooks

With the various life cycle hook resources in place, the final piece of the puzzle is to create a Lambda function and associated resources that will subscribe to the life cycle hook SNS topic you defined in the previous section and will ultimately perform ECS container instance draining before signalling that the life cycle hook action can continue.

Let's first focus on the Lambda function itself and the associated source code that it will need to execute:

......Resources:  LifecycleHookFunction:    Type: AWS::Lambda::Function    DependsOn:      - LifecycleHookFunctionLogGroup    Properties:      Role: !Sub ${LifecycleFunctionRole.Arn}      FunctionName: !Sub ${AWS::StackName}-lifecycleHooks Description: !Sub ...

Get Docker on Amazon Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.