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

Key must be a buffer #363

Open
jpswade opened this issue Jul 27, 2017 · 5 comments
Open

Key must be a buffer #363

jpswade opened this issue Jul 27, 2017 · 5 comments
Labels

Comments

@jpswade
Copy link

jpswade commented Jul 27, 2017

+ node-lambda deploy
=> Moving files to temporary directory
=> Running npm install --production
=> Zipping deployment package
=> Zipping repo. This might take up to 30 seconds
=> Reading zip file to memory
=> Reading event source file to memory
=> Uploading zip file to AWS Lambda eu-west-1 with parameters:
{ FunctionName: 'api-production',
  Code: { ZipFile: <Buffer 50 4b 03 04 14 00 08 00 08 00 48 6c fb 4a 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 2e 65 6e 76 4d 8e 4d 6f 82 40 18 84 ef fc 0c ef da 6a ad 35 ... > },
  Handler: 'index.handler',
  Role: 'arn:aws:iam::123456789012:role/<lambda_role>',
  Runtime: 'nodejs6.10',
  Description: 'api',
  MemorySize: '128',
  Timeout: '3',
  Publish: false,
  VpcConfig: { SubnetIds: [], SecurityGroupIds: [] },
  Environment: { Variables: null },
  DeadLetterConfig: { TargetArn: null },
  TracingConfig: { Mode: null } }
Key must be a buffer
=> Retrying
{ TypeError: Key must be a buffer
    at TypeError (native)
    at new Hmac (crypto.js:91:16)
    at Object.Hmac (crypto.js:89:12)
    at Object.hmac (/usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/util.js:401:30)
    at Object.getSigningKey (/usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/signers/v4_credentials.js:59:8)
    at V4.signature (/usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/signers/v4.js:97:36)
    at V4.authorization (/usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/signers/v4.js:92:36)
    at V4.addAuthorization (/usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/signers/v4.js:34:12)
    at /usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/event_listeners.js:215:18
    at finish (/usr/lib/node_modules/node-lambda/node_modules/aws-sdk/lib/config.js:315:7) retryDelay: 91.55329953571814 }

I suspect that this is because I am not giving it an IAM account credentials, instead opting to use EC2 roles...

"If your application has AWS credentials baked into it, you're "doing it wrong""

@DeviaVir DeviaVir added the bug label Jul 27, 2017
@abetomo
Copy link
Contributor

abetomo commented Aug 9, 2017

@jpswade Is there anything we can do to help you?
It seems that you are grasping the cause, so I thought it could be solved.

@jpswade
Copy link
Author

jpswade commented Aug 14, 2017

@abetomo Yes. I would recommend that instead of throwing an error, the issue is handled gracefully and you are advised that it does not support EC2 roles.

Or you could support EC2 roles.

@DeviaVir
Copy link
Collaborator

@abetomo my guess is that we should check if these keys are set:
https://github.com/motdotla/node-lambda/blob/master/lib/main.js#L757-L760
before assigning them. If you leave them empty EC2 roles should do the right thing.

If neither of you can create a PR for this earlier than me, I will pick this up soon.

@abetomo
Copy link
Contributor

abetomo commented Aug 15, 2017

@jpswade @DeviaVir
I misunderstood the contents of the problem.
I understood, so I will fix it.

@abetomo
Copy link
Contributor

abetomo commented Aug 15, 2017

@jpswade @DeviaVir
Even with the current code, it seems that EC2 role is used when emptying or deleting the value of authentication information in the setting of .env.

If EC2 role is attached, will you modify it so that it will be used preferentially?

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

3 participants