Create a Confidential VM instance

You can create a Confidential VM instance as part of creating a new Compute Engine virtual machine.

Before you begin

Before creating a Confidential VM instance, you need to set up your environment as follows:

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Compute Engine API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Compute Engine API.

    Enable the API

  8. Optional: To use the gcloud CLI examples in this guide:
  9. Optional: To use the API examples in this guide, set up authentication for your requests. Learn more about OAuth 2.0.

Create an instance

Console

To create an SEV Confidential VM with the Google Cloud console, complete the following steps.

  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. Click Create instance.

  3. In the Confidential VM service section, click Enable.

  4. In the Enable Confidential Computing dialog, review the list of settings that are updated when you enable the service. They can include the following fields, if they were set to incompatible values.

  5. Click Enable.

  6. In the Machine configuration section, expand Advanced configurations.

  7. For the CPU platform, choose AMD Milan or later.

  8. Verify that you are satisfied with these settings, and then click Create.

After you click Create, the VM instances page opens. On this page you can view the status and details for your new instance. When an green checkmark Available icon appears in the Status column for your Confidential VM instance, it's ready to use.

gcloud

AMD SEV

To create an AMD SEV Confidential VM instance with the gcloud CLI, use the instances create sub-command with the --confidential-compute flag.

gcloud compute instances create INSTANCE_NAME \
    --machine-type=MACHINE_TYPE \
    --min-cpu-platform="AMD Milan" \
    --zone=ZONE_NAME \
    --confidential-compute \
    --image-family=IMAGE_FAMILY_NAME \
    --image-project=IMAGE_PROJECT \
    --project=PROJECT_ID

Provide the following values:

  • INSTANCE_NAME: The name of the new VM instance.

  • MACHINE_TYPE: The VM machine type—for example, n2d-standard-2. Must be either an N2D or C2D variant. Only N2D supports live migration—if you choose a C2D machine type, you must add the --maintenance-policy=TERMINATE flag.

  • ZONE_NAME: The Confidential VM-supported zone in which to create the instance.

  • IMAGE_FAMILY_NAME: The family for the Confidential VM-supported operating system image. When you don't additionally specify --image, the latest image version is selected.

  • IMAGE_PROJECT: The project containing the supported operating system image.

  • PROJECT_ID: Optional. The ID of the project to create the VM in.

Example

Run the following command to create an n2d-standard-2 instance called my-instance in the us-central1-a zone:

gcloud compute instances create my-instance \
    --machine-type=n2d-standard-2 \
    --min-cpu-platform="AMD Milan" \
    --zone=us-central1-a \
    --confidential-compute \
    --image-family=cos-109-lts \
    --image-project=cos-cloud

AMD SEV-SNP

To create an AMD SEV-SNP (Preview) Confidential VM instance with the gcloud CLI, use the instances create sub-command with the --confidential-compute-type flag.

gcloud beta compute instances create INSTANCE_NAME \
    --machine-type=MACHINE_TYPE \
    --min-cpu-platform="AMD Milan" \
    --zone=ZONE_NAME \
    --confidential-compute-type=SEV_SNP \
    --maintenance-policy=TERMINATE \
    --image-family=IMAGE__FAMILY_NAME \
    --image-project=IMAGE_PROJECT \
    --project=PROJECT_ID

You must set the --maintenance-policy flag to TERMINATE because AMD SEV-SNP (Preview) VM instances don't support live migration.

Provide the following values:

  • INSTANCE_NAME: The name of the new VM instance.

  • MACHINE_TYPE: The VM machine type—for example, n2d-standard-2. AMD SEV-SNP machines must be an N2D variant.

  • ZONE_NAME: The Confidential VM-supported zone in which to create the instance.

  • IMAGE_FAMILY_NAME: The family for the Confidential VM-supported operating system image. When you don't additionally specify --image, the latest image version is selected.

  • IMAGE_PROJECT: The project containing the supported operating system image.

  • PROJECT_ID: Optional. The ID of the project to create the VM in.

Example

Run the following command to create an n2d-standard-2 instance called my-instance in the us-central1-a zone:

gcloud beta compute instances create my-instance \
    --machine-type=n2d-standard-2 \
    --min-cpu-platform="AMD Milan" \
    --zone=us-central1-a \
    --confidential-compute-type=SEV_SNP \
    --maintenance-policy=TERMINATE \
    --image-family=cos-109-lts \
    --image-project=cos-cloud

Intel TDX

To create an Intel TDX (Preview) Confidential VM instance with the gcloud CLI, use the instances create sub-command with the --confidential-compute-type flag.

gcloud beta compute instances create INSTANCE_NAME \
    --machine-type=MACHINE_TYPE \
    --zone=ZONE_NAME \
    --confidential-compute-type=TDX \
    --maintenance-policy=TERMINATE \
    --image-family=IMAGE_FAMILY_NAME \
    --image-project=tdx-guest-images \
    --project=PROJECT_ID

You must set the --maintenance-policy flag to TERMINATE because Intel TDX (Preview) VM instances don't support live migration.

Provide the following values:

  • INSTANCE_NAME: The name of the new VM instance.

  • MACHINE_TYPE: The VM machine type — for example, c3-standard-4. Intel TDX machines must be a C3 standard variant.

  • ZONE_NAME: The Confidential VM-supported zone in which to create the instance.

  • IMAGE_FAMILY_NAME: The family for the Confidential VM-supported operating system image. When you don't additionally specify --image, the latest image version is selected.

  • PROJECT_ID: Optional. The ID of the project to create the VM in.

Example

Run the following command to create an c3-standard-4 instance called my-instance in the us-central1-a zone:

gcloud beta compute instances create my-instance \
    --machine-type=c3-standard-4 \
    --zone=us-central1-a \
    --confidential-compute-type=TDX \
    --maintenance-policy=TERMINATE \
    --image-family=cos-tdx-109-lts \
    --image-project=tdx-guest-images

REST

AMD SEV

To create an AMD SEV Confidential VM instance, you need to send a POST request with the appropriate body content.

HTTP method and URL:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/instances

Request JSON body:

{
  "machineType": "zones/ZONE_NAME/machineTypes/MACHINE_TYPE",
  "name": "INSTANCE_NAME",
  "minCpuPlatform": "CPU_PLATFORM",
  "confidentialInstanceConfig": {
    "enableConfidentialCompute": true
  },
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY_NAME"
      }
    }
  ],
  "networkInterfaces": [
    {
      "nicType": "gVNIC"
    }
  ],
  "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "preemptible": false
  }
}

Provide the following values:

  • PROJECT_ID: The ID of the project to create the VM in.

  • ZONE_NAME: The Confidential VM-supported zone in which to create the instance.

  • MACHINE_TYPE: The VM machine type—for example, n2d-standard-2. Must be either an N2D or C2D variant. Only N2D supports live migration—if you choose a C2D machine type, you must add the --maintenance-policy=TERMINATE flag.

  • INSTANCE_NAME: The name of new VM instance.

  • CPU_PLATFORM: Optional. AMD Milan is recommended.

  • IMAGE_FAMILY_NAME: The family for the Confidential VM-supported operating system image. When you don't additionally specify --image, the latest image version is selected.

  • IMAGE_PROJECT: The project containing the supported operating system image.

AMD SEV-SNP

To create an AMD SEV-SNP (Preview) Confidential VM instance, you need to send a POST request with the appropriate body content.

HTTP method and URL:

POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE_NAME/instances

Request JSON body:

{
  "machineType": "zones/ZONE_NAME/machineTypes/MACHINE_TYPE",
  "name": "INSTANCE_NAME",
  "minCpuPlatform": "AMD Milan",
  "confidentialInstanceConfig": {
    "confidentialInstanceType": "SEV_SNP"
  },
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY_NAME"
      }
    }
  ],
  "networkInterfaces": [
    {
      "nicType": "gVNIC"
    }
  ],
  "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "onHostMaintenance": "TERMINATE",
    "preemptible": false
  }
}

You must set onHostMaintenance to TERMINATE because AMD SEV-SNP VM (Preview) instances don't support live migration.

Provide the following values:

  • PROJECT_ID: The ID of the project to create the VM in.

  • ZONE_NAME: The Confidential VM-supported zone in which to create the instance.

  • MACHINE_TYPE: The VM machine type—for example, n2d-standard-2. AMD SEV-SNP machines must be an N2D variant.

  • INSTANCE_NAME: The name of new VM instance.

  • IMAGE_FAMILY_NAME: The family for the Confidential VM-supported operating system image. When you don't additionally specify --image, the latest image version is selected.

  • IMAGE_PROJECT: The project containing the supported operating system image.

Intel TDX

To create an Intel TDX (Preview) Confidential VM instance, you need to send a POST request with the appropriate body content.

HTTP method and URL:

POST https://compute.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE_NAME/instances

Request JSON body:

{
  "machineType": "zones/ZONE_NAME/machineTypes/MACHINE_TYPE",
  "name": "INSTANCE_NAME",
  "confidentialInstanceConfig": {
    "confidentialInstanceType": "TDX"
  },
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/tdx-guest-images/global/images/family/IMAGE_FAMILY_NAME"
      }
    }
  ],
  "networkInterfaces": [
    {
      "nicType": "gVNIC"
    }
  ],
  "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "onHostMaintenance": "TERMINATE",
    "preemptible": false
  }
}

You must set onHostMaintenance to TERMINATE because Intel TDX (Preview) VM instances don't support live migration.

Provide the following values:

  • PROJECT_ID: The ID of the project to create the VM in.

  • ZONE_NAME: The Confidential VM-supported zone in which to create the instance.

  • MACHINE_TYPE: The VM machine type—for example, c3-standard-4. Intel TDX machines must be a C3 standard variant.

  • INSTANCE_NAME: The name of new VM instance.

  • IMAGE_FAMILY_NAME: The family for the Confidential VM-supported operating system image. When you don't additionally specify --image, the latest image version is selected.

Example

Run one of the following commands to create an n2d-standard-2 instance called my-instance in the us-central1-a zone, in the my-project project:

AMD SEV

curl (Linux, macOS, or Cloud Shell)

curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -d '{
           "machineType": "zones/us-central1-a/machineTypes/n2d-standard-2",
           "name": "my-instance",
           "minCpuPlatform": "AMD Milan",
           "confidentialInstanceConfig": {
             "enableConfidentialCompute": true
           },
           "disks": [
             {
               "boot": true,
               "initializeParams": {
                 "sourceImage": "projects/cos-cloud/global/images/family/cos-109-lts"
               }
             }
           ],
           "networkInterfaces": [
             {
               "nicType": "gVNIC"
             }
           ],
           "scheduling": {
             "automaticRestart": true,
             "nodeAffinities": [],
             "preemptible": false
           }
         }' \
     https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances

PowerShell (Windows)

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
$body = @"
{
  "machineType": "zones/us-central1-a/machineTypes/n2d-standard-2",
  "name": "my-instance",
  "minCpuPlatform": "AMD Milan",
  "confidentialInstanceConfig": {
    "enableConfidentialCompute": true
  },
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/cos-cloud/global/images/family/cos-109-lts"
      }
    }
  ],
  "networkInterfaces": [
    {
      "nicType": "gVNIC"
    }
  ],
  "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "preemptible": false
  }
}
"@
Invoke-WebRequest `
  -Method POST `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body $body `
  -Uri "https://compute.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances" | Select-Object -Expand Content

AMD SEV-SNP

curl (Linux, macOS, or Cloud Shell)

curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -d '{
           "machineType": "zones/us-central1-a/machineTypes/n2d-standard-2",
           "name": "my-instance",
           "minCpuPlatform": "AMD Milan",
           "confidentialInstanceConfig": {
             "confidentialInstanceType": "SEV_SNP"
           },
           "disks": [
             {
               "boot": true,
               "initializeParams": {
                 "sourceImage": "projects/cos-cloud/global/images/family/cos-109-lts"
               }
             }
           ],
           "networkInterfaces": [
             {
               "nicType": "gVNIC"
             }
           ],
           "scheduling": {
             "automaticRestart": true,
             "nodeAffinities": [],
             "onHostMaintenance": "TERMINATE",
             "preemptible": false
           }
         }' \
     https://compute.googleapis.com/compute/beta/projects/my-project/zones/us-central1-a/instances

PowerShell (Windows)

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
$body = @"
{
  "machineType": "zones/us-central1-a/machineTypes/n2d-standard-2",
  "name": "my-instance",
  "minCpuPlatform": "AMD Milan",
  "confidentialInstanceConfig": {
    "confidentialInstanceType": "SEV_SNP"
  },
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/cos-cloud/global/images/family/cos-109-lts"
      }
    }
  ],
  "networkInterfaces": [
    {
      "nicType": "gVNIC"
    }
  ],
  "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "onHostMaintenance": "TERMINATE",
    "preemptible": false
  }
}
"@
Invoke-WebRequest `
  -Method POST `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body $body `
  -Uri "https://compute.googleapis.com/compute/beta/projects/my-project/zones/us-central1-a/instances" | Select-Object -Expand Content

Intel TDX

curl (Linux, macOS, or Cloud Shell)

curl -X POST \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     -H "Content-Type: application/json" \
     -d '{
           "machineType": "zones/us-central1-a/machineTypes/c3-standard-4",
           "name": "my-instance",
           "confidentialInstanceConfig": {
             "confidentialInstanceType": "TDX"
           },
           "disks": [
             {
               "boot": true,
               "initializeParams": {
                 "sourceImage": "projects/tdx-guest-images/global/images/family/cos-tdx-109-lts"
               }
             }
           ],
           "networkInterfaces": [
             {
               "nicType": "gVNIC"
             }
           ],
           "scheduling": {
             "automaticRestart": true,
             "nodeAffinities": [],
             "onHostMaintenance": "TERMINATE",
             "preemptible": false
           }
         }' \
     https://compute.googleapis.com/compute/beta/projects/my-project/zones/us-central1-a/instances

PowerShell (Windows)

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
$body = @"
{
  "machineType": "zones/us-central1-a/machineTypes/c3-standard-4",
  "name": "my-instance",
  "confidentialInstanceConfig": {
    "confidentialInstanceType": "TDX"
  },
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/tdx-guest-images/global/images/family/cos-tdx-109-lts"
      }
    }
  ],
  "networkInterfaces": [
    {
      "nicType": "gVNIC"
    }
  ],
  "scheduling": {
    "automaticRestart": true,
    "nodeAffinities": [],
    "onHostMaintenance": "TERMINATE",
    "preemptible": false
  }
}
"@
Invoke-WebRequest `
  -Method POST `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body $body `
  -Uri "https://compute.googleapis.com/compute/beta/projects/my-project/zones/us-central1-a/instances" | Select-Object -Expand Content

Response

A response to a creation request looks similar to the following example:

{
  "kind": "compute#operation",
  "id": "REQUEST_ID",
  "name": "OPERATION_ID",
  "zone": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME",
  "operationType": "insert",
  "targetLink": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/instances/INSTANCE_NAME",
  "targetId": "TARGET_ID",
  "status": "RUNNING",
  "user": "USERNAME",
  "progress": 0,
  "insertTime": "2023-08-01T16:35:15.144-07:00",
  "startTime": "2023-08-01T16:35:15.144-07:00",
  "selfLink": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/operations/OPERATION_ID"
}

You can check the VM creation progress by making a GET request to the selfLink:

GET https://www.googleapis.com/compute/beta/projects/PROJECT_ID/zones/ZONE_NAME/operations/OPERATION_ID

Enable higher network bandwidth for C2D machine types

The three largest C2D Compute Engine VM shapes (32, 56, and 112) support high-bandwidth networking. When you select a Tier 1 network bandwidth configuration, the data transfer out bandwidth increases from the default 32 Gbps to 50 or 100 Gbps. To achieve the higher Tier 1 bandwidth speeds, the instance must be running the gVNIC virtual network driver. Learn more about configuring a VM with higher bandwidth.

What's next

Learn how to use Cloud Monitoring to validate your Confidential VM instances.