serverless-python-requirements
serverless-python-requirements copied to clipboard
No such file error while using Custom Image for Lambda
Are you certain it's a bug?
- [X] Yes, it looks like a bug
Are you using the latest plugin release?
- [X] Yes, I'm using the latest plugin release
Is there an existing issue for this?
- [X] I have searched existing issues, it hasn't been reported yet
Issue description
When we've configured lambda with a custom docker image, and also configured python requirements layer using serverless-python-requirements
(of course for custom image functions we can't attach a layer)
Here expected to deploy the application without error, or at least show an error/warning to convey that layers are not supported for custom image functions, instead I got the error.
Here better to add one validation, which will raise an error if we configure the layers for custom image functions.
Service configuration (serverless.yml) content
service: my-service
useDotenv: true
provider:
name: aws
runtime: python3.9
stage: ${opt:stage, 'alpha'}
apiName: ${self:service}
region: ap-south-1
memorySize: 512
timeout: 60
lambdaHashingVersion: 20201221
endpointType: regional
logs:
restApi: true
level: INFO
deploymentBucket:
blockPublicAccess: true
name: ${env:CODE_DEPLOYMENT_BUCKET}
maxPreviousDeploymentArtifacts: 3
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
slim: true
useDownloadCache: false
useStaticCache: false
layer:
name: ${self:service}-${self:provider.stage}-requirements-python39
description: Requirements Lambda layer for My Lambda Function
compatibleRuntimes:
- python3.9
config:
CODE_DEPLOYMENT_BUCKET: ${env:CODE_DEPLOYMENT_BUCKET}
DOCKER_IMAGE_NAME: ${env:DOCKER_IMAGE_NAME}
DOCKER_IMAGE_NAME_WITH_TAG_IN_ECR: ${aws:accountId}.dkr.ecr.${self:provider.region}.amazonaws.com/${self:custom.config.DOCKER_IMAGE_NAME}:${self:provider.stage}
functions:
debugger_handler:
image: ${self:custom.config.DOCKER_IMAGE_NAME_WITH_TAG_IN_ECR}
name: ${self:service}-${self:provider.stage}
layers:
- {Ref: PythonRequirementsLambdaLayer}
events:
- http:
path: /mypath/
method: post
integration: lambda-proxy
cors: true
Command name and used flags
serverless deploy --stage alpha
Command output
✖ Stack my-service-alpha failed to deploy (0s)
Environment: linux, node 12.20.1, framework 3.26.0, plugin 6.2.2, SDK 4.3.2
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Error: ENOENT: no such file or directory, open '.serverless/requirements.txt'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at module.exports (/home/ib-developer/node_modules/sha256-file/index.js:24:19)
at sha256Path (/home/ib-developer/node_modules/serverless-python-requirements/lib/shared.js:134:10)
at ServerlessPythonRequirements.zipRequirements (/home/ib-developer/node_modules/serverless-python-requirements/lib/layer.js:16:23)
at ServerlessPythonRequirements.tryCatcher (/home/ib-developer/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/ib-developer/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/ib-developer/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromiseCtx (/home/ib-developer/node_modules/bluebird/js/release/promise.js:641:10)
at _drainQueueStep (/home/ib-developer/node_modules/bluebird/js/release/async.js:97:12)
at _drainQueue (/home/ib-developer/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/home/ib-developer/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/home/ib-developer/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:461:21)
1 deprecation found: run 'serverless doctor' for more details
Environment information
Framework Core: 3.26.0
Plugin: 6.2.2
SDK: 4.3.2
@serverless @pgrzesik any update on this?