This document explains how to purchase resource-based commitments for OS licenses by using the Google Cloud console, the gcloud CLI, or REST.
To learn more about license commitments, including the qualifying images and discount rates, see Software license commitments.
Before you begin
-
If you haven't already, set up authentication.
Authentication verifies your identity 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
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud initIf 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.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
Required roles
To get the permission that
you need to purchase commitments for licenses,
ask your administrator to grant you the
Compute Admin (roles/compute.admin) IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the
compute.commitments.create
permission,
which is required to
purchase commitments for licenses.
You might also be able to get this permission with custom roles or other predefined roles.
By default, project owners have permission to purchase resource-based commitments. However, it's possible for owners to create custom roles that include or exclude certain users. Read about access control to make sure that you have permission to purchase a resource-based commitment.
Purchase an OS license commitment
Purchase software resource-based commitments for OS licenses using the Google Cloud console, the gcloud CLI, or REST.
After you purchase a commitment, your commitment becomes active on the following day at 12 AM US and Canadian Pacific Time (UTC-8, or UTC-7 during daylight saving time). Compute Engine maintains a lien on your project for each region in your project where you purchase a commitment. When you purchase a new commitment for any region in your project, Compute Engine associates the lien for that region with the newly created commitment.
Between the time of your commitment purchase and its activation time, the
status of your commitment remains as NOT_YET_ACTIVE (or as PENDING on the
Google Cloud console). After activation, the status of your commitment changes to
ACTIVE.
For example, suppose you purchase your commitment on January 20, 2024, at 10:00 PM
US and Canadian Pacific Time (UTC-8 or UTC-7). Compute Engine creates your
commitment immediately with its status as NOT_YET_ACTIVE. Your
commitment becomes ACTIVE on January 21, 2024, at 12:00 AM US
and Canadian Pacific Time (UTC-8 or UTC-7).
Console
Before you purchase a commitment using the Google Cloud console, select the project where you want to use the resources and apply your CUDs. If you enabled CUD sharing for your project's Cloud Billing account, then you can purchase the commitment for any project from that Cloud Billing account.
After you select the project, perform the following steps:
In the Google Cloud console, go to the Committed use discounts page.
The Commitment list page appears and displays the Hardware commitments tab.
Click Software license commitments.
Click Purchase commitment.
The Purchase a committed use discount page appears.
In the Name field, enter a name for your commitment.
In the Region field, select the region where you want to use resources at committed-use-discounted prices.
For Duration, select either 1 year or 3 years as the plan for your commitment. The plan determines the CUD rate and preset term duration of your commitment.
In the License family field, select the OS license for which you want to purchase the commitment.
In the License type and quantity section, do the following:
- For Type, select the number of vCPUs that applies.
- For Number of licenses, enter the number of OS licenses that you want to commit to purchasing.
In the Summary pane, review your commitment timeline and details.
To purchase your commitment, do the following:
Click Purchase. The Purchase a committed use discount dialog appears.
In the dialog, review the acceptance disclosures regarding monthly fees, commitment terms, and the service specific terms.
To confirm your commitment purchase, click Purchase.
gcloud
Using the gcloud CLI, run the
gcloud compute commitments create-license
command to purchase a license commitment.
gcloud compute commitments create-license COMMITMENT_NAME \
--license `LICENSE_URI`
--amount NUMBER_OF_LICENSES \
--cores-per-license CORES_PER_LICENSE \
--plan PLAN \
--region REGION \
Replace the following:
COMMITMENT_NAME: the name for your commitment.LICENSE_URI: the license URI. For example:https://www.googleapis.com/compute/v1/projects/myproject/global/licenses/sles-sap-12NUMBER_OF_LICENSES: the number of licenses you plan to purchase.CORES_PER_LICENSE: the number of cores per license. Enter1-2,3-4, or5+.PLAN: enter the plan length:12-monthor36-month.REGION: the region where this commitment applies.
For example, to purchase a 3-year commitment for 4 SAP licenses with 3-4
cores per license in the us-central1 region, run the following command:
gcloud compute commitments create-license commitment-1
--license https://www.googleapis.com/compute/v1/projects/myproject/global/licenses/sles-12
--amount=4
--cores-per-license=3-4
--plan=36-month
--region=us-central1
For example, to purchase a 1-year commitment for 2 SLES for SAP licenses
with 1-2 cores per license in the us-central1 region, run the following
command:
gcloud compute commitments create-license commitment-2
--license https://www.googleapis.com/compute/v1/projects/myproject/global/licenses/sles-sap-12
--amount=2
--cores-per-license=1-2
--plan=12-month
--region=us-central1
REST
Use the regionCommitments.insert method
and include the licenseResource field to define the license commitment's
properties.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/commitments?requestId=OPTIONAL_UNIQUE_ID
{
"name": "COMMITMENT_NAME",
"plan": "PLAN",
"category": "LICENSE",
"licenseResource": {
"coresPerLicense": "CORES_PER_LICENSE",
"amount": "NUMBER_OF_LICENSES",
"license": "LICENSE_URI"
}
}Replace the following:
PROJECT_ID: the ID of the project where you want to purchase the commitment.OPTIONAL_UNIQUE_ID: Optional. A unique request ID to help prevent unintended duplicate requests.COMMITMENT_NAME: the name for your commitment.LICENSE_URI: the license URI. For example:https://www.googleapis.com/compute/v1/projects/myproject/global/licenses/sles-sap-12NUMBER_OF_LICENSES: the number of licenses you plan to purchase.CORES_PER_LICENSE: the number of cores per license. Enter1-2,3-4, or5+.PLAN: enter the plan length:12-monthor36-month.REGION: the region where this commitment applies.
For example, to purchase a 3-year commitment for 4 SLES for SAP licenses
with 3-4 cores per license in the us-central1 region, make the following
POST request:
POST https://compute.googleapis.com/compute/v1/projects/myproject/regions/us-central1/commitments
{
"name": "commitment-3",
"plan": "THIRTY_SIX_MONTH",
"category": "LICENSE",
"licenseResource": {
"coresPerLicense": "3-4",
"amount": "4",
"license": "https://www.googleapis.com/compute/v1/projects/suse-sap-cloud/global/licenses/sles-sap-12"
}
}