1 回答

TA貢獻2065條經驗 獲得超14個贊
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 關注
- 175 瀏覽
添加回答
舉報