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

sls invoke local replaces environment variables with [object Object] #3080

Closed
gwsii opened this Issue Jan 11, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@gwsii
Copy link
Contributor

gwsii commented Jan 11, 2017

Bug Report

Description

For bug reports:

  • What went wrong?
    Attempted to run my Lambda function locally.

  • What did you expect should have happened?
    Function runs locally in the same way that it would be invoked in AWS.

  • What was the config you used?
    Here's the relevant declaration:

functions:
scrapeProducts:
handler: 'produce-products.handler'
environment:
STREAM_WRITER_ROLE:
'Fn::ImportValue': 'hello-retail-stream:${self:custom.stage}:RetailStreamWriterArn'
STREAM_NAME:
'Fn::ImportValue': 'hello-retail-stream:${self:custom.stage}:RetailStreamName'
role:
Fn::GetAtt:
- ProductStreamProducer
- Arn

  • What stacktrace or error message from your provider did you see?

{ [ValidationError: Missing credentials in config]
message: 'Missing credentials in config',
code: 'CredentialsError',
time: Tue Jan 10 2017 16:16:42 GMT-0800 (PST),
requestId: '3ad96a44-d793-11e6-8116-834f226c697d',
statusCode: 400,
retryable: false,
retryDelay: 85.4559698374942,
originalError:
{ message: 'Could not load credentials from TemporaryCredentials',
code: 'CredentialsError',
time: Tue Jan 10 2017 16:16:42 GMT-0800 (PST),
requestId: '3ad96a44-d793-11e6-8116-834f226c697d',
statusCode: 400,
retryable: false,
retryDelay: 85.4559698374942,
originalError:
{ message: '1 validation error detected: Value '[object Object]' at 'roleArn' failed to satisfy constraint: Member must have length greater than or equal to 20',
code: 'ValidationError',
time: Tue Jan 10 2017 16:16:42 GMT-0800 (PST),
requestId: '3ad96a44-d793-11e6-8116-834f226c697d',
statusCode: 400,
retryable: false,
retryDelay: 85.4559698374942 } } }

Additional Data

Have a look at the project here for a more complete picture:

https://github.com/Nordstrom/hello-retail/tree/scrape-store-products

It makes some sense that SLS may not be able to resolve the CF template values when running locally. But, having the string value "[object Object]" in place of the correct value was very confusing.

  • Serverless Framework Version you're using: 1.4
  • Operating System: Mac OS El Capitan
  • Stack Trace: See above
  • Provider Error messages: '1 validation error detected: Value '[object Object]' at 'roleArn' failed to satisfy constraint: Member must have length greater than or equal to 20'

@pmuens pmuens added the bug label Jan 11, 2017

@arabold

This comment has been minimized.

Copy link

arabold commented May 17, 2017

This is still an issue and inspired us to write a simple plugin for that: https://github.com/arabold/serverless-export-env

This will hook into sls invoke local and ensure all environment variables are properly resolved using their CloudFormation values. This, of course, requires your stack to be already deployed so all the variables do exist. But it still runs your local code so you can test your environment as expected.

@pmuens

This comment has been minimized.

Copy link
Member

pmuens commented Feb 7, 2019

Closing since this issue is quite old and we've published lots of releases with fixes in the past.

Feel free to re-open if this is still a problem.

@pmuens pmuens closed this Feb 7, 2019

@finch-podium

This comment has been minimized.

Copy link

finch-podium commented Feb 15, 2019

@pmuens Ive had my serverless project working well with using invoke-local for several months now. Now suddenly, I am experiencing this issue on version 1.37.1.

What is the accepted method of resolving this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.