Dan Coates
05/20/2022, 2:07 AMchrome-aws-lambda
and puppeteer working with local sst start. I've tried various combinations of bundle options including nodeModules
and externalModules
and copyFiles
but nothing seems to work and the nodeModules
and copyFiles
settings seem to have no effect on what ends up in the artifact file when running via sst start
.
I've also tested out the example at https://github.com/serverless-stack/serverless-stack/tree/master/examples/layer-chrome-aws-lambda and get the same error of Cannot find module 'chrome-aws-lambda'
If I remove chrome-aws-lambda
from the externalModules
setting then there is a different error Cannot find module ...<path omitted>/backend/functions/puppeteer/lib/Browser
The readme in the example makes it seem like it should work with sst start
but it doesn't seem to.outaTiME
05/20/2022, 3:08 AMoutaTiME
05/20/2022, 3:08 AMoutaTiME
05/20/2022, 3:10 AMpuppeteer
as a dev dependencyoutaTiME
05/20/2022, 3:11 AMchrome-aws-lambda
and puppeteer-core
as dependenciesDan Coates
05/20/2022, 3:55 AMDan Coates
05/20/2022, 3:57 AMi can share some examples so I want to know what version you are usingthat'd be fantastic if you could, thank you
outaTiME
05/20/2022, 4:05 AM"dependencies": {
"@serverless-stack/cli": "1.1.2",
"@serverless-stack/resources": "1.1.2",
"aws-cdk-lib": "2.24.0",
"chrome-aws-lambda": "^10.1.0",
"puppeteer-core": "^10.1.0",
},
"devDependencies": {
"puppeteer": "^10.1.0"
}
this is the definition on my stack:
socialNotify: {
function: {
handler: 'src/subscribers/social-notify.handler',
bundle: {
externalModules: ['chrome-aws-lambda'],
},
layers: ['arn:aws:lambda:us-east-1:764866452798:layer:chrome-aws-lambda:25'],
// ~30s
timeout: '1 minute',
},
cdk: {
subscription: {
filterPolicy: {
event: SubscriptionFilter.stringFilter({
allowlist: ['social-notify'],
}),
},
},
},
},
finally, you can check my lambda here: https://github.com/outaTiME/ambito-dolar/blob/master/packages/api/src/subscribers/social-notify.js
side note, that’s my app’s productive repository that uses SST 0.69 but the lambda stays intact for SST 1.x, hope it helps 🙏Dan Coates
05/20/2022, 4:35 AMmanitej
05/20/2022, 5:38 AMDan Coates
05/20/2022, 5:49 AMmanitej
05/20/2022, 5:53 AMDan Coates
05/20/2022, 5:53 AMFrank
Frank
Frank
Dan Coates
05/22/2022, 3:10 AMchrome-aws-lambda
is marked as an externalModule in the stack config, and even if you remove that, you get the Cannot find module ...<path omitted>/backend/functions/puppeteer/lib/Browser
error I mentioned above.Tony J
06/03/2022, 2:41 AMDan Coates
06/03/2022, 2:43 AM