AWS Fundamentals Logo
AWS Fundamentals
L1 ConstructAWS::CloudFormation::LambdaHook

CfnLambdaHook

The `AWS::CloudFormation::LambdaHook` resource creates and activates a Lambda Hook. You can use a Lambda Hook to evaluate your resources before allowing stack operations. This resource forwards requests for resource evaluation to a Lambda function. For more information, see [Lambda Hooks](https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/lambda-hooks.html) in the *CloudFormation Hooks User Guide* .

Import

import { CfnLambdaHook } from 'aws-cdk-lib/aws-cloudformation';

Or use the module namespace:

import * as cloudformation from 'aws-cdk-lib/aws-cloudformation';
// cloudformation.CfnLambdaHook

Properties

Configuration passed to the constructor as CfnLambdaHookProps.

aliasRequired
string

The type name alias for the Hook. This alias must be unique per account and Region. The alias must be in the form `Name1::Name2::Name3` and must not begin with `AWS` . For example, `Private::Lambda::MyTestHook` .

executionRoleRequired
string

The IAM role that the Hook assumes to invoke your Lambda function.

failureModeRequired
string

Specifies how the Hook responds when the Lambda function invoked by the Hook returns a `FAILED` response. - `FAIL` : Prevents the action from proceeding. This is helpful for enforcing strict compliance or security policies. - `WARN` : Issues warnings to users but allows actions to continue. This is useful for non-critical validations or informational checks.

hookStatusRequired
string

Specifies if the Hook is `ENABLED` or `DISABLED` .

Default: - "ENABLED"

lambdaFunctionRequired
string

Specifies the Lambda function for the Hook. You can use:. - The full Amazon Resource Name (ARN) without a suffix. - A qualified ARN with a version or alias suffix.

targetOperationsRequired
string[]

Specifies the list of operations the Hook is run against. For more information, see [Hook targets](https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/hooks-concepts.html#hook-terms-hook-target) in the *CloudFormation Hooks User Guide* . Valid values: `STACK` | `RESOURCE` | `CHANGE_SET` | `CLOUD_CONTROL`

stackFiltersOptional
IResolvable | StackFiltersProperty

Specifies the stack level filters for the Hook. Example stack level filter in JSON: `"StackFilters": {"FilteringCriteria": "ALL", "StackNames": {"Exclude": [ "stack-1", "stack-2"]}}` Example stack level filter in YAML: `StackFilters: FilteringCriteria: ALL StackNames: Exclude: - stack-1 - stack-2`

targetFiltersOptional
IResolvable | TargetFiltersProperty

Specifies the target filters for the Hook. Example target filter in JSON: `"TargetFilters": {"Actions": [ "CREATE", "UPDATE", "DELETE" ]}` Example target filter in YAML: `TargetFilters: Actions: - CREATE - UPDATE - DELETE`

CloudFormation Resource

This L1 construct maps directly to the following CloudFormation resource type.

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter