Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation: Template error: every Ref object must have a single String value

I'm attempting to create a CloudFormation stack and am getting the following error:

A client error (ValidationError) occurred when calling the CreateStack operation: Template error: every Ref object must have a single String value.

However, when I grep the template looking for Ref objects they are all Strings except for a single lookup which looks like

{
  "Ref": {
     "Fn::FindInMap": [
         "InfraMap",
         "SecurityGroups",
         "NATSecurityGroup"
     ]
  }
}

The value for this reference is "NATSecurityGroup": "sg-54e6be30", which seems OK to me.

Any other thoughts on what this error could be referring to?

like image 895
mjallday Avatar asked May 07 '15 00:05

mjallday


People also ask

How do you ensure that the Cloudformation template is valid and error free?

To check your template file for syntax errors, you can use the aws cloudformation validate-template command. The aws cloudformation validate-template command is designed to check only the syntax of your template.

How do I validate aws Cloudformation template?

Validate template syntaxCreate your stack with AWS CloudFormation Designer. Validate your JSON syntax with a text editor, or a command line tool such as the AWS CLI template validator. Validate your YAML syntax with the aws cloudformation validate-template command.

What is the use of Cloudformation in aws?

AWS CloudFormation is a service that gives developers and businesses an easy way to create a collection of related AWS and third-party resources, and provision and manage them in an orderly and predictable fashion.


1 Answers

"Ref": {
     "Fn::FindInMap": [
         "InfraMap",
         "SecurityGroups",
         "NATSecurityGroup"
     ]
}

This is not correct, the Ref is not required in this case, where the value it is referencing is a constant and not a variable created during the creation of the stack.

Replacing it with

"Fn::FindInMap": [
     "InfraMap",
     "SecurityGroups",
     "NATSecurityGroup"
]

Resolves the issue.

like image 174
mjallday Avatar answered Sep 17 '22 02:09

mjallday