1 回答
TA贡献2065条经验 获得超13个赞
lambda 函数的部署归结为包/模块组织和自动化部署工具。第一个看起来像是在您的问题中解决了共享代码被放置到 util 并且每个 lambda 都有一个单独的包。在问题中,不清楚使用的是什么部署方法。有多种方法可以部署 lambda
命令行界面
AWS 无服务器应用程序模型
Endly - 自动化和 e2e 运行器
地貌
虽然我一直是 e2e 和自动化的倡导者,但针对各种事件的最终运行器多 lambda 部署工作流程可能如下所示
init:
fn1ZipLocation: somepath1.zip
fn2ZipLocation: somepath2.zip
fnXZipLocation: somepathX.zip
pipeline:
build:
fn1:
action: exec:run
target: $target
sleepTimeMs: 1500
errors:
- ERROR
commands:
- cd ${appPath}aeroagg/app
- unset GOPATH
- export GOOS=linux
- export GOARCH=amd64
- go build -o function1
- zip -j somepath1.zip function1
...
deployFunctions:
fn1:
action: aws/lambda:deploy
credentials: aws-e2e
functionname: fn1
runtime: go1.x
handler: main
code:
zipfile: $LoadBinary(${fn1ZipLocation})
rolename: lambda-fn1-executor
define:
- policyname: xxx-resource-fn1-role
policydocument: $Cat('${privilegePolicy}')
attach:
- policyarn: arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
triggers:
- source: somequeue
type: sqs
enabled: true
batchSize: 20000
fn2:
action: aws/lambda:deploy
credentials: aws-e2e
functionname: fn2
runtime: go1.x
handler: main
code:
zipfile: $LoadBinary(${fn2ZipLocation})
rolename: lambda-fn2-executor
define:
- policyname: xxx-resource-fn2-role
policydocument: $Cat('${privilegePolicy}')
attach:
- policyarn: arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
notification:
action: aws/s3:setupBucketNotification
bucket: someBucket
lambdaFunctionConfigurations:
- functionName: fn2
id: ObjectCreatedEvents
events:
- s3:ObjectCreated:*
filter:
prefix:
- folderXXX
suffix:
- .csv
...
fnX:
action: aws/lambda:deploy
functionname: fnX
runtime: go1.x
handler: main
timeout: 360
vpcMatcher:
instance:
name: instanceWithVPC
environment:
variables:
CONFIG: $AsString($config)
code:
zipfile: $LoadBinary(${fn2ZipLocation})
rolename: lambda-fn3-executor
define:
- policyname: lambda-sns-execution-role
policydocument: $Cat('${privilegePolicy}')
attach:
- policyarn: arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
- policyarn: arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
setupSubscription:
action: aws/sns:setupSubscription
protocol: lambda
endpoint: fnX
topic: someTopic
deployGatewayAPI:
redeploy: true
action: aws/apigateway:setupRestAPI
'@name': myAPIName
resources:
- path: /
methods:
- httpMethod: GET
functionname: fn3
- path: /{proxy+}
methods:
- httpMethod: GET
functionname: fn4
- path: /v1/api/fn4
methods:
- httpMethod: GET
functionname: fn5
最后,您可以使用 lambda e2e 实际测试示例检查 无服务器 e2e。
- 1 回答
- 0 关注
- 127 浏览
添加回答
举报