simulatePermissions()
通过 AWS 模拟器运行测试,确保为经过身份验证的用户设置了所有必要的权限。
🌐 Runs tests through the AWS Simulator ensuring that all the necessary permissions are set for the authenticated user.
CLI 等效项是 npx remotion lambda policies validate。
🌐 The CLI equivalent is npx remotion lambda policies validate.
如果缺少权限,该函数不会因错误而拒绝,而是会在返回值中指示缺少的权限。
🌐 The function does not reject with an error if a permission is missing, rather the missing permission is indicated in the return value.
此功能仅验证用户策略的有效性,而不验证角色策略。
🌐 This function does only validate the validity of the user policy, not the role policy.
示例
🌐 Example
import {simulatePermissions } from '@remotion/lambda';
const {results } = await simulatePermissions ({
region : 'us-east-1',
});
for (const result of results ) {
console .log (result .decision ); // "allowed"
console .log (result .name ); // "iam:SimulatePrincipalPolicy"
}参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
region
你想查询的 AWS 区域。
🌐 The AWS region that you would like to query.
onSimulation?
每当执行新的模拟时都会调用的回调函数。这允许你比等待函数的返回值更快地对新的模拟结果做出反应。例如:
🌐 A callback function that gets called every time a new simulation has been executed. This allows you to react to new simulation results coming in much faster than waiting for the return value of the function. Example:
import {simulatePermissions } from '@remotion/lambda';
const {results } = await simulatePermissions ({
region : 'us-east-1',
onSimulation : (result ) => {
console .log (result .decision ); // "allowed"
console .log (result .name ); // "iam:SimulatePrincipalPolicy"
},
});返回值
🌐 Return value
包含模拟每个必要权限结果的对象数组。这些对象包含以下键:
decision
要么是 "allowed"、"implicitDeny",要么是 "explicitDeny"。
🌐 Either "allowed", "implicitDeny" or "explicitDeny".
name
所需权限的标识符。请参阅权限页面以查看所需权限的列表。
🌐 The identifier of the required permission. See the Permissions page to see a list of required permissions.
另请参阅
🌐 See also