Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse fails when using a number as a Lambda environment value #639

Open
jpeach opened this issue Nov 27, 2023 · 0 comments
Open

Parse fails when using a number as a Lambda environment value #639

jpeach opened this issue Nov 27, 2023 · 0 comments

Comments

@jpeach
Copy link

jpeach commented Nov 27, 2023

I used goformation.ParseYAML() to parse a working CloudFormation template that has some Lambda resources. The parse files with the following error:

json: cannot unmarshal number into Go struct field Template.Resources of type string

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 as map[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.html

In my case, I have something like this:

Parameters:
  DataVolSize:
    Type: Number
    Description: >-
      Minimum: 100 GB
    Default: 100
    MinValue: 100
Resources:
  Initializer:
    Type: 'AWS::Lambda::Function'
    Properties:
      Environment:
        Variables:
          data_volume_size: !Ref DataVolSize
      Code:
        ZipFile: |-

So the JSON parsing that is done via goformation.ParseYAML() requires me to convert the value of data_volume_size to a string, but there doesn't seem to be a way to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant