in secret-manager/iamRevokeAccess.js [37:63]
async function grantAccess() {
// Get the current IAM policy.
const [policy] = await client.getIamPolicy({
resource: name,
});
// Build a new list of policy bindings with the user excluded.
for (const i in policy.bindings) {
const binding = policy.bindings[i];
if (binding.role !== 'roles/secretmanager.secretAccessor') {
continue;
}
const idx = binding.members.indexOf(member);
if (idx !== -1) {
binding.members.splice(idx, 1);
}
}
// Save the updated IAM policy.
await client.setIamPolicy({
resource: name,
policy: policy,
});
console.log(`Updated IAM policy for ${name}`);
}