27

I'm attempting to validate a cloudformation template, and cfn-validate returns a useless error of

"Malformed input-Template format error: Every Default member must be a string".

Does anybody have an idea on how to debug this? It would be awesome if cfn- validate would return errors or at least resource names when errors are given.

CloudformationTemplates are incredibly painful to debug.

3
  • 2
    The error message seems pretty useful to me. Go through every default member and validate that they're all strings, maybe? Commented Mar 19, 2015 at 19:08
  • Error strings should be on a seperate line and put in as a quote using the > use the `backtick to highlight code inline of a sentence Commented Mar 19, 2015 at 22:41
  • Keep in mind that the results of Fn::Join do NOT count as strings Commented Dec 14, 2017 at 23:11

5 Answers 5

31

This problem occurs when you specify Parameters and have their default value calculated in some way (usually be referencing other parameters).

This definition is not valid - parameters' default values must be strictly strings that the command line tool can replace with other strings.

Sign up to request clarification or add additional context in comments.

3 Comments

yeah , even i faced this error .Just check this value should be STRICT STRING " "Default": "aaa-bbb-ccc".No other value will be accepted here .Earlier i was passing array of Strings , so got this error.
Do you have a reference to AWS documentation for that? @guss
@KonstantinA.Magg - the documentation for this is here: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/… . It's not immediately obvious from the docs, but when they say "A value of the appropriate type" they mean an actual value and not a formula or code to compute a value. Its not true that has it be a strict string - although all JSON examples are strings, even those that are for a Number type - they can also be YAML numbers, but they do have to be literal values.
21

I received the same error message when using the Parameter of type CommaDelimitedList in my cfn template.

  LoadBalancerSubnets:
    Description: List of subnets for the ApplicationLoadBalancer
    Type: CommaDelimitedList
    Default: [ "subnet-123456", "subnet-012345" ]

This was due to my mis-interpretation of the CommaDelimitedList type. I thought it is actually a list but it turns out that the value should be a single String value in which the various elements should be separated by a comma. So, I changed my template to look like this:

  LoadBalancerSubnets:
    Description: List of subnets for the ApplicationLoadBalancer
    Type: CommaDelimitedList
    Default: "subnet-123456,subnet-012345"

and this worked.

The error was a very generic one and there may be other scenarios as well in which the same error gets thrown.

However, I thought about sharing my experience with this error so it may help others who got stuck with the same problem.

1 Comment

"The error was a very generic one" -- indeed. This fixed my issue where Type: List<AWS::EC2::Subnet::Id> and the default needed to be subnet-123,subnet-456
3

This happens in Cloudformation Outputs definition when the result of a ´Fn::...´ is a list and not a string.

To make strings out of Lists you can ´Fn::Join´ the list result to a comma separated string. e.g.:

 "VpcSubnets": {
      "Export": {
        "Name": "VpcSubnets"
      },
      "Value": {
        "Fn::Join": [
          ",",
          {
            "Fn::GetAtt": [
              "MyVpc",
              "Subnets"
            ]
          }
        ]
      }
    }

1 Comment

For those looking for the YAML equivalent, it would be Value: !Join [ ",", Fn::GetAtt: [MyVpc, Subnets] ]. You have to use the long form of Fn::GetAtt inside the brackets.
2

I have seen this error for the Outputs description field as well (I was using !Sub). Had to remove !Sub and just use plain text.

1 Comment

Ditto for the Description inside a Parameter list. Was hoping to !Sub in the ${AWS::Region}, but no, that would have been too useful.
0

I think you have unnecessary !Ref or !Sub like this one

Parameters:
  RelationTableName: 
    Description: relations table name
    Type: String
    Default: !Ref "relations"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.