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

deploy command not picking up deploy.env variables #301

Open
gitgrimbo opened this issue May 29, 2017 · 12 comments
Open

deploy command not picking up deploy.env variables #301

gitgrimbo opened this issue May 29, 2017 · 12 comments
Labels

Comments

@gitgrimbo
Copy link

gitgrimbo commented May 29, 2017

In my package.json I have the following deploy command in scripts:

  "scripts": {
    "deploy": "node-lambda deploy --configFile deploy.env --prebuiltDirectory dist",

My deploy.env is:

AWS_ACCESS_KEY_ID=xxx
AWS_SECRET_ACCESS_KEY=yyy

If I log the key and secret key here I get this:

your_key your_secret

followed by this error:

The security token included in the request is invalid.

UnrecognizedClientException: The security token included in the request is invalid.
    at Object.extractError (MY_PROJECT\node_modules\aws-sdk\lib\protocol\json.js:48:27)
    at Request.extractError (MY_PROJECT\node_modules\aws-sdk\lib\protocol\rest_json.js:37:8)
    at Request.callListeners (MY_PROJECT\node_modules\aws-sdk\lib\sequential_executor.js:105:20)
    at Request.emit (MY_PROJECT\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
    at Request.emit (MY_PROJECT\node_modules\aws-sdk\lib\request.js:678:14)
    at Request.transition (MY_PROJECT\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (MY_PROJECT\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at MY_PROJECT\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (MY_PROJECT\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (MY_PROJECT\node_modules\aws-sdk\lib\request.js:680:12)

I'm not sure what the problem is here. Can I not use a combination of --configFile and other node-lambda CLI parameters?

The env vars are in the params if I print those out:

params { FunctionName: 'MY_FUNCTION_NAME',
  Code: { ZipFile: <Buffer 50 4b 03 04 0a 00 00 00 08 00 49 58 bd 4a 9e b6 b4 2d 70 ff 07 00 81 ac 24 00 08 00 00 00 69 6e 64 65 78 2e 6a 73 ec bd 7b 7b 1b 37 ae 38 fc 7f 9e e7 ... > },
  Handler: 'index.handler',
  Role: 'your_amazon_role',
  Runtime: 'nodejs6.10',
  Description: '',
  MemorySize: '128',
  Timeout: '3',
  Publish: false,
  VpcConfig: { SubnetIds: [], SecurityGroupIds: [] },
  Environment:
   { Variables:
      { AWS_ACCESS_KEY_ID: 'xxx',
        AWS_SECRET_ACCESS_KEY: 'yyy' } },
  DeadLetterConfig: { TargetArn: null },
  TracingConfig: { Mode: null } }
@abetomo
Copy link
Contributor

abetomo commented May 29, 2017

@gitgrimbo
Running node-lambda setup also creates .env.
It is good to set AWS_ACCESS_KEY_ID etc there.

@gitgrimbo
Copy link
Author

Thanks. Is that to say using configFile doesn't work with deploy.env and I should be using no configFile argument and a .env file instead?

@abetomo
Copy link
Contributor

abetomo commented May 29, 2017

@gitgrimbo
.env is automatically loaded so you do not need to specify options.
--configFile and deploy.env are used to configure "Environment variables" which can be checked on the web console.

@gitgrimbo
Copy link
Author

Ah, so .env and my deploy.env actually serve different purposes?

@abetomo
Copy link
Contributor

abetomo commented May 29, 2017

Yes. The roles of .env and deploy.env are different.

Basically it can be deployed by setting the necessary values in the .env created by running node-lambda setup.
(Use deploy.env to set the environment variables you want to use on Lambda. It can be deployed without setting deploy.env.)

@gitgrimbo
Copy link
Author

Thanks for your help.

@DeviaVir
Copy link
Collaborator

Should we clarify this better in the docs, or should we close this issue?

@RickDT
Copy link

RickDT commented May 29, 2017 via email

@gitgrimbo
Copy link
Author

One file is for the secrets that are used to connect to AWS (.env), the other could be for secrets that are used by the function at run time (deploy.env / secrets)? I think that's where I was getting mixed up.

@madorb
Copy link

madorb commented Jun 15, 2017

build.env / runtime.env? the deploy naming is confusing - it could reasonably be interpretted as either the vars for use in the deployment process or the vars that are deployed by said process.

@forzagreen
Copy link

@abetomo if I want to use only .env:
if I put all my "Environment variables" in .env, will this work out ? i.e. will these variables be available in my deployed lambda ?

@abetomo
Copy link
Contributor

abetomo commented Aug 17, 2017

@forzagreen
Environment variables you wish to use with Lambda Funciton must be set in deploy.env and must be specified as an option when deploying.

example:

% node-lambda deploy -f ./deploy.env

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

No branches or pull requests

6 participants