Try to pass parameters from the master template to the child

I am trying to pass the list parameters from the main to the child template, however I encountered two errors. These are my current settings in the main template.

"Parameters": {
    "ELBSubnets": {
        "Default": "subnet-5d8fea67,subnet-3e35cf15",
        "Type": "CommaDelimitedList"
    },
    "LCKeyPair": {
        "Default": "key-master",
        "Type": "String"
    },
    "LCSecurityGroups": {
        "Default": "sg-10a15c74,sg-880e5fec",
        "Type": "CommaDelimitedList"
    }
},

They refer to this method on the same template when passed to the child template.

    "ChildTempate1": {
        "Properties": {
            "Parameters": {
                "ELBSubnets": {
                    "Ref": "ELBSubnets"
                },
                "KeyPair": {
                    "Ref": "LCKeyPair"
                },
                "LCSecurityGroups": {
                    "Ref": "LCSecurityGroups"
                }
            },

In the child template, they are declared exactly the same.

"Parameters": {
    "ELBSubnets": {
        "Type": "CommaDelimitedList"
    },
    "LCKeyPair": {
        "Type": "String"
    },
    "LCSecurityGroups": {
        "Type": "CommaDelimitedList"
    }
},

And they reference this method in the child template.

            "KeyName": {
                "Ref": "LCKeyPair"
            },
            "SecurityGroups": {
                "Fn::Join": [
                    ",",
                    [
                        {
                            "Ref": "LCSecurityGroups"
                        }
                    ]
                ]
            }
        },

This is another part of the template.

            "Subnets": {
                "Fn::Join": [
                    ",",
                    [
                        {
                            "Ref": "ELBSubnets"
                        }
                    ]
                ]
            }
        },

When I try to use fn :: join in the main template, it says

"Template validation error: template error: each Fn :: Join object requires two parameters: (1) a line separator and (2) a list of connected lines or a function that returns a list of lines (for example, Fn :: GetAZs).

When I do not use fn :: join on the main template, an error

String ( )

, fn:: join .

: https://github.com/slimg00dy/Troposphere-CloudformationTests

+4
3

, Ref CommaDelimitedList , "[a, b, c]", "a, b, c"

, Join ( "," ) Join ("") . , "a, b, c" "String"

CommaDelimitedLists String String. , .

Ref Child Join() . CommaDelimitedLists , Join ("") .

.

"Parameters": {
    "ELBSubnets": {
        "Default": "subnet-5d8fea67,subnet-3e35cf15",
        "Type": "CommaDelimitedList"
    },
    "LCKeyPair": {
        "Default": "key-master",
        "Type": "CommaDelimitedList"
    },
    "LCSecurityGroups": {
        "Default": "sg-10a15c74,sg-880e5fec",
        "Type": "CommaDelimitedList"
    }
},

Join ( "," ), Join ("") Ref. Ref CommaDelimitedLists , Join ( "," ), CommaDelimitedLists .

KeyPair String, , CommaDelimitedList Join (""), .

            "Parameters": {
                "ELBSubnets": {
                    "Fn::Join": [
                        ",",
                        {
                            "Ref": "ELBSubnets"
                        }
                    ]
                },
                "LCKeyPair": {
                    "Fn::Join": [
                        " ",
                        {
                            "Ref": "LCKeyPair"
                        }
                    ]
                },
                "LCSecurityGroups": {
                    "Fn::Join": [
                        ",",
                        {
                            "Ref": "LCSecurityGroups"
                        }
                    ]
                }
            },

.

 "Parameters": {
    "ELBSubnets": {
        "Type": "CommaDelimitedList"
    },
    "LCKeyPair": {
        "Type": "String"
    },
    "LCSecurityGroups": {
        "Type": "CommaDelimitedList"
    }
},

Join .

Subnets": {
                "Ref": "ELBSubnets"
            }

, . , , . , . , .

, " : "

+4

CommaDelimtedList , "String", , CommaDelimitedList, .

, CloudFormation CommaDelimitedList , .

+2

, - , . () CommaDelimitedList, , . , , , . , !

0

Source: https://habr.com/ru/post/1589524/


All Articles