Class: AWSCDK::Synthetics::Code

Inherits:
Jsii::Object
  • Object
show all
Defined in:
synthetics/code.rb

Overview

The code the canary should execute.

Direct Known Subclasses

AssetCode, InlineCode, S3Code

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCode

Returns a new instance of Code.



8
9
10
# File 'synthetics/code.rb', line 8

def initialize
  Jsii::Object.instance_method(:initialize).bind(self).call
end

Class Method Details

.from_asset(asset_path, options = nil) ⇒ AWSCDK::Synthetics::AssetCode

Specify code from a local path.

Path must include the folder structure nodejs/node_modules/myCanaryFilename.js.

Parameters:

Returns:

See Also:



26
27
28
29
30
31
# File 'synthetics/code.rb', line 26

def self.from_asset(asset_path, options = nil)
  Jsii::Type.check_type(asset_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assetPath")
  options = options.is_a?(Hash) ? ::AWSCDK::S3Assets::AssetOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfczNfYXNzZXRzLkFzc2V0T3B0aW9ucyJ9")), "options") unless options.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_synthetics.Code", "fromAsset", [asset_path, options])
end

.from_bucket(bucket, key, object_version = nil) ⇒ AWSCDK::Synthetics::S3Code

Specify code from an s3 bucket.

The object in the s3 bucket must be a .zip file that contains the structure nodejs/node_modules/myCanaryFilename.js.

Parameters:

Returns:

See Also:



43
44
45
46
47
48
# File 'synthetics/code.rb', line 43

def self.from_bucket(bucket, key, object_version = nil)
  Jsii::Type.check_type(bucket, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19zMy5JQnVja2V0UmVmIn0=")), "bucket")
  Jsii::Type.check_type(key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "key")
  Jsii::Type.check_type(object_version, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "objectVersion") unless object_version.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_synthetics.Code", "fromBucket", [bucket, key, object_version])
end

.from_inline(code) ⇒ AWSCDK::Synthetics::InlineCode

Specify code inline.

Parameters:

  • code (String)

    The actual handler code (limited to 5MB).

Returns:



54
55
56
57
# File 'synthetics/code.rb', line 54

def self.from_inline(code)
  Jsii::Type.check_type(code, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "code")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_synthetics.Code", "fromInline", [code])
end

.jsii_overridable_methodsObject



12
13
14
15
16
# File 'synthetics/code.rb', line 12

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

Instance Method Details

#bind(scope, handler, family, runtime_name = nil) ⇒ AWSCDK::Synthetics::CodeConfig

Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.

Parameters:

Returns:



66
67
68
69
70
71
72
# File 'synthetics/code.rb', line 66

def bind(scope, handler, family, runtime_name = nil)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(handler, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "handler")
  Jsii::Type.check_type(family, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc3ludGhldGljcy5SdW50aW1lRmFtaWx5In0=")), "family")
  Jsii::Type.check_type(runtime_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "runtimeName") unless runtime_name.nil?
  jsii_call_method("bind", [scope, handler, family, runtime_name])
end