Creating a Confidential VM instance

This page guides you through setting up a new Confidential VM instance.

For more information about Confidential VM, see Confidential VMs and Compute Engine.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to the project selector page

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

  4. Enable the Compute Engine API.

    Enable Compute Engine API

  5. If you want to use the command-line examples in this guide:
  6. If you want to use the API examples in this guide, set up API access.

Create a new Confidential VM instance

Cloud Console

To create a new Confidential VM on the AMD Secure Encrypted Virtualization (SEV) CPU platform using the Google Cloud Console:

  1. In the Cloud Console, go to the VM Instances page.

    Go to the VM Instances page

  2. Click Create instance.
  3. Click CPU platform and GPU to expand the section.

  4. Leave CPU Platform set to Automatic.
  5. Select the Confidential VM Service checkbox.

  6. A message appears letting you know the settings that will be changed if you enable the service. Click Enable.

The default OS boot disk changes to Shielded Container Optimized OS (COS). To change the boot disk to a different OS, click Change to select one of the supported OSes for Confidential VM.

You can keep the remaining options at their default values or make any changes you might want. To learn more about the available options, see Creating a VM instance with a custom machine type in Compute Engine documentation. When you're done, click Create.

When you're done, click Create.

gcloud

To create new Confidential VM instances, you can use one of several Confidential VM-supported Compute Engine images.

List supported images

To list all existing Confidential VM-supported images, use one of the following commands:

Shielded Container Optimized OS (COS):

gcloud compute images list --filter="guestOsFeatures[].type:(SEV_CAPABLE)" --project cos-cloud;

Ubuntu Linux:

gcloud compute images list --filter="guestOsFeatures[].type:(SEV_CAPABLE)" --project ubuntu-os-cloud;

View image details

To view details about a specific image, use the zones describe subcommand as shown here, replacing the IMAGE_NAME placeholder with the name of the image and IMAGE_PROJECT_NAME with the name of the image's project:

gcloud compute images describe IMAGE_NAME --project IMAGE_PROJECT_NAME;

List per-zone available CPU platforms

To get a list of the available CPU platforms in specific zones, use the zones describe subcommand as shown here, replacing the ZONE_NAME placeholder with the name of the zone:

gcloud beta compute zones describe ZONE_NAME --format="value(availableCpuPlatforms)"

For example, the following command shows you what CPU platforms are available in zone us-central1-f:

gcloud beta compute zones describe us-central1-f --format="value(availableCpuPlatforms)"

Create a new instance

To create a new Confidential VM instance on the AMD Secure Encrypted Virtualization (SEV) CPU platform using the gcloud command-line tool, use the gcloud beta component.

To create the new instance, use the instances create subcommand followed by the --confidential-compute flag to specify a Confidential VM opt-in. Replace the following placeholders with their corresponding values:

  • INSTANCE_NAME: The name to give the new instance.
  • MACHINE_TYPE: The N2D machine type to use.
  • ZONE_NAME: The name of the zone in which to create the instance. To learn how to see a list of the available CPU platforms in specific zones, see List per-zone available CPU platforms, earlier in this topic.
  • IMAGE_NAME: The name of the Confidential VM-supported image to use.
  • IMAGE_PROJECT: project containing the image.
gcloud beta compute instances create INSTANCE_NAME \
  --machine-type "MACHINE_TYPE" --zone "ZONE_NAME" \
  --confidential-compute --maintenance-policy=TERMINATE \
  --image=IMAGE_NAME
  --image-project=IMAGE_PROJECT

The following example command creates an n2d-standard-16-type instance called "example-instance" on the AMD SEV CPU platform in the us-central1-f zone:

gcloud beta compute instances create example-instance \
  --machine-type "n2d-standard-16" --zone "us-central1-f" \
  --confidential-compute --maintenance-policy=TERMINATE \
  --image="example-cvm-image"
  --image-project="public-image-project"

API

To create a new Confidential VM on the AMD Secure Encrypted Virtualization (SEV) CPU platform using the Compute Engine API, you post an instance creation request as you would normally. One critical difference is setting enableConfidentialCompute to true.

You can optionally specify a minimum CPU platform by setting the minCpuPlatform property to a value.

Following is an example of a JSON object POSTed to the Instances beta REST resource of the Compute Engine API. To use this request to create a new Confidential VM-supported instance, replace the corresponding placeholders:

  • PROJECT_ID: Your project identifier.
  • ZONE_NAME: The zone in which to create the instance.
  • MACHINE_TYPE: The N2D machine type to use.
  • INSTANCE_NAME: The name to give the new instance.
POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE_NAME/instances

{
  "machineType": "zones/ZONE_NAME/machineTypes/MACHINE_TYPE",
  "name": "INSTANCE_NAME",
  "confidentialInstanceConfig": {
    "enableConfidentialCompute": true
  },
    "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "onHostMaintenance": "TERMINATE",
    "preemptible": false
  }
  ...
}

Connect to your instance

To connect to your newly-created instance, do the following:

  1. In the Cloud Console, go to the VM Instances page.

    Go to the VM Instances page

  2. In the list of virtual machine instances, click SSH in the row of the instance that you want to connect to.

You now have a terminal window for interacting with your Confidential VM instance.

Verify that AMD SEV is enabled

To verify that the newly created Confidential VM instance is using AMD SEV, run the following command after you've connected to the instance:

dmesg | grep SEV | head

If AMD SEV is enabled, you'll see a response like the following:

[    0.290272] AMD Secure Encrypted Virtualization (SEV) active

To learn how to obtain more detailed information about the state of the Confidential VM instance by examining Cloud Monitoring integrity validation events, see Validating Confidential VMs using Cloud Monitoring.

Clean up

  1. In the Cloud Console, go to the VM Instances page.

    Go to the VM Instances page

  2. Click the checkbox for the instance you want to delete.
  3. Click Delete to delete the instance.

What's next