1 回答

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個(gè)贊
lambda 函數(shù)的部署歸結(jié)為包/模塊組織和自動(dòng)化部署工具。第一個(gè)看起來(lái)像是在您的問(wèn)題中解決了共享代碼被放置到 util 并且每個(gè) lambda 都有一個(gè)單獨(dú)的包。在問(wèn)題中,不清楚使用的是什么部署方法。有多種方法可以部署 lambda
命令行界面
AWS 無(wú)服務(wù)器應(yīng)用程序模型
Endly - 自動(dòng)化和 e2e 運(yùn)行器
地貌
雖然我一直是 e2e 和自動(dòng)化的倡導(dǎo)者,但針對(duì)各種事件的最終運(yùn)行器多 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 實(shí)際測(cè)試示例檢查?無(wú)服務(wù)器 e2e。
- 1 回答
- 0 關(guān)注
- 170 瀏覽
添加回答
舉報(bào)