View a markdown version of this page

⭐ Must Read: serverless application model/latest/developerguide/sam property function hooks.html - Kapook Update 2025

Hooks

Validation Lambda functions that are run before and after traffic shifting.

Note

The Lambda functions referenced in this property configure the CodeDeployLambdaAliasUpdate object of the resulting AWS::Lambda::Alias resource. For more information, see CodeDeployLambdaAliasUpdate Policy in the AWS CloudFormation User Guide.

Syntax

To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.

YAML

PostTraffic: String PreTraffic: String

Properties

PostTraffic

Lambda function that is run after traffic shifting.

Type: String

Required: No

CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

PreTraffic

Lambda function that is run before traffic shifting.

Type: String

Required: No

CloudFormation compatibility: This property is unique to AWS SAM and doesn't have an CloudFormation equivalent.

Examples

Hooks

Example hook functions

YAML

Hooks: PreTraffic: Ref: PreTrafficLambdaFunction PostTraffic: Ref: PostTrafficLambdaFunction