CfnCondition is instance of Construct
See original GitHub issueI’m wondering why a the Construct Condition in an AWS template is an instanceof software.amazon.awscdk.core.Construct and not and instanceof CfnCondition?
Reproduction Steps
Given the java code:
CfnInclude template;
List<IConstruct> lic = template.getNode().getChildren();
for (IConstruct IC : lic) {
LOG.debug("TemplateToTreeMap class name " + IC.getClass().getTypeName());
if (IC instanceof CfnCondition) {
LOG.debug("IC is instanceof of CfnCondition");
}else if (IC instanceof CfnParameter) {
LOG.debug("IC is instanceof of CfnParameter");
}
}
When the Construct is a template Condition it is an instanceof software.amazon.awscdk.core.Construct rather than a CfnCondition which differs from the case when the Construct is a CfnParameter which is an instanceof CfnParameter.
Both CfnCondition and CfnParameter extend CfnElement.
Why does that happen and how then do I identify a Condition?
Alternatively I’ve tried as a work around the following:
if (IC.toString().contains("$Conditions")) { LOG.debug(IC.toString()); Construct C = (Construct) IC; LOG.debug(toJsonString(C.getNode())); LOG.debug(stack.resolve(C).toString());
Which gives output as follows
AwsCdkStack/Template/$Conditions ${Token[TOKEN.646]}
But then results in an error
software.amazon.jsii.JsiiException:
Unable to resolve object tree with circular reference. Path: /node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node Error: Unable to resolve object tree with circular reference. Path: /node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node/host/node at resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:35:15) at Object.resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:29:33) at resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:118:43) at Object.resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:29:33) at resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:118:43) at Object.resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:29:33) at resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:118:43) at Object.resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:29:33) at resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:118:43) at Object.resolve (/tmp/jsii-kernel-w8xgCb/node_modules/@aws-cdk/core/lib/private/resolve.js:29:33) at com.iriusrisk.cfimport.BasicApplicationTests.Example1_1(BasicApplicationTests.java:29)
What did you expect to happen?
The Template Condition to be a CfnCondition
What actually happened?
The Template condition was an instanceof Construct
Environment
<dependency> <groupId>software.amazon.awscdk</groupId> <artifactId>cdk-cloudformation-include</artifactId> <version>1.86.0</version> </dependency> <dependency> <groupId>software.amazon.jsii</groupId> <artifactId>jsii-runtime</artifactId> <version>1.20.1</version> </dependency>- CDK CLI Version :1.79
- Framework Version:1.86.0
- Node.js Version:v14.15.3
- OS : Ubuntu 18.04
- Language (Version):Java 8–>
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
@skinny85 we are done thanks again
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.