[英]AWS api gateway custom authorizer: access context variable in mapping template
我已经使用python在AWS API Gateway
实现了自定义授权模块。 基本上,它可能会返回如下内容:
access = {
"principalId": "yyyyyyyy",
"policyDocument" : {
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Resource": [
"some-arn/*/GET/organisation"
],
"Effect": "Allow"
}
]
},
"context" : {
"organization_id": "123"
}
}
在后端站点上,我想在DynamoDb上执行GetItem。 映射模板如下所示:
{
"TableName":"Organisation",
"Key":{
"id":{
"S":"$context.authorizer.organization_id"
}
}
}
但是,我收到一个错误,因为context
变量似乎为空:
Mon Jul 10 19:47:16 UTC 2017 : Endpoint request body after transformations: { ""
"TableName":"Organisation",
"Key":{
"id":{
"S":""
}
}
}
Mon Jul 10 19:47:16 UTC 2017 : Endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}
任何建议,我在这里做错了什么?
经过大量测试,我发现问题仅在使用AWS控制台进行测试时才出现。 此问题也在此处讨论 。 希望AWS会尽快解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.