

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Hooks
<a name="sam-property-function-hooks"></a>

流量转移之前和之后运行的验证 Lambda 函数。

**注意**  
此属性中引用的 Lambda 函数会配置生成的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-alias.html) 资源的 `CodeDeployLambdaAliasUpdate` 对象。有关更多信息，请参阅《*AWS CloudFormation 用户指南*》中的[CodeDeployLambdaAliasUpdate 策略](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-codedeploylambdaaliasupdate)。

## 语法
<a name="sam-property-function-hooks-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-hooks-syntax.yaml"></a>

```
  [PostTraffic](#sam-function-hooks-posttraffic): String
  [PreTraffic](#sam-function-hooks-pretraffic): String
```

## Properties
<a name="sam-property-function-hooks-properties"></a>

 `PostTraffic`   <a name="sam-function-hooks-posttraffic"></a>
流量转移之后运行的 Lambda 函数。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `PreTraffic`   <a name="sam-function-hooks-pretraffic"></a>
流量转移之前运行的 Lambda 函数。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

## 示例
<a name="sam-property-function-hooks--examples"></a>

### 挂钩
<a name="sam-property-function-hooks--examples--hooks"></a>

示例钩子函数

#### YAML
<a name="sam-property-function-hooks--examples--hooks--yaml"></a>

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