gpt4 book ai didi

amazon-web-services - aws lambda : invoke with payload from cli

转载 作者:行者123 更新时间:2023-12-04 11:17:58 28 4
gpt4 key购买 nike

我正在尝试使用 aws cli 调用我的 lambda:

$ aws lambda invoke \
--function-name soc-update-dynamodb-java \
--invocation-type Event \
--payload file://invoke-payload.json \
response.json

但是,我收到此消息:

An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Invalid UTF-8 middle byte 0x28 at [Source: (byte[])"E�(�����U�슉���ޞԨ��k.....


payload.json 内容是一个类似 s3 事件的 json:
{
"Records": [
{
"eventVersion": "2.0",
"eventSource": "aws:s3",
"awsRegion": "eu-central-1",
"eventTime": "1970-01-01T00:00:00.000Z",
"eventName": "ObjectCreated:Put",
"userIdentity": {
"principalId": "EXAMPLE"
},
"requestParameters": {
"sourceIPAddress": "127.0.0.1"
},
"responseElements": {
"x-amz-request-id": "EXAMPLE123456789",
"x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH"
},
"s3": {
"s3SchemaVersion": "1.0",
"configurationId": "testConfigRule",
"bucket": {
"name": "soc-connect",
"ownerIdentity": {
"principalId": "EXAMPLE"
},
"arn": "arn:aws:s3:::example"
},
"object": {
"key": "example.key",
"size": 1024,
"eTag": "0123456789abcdef0123456789abcdef",
"sequencer": "0A1B2C3D4E5F678901"
}
}
}
]
}

我可以使用此事件从 aws Web 控制台执行它,但是我在尝试使用 aws cli 调用它时遇到问题。

我从 invoke-payload.json 得到编码:
$ file -i invoke-payload.json 
invoke-payload.json: text/plain; charset=us-ascii

如您所见,编码是 us-ascii

编辑

我还尝试发送嵌入命令的有效载荷。正如您在图片上看到的,我收到了相同的消息:

enter image description here

有任何想法吗?

最佳答案

对有效负载参数使用 fileb://(“文件二进制”)语法,这样您就不必通过 base64 运行它
...
--payload fileb://invoke-payload.json

关于amazon-web-services - aws lambda : invoke with payload from cli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60970252/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com