Class: AWSCDK::CfnJson

Inherits:
Constructs::Construct
  • Object
show all
Includes:
IResolvable
Defined in:
cfn_json.rb

Overview

Captures a synthesis-time JSON object a CloudFormation reference which resolves during deployment to the resolved values of the JSON object.

The main use case for this is to overcome a limitation in CloudFormation that does not allow using intrinsic functions as dictionary keys (because dictionary keys in JSON must be strings). Specifically this is common in IAM conditions such as StringEquals: { lhs: "rhs" } where you want "lhs" to be a reference.

This object is resolvable, so it can be used as a value.

This construct is backed by a custom resource.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ CfnJson

Returns a new instance of CfnJson.

Parameters:



22
23
24
25
26
27
28
# File 'cfn_json.rb', line 22

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::CfnJsonProps.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("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5Kc29uUHJvcHMifQ==")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.jsii_overridable_methodsObject



30
31
32
33
34
35
36
37
38
39
40
# File 'cfn_json.rb', line 30

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :creation_stack => { kind: :property, name: "creationStack", is_optional: false },
    :value => { kind: :property, name: "value", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :resolve => { kind: :method, name: "resolve", is_optional: false },
    :to_json => { kind: :method, name: "toJSON", is_optional: false },
  }
end

Instance Method Details

#creation_stackArray<String>

The creation stack of this resolvable which will be appended to errors thrown during resolution.

This may return an array with a single informational element indicating how to get this property populated, if it was skipped for performance reasons.

Returns:

  • (Array<String>)


55
56
57
# File 'cfn_json.rb', line 55

def creation_stack()
  jsii_get_property("creationStack")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


45
46
47
# File 'cfn_json.rb', line 45

def node()
  jsii_get_property("node")
end

#resolve(_context) ⇒ Object

Produce the Token's value at resolution time.

Parameters:

Returns:

  • (Object)


96
97
98
99
# File 'cfn_json.rb', line 96

def resolve(_context)
  Jsii::Type.check_type(_context, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JUmVzb2x2ZUNvbnRleHQifQ==")), "_context")
  jsii_call_method("resolve", [_context])
end

#to_jsonString

This is required in case someone JSON.stringifys an object which references this object. Otherwise, we'll get a cyclic JSON reference.

Returns:

  • (String)


104
105
106
# File 'cfn_json.rb', line 104

def to_json()
  jsii_call_method("toJSON", [])
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


72
73
74
# File 'cfn_json.rb', line 72

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

#valueAWSCDK::Reference

An Fn::GetAtt to the JSON object passed through value and resolved during synthesis.

Normally there is no need to use this property since CfnJson is an IResolvable, so it can be simply used as a value.

Returns:



65
66
67
# File 'cfn_json.rb', line 65

def value()
  jsii_get_property("value")
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



85
86
87
88
89
90
# File 'cfn_json.rb', line 85

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