Class CfnJson

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.CfnJson
All Implemented Interfaces:
IConstruct, IDependable, IResolvable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:54.856Z") @Stability(Stable) public class CfnJson extends Construct implements IResolvable
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.

Example:

 CfnParameter tagParam = new CfnParameter(this, "TagName");
 CfnJson stringEquals = CfnJson.Builder.create(this, "ConditionJson")
         .value(Map.of(
                 String.format("aws:PrincipalTag/%s", tagParam.getValueAsString()), true))
         .build();
 PrincipalBase principal = new AccountRootPrincipal().withConditions(Map.of(
         "StringEquals", stringEquals));
 Role.Builder.create(this, "MyRole").assumedBy(principal).build();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A fluent builder for CfnJson.

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct

    IConstruct.Jsii$Default, IConstruct.Jsii$Proxy

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$Proxy

    Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IResolvable

    IResolvable.Jsii$Default, IResolvable.Jsii$Proxy
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CfnJson(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    CfnJson(software.amazon.jsii.JsiiObjectRef objRef)
     
     
    CfnJson(software.constructs.Construct scope, String id, CfnJsonProps props)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    The creation stack of this resolvable which will be appended to errors thrown during resolution.
    An Fn::GetAtt to the JSON object passed through value and resolved during synthesis.
    Produce the Token's value at resolution time.
    This is required in case someone JSON.stringifys an object which refrences this object.

    Methods inherited from class software.amazon.awscdk.core.Construct

    getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate

    Methods inherited from class software.constructs.Construct

    toString

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface software.amazon.awscdk.core.IResolvable

    toString

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • CfnJson

      protected CfnJson(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnJson

      protected CfnJson(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnJson

      @Stability(Stable) public CfnJson(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnJsonProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • resolve

      @Stability(Stable) @NotNull public Object resolve(@NotNull IResolveContext __)
      Produce the Token's value at resolution time.

      Specified by:
      resolve in interface IResolvable
      Parameters:
      __ - This parameter is required.
      _ - This parameter is required.
    • toJSON

      @Stability(Stable) @NotNull public String toJSON()
      This is required in case someone JSON.stringifys an object which refrences this object. Otherwise, we'll get a cyclic JSON reference.
    • getCreationStack

      @Stability(Stable) @NotNull public List<String> getCreationStack()
      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.

      Specified by:
      getCreationStack in interface IResolvable
    • getValue

      @Stability(Stable) @NotNull public Reference getValue()
      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.