| 79 | }; |
| 80 | |
| 81 | async function createDenyPolicy() { |
| 82 | const request = { |
| 83 | parent: `policies/${attachmentPoint}/denypolicies`, |
| 84 | policy: { |
| 85 | displayName: 'Restrict project deletion access', |
| 86 | rules: [ |
| 87 | { |
| 88 | description: |
| 89 | 'block all principals from deleting projects, unless the principal is a member of project-admins@example.com and the project being deleted has a tag with the value test', |
| 90 | denyRule, |
| 91 | }, |
| 92 | ], |
| 93 | }, |
| 94 | policyId, |
| 95 | }; |
| 96 | |
| 97 | const [operation] = await iamClient.createPolicy(request); |
| 98 | const [policy] = await operation.promise(); |
| 99 | |
| 100 | console.log(`Created the deny policy: ${policy.name}`); |
| 101 | } |
| 102 | |
| 103 | createDenyPolicy(); |
| 104 | // [END iam_create_deny_policy] |