CfnJson

class aws_cdk.core.CfnJson(scope, id, *, value)

Bases: aws_cdk.core.Construct

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.

__init__(scope, id, *, value)
Parameters
  • scope (Construct) –

  • id (str) –

  • value (Any) – The value to resolve. Can be any JavaScript object, including tokens and references in keys or values.

Return type

None

Methods

resolve(_)

Produce the Token’s value at resolution time.

Parameters

_

Return type

Any

to_json()

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

Return type

str

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

creation_stack

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

If this returns an empty array the stack will not be attached.

Return type

List[str]

node

The construct tree node associated with this construct.

Return type

ConstructNode

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool