cloudtools/troposphere

TemplateGenerator: Cloudformation split function call wrapped inside list

ilons opened this issue · 0 comments

ilons commented

I'm trying to parse a cloudformation template into a troposphere template using the TemplateGenerator class.

This works good for most parts, but I've ran into an issue where TemplateGenerator would wrap calls to Fn::Split inside a list, making the result invalid (as it becomes a list of lists when deployed by cloudformation).

Small snippet to reproduce this issue:


template = troposphere.template_generator.TemplateGenerator({
    "Resources": {
        "TestLB": {
            "Properties": {
                "IpAddressType": "ipv4",
                "Name": "MyTestLB",
                "Scheme": "internet-facing",
                "SecurityGroups": [
                    {
                        "Ref": "MySG"
                    }
                ],
                "Subnets": {
                    "Fn::Split": [
                        ",",
                        {
                            "Fn::ImportValue": "MyPublicSubnets"
                        }
                    ]
                },
                "Type": "application"
            },
            "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer"
        }
    }
})
assert isinstance(template.resources["TestLB"].properties["Subnets"], troposphere.Split), "Expected troposphere.Split"

I'm getting this running:

Python 3.10.6

cfn-flip==1.3.0
click==8.1.3
PyYAML==6.0
six==1.16.0
troposphere==4.3.2

Is there any way around this?