Class: AWSCDK::AutoScalingHookTargets::FunctionHook

Inherits:
Jsii::Object
  • Object
show all
Includes:
AWSCDK::Autoscaling::ILifecycleHookTarget
Defined in:
auto_scaling_hook_targets/function_hook.rb

Overview

Use a Lambda Function as a hook target.

Internally creates a Topic to make the connection.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fn, encryption_key = nil) ⇒ FunctionHook

Returns a new instance of FunctionHook.

Parameters:

  • fn (AWSCDK::Lambda::IFunction)

    Function to invoke in response to a lifecycle event.

  • encryption_key (AWSCDK::KMS::IKey, nil) (defaults to: nil)

    If provided, this key is used to encrypt the contents of the SNS topic.



13
14
15
16
17
# File 'auto_scaling_hook_targets/function_hook.rb', line 13

def initialize(fn, encryption_key = nil)
  Jsii::Type.check_type(fn, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "fn")
  Jsii::Type.check_type(encryption_key, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfa21zLklLZXkifQ==")), "encryptionKey") unless encryption_key.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(fn, encryption_key)
end

Class Method Details

.jsii_overridable_methodsObject



19
20
21
22
23
# File 'auto_scaling_hook_targets/function_hook.rb', line 19

def self.jsii_overridable_methods
  {
    :bind => { kind: :method, name: "bind", is_optional: false },
  }
end

Instance Method Details

#bind(_scope, options) ⇒ AWSCDK::Autoscaling::LifecycleHookTargetConfig

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:

Returns:



32
33
34
35
36
37
# File 'auto_scaling_hook_targets/function_hook.rb', line 32

def bind(_scope, options)
  Jsii::Type.check_type(_scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "_scope")
  options = options.is_a?(Hash) ? ::AWSCDK::Autoscaling::BindHookTargetOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuQmluZEhvb2tUYXJnZXRPcHRpb25zIn0=")), "options")
  jsii_call_method("bind", [_scope, options])
end