Skip to content

Variables from external yml file not being referenced properly when writing to lambda environment #5272

Closed

Description

@AJF4

This is a Bug Report

Description

  • What went wrong?

I'm using a config.yml which is imported wholly as self:custom.parameters.
Some of the variables within the config.yml are passed to a lambda as environment variables.
The stack deploys properly, but inspecting the values written to the lambda environment shows that they are incorrect. They have values similar to : ${{deep:5}.concat_regex}

  • What did you expect should have happened?

The values written to the environment should be the dereferenced version, ie the value of concat_regex

  • What was the config you used?

serverless.yml (abridged)

service: test_service

custom:
  parameters: ${file(${{opt:config_file}})}
  topicName: 'TestTopic'

provider:
  variableSyntax: "\\${{([ ~:a-zA-Z0-9._\\'\",\\-\\/\\(\\)]+?)}}"
  name: aws
  runtime: python3.6
  timeout: 300

functions:
  startup:
    handler: handler.startup
    events:
      - sns:
          arn:
            Ref: UploadNotificationTopic
          topicName:  ${{self:custom.newItemNotificationTopic}}
    environment:
      concat_regex: ${{self:custom.parameters.concat_regex}}

config.yml

concat_regex: '.*list\.lst$'
  • What stacktrace or error message from your provider did you see?

No errors reported, but Startup lambda environment actually has value ${{deep:5}.concat_regex} instead of *list.lst$

Similar or dependent issues:
*

Additional Data

  • Serverless Framework Version you're using:
    Originally found on 1.27.3, now upgrade to 1.30.3
  • Operating System:
    Mac OS 10.13.6
  • Stack Trace:
  • Provider Error messages:

Activity

  1. AJF4 commented on Sep 4, 2018

    @AJF4
    Author

    Additional info:

    Replacing

    functions:
      startup:
        handler: handler.startup
        events:
          - sns:
              arn:
                Ref: UploadNotificationTopic
              topicName:  ${{self:custom.newItemNotificationTopic}}
        environment:
          concat_regex: ${{self:custom.parameters.concat_regex}}
    

    with

    functions:
      startup:
        handler: handler.startup
        events:
          - sns:
              arn:
                Ref: UploadNotificationTopic
              topicName:  ${{self:custom.newItemNotificationTopic}}
        environment:
          concat_regex: ${{file(${{opt:config_file}}):concat_regex}}
    

    results in correct dereferencing.

  2. medikoo commented on Apr 12, 2021

    @medikoo
    Contributor

    Issue refers to old variable resolver which is deprecated and has most of its issues solved by new resolver.

    Closing as I believe with new resolver there's no longer need to tweak provider.variableSyntax and here it's the source of an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions