diff --git a/README.rst b/README.rst index 7b76440..916cb8c 100644 --- a/README.rst +++ b/README.rst @@ -136,4 +136,4 @@ If you wish to include some static cloudformation json and have it merged with t includes: - /path/to/cloudformation.json -The tool will then merge this with the generated template *overwriting* any keys in the original template that clash. +The tool will then perform a deep merge of the includes with the generated template dictionary. Any keys or subkeys in the template dictionary that clash will have their values **overwritten** by the included dictionary or recursively merged if the value is itself a dictionary. diff --git a/bootstrap_cfn/config.py b/bootstrap_cfn/config.py index 149ed89..718ffdc 100644 --- a/bootstrap_cfn/config.py +++ b/bootstrap_cfn/config.py @@ -79,7 +79,7 @@ def process(self): if 'includes' in self.data: for inc_path in self.data['includes']: inc = json.load(open(inc_path)) - utils.dict_merge(template, inc) + template = utils.dict_merge(template, inc) return json.dumps( template, sort_keys=True, indent=4, separators=(',', ': ')) diff --git a/bootstrap_cfn/utils.py b/bootstrap_cfn/utils.py index 4c58adc..981676d 100644 --- a/bootstrap_cfn/utils.py +++ b/bootstrap_cfn/utils.py @@ -57,7 +57,7 @@ def dict_merge(target, *args): # Merge multiple dicts if len(args) > 1: for obj in args: - self.dict_merge(target, obj) + dict_merge(target, obj) return target # Recursively merge dicts and set non-dict values