Skip to content

CDK 1.56.0 upgrade -- jsii.errors.JSIIError: CDK doesn't know how to merge two instances of the CFN template section 'Rules' - please remove one of them from your code #9485

@aaroncarlucci

Description

@aaroncarlucci

We are using CDK to output raw CloudFormation templates. As such we are using many Cfn* resource types. I have code that was working just fine using CDK version 1.42.1, but when I tried to upgrade to the latest 1.56.0, I received the following error on synth:

jsii.errors.JSIIError: CDK doesn't know how to merge two instances of the CFN template section 'Rules' - please remove one of them from your code

In the stack, we have two declarations of CfnRule constructs. When I remove them both, or comment one out and leave the other, the template compiles fine.

Haven't found much on Google, but smells like it could be related to this change:

#8251

Reproduction Steps

rule1 = CfnRule(...)
rule2 = CfnRule(...)

What did you expect to happen?

Template should synthesize

What actually happened?

ERROR: jsii.errors.JSIIError: CDK doesn't know how to merge two instances of the CFN template section 'Rules' - please remove one of them from your code

Environment

  • CLI Version : 1.56.0
  • Framework Version: 1.56.0
  • Node.js Version: 10.19.0
  • OS : Ubuntu 18.04
  • Language (Version): Python >=3.6

Other

jsii.errors.JavaScriptError: 
  Error: CDK doesn't know how to merge two instances of the CFN template section 'Rules' - please remove one of them from your code
      at mergeSection (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/stack.js:682:19)
      at merge (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/stack.js:660:33)
      at Stack._toCloudFormation (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/stack.js:542:13)
      at Stack.synthesize (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/stack.js:503:42)
      at Stack.onSynthesize (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/construct-compat.js:87:14)
      at construct (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/private/synthesis.js:87:48)
      at visit (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/private/synthesis.js:121:9)
      at visit (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/private/synthesis.js:118:9)
      at synthesizeTree (/tmp/jsii-kernel-oJMZeB/node_modules/@aws-cdk/core/lib/private/synthesis.js:87:5)
      at Kernel._wrapSandboxCode (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:8398:19)
      at ret._ensureSync (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7746:25)
      at Kernel._ensureSync (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:8371:20)
      at Kernel.invoke (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7745:26)
      at KernelHost.processRequest (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7446:28)
      at KernelHost.run (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7384:14)
      at Immediate.setImmediate [as _onImmediate] (/usr/local/lib/python3.8/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7387:37)
      at runCallback (timers.js:705:18)
      at tryOnImmediate (timers.js:676:5)
      at processImmediate (timers.js:658:5)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 20, in <module>
    app.synth()
  File "/usr/local/lib/python3.8/dist-packages/aws_cdk/core/__init__.py", line 11403, in synth
    return jsii.invoke(self, "synth", [options])
  File "/usr/local/lib/python3.8/dist-packages/jsii/_kernel/__init__.py", line 113, in wrapped
    return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
  File "/usr/local/lib/python3.8/dist-packages/jsii/_kernel/__init__.py", line 288, in invoke
    response = self.provider.invoke(
  File "/usr/local/lib/python3.8/dist-packages/jsii/_kernel/providers/process.py", line 348, in invoke
    return self._process.send(request, InvokeResponse)
  File "/usr/local/lib/python3.8/dist-packages/jsii/_kernel/providers/process.py", line 318, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: CDK doesn't know how to merge two instances of the CFN template section 'Rules' - please remove one of them from your code
Subprocess exited with error 1
Makefile:102: recipe for target 'synth' failed
make: *** [synth] Error 1

This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/coreRelated to core CDK functionalitybugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions