function getRoleBindings()

in 1-org/modules/cai-monitoring/function-source/index.js [118:141]


function getRoleBindings(asset) {
    try {
        var foundRoles = [];
        var bindings = asset.iamPolicy.bindings;

        // Check for bindings that include the list of roles
        bindings.forEach(binding => {
            if (searchroles.includes(binding.role)) {
                binding.members.forEach(member => {
                    foundRoles.push({
                        member: member,
                        role: binding.role,
                        action: 'ADD'
                    });
                });
            }
        });

        return foundRoles;
    } catch (error) {
        console.warn(`Returning empty bindings with message: ${error.message}`);
        return [];
    }
}