troposphere icon indicating copy to clipboard operation
troposphere copied to clipboard

importing troposphere causes yaml.load to output OrderedDict.

Open jeffreyctang opened this issue 9 years ago • 9 comments

I installed troposphere from the git master (3a3004a183fd0d70e57b9c9d1b92763b2962d09e) and yaml.load behavior changed: Here's a test script:

#!/usr/bin/env python3
from pprint import pprint
import yaml
from troposphere import Template
yaml_string = '''
base:
  - name: everyone
    ips: [ 0.0.0.0/0 ]
'''

config = yaml.load(yaml_string)
pprint(config)

It shows "base" as a list of OrderedDict. If I run off of 1.9.4 it's just a list of a dict.

jeffreyctang avatar Jul 11 '17 04:07 jeffreyctang

The cfn_flip module is the one causing this.

jeffreyctang avatar Jul 11 '17 13:07 jeffreyctang

I've opened an issue: https://github.com/awslabs/aws-cfn-template-flip/issues/14

jeffreyctang avatar Jul 11 '17 13:07 jeffreyctang

Thanks for the issue and adding the cfn_flip issue as well.

markpeek avatar Jul 11 '17 13:07 markpeek

@jeffreyctang I haven't seen any comments yet in the aws-cfn-template-flip issue. While I understand this is a change in behavior for your existing yaml uses I'd like to understand the impact of keeping the yaml changes (cfn_flip) in the code vs. pulling it or rewriting it.

markpeek avatar Jul 14 '17 00:07 markpeek

I've got 6k lines of yaml configuration for building our AWS assets using troposphere.

I imagine there's some way of isolating the aws-template-flip yaml settings from mine. I'm no python expert amd the 10 minutes I spent on it yielded no solutions.

If this was included in a release, I would be forced to either

  1. figure out the yaml isolation, which I'm not confident I can do or is reasonably possible.
  2. postprocess my yaml.load output and convert all the OrderedDicts, which I'm confident I can manage.

I could live with it and I am waiting for the next release for a couple of items.

That said, I would imagine many other users of troposphere are loading yaml in some capacity or another and this would break things for them. It's a disconcerting error and not at all obvious that it's related to troposphere.

jeffreyctang avatar Jul 14 '17 01:07 jeffreyctang

Fixed in cfn_flip now :)

stilvoid avatar Jul 20 '17 14:07 stilvoid

@stilvoid thank you for making the change. @jeffreyctang can you verify from your side and then we can close this out?

markpeek avatar Jul 20 '17 16:07 markpeek

Confirmed. The new cfn_flip modules doesn't affect my yaml parsing.

jeffreyctang avatar Jul 20 '17 17:07 jeffreyctang

Thanks! Closing due to upstream fix.

markpeek avatar Jul 20 '17 17:07 markpeek