RegionCommitment class

Represents a regional Commitment resource.

Creating a commitment resource means that you are purchasing a committed use contract with an explicit start and end time. You can create commitments based on vCPUs and memory usage and receive discounted rates.

To get more information about RegionCommitment, see:

Example Usage

Compute Region Commitment Basic

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const foobar = new gcp.compute.RegionCommitment("foobar", {
    name: "my-region-commitment",
    plan: "THIRTY_SIX_MONTH",
    resources: [
        {
            type: "VCPU",
            amount: "4",
        },
        {
            type: "MEMORY",
            amount: "9",
        },
    ],
});
import pulumi
import pulumi_gcp as gcp

foobar = gcp.compute.RegionCommitment("foobar",
    name="my-region-commitment",
    plan="THIRTY_SIX_MONTH",
    resources=[
        {
            "type": "VCPU",
            "amount": "4",
        },
        {
            "type": "MEMORY",
            "amount": "9",
        },
    ])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var foobar = new Gcp.Compute.RegionCommitment("foobar", new()
    {
        Name = "my-region-commitment",
        Plan = "THIRTY_SIX_MONTH",
        Resources = new[]
        {
            new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
            {
                Type = "VCPU",
                Amount = "4",
            },
            new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
            {
                Type = "MEMORY",
                Amount = "9",
            },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewRegionCommitment(ctx, "foobar", &compute.RegionCommitmentArgs{
			Name: pulumi.String("my-region-commitment"),
			Plan: pulumi.String("THIRTY_SIX_MONTH"),
			Resources: compute.RegionCommitmentResourceArray{
				&compute.RegionCommitmentResourceArgs{
					Type:   pulumi.String("VCPU"),
					Amount: pulumi.String("4"),
				},
				&compute.RegionCommitmentResourceArgs{
					Type:   pulumi.String("MEMORY"),
					Amount: pulumi.String("9"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_compute_regioncommitment" "foobar" {
  name = "my-region-commitment"
  plan = "THIRTY_SIX_MONTH"
  resources {
    type   = "VCPU"
    amount = "4"
  }
  resources {
    type   = "MEMORY"
    amount = "9"
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.RegionCommitment;
import com.pulumi.gcp.compute.RegionCommitmentArgs;
import com.pulumi.gcp.compute.inputs.RegionCommitmentResourceArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var foobar = new RegionCommitment("foobar", RegionCommitmentArgs.builder()
            .name("my-region-commitment")
            .plan("THIRTY_SIX_MONTH")
            .resources(
                RegionCommitmentResourceArgs.builder()
                    .type("VCPU")
                    .amount("4")
                    .build(),
                RegionCommitmentResourceArgs.builder()
                    .type("MEMORY")
                    .amount("9")
                    .build())
            .build());

    }
}
resources:
  foobar:
    type: gcp:compute:RegionCommitment
    properties:
      name: my-region-commitment
      plan: THIRTY_SIX_MONTH
      resources:
        - type: VCPU
          amount: '4'
        - type: MEMORY
          amount: '9'

Compute Region Commitment Full

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const tagKey = new gcp.tags.TagKey("tag_key", {
    parent: "organizations/ORG_ID",
    shortName: "tagkey",
});
const tagValue = new gcp.tags.TagValue("tag_value", {
    parent: tagKey.id,
    shortName: "tagvalue",
});
const foobar = new gcp.compute.RegionCommitment("foobar", {
    name: "my-full-commitment",
    description: "some description",
    plan: "THIRTY_SIX_MONTH",
    type: "MEMORY_OPTIMIZED",
    category: "MACHINE",
    autoRenew: true,
    resources: [
        {
            type: "VCPU",
            amount: "4",
        },
        {
            type: "MEMORY",
            amount: "9",
        },
    ],
    params: {
        resourceManagerTags: pulumi.all([tagKey.id, tagValue.id]).apply(([tagKeyId, tagValueId]) => {
            [tagKeyId]: tagValueId,
        }),
    },
});
import pulumi
import pulumi_gcp as gcp

tag_key = gcp.tags.TagKey("tag_key",
    parent="organizations/ORG_ID",
    short_name="tagkey")
tag_value = gcp.tags.TagValue("tag_value",
    parent=tag_key.id,
    short_name="tagvalue")
foobar = gcp.compute.RegionCommitment("foobar",
    name="my-full-commitment",
    description="some description",
    plan="THIRTY_SIX_MONTH",
    type="MEMORY_OPTIMIZED",
    category="MACHINE",
    auto_renew=True,
    resources=[
        {
            "type": "VCPU",
            "amount": "4",
        },
        {
            "type": "MEMORY",
            "amount": "9",
        },
    ],
    params={
        "resource_manager_tags": pulumi.Output.all(
            tagKeyId=tag_key.id,
            tagValueId=tag_value.id
).apply(lambda resolved_outputs: {
            str(resolved_outputs['tagKeyId']): resolved_outputs['tagValueId'],
        })
,
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var tagKey = new Gcp.Tags.TagKey("tag_key", new()
    {
        Parent = "organizations/ORG_ID",
        ShortName = "tagkey",
    });

    var tagValue = new Gcp.Tags.TagValue("tag_value", new()
    {
        Parent = tagKey.Id,
        ShortName = "tagvalue",
    });

    var foobar = new Gcp.Compute.RegionCommitment("foobar", new()
    {
        Name = "my-full-commitment",
        Description = "some description",
        Plan = "THIRTY_SIX_MONTH",
        Type = "MEMORY_OPTIMIZED",
        Category = "MACHINE",
        AutoRenew = true,
        Resources = new[]
        {
            new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
            {
                Type = "VCPU",
                Amount = "4",
            },
            new Gcp.Compute.Inputs.RegionCommitmentResourceArgs
            {
                Type = "MEMORY",
                Amount = "9",
            },
        },
        Params = new Gcp.Compute.Inputs.RegionCommitmentParamsArgs
        {
            ResourceManagerTags = Output.Tuple(tagKey.Id, tagValue.Id).Apply(values =>
            {
                var tagKeyId = values.Item1;
                var tagValueId = values.Item2;
                return
                {
                    { tagKeyId, tagValueId },
                };
            }),
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/tags"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tagKey, err := tags.NewTagKey(ctx, "tag_key", &tags.TagKeyArgs{
			Parent:    pulumi.String("organizations/ORG_ID"),
			ShortName: pulumi.String("tagkey"),
		})
		if err != nil {
			return err
		}
		tagValue, err := tags.NewTagValue(ctx, "tag_value", &tags.TagValueArgs{
			Parent:    tagKey.ID().ToIDOutput().ToStringOutput(),
			ShortName: pulumi.String("tagvalue"),
		})
		if err != nil {
			return err
		}
		_, err = compute.NewRegionCommitment(ctx, "foobar", &compute.RegionCommitmentArgs{
			Name:        pulumi.String("my-full-commitment"),
			Description: pulumi.String("some description"),
			Plan:        pulumi.String("THIRTY_SIX_MONTH"),
			Type:        pulumi.String("MEMORY_OPTIMIZED"),
			Category:    pulumi.String("MACHINE"),
			AutoRenew:   pulumi.Bool(true),
			Resources: compute.RegionCommitmentResourceArray{
				&compute.RegionCommitmentResourceArgs{
					Type:   pulumi.String("VCPU"),
					Amount: pulumi.String("4"),
				},
				&compute.RegionCommitmentResourceArgs{
					Type:   pulumi.String("MEMORY"),
					Amount: pulumi.String("9"),
				},
			},
			Params: &compute.RegionCommitmentParamsArgs{
				ResourceManagerTags: pulumi.StringMap(pulumi.All(tagKey.ID(), tagValue.ID()).ApplyT(func(_args []interface{}) (map[string]pulumi.ID, error) {
					tagKeyId := _args[0].(pulumi.ID)
					tagValueId := _args[1].(pulumi.ID)
					return map[string]pulumi.ID(pulumi.String(tagKeyId).ApplyT(func(__convert string) (map[string]pulumi.ID, error) {
						return map[string]pulumi.ID{
							__convert: tagValueId,
						}, nil
					}).(pulumi.IDMapOutput)), nil
				}).(pulumi.IDMapOutput)),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_compute_regioncommitment" "foobar" {
  name        = "my-full-commitment"
  description = "some description"
  plan        = "THIRTY_SIX_MONTH"
  type        = "MEMORY_OPTIMIZED"
  category    = "MACHINE"
  auto_renew  = true
  resources {
    type   = "VCPU"
    amount = "4"
  }
  resources {
    type   = "MEMORY"
    amount = "9"
  }
  params = {
    resource_manager_tags = {
      gcp_tags_tagkey.tag_key.id = gcp_tags_tagvalue.tag_value.id
    }
  }
}
resource "gcp_tags_tagkey" "tag_key" {
  parent     = "organizations/ORG_ID"
  short_name = "tagkey"
}
resource "gcp_tags_tagvalue" "tag_value" {
  parent     = gcp_tags_tagkey.tag_key.id
  short_name = "tagvalue"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.tags.TagKey;
import com.pulumi.gcp.tags.TagKeyArgs;
import com.pulumi.gcp.tags.TagValue;
import com.pulumi.gcp.tags.TagValueArgs;
import com.pulumi.gcp.compute.RegionCommitment;
import com.pulumi.gcp.compute.RegionCommitmentArgs;
import com.pulumi.gcp.compute.inputs.RegionCommitmentResourceArgs;
import com.pulumi.gcp.compute.inputs.RegionCommitmentParamsArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var tagKey = new TagKey("tagKey", TagKeyArgs.builder()
            .parent("organizations/ORG_ID")
            .shortName("tagkey")
            .build());

        var tagValue = new TagValue("tagValue", TagValueArgs.builder()
            .parent(tagKey.id())
            .shortName("tagvalue")
            .build());

        var foobar = new RegionCommitment("foobar", RegionCommitmentArgs.builder()
            .name("my-full-commitment")
            .description("some description")
            .plan("THIRTY_SIX_MONTH")
            .type("MEMORY_OPTIMIZED")
            .category("MACHINE")
            .autoRenew(true)
            .resources(
                RegionCommitmentResourceArgs.builder()
                    .type("VCPU")
                    .amount("4")
                    .build(),
                RegionCommitmentResourceArgs.builder()
                    .type("MEMORY")
                    .amount("9")
                    .build())
            .params(RegionCommitmentParamsArgs.builder()
                .resourceManagerTags(Output.tuple(tagKey.id(), tagValue.id()).applyValue(values -> {
                    var tagKeyId = values.t1;
                    var tagValueId = values.t2;
                    return tagKeyId.applyValue(___convert -> Map.of(___convert, tagValueId));
                }))
                .build())
            .build());

    }
}
resources:
  foobar:
    type: gcp:compute:RegionCommitment
    properties:
      name: my-full-commitment
      description: some description
      plan: THIRTY_SIX_MONTH
      type: MEMORY_OPTIMIZED
      category: MACHINE
      autoRenew: true
      resources:
        - type: VCPU
          amount: '4'
        - type: MEMORY
          amount: '9'
      params:
        resourceManagerTags:
          ${tagKey.id}: ${tagValue.id}
  tagKey:
    type: gcp:tags:TagKey
    name: tag_key
    properties:
      parent: organizations/ORG_ID
      shortName: tagkey
  tagValue:
    type: gcp:tags:TagValue
    name: tag_value
    properties:
      parent: ${tagKey.id}
      shortName: tagvalue

Import

RegionCommitment can be imported using any of these accepted formats:

  • projects/{{project}}/regions/{{region}}/commitments/{{name}}
  • {{project}}/{{region}}/{{name}}
  • {{region}}/{{name}}
  • {{name}}

When using the pulumi import command, RegionCommitment can be imported using one of the formats above. For example:

$ pulumi import gcp:compute/regionCommitment:RegionCommitment default projects/{{project}}/regions/{{region}}/commitments/{{name}}
$ pulumi import gcp:compute/regionCommitment:RegionCommitment default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/regionCommitment:RegionCommitment default {{region}}/{{name}}
$ pulumi import gcp:compute/regionCommitment:RegionCommitment default {{name}}

Constructors

RegionCommitment(String name, {RegionCommitmentArgs? args, CustomResourceOptions? options})
Creates a new RegionCommitment. name The Pulumi resource name. args Arguments used to configure this RegionCommitment. The set of arguments for RegionCommitment. options Resource options controlling this resource's behavior.
RegionCommitment.reference(String urn)
Creates a typed reference to an existing RegionCommitment resource.

Properties

autoRenew ↔ Output<bool>
Specifies whether to enable automatic renewal for the commitment. The default value is false if not specified. If the field is set to true, the commitment will be automatically renewed for either one or three years according to the terms of the existing commitment.
latefinal
category ↔ Output<String>
The category of the commitment. Category MACHINE specifies commitments composed of machine resources such as VCPU or MEMORY, listed in resources. Category LICENSE specifies commitments composed of software licenses, listed in licenseResources. Note that only MACHINE commitments should have a Type specified. Possible values are: LICENSE, MACHINE.
latefinal
childResources → Set<Resource>
finalinherited
commitmentId ↔ Output<int>
Unique identifier for the resource.
latefinal
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
creationTimestamp ↔ Output<String>
Creation timestamp in RFC3339 text format.
latefinal
description ↔ Output<String?>
An optional description of this resource.
latefinal
endTimestamp ↔ Output<String>
Commitment end time in RFC3339 text format.
latefinal
existingReservations ↔ Output<String?>
Specifies the already existing reservations to attach to the Commitment. This field will suppress diffs that change the value from empty to non-empty. To force changing this field from empty to non-empty, change another field at the same time.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
licenseResource ↔ Output<RegionCommitmentLicenseResource?>
The license specification required as part of a license commitment. Structure is documented below.
latefinal
name ↔ Output<String>
Name of the resource. The name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
latefinal
params ↔ Output<RegionCommitmentParams?>
Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
latefinal
plan ↔ Output<String>
The plan for this commitment, which determines duration and discount rate. The currently supported plans are TWELVE_MONTH (1 year), and THIRTY_SIX_MONTH (3 years). Possible values are: TWELVE_MONTH, THIRTY_SIX_MONTH.
latefinal
project ↔ Output<String>
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
latefinal
region ↔ Output<String>
URL of the region where this commitment may be used.
latefinal
resources ↔ Output<List<RegionCommitmentResource>?>
A list of commitment amounts for particular resources. Note that VCPU and MEMORY resource commitments must occur together. Structure is documented below.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
The URI of the created resource.
latefinal
startTimestamp ↔ Output<String>
Commitment start time in RFC3339 text format.
latefinal
status ↔ Output<String>
Status of the commitment with regards to eventual expiration (each commitment has an end date defined).
latefinal
statusMessage ↔ Output<String>
A human-readable explanation of the status.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
type ↔ Output<String>
The type of commitment, which affects the discount rate and the eligible resources. The type could be one of the following value: MEMORY_OPTIMIZED, ACCELERATOR_OPTIMIZED, GENERAL_PURPOSE, GENERAL_PURPOSE_N2, GENERAL_PURPOSE_N2D, GENERAL_PURPOSE_E2, GENERAL_PURPOSE_T2D, GENERAL_PURPOSE_C3, COMPUTE_OPTIMIZED_C2, COMPUTE_OPTIMIZED_C2D and GRAPHICS_OPTIMIZED_G2
latefinal
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {RegionCommitmentState? state, CustomResourceOptions? options}) → RegionCommitment
Gets an existing RegionCommitment resource's state with the given name and id.