python - 无法使用 serverless-python-requirements STDERR 部署无服务器烧瓶应用程序:
问题描述
按照这个https://www.serverless.com/blog/flask-python-rest-api-serverless-lambda-dynamodb
在 AWS Lambda 上构建一些烧瓶应用程序
我已经用 python3.8 激活了 venv
virtualenv venv --python=python3
source venv/bin/activate
我对本地很好,但我无法将应用程序部署到 AWS Lambda 这是我的错误
Error --------------------------------------------------
Error: STDOUT: Collecting boto3
Using cached boto3-1.17.74.tar.gz (98 kB)
Collecting flask
Using cached Flask-2.0.0-py3-none-any.whl (93 kB)
Collecting keras
Using cached Keras-2.4.3-py2.py3-none-any.whl (36 kB)
Collecting numpy
Using cached numpy-1.20.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.4 MB)
Collecting opencv-python
Using cached opencv_python-4.5.2.52-cp38-cp38-manylinux2014_x86_64.whl (51.0 MB)
Collecting tensorflow
这是我的 serverless.yml
service: flask-app
plugins:
- serverless-python-requirements
- serverless-wsgi
provider:
name: aws
runtime: python3.8
stage: dev
region: ap-southeast-1
versionFunctions: false
profile: serverless-agent
memorySize: 128
timeout: 30
logRetentionInDays: 14
logs:
restApi: true
environment:
NODE_ENV: ${self:provider.stage}
AWS_PROFILE: ${self:provider.profile}
vpc:
securityGroupIds:
- sg-xxxx
subnetIds:
- subnet-xxxx
iamRoleStatements:
- Effect: "Allow"
Action:
- "secretsmanager:GetSecretValue"
Resource:
- "*"
- Effect: "Allow"
Action:
- "s3:PutObject"
- "s3:PutObjectAcl"
- "s3:GetObject"
- "s3:ListBucket"
- "s3:DeleteObject"
Resource:
- "*"
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource:
- Fn::Join:
- ":"
- - arn:aws:lambda
- Ref: AWS::Region
- Ref: AWS::AccountId
- function:${self:service}-${self:provider.stage}-*
- Effect: "Allow"
Action:
- "sqs:SendMessage"
Resource:
- "*"
functions:
app:
handler: wsgi.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
package:
individually: true
exclude:
- ./node_modules/**
- ./venv/**
custom:
webpack:
packager: "npm"
keepOutputDirectory: true
includeModules:
forceExclude:
- aws-sdk
warmup:
default: true
memorySize: 128
timeout: 60
prewarm: true
schedule: rate(1 minute)
concurrency: 1
wsgi:
app: app.app
packRequirements: false
pythonRequirements:
dockerizePip: non-linux
以及我在 requirements.txt 中的依赖项
flask
numpy
tensorflow
keras
opencv-python
boto3
有什么我错过的吗?
解决方案
我已经知道它了,因为我在 AWS 控制台上进行了测试,并且它没有 http 标头。这是我使用邮递员的时候。
推荐阅读
- spring - Spring-integration:通过链保持消息的上下文
- python - 如何处理媒体文件而不将其保存在 django 中
- c++ - 运行简单代码时出现巨大的延迟峰值
- django - 如何在 Django 中通过多个表单捕获复杂的数据库事务
- css - DIV 角上的三角形
- jsf - Primefaces JSF App的Tomcat8启动失败
- asp.net-core - 为单元测试 Signalr .NetCore 消息集线器模拟 Context.ConnectionId
- hyperledger-fabric - 从客户端发送查询请求时出错:没有可查询的对等方
- r - 除第一列外,删除所有 NA 的行
- php - 无法插入数据库 - PHP