cim icon indicating copy to clipboard operation
cim copied to clipboard

TypeError when running stack-up with multiple levels of parents

Open jfrndz opened this issue 6 years ago • 0 comments

We're currently using CIM to manage a number of CloudFormation stacks. Parent stacks are used to pass stack names to child stacks which are then used to derive export names. There seems to be a bug that manifests when a parent stack has parent stacks of its own.

Consider the following example: Three stacks: (A, B, and C) where A is a parent of B and B is a parent of C.

# A/_cim.yml
---
stack:
  name: a-stack
  template: ...
# B/_cim.yml
---
stack:
  name: b-stack
  template: ...
  parents:
     base: ../A
  parameters:
     SomeExport: "${stack.parents.base.stack.name}-SomeValue"
# C/_cim.yml
---
stack:
   name: c-stack
   template: ...
   parents:
    core: ../B
   parameters:
      OtherExport: "${stack.parents.core.stack.name}-OtherValue"

Given these stacks, running cim stack-up from C\ throws the following stacktrace:

TypeError: Cannot read property 'stack' of undefined
    at eval (lodash.templateSources[0]:9:29)
    at Object.functions.do_resolve_stack_params (/usr/local/lib/node_modules/cim/lib/util/configs.js:201:22)
    at /usr/local/lib/node_modules/cim/lib/util/configs.js:216:38
    at replenish (/usr/local/lib/node_modules/cim/node_modules/async/dist/async.js:1011:17)
    at /usr/local/lib/node_modules/cim/node_modules/async/dist/async.js:1016:9
    at eachOfLimit (/usr/local/lib/node_modules/cim/node_modules/async/dist/async.js:1041:24)
    at /usr/local/lib/node_modules/cim/node_modules/async/dist/async.js:1046:16
    at Object.eachOf (/usr/local/lib/node_modules/cim/node_modules/async/dist/async.js:1117:5)
    at Object.functions.resolve_stack (/usr/local/lib/node_modules/cim/lib/util/configs.js:213:11)
    at /usr/local/lib/node_modules/cim/lib/util/configs.js:239:23

However, changing the name of C's parent stack to base to match B's parents works as expected. This is sufficient as a workaround but a fix would allow CIM stacks to use more descriptive parent names.

jfrndz avatar Sep 04 '19 18:09 jfrndz