You can switch between pay-as-you-go (PAYG) and bring your own subscription (BYOS) billing models by replacing one license reference or code with another. For details on license codes and how to determine allowed license modifications, see License changes and restrictions.
Before you begin
-
If you haven't already, then set up authentication.
Authentication is
the process by which your identity is verified for access to Google Cloud services and APIs.
To run code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
-
Change a PAYG license to a BYOS license
To replace a PAYG license with a BYOS license, use the Google Cloud CLI or the Compute Engine API.
gcloud
To replace a disk's license with a license reference or code, use the
gcloud compute disks update
command:
gcloud compute disks update DISK_NAME \ --replace-license=PREVIOUS_LICENSE,NEW_LICENSE
Replace the following:
DISK_NAME
: the name of the disk to replace.PREVIOUS_LICENSE
: the previous license reference being replaced, for example,"rhel-6-server"
,"rhel-7-server"
.NEW_LICENSE
: the new license reference, for example,"rhel-6-byos"
,"rhel-7-byos"
.
REST
To replace a disk's license, add the new license to the request body and
omit the previous license. Call the following
disks.update
v1 method:
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks/DISK_NAME?paths=licenses --data '{"name":"DISK_NAME", "licenses":["https://www.googleapis.com/compute/v1/NEW_LICENSE"]}'
Replace the following:
PROJECT
: the name of the projectZONE
: the zone containing the VMDISK_NAME
: the name of the diskNEW_LICENSE
: the new license reference, for example,"rhel-6-byos"
,"rhel-7-byos"
, or license code, for example,"4720191914037931587"
,"1492188837615955530"
.