Class: AWSCDK::CustomResources::AWSCustomResource

Inherits:
Constructs::Construct
  • Object
show all
Includes:
IAM::IGrantable
Defined in:
custom_resources/aws_custom_resource.rb

Overview

Defines a custom resource that is materialized using specific AWS API calls.

These calls are created using a singleton Lambda function.

Use this to bridge any gap that might exist in the CloudFormation Coverage. You can specify exactly which calls are invoked for the 'CREATE', 'UPDATE' and 'DELETE' life cycle events.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ AWSCustomResource

Returns a new instance of AWSCustomResource.

Parameters:



18
19
20
21
22
23
24
# File 'custom_resources/aws_custom_resource.rb', line 18

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::CustomResources::AWSCustomResourceProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jdXN0b21fcmVzb3VyY2VzLkF3c0N1c3RvbVJlc291cmNlUHJvcHMifQ==")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.jsii_overridable_methodsObject



26
27
28
29
30
31
32
33
34
35
# File 'custom_resources/aws_custom_resource.rb', line 26

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :grant_principal => { kind: :property, name: "grantPrincipal", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :get_response_field => { kind: :method, name: "getResponseField", is_optional: false },
    :get_response_field_reference => { kind: :method, name: "getResponseFieldReference", is_optional: false },
  }
end

.PROPERTY_INJECTION_IDString

Uniquely identifies this class.

Returns:

  • (String)


47
48
49
# File 'custom_resources/aws_custom_resource.rb', line 47

def self.PROPERTY_INJECTION_ID()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.custom_resources.AwsCustomResource", "PROPERTY_INJECTION_ID")
end

.PROVIDER_FUNCTION_UUIDString

The uuid of the custom resource provider singleton lambda function.

Returns:

  • (String)


54
55
56
# File 'custom_resources/aws_custom_resource.rb', line 54

def self.PROVIDER_FUNCTION_UUID()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.custom_resources.AwsCustomResource", "PROVIDER_FUNCTION_UUID")
end

Instance Method Details

#get_response_field(data_path) ⇒ String

Returns response data for the AWS SDK call as string.

Example for S3 / listBucket : 'Buckets.0.Name'

Note that you cannot use this method if ignore_error_codes_matching is configured for any of the SDK calls. This is because in such a case, the response data might not exist, and will cause a CloudFormation deploy time error.

Parameters:

  • data_path (String)

    the path to the data.

Returns:

  • (String)


98
99
100
101
# File 'custom_resources/aws_custom_resource.rb', line 98

def get_response_field(data_path)
  Jsii::Type.check_type(data_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "dataPath")
  jsii_call_method("getResponseField", [data_path])
end

#get_response_field_reference(data_path) ⇒ AWSCDK::Reference

Returns response data for the AWS SDK call.

Example for S3 / listBucket : 'Buckets.0.Name'

Use Token.asXxx to encode the returned Reference as a specific type or use the convenience get_data_string for string attributes.

Note that you cannot use this method if ignore_error_codes_matching is configured for any of the SDK calls. This is because in such a case, the response data might not exist, and will cause a CloudFormation deploy time error.

Parameters:

  • data_path (String)

    the path to the data.

Returns:



116
117
118
119
# File 'custom_resources/aws_custom_resource.rb', line 116

def get_response_field_reference(data_path)
  Jsii::Type.check_type(data_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "dataPath")
  jsii_call_method("getResponseFieldReference", [data_path])
end

#grant_principalAWSCDK::IAM::IPrincipal

The principal to grant permissions to.



61
62
63
# File 'custom_resources/aws_custom_resource.rb', line 61

def grant_principal()
  jsii_get_property("grantPrincipal")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


40
41
42
# File 'custom_resources/aws_custom_resource.rb', line 40

def node()
  jsii_get_property("node")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


68
69
70
# File 'custom_resources/aws_custom_resource.rb', line 68

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

    The mixins to apply.

Returns:

  • (Constructs::IConstruct)

    This construct for chaining



81
82
83
84
85
86
# File 'custom_resources/aws_custom_resource.rb', line 81

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end