| 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] |