by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 01 2016 23:48
    @gojko banned @codepreneur
Tadej Vengust
@MoMannn
works without a problem with 5.11.0
Kirtesh Jain
@kirteshjain
how to use claudia deploy with an existing iam role
Lucas de Araújo
@lucasnasuecia_twitter
You can use the --role parameter
Wes
@wmelton
Is there a preferred way using Express to export the module if its running on AWS but run it as a thread if devving local? This approach throws an error.
if (isLambda) {
    // You're on AWS Lambda
    module.exports = app;
} else {
    // Local or elsewhere
    app.listen(3000);
}
index.js does not export method handler
Slobodan Stojanović
@stojanovic
Create another file for running the Express server locally. For example, app.local.js, similar to the one in this example: https://link.medium.com/upJrZSfaq6
Wes
@wmelton
@stojanovic brilliant. Thank you!
Kirtesh Jain
@kirteshjain
when I upload my express api project to aws lambda
it says deployment package too large
Is there anyway I can seperate my api routes into seperate aws lambda function
Slobodan Stojanović
@stojanovic
Not out of the box. How big is your app? You can use S3 to be able to upload larger apps (up to 250mb instead of 50mb)
Kirtesh Jain
@kirteshjain
currently its 10mb
but I see most of the size is due to node_modules
Slobodan Stojanović
@stojanovic
It’s more than that, try claudia pack, that will show you the size of the zip file
Kirtesh Jain
@kirteshjain
Is there any benefit of using 1 lambda function for app vs seperate aws lambda function for each route ?
Slobodan Stojanović
@stojanovic
Use --use-s3-bucket to upload larger packages
Kirtesh Jain
@kirteshjain
ok thanks
Is there any benefit of using 1 lambda function for app vs seperate aws lambda function for each route ?
Slobodan Stojanović
@stojanovic
I would suggest using multiple Lambda functions, but no one can automatically split the express app for you.
Kirtesh Jain
@kirteshjain
what advantages I have using seperate lambda functions
I was wondering how do I deploy it as seperate lambda function from my express app. The only way I see is to go in aws and create functions there
Slobodan Stojanović
@stojanovic

If you want to have your app in AWS Lambda fast, deploy your express app directly, then start splitting it.

There are many benefits. Smaller apps are faster (you probably heard about cold start, it almost doesn’t not exist with small lambdas). It’s easier to debug (logs will be separated by routes)...

Kirtesh Jain
@kirteshjain
ok
thanks for your response
Slobodan Stojanović
@stojanovic
You can create multiple functions using Claudia or even easier using AWS SAM, but you’ll need to change your code. You can’t just deploy parts of Express app to different Lambdas.
Kirtesh Jain
@kirteshjain
how to create multiple functions using claudia ?
any article you can direct me to achieve that ?
Ghost
@ghost~529c6a01ed5ab0b3bf04d228
Hi,
I want to create a nodejs layer, in order to later create multiple functions that require it.
Is there a way to create the layer using claudia ?I have seen the announcement that linking layers is now supported (5.3), but I could not find info on creating the actual layer.
Ross Coundon
@rcoundon
I'm back to trying to get sharp working with Lambda (having failed previously)
I'm following the instructions here to create a layer - https://github.com/lovell/sharp/issues/1702#issuecomment-499331245
But I cannot seem to reference sharp from within my lambda. I'm lazy loading it (have tried from 'sharp' and from '../../opt/node_modules/sharp' but I'm getting MODULE_NOT_FOUND. Anyone have any clues?
Ross Coundon
@rcoundon

I'm back to trying to get sharp working with Lambda (having failed previously)
I'm following the instructions here to create a layer - https://github.com/lovell/sharp/issues/1702#issuecomment-499331245
But I cannot seem to reference sharp from within my lambda. I'm lazy loading it (have tried from 'sharp' and from '../../opt/node_modules/sharp' but I'm getting MODULE_NOT_FOUND. Anyone have any clues?

I've finally done it :-D. If anyone is trying to do similar. I created a layer and installed sharp using npm install --arch=x64 --platform=linux sharp.
I zipped this and added it to AWS as a lambda layer. Then I lazy-loaded sharp in my code using
const sharp = require('/opt/node_modules/sharp');

Jacky Liang
@mrjackyliang
When using the authorizer, I am getting an API_CONFIGURATION_ERROR only on the prod stage. The dev stage works fine.
Weird thing is that when I call an endpoint, only one of the prod URLs work, and everything else doesn't. I'm confused on where to continue.
I have set a dev and prod stage to the authorizer, but I doubt that works because the authorizer itself isn't attached to any API gateway.
Jacky Liang
@mrjackyliang
This is what I get on the CloudWatch logs Execution failed due to configuration error: Invalid permissions on Lambda function
Jacky Liang
@mrjackyliang
I used the set-version command to make the prod stage
There's an error, but I don't know what it means
What I noticed is that the prod stage doesn't link to the API Gateway like the dev stage.
Jacky Liang
@mrjackyliang
@gojko @stojanovic Any ideas on how to fix this issue?
Jacky Liang
@mrjackyliang
Okay so I found the issue, and it seems to be a bug of Claudia? When using the set-version command, it doesn't create a proper permission policy for that stage. So, I created a command for aws command line.
aws lambda add-permission --function-name FUNCTION:STAGE --statement-id web-api-access-STAGE-TIMESTAMP --action lambda:InvokeFunction --principal apigateway.amazonaws.com --source-arn arn:aws:execute-api:REGION:ACCOUNT_ID:API_ID/authorizers/\*
Jacky Liang
@mrjackyliang
Surprisingly, I found out you must run the update command for the prod after running set-version. So I assume it's problem solved.
Gojko Adzic
@gojko
@mrjackyliang set-version is designed to be a very quick alias update, as opposed to uploading new code, function config etc
so you can't set the version to an alias that's never been deployed before; you need to use claudia update at least once for that alias
or claudia create to set it initially
after, that, you can use set-version to reassign a deployed alias
Jacky Liang
@mrjackyliang
So the commands would be claudia create --version dev, then claudia set-version --version prod, and finally claudia update --version prod
Cody Seibert
@codyseibert
when running claudia in a ci/cd pipeline, do you store the claudia.json in s3 and fetch it before you run a deploy? Where are docs on using this in a ci/cd pipeline?
Oguzhan Cakmak
@muratcakmak
Hey folks,
I can't see anywhere if there is an argument to switch yarn instead of npm. I am using yarn workspaces and try to create a lambda function from a project which depends on another local package in monorepo. npm --production fails to recognize local packages so yarn support would be life saver
Gojko Adzic
@gojko
@codyseibert we commit claudia.json to version control