| 39 | const keyRingName = client.keyRingPath(projectId, locationId, keyRingId); |
| 40 | |
| 41 | async function createKeyMac() { |
| 42 | const [key] = await client.createCryptoKey({ |
| 43 | parent: keyRingName, |
| 44 | cryptoKeyId: id, |
| 45 | cryptoKey: { |
| 46 | purpose: 'MAC', |
| 47 | versionTemplate: { |
| 48 | algorithm: 'HMAC_SHA256', |
| 49 | }, |
| 50 | |
| 51 | // Optional: customize how long key versions should be kept before |
| 52 | // destroying. |
| 53 | destroyScheduledDuration: {seconds: 60 * 60 * 24}, |
| 54 | }, |
| 55 | }); |
| 56 | |
| 57 | console.log(`Created mac key: ${key.name}`); |
| 58 | return key; |
| 59 | } |
| 60 | |
| 61 | return createKeyMac(); |
| 62 | // [END kms_create_key_mac] |