我有一个使用私有Git(在Github上)repo上的Python无服务器项目.
Requirements.txt文件如下所示:
itsdangerous==0.24
boto3>=1.7
git+ssh://git@github.com/company/repo.git#egg=my_alias
Run Code Online (Sandbox Code Playgroud)
项目的配置主要是这样的
plugins:
- serverless-python-requirements
- serverless-wsgi
custom:
wsgi:
app: app.app
packRequirements: false
pythonRequirements:
dockerizePip: true
dockerSsh: true
Run Code Online (Sandbox Code Playgroud)
当我使用此命令进行部署时:
sls deploy --aws-profile my_id --stage dev --region eu-west-1
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Command "git clone -q ssh://git@github.com/company/repo.git /tmp/pip-install-a0_8bh5a/my_alias" failed with error code 128 in None
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?我怀疑我为Github访问配置SSH密钥的方式或无服务器包的配置.
我知道这首先错过了使用Cloud Functions的意义,但是在我的特定情况下,我正在使用Cloud Functions,因为这是将Next.js与Firebase Hosting桥接的唯一方法。我不需要使其具有成本效益,等等。
话虽如此,Cloud Functions的冷启动时间简直难以忍受,而且还不能投入生产,对于我的样板,平均大约需要10到15秒。
我当然已经看过Google的这段视频(https://www.youtube.com/watch?v=IOXrwFqR6kY),其中谈到了如何减少冷启动时间。简而言之:1)修剪依赖关系; 2)依赖关系版本在Google网络缓存中的尝试和错误; 3)延迟加载。
但是,嘿,1)我可以裁剪的依赖项太多了。2)真是无用的建议!我怎么知道哪个版本的缓存更多?3)只有太多依赖项可以延迟加载。
另一种方法是一起避免冷启动。从本质上讲,我可以使(一个或唯一一个)云功能保持温暖是什么好方法?
使用 apollo-server-lambda 在 lambda 无服务器中设置 cookie
我正在从 apollo-server 迁移到无服务器版本。有没有办法可以访问响应对象或其他方式来设置 cookie?
context: ({ event, context }) => ({
headers: event.headers,
functionName: context.functionName,
event,
context,
}),
Run Code Online (Sandbox Code Playgroud)
我期望在上下文中可以像在 apollo-server 中一样访问 res 对象。
期望的行为如下:
所需的解决方案将有两个管道,第二个管道由第一个管道的成功触发。
如果您有任何其他想法,我很高兴听到!
提前致谢
amazon-web-services devops aws-codecommit aws-codepipeline serverless
我希望在 Amazon S3 上托管一个静态网站,而不实际授予公众对存储桶的访问权限。我正在使用一个客户端AWS帐户,其中所有存储桶都已被阻止公共访问,当我尝试将我的存储桶配置为公共时,它会将我重定向到一个页面,我必须在其中授予对所有存储桶的公共访问权限。
我想在我的kali linux上使用无服务器.为了进行无服务器安装,我们需要节点js安装,我已经完成了.
root@gpunk:~# npm --version
3.10.10
root@gpunk:~# node --version
v6.10.0
root@gpunk:~# nvm --version
0.31.0
Run Code Online (Sandbox Code Playgroud)
(github上的一些解决方案建议由nvm安装节点js来解决这个问题,并尝试了这一点.).现在当我运行命令来npm install -g serverless安装无服务器时,我收到以下错误消息.
root@gpunk:~# npm install -g serverless
/root/.nvm/versions/node/v6.10.0/bin/serverless -> /root/.nvm/versions/node/v6.10.0/lib/node_modules/serverless/bin/serverless
/root/.nvm/versions/node/v6.10.0/bin/slss -> /root/.nvm/versions/node/v6.10.0/lib/node_modules/serverless/bin/serverless
/root/.nvm/versions/node/v6.10.0/bin/sls -> /root/.nvm/versions/node/v6.10.0/lib/node_modules/serverless/bin/serverless
> serverless@1.24.1 postinstall /root/.nvm/versions/node/v6.10.0/lib/node_modules/serverless
> node ./scripts/postinstall.js
?????????????????????????????????????????????????????
? serverless update check failed ?
? Try running with sudo or get access ?
? to the local update config store via ?
? sudo chown -R $USER:$(id -gn $USER) /root/.config ?
?????????????????????????????????????????????????????
/root/.nvm/versions/node/v6.10.0/lib
`-- serverless@1.24.1
Run Code Online (Sandbox Code Playgroud)
我犯了什么可能的错误,以及如何克服它?
尝试运行无服务器时收到以下警告。
无服务器警告 -------------------------------------
找不到满足声明 'opt:stage' 的有效选项。下面是我的 serverless.yml 文件
# Serverless Config
service: api-service
# Provider
provider:
name: aws
runtime: nodejs8.10
region: ${opt:region, 'ap-east-1'}
stage: ${opt:stage, 'dev'}
# Enviroment Varibles
environment:
STAGE: ${self:custom.myStage}
MONGO_DB_URI: ${file(./serverless.env.yml):${opt:stage}.MONGO_DB_URI}
LAMBDA_ONLINE: ${file(./serverless.env.yml):${opt:stage}.LAMBDA_ONLINE}
# Constants Varibles
custom:
# environments Variables used for convert string in upper case format
environments:
myStage: ${opt:stage, self:provider.stage}
stages:
- dev
- qa
- staging
- production
region:
dev: 'ap-east-1'
stage: 'ap-east-1'
production: 'ap-east-1'
# Function
functions:
testFunc:
handler: index.handler
description: ${opt:stage} API's …Run Code Online (Sandbox Code Playgroud) 我正在构建一个无服务器应用程序,它在资源中定义了一个 SQS 队列,如下所示:
resources:
Resources:
TheQueue:
Type: "AWS:SQS:Queue"
Properties:
QueueName: "TheQueue"
Run Code Online (Sandbox Code Playgroud)
我想从其中一个函数中向这个队列发送消息。如何从函数内部访问 URL?我想把它放在这里:
const params = {
MessageBody: 'message body here',
QueueUrl: 'WHATS_THE_URL_HERE',
DelaySeconds: 5
};
Run Code Online (Sandbox Code Playgroud) 我正在运行我的 nodejs 代码并安装了无服务器(npm i -g serverless)但是在使用命令运行它时sls offline start --CacheInvalidations我收到错误:-
无服务器错误 -------------------------------
未找到无服务器命令“离线”。您指的是 “config” 吗? 运行“无服务器帮助”以获取所有可用命令的列表。
得到支持 - - - - - - - - - - - - - - - - - - - - - -
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Run Code Online (Sandbox Code Playgroud)
您的环境信息 ---------------------------
Operating System: linux
Node Version: 12.18.2
Framework Version: 1.79.0
Plugin Version: 3.7.1
SDK Version: 2.3.1
Components Version: 2.34.6
Run Code Online (Sandbox Code Playgroud) 今天早上,我项目的无服务器部署开始失败。我没有更改代码中的任何内容,最后一次成功部署大约是在一周前。
这是部署日志:
Error --------------------------------------------------
Error: Unknown object type "asyncfunction"
at Object._object (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:218:17)
at Object._function (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:319:14)
at Object.dispatch (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:185:30)
at /usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:242:21)
at Object._function (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:319:14)
at Object.dispatch (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:185:30)
at /usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:242:21)
at Object.dispatch (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:185:30)
at /usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:242:21)
at Object.dispatch (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:185:30)
at /usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:242:21)
at Object.dispatch (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:185:30)
at /usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:246:18
at Array.forEach (<anonymous>)
at Object._object (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:242:21)
at Object.dispatch (/usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:185:30)
at /usr/local/lib/node_modules/serverless/node_modules/object-hash/index.js:246:18
at Array.forEach …Run Code Online (Sandbox Code Playgroud) serverless ×10
node.js ×2
amazon-s3 ×1
amazon-sqs ×1
aws-lambda ×1
cloud ×1
devops ×1
graphql ×1
hosting ×1
javascript ×1
jenkins ×1
lambda ×1
linux ×1
next.js ×1
npm ×1
pip ×1
python ×1