我正在使用具有以下策略生成代码的APIGateway lambda Authorizer,但即使将授权者lambda的生存时间设置为零,似乎仍然出于某些原因而缓存了该策略。
这是我的代码:
var generatePolicy = function(principalId, effect, resource) {
var authResponse = {};
authResponse.principalId = principalId;
if (effect && resource) {
var policyDocument = {};
policyDocument.Version = '2012-10-17';
policyDocument.Statement = [];
var statementOne = {};
statementOne.Action = 'execute-api:Invoke';
statementOne.Effect = effect;
statementOne.Resource = resource.replace(/:function:.+$/, ':function:*');
policyDocument.Statement[0] = statementOne;
authResponse.policyDocument = policyDocument;
}
authResponse.context = {
"stringKey": "stringval",
"numberKey": 123,
"booleanKey": true
};
return authResponse;
}
}
答案 0 :(得分:1)
statementOne.Resource = '*';
即可。