FunctionHook

class aws_cdk.aws_autoscaling_hooktargets.FunctionHook(fn, encryption_key=None)

Bases: object

Use a Lambda Function as a hook target.

Internally creates a Topic to make the connection.

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_autoscaling_hooktargets as autoscaling_hooktargets
import aws_cdk.aws_kms as kms
import aws_cdk.aws_lambda as lambda_

# function_: lambda.Function
# key: kms.Key

function_hook = autoscaling_hooktargets.FunctionHook(function_, key)
Parameters:
  • fn (IFunction) – Function to invoke in response to a lifecycle event.

  • encryption_key (Optional[IKey]) – If provided, this key is used to encrypt the contents of the SNS topic.

Methods

bind(_scope, *, lifecycle_hook, role=None)

If the IRole does not exist in options, will create an IRole and an SNS Topic and attach both to the lifecycle hook.

If the IRole does exist in options, will only create an SNS Topic and attach it to the lifecycle hook.

Parameters:
  • _scope (Construct) –

  • lifecycle_hook (LifecycleHook) – The lifecycle hook to attach to. [disable-awslint:ref-via-interface]

  • role (Optional[IRole]) – The role to use when attaching to the lifecycle hook. [disable-awslint:ref-via-interface] Default: : a role is not created unless the target arn is specified

Return type:

LifecycleHookTargetConfig