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

Function createKeyHsm

kms/createKeyHsm.js:41–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected