Skip to content

Variables: Pass CLI params to JS file resolvers #4143

Closed

Description

@awildturtok

This is a Feature Proposal

Description

The functionality to include and evaluate JavaScript files is pretty neat, though it seems to be kinda inflexible. My proposal would be to pass the options object that is already available into the handler, when evaluating the js file.

The only change necessary seems to be adding the options here.

It's obviously debatable wether this strays too far into the territory of plugins, but it would make my life right now a lot easier without any (for me) obvious drawbacks.

Activity

  1. martinjlowm commented on Mar 23, 2018

    @martinjlowm

    Any news on this issue?

    My current situation is that I need to know provider information in a JavaScript file. A smart way would be to simply pass that information with something like ${file(config.js):someVariable(${self:provider.region}). - obviously, that is not yet possible.

    A hacky workaround is to pass arguments as environment variables, but that would (to be dynamic) require region in serverless.yml to be set with ${env:REGION} and then reference process.env.REGION in the JavaScript file.

  2. changed the title [-]Passing options to invoked javascript files, with file syntax[/-] [+]Variables: Pass CLI params to JS file resolvers[/+] on Dec 29, 2020
  3. medikoo commented on Dec 29, 2020

    @medikoo
    Contributor

    I think it's doable to pass CLI params (so what internally is often called options) to JS file variable resolvers, and we'll take it into account when rewriting variable resolver, which is covered here: #7207

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