Open jpeach opened 7 months ago
Similarly I encountered the following error
json: cannot unmarshal string into Go struct field Template.Resources of type int
When running goformation.Open()
_, err := goformation.Open(path)
if err != nil {
fmt.Println(err.Error())
}
On this Yaml
AWSTemplateFormatVersion: '2010-09-09'
Description: Lambda with timeout as string
Resources:
LambdaWithTimeout:
Type: AWS::Lambda::Function
Properties:
FunctionName: lambda-with-timeout
Timeout: '60'
Runtime: python3.12
Removing the quotes for Timeout ('60' > 60
) resolves this issue. However, I believe both are valid Cloudformation templates.
I used
goformation.ParseYAML()
to parse a working CloudFormation template that has some Lambda resources. The parse files with the following error:In general, the parser seems to be more sensitive to the YAML types that the real CloudFormation service is, which I guess is reasonable. However, I tracked this down to a parsing issue in
AWSLambdaFunction_Environment
.AWSLambdaFunction_Environment
defines Variables asmap[string]string
, but the CloudFormation docs imply that any type is allowed as a value, https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.htmlIn my case, I have something like this:
So the JSON parsing that is done via
goformation.ParseYAML()
requires me to convert the value ofdata_volume_size
to a string, but there doesn't seem to be a way to do that.