
我尝试在生成的 aws codepipeline 模板中设置 userparameters 配置,
name: ...
actions:
- name: invoke-lambda
actiontypeid:
category: invoke
owner: aws
provider: lambda
version: '1'
configuration:
functionname: examplelambdafunction
userparameters: '{"example":"user-parameters"}'
在用 go 编写的 aws lambda 上对其进行测试时,需要比平时更长的时间才能找到处理程序的函数定义,以解析将发送的 aws codepipeline json 事件,例如:
{
"codepipeline.job": {
"id": "11111111-abcd-1111-abcd-111111abcdef",
"accountid": "111111111111",
"data": {
"actionconfiguration": {
"configuration": {
"functionname": "examplelambdafunction",
"userparameters": "{\"example\":\"user-parameters\"}"
}
},
"inputartifacts": [
...
],
...
}
}
}
使用 github.com/aws/aws-lambda-go/events 包链接,其中包含 events.codepipelinejobevent,可帮助解组正在发送的 aws codepipeline json 事件
package main
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func Handler(ctx context.Context, event events.CodePipelineJobEvent) (string, error) {
fmt.Printf("received codepipeline event function name: %+v\n", event.CodePipelineJob.Data.ActionConfiguration.Configuration.FunctionName)
fmt.Printf("received codepipeline event user parameters: %+v\n", event.CodePipelineJob.Data.ActionConfiguration.Configuration.UserParameters)
return "cool", nil
}
func main() {
lambda.Start(Handler)
}
以上就是在 Go 中解析从 AWS CodePipeline 发送到 AWS Lambda 的 UserParameters的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号