MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / iamAddMember

Function iamAddMember

kms/iamAddMember.js:51–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 // const resourceName = client.keyRingPath(projectId, locationId, keyRingId);
50
51 async function iamAddMember() {
52 // Get the current IAM policy.
53 const [policy] = await client.getIamPolicy({
54 resource: resourceName,
55 });
56
57 // Add the member to the policy.
58 policy.bindings.push({
59 role: 'roles/cloudkms.cryptoKeyEncrypterDecrypter',
60 members: [member],
61 });
62
63 // Save the updated policy.
64 const [updatedPolicy] = await client.setIamPolicy({
65 resource: resourceName,
66 policy: policy,
67 });
68
69 console.log('Updated policy');
70 return updatedPolicy;
71 }
72
73 return iamAddMember();
74 // [END kms_iam_add_member]

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected