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