serverless / serverless/examples

Variables from Javascript module, instance of serverless undefined

Open
#260 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.5k
Forks
4.4k
Avg merge
2h 55m
Merged PRs (30d)
3

Description

HI, trying to make use of variables exported from a JS file as I need access to the serverless object.

module.exports = (serverless) => {
  serverless.cli.consoleLog('You can access Serverless config and methods as well!'); //<-- always null for me

  return {
    property1: 'some value',
    property2: 'some other value'
  }
}

in serverless.yml

stackTags: ${file(./lib/stackTags.js)}

from https://serverless.com/framework/docs/providers/aws/guide/variables/#reference-variables-in-javascript-files

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JavaScript variable example in lib/stackTags.js and its stackTags reference in serverless.yml, then compare the observed undefined serverless object with the linked Serverless variable documentation. Reproduce the configuration load and determine whether the documented behavior works; done when the behavior is corrected or clearly documented as unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.