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

Function main

kms/createKeyRing.js:17–51  ·  view source on GitHub ↗
(
  projectId = 'my-project',
  locationId = 'us-east1',
  id = 'my-key-ring'
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17async function main(
18 projectId = 'my-project',
19 locationId = 'us-east1',
20 id = 'my-key-ring'
21) {
22 // [START kms_create_key_ring]
23 //
24 // TODO(developer): Uncomment these variables before running the sample.
25 //
26 // const projectId = 'my-project';
27 // const locationId = 'us-east1';
28 // const id = 'my-key-ring';
29
30 // Imports the Cloud KMS library
31 const {KeyManagementServiceClient} = require('@google-cloud/kms');
32
33 // Instantiates a client
34 const client = new KeyManagementServiceClient();
35
36 // Build the parent location name
37 const locationName = client.locationPath(projectId, locationId);
38
39 async function createKeyRing() {
40 const [keyRing] = await client.createKeyRing({
41 parent: locationName,
42 keyRingId: id,
43 });
44
45 console.log(`Created key ring: ${keyRing.name}`);
46 return keyRing;
47 }
48
49 return createKeyRing();
50 // [END kms_create_key_ring]
51}
52module.exports.main = main;
53
54/* c8 ignore next 10 */

Callers 1

createKeyRing.jsFile · 0.70

Calls 1

createKeyRingFunction · 0.85

Tested by

no test coverage detected