code: async function setPrimaryCryptoKeyVersion(
    projectId = 'your-project-id', // Your GCP projectId
    keyRingId = 'my-key-ring', // Name of the crypto key version's key ring
    cryptoKeyId = 'my-key', // Name of the version's crypto key
    version = 1234 // The version's id
  ) {
    // Import the library and create a client
    const kms = require('@google-cloud/kms');
    const client = new kms.KeyManagementServiceClient();
  
    // The location of the crypto key versions's key ring, e.g. "global"
    const locationId = 'global';
  
    const name = client.cryptoKeyPath(
      projectId,
      locationId,
      keyRingId,
      cryptoKeyId
    );
    const cryptoKeyVersionId = version;
    const request = {name, cryptoKeyVersionId};
  
    // Sets a crypto key's primary version
    const [cryptoKey] = await client.updateCryptoKeyPrimaryVersion(request);
    console.log(
      `Set ${version} as primary version for crypto key ${cryptoKeyId}.\n`
    );
    console.log(`Name: ${cryptoKey.name}:`);
    console.log(`Created: ${new Date(cryptoKey.createTime)}`);
    console.log(`Purpose: ${cryptoKey.purpose}`);
    console.log(`Primary: ${cryptoKey.primary.name}`);
    console.log(`  State: ${cryptoKey.primary.state}`);
    console.log(`  Created: ${new Date(cryptoKey.primary.createTime)}`);
  }
docs: [START kms_set_cryptokey_primary_version]